▲ | Animats 12 hours ago | |
In a compiled language, it takes one or two machine instructions to test
Works in C, C++, Go, Rust...Amusingly, nowhere in the original article is it mentioned that the article is only about Javascript. Languages should have compile time strong typing for at least the machine types: integers, floats, characters, strings, and booleans. If user defined types are handled as an "any" type resolved at run time, performance is OK, because there's enough overhead dealing with user defined structures that the run time check won't kill performance. (This is why Python needs NumPy to get decent numeric performance.) | ||
▲ | whilenot-dev 12 hours ago | parent [-] | |
Sure, use macros in function bodies. That won't affect the function signature in any meaningful way for the type checker and remains a check at runtime only, doesn't it? It seems like the point of the article was to not do that though, contrary to my own opinion, and I just wonder why... |