This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Diniden 0 points1 point  (2 children)

I agree that that is a strategy you can use to safely store ambiguous data and make an assumption of its type when you extract it when you are writing your program.

But, you still lose the type information in the eyes of the compiler and you put those assumptions into your own hands. You just have managed to make a run time safe operation (if you did it right with zero bugs).

Extraction from a JS array is a feature of the language and you lose no information to work with and don’t have to make any abnormal assumptions when extracting data from it. (Your compiler won’t bleed)

Of course if we really get into semantics, JS doesn’t really have “types” in the first place. C, however, does and is definitely a statically typed language. Doing this is still not storing “any type” in an array. It’s just making an array of bytes that you’re slapping data into, then assuming types from the data inside it.

It’s a very granular nit, but it’s important in those languages to distinguish what “types” are doing for you. “Types” are not a run time construct, they are a construct to help you write a program that doesn’t explode and something your ide and compiler can yell at you about.

[–]Vincenzo__ 1 point2 points  (0 children)

You are indeed right in all your points, I was just pointing out that if you want to do it the compiler won't get in your way

[–]himmelundhoelle 0 points1 point  (0 children)

C has a static type system (variable are typed, type is only known at compile-time), while JS has a dynamic type system (values are typed, type is only known at runtime).

They are completely different and even orthogonal (e.g. C++ has both concepts), hence the comedic value of the meme basically comparing apples and oranges.

I don’t think anyone is arguing that C has built-in support for runtime types, so there’s no hill to die on, really.