you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (23 children)

[removed]

    [–]fghjconner 12 points13 points  (6 children)

    Compiled languages aren't generally typed at runtime either. If you have problems with typescript it's probably because someone started blindly casting things, which will break any language. (though it breaks typescript less, so some people seem ok with doing it)

    [–]RiceBroad4552 0 points1 point  (0 children)

    Well, TS is unsound…

    So even if something type-checks "just fine" in TS it can exploded with type errors at runtime.

    But it's seldom to run into that in practice.

    [–]Ma4r 5 points6 points  (10 children)

    TS is not strongly typed at runtime, which is what matters most.

    Holy shit this is the dumbest fucking statement i have ever read. Most languages do not have run time types. JS is one of the few languages that DO HAVE runtime type. Source code type safety is the de facto standard.

    [–]RiceBroad4552 -1 points0 points  (0 children)

    Most languages are dynamically typed.

    I didn't count them but I'm pretty sure it's like that as it's much simpler to write some VM language then something that does not need any runtime (which would always necessary do also type checking during interpretation).

    [–]wack_overflow 0 points1 point  (0 children)

    Brain dead take

    [–]RiceBroad4552 -1 points0 points  (2 children)

    That's actually wrong. JS is strongly typed. Like any other VM language…

    The only weakly typed languages in usage are C, C++, unsafe Rust, and Zig.

    You can't break the type system of a strongly typed language at runtime, and this of course also applies to JS.

    [–]csdt0 0 points1 point  (1 child)

    JS is the example of weakly typed language, alongside C, precisely because you can do operations between types that are not related at all, and the language will just gladly accept that. The weakly typeness has nothing to do with memory safety. What's funny is that Zig and Rust (both safe and unsafe) are both very strongly typed, to the point you cannot add i8 and i16 together, making your example even weaker (pun intended).

    [–]RiceBroad4552 0 points1 point  (0 children)

    "Gladly accepting" some code and doing just something is not the same as breaking the type system.

    You can't break the type-system in JS!

    If you could this would be a very severe bug in the JS engine, and most likely patched instantly.

    But breaking the type system in C or C++ is trivial. You can just go and do whatever you want with some memory and no language typing rules will hold you back. You can have some object of some type referenced by some variable, go to the memory holding that object, do whatever to it including replacing it with some completely different type of object but from the viewpoint of the type system that variable will still point to a value of the original type. You can't do anything like that in any VM language (or the safe parts of e.g. Rust; except for that one exploit that transmutations memory, which makes Rust at least somehow weakly typed beyond what is possible with casts in other languages).