Hacker News new | ask | show | jobs
by mgaunard 961 days ago
Type annotations for dynamically-typed languages is just a bad idea.

JavaScript's only reason for existence is web browsers. If you're not doing web stuff do yourself a favour and use something else.

3 comments

“C++’s only reason for existence is legacy GUI apps. If you’re not doing embedded stuff do yourself a favor and use something else.”
I would say this is largely true. C++ is incredibly fun and incredibly hard to wrangle. I think it's one of the most interesting ecosystems out there and you would have to do a lot of convincing to get me to start a new project in it. Everybody says they're going to be more disciplined this time, but after enough time, they remember the not-so-fun parts of the language. I'm not one of those freaks that has a fanatical drive to rewrite existing C++ software in Rust, but I do think it's something that's best avoided if you can help it.
As far as I recall, all compiled languages use untyped target languages. The only downside with TS/JS is that the JS implementation loses an optimization opportunity by not being aware of the TS-checked types.
I think probably the Java bytecode is type aware ? But yes, in general AOT compiled languages result in machine code, and so it isn't type aware after transformation.
> Type annotations for dynamically-typed languages is just a bad idea.

Yet, as with the parent comment, you haven't divulged your reasoning behind this statement. If you're going to make such a broad statement, at least place your rationale beside it.

> JavaScript's only reason for existence is web browsers.

JavaScript has seen broad adoption throughout the industry, for servers (Node.js, Deno, Bun), IoT (DeviceScript), browsers (duh) and mobile apps (NativeScript, React Native, etc.). It has its weak points, but downright dismissing it (again, without any rationale) is unfair and disingenuous IMO.

It breaks the whole point of typing being dynamic to begin with.

You don't build static typing on top of dynamic typing; it's silly. You do it the other way around.

If you're going to be outside of the browser, just use Python, which is not only somewhat similar but also the world's most popular programming language.