5 ms·
If the main goal is static typing, it seems like using a static compile-to-JS language may be better because you can use the whole Node ecosystem. A few choices
by dangoor 11y ago
If the main goal is static typing, it seems like using a static compile-to-JS language may be better because you can use the whole Node ecosystem. A few choices for static typing (the first two are JS supersets, the second two are just different languages):
* Flow from Facebook
* TypeScript
* Elm
* PureScript
- Keats 11y agoFrom my experience (used Typescript for a few projects for frontend and tried Flow but ran into bugs/missing things) both TS and Flow type system are easy to fool and in the end you are still writing javascript. I've never heard of Elm or PureScript being used for backends, users would prefer Haskell I presume. With elm it would require using ports for almost everything, I haven't used PureScript so I can't comment on that. And as far as ecosystems go, I would prefer using the Python one rather than the Node one.
- purescript 11y agoThere are some PureScript projects that I know of running on Node, although it is admittedly less common. I'm currently working on a framework to build REST services in PureScript, so hopefully the situation will improve shortly.
- deleted 11y ago[deleted]
- smt88 11y agoI just decided to use TypeScript for a new REST API I'm writing. I'd have liked to use Rust instead, but I felt it was still too early (and can't afford the productivity hits of using a new-ish ecosystem). So far, TypeScript's type system isn't perfect, but it is strict enough to help me catch errors before runtime. Also, there's the (huge) added benefit of making code more readable and self-documenting. I think I've only had one instance where I violated a type at runtime, but keeping the type system in mind as you're writing your code, you know exactly where those things can or can't happen. I am really enjoying using Visual Studio's excellent IntelliSense and debugging features, which are on-par with any other web language I've used. Generally speaking, the typing makes hints and autocompletion far better. Overall, I'd give the whole experience a 7 out of 10. I don't really know of a more productive way to write asynchronous code at the moment.
- spion 11y agoI'd be curious to know how Flow is easy to fool (other than uninitialised class members).
- Yoric 11y agoOut of curiosity, how is that better than using Rust? My personal intuition is that by using a compile-to-JS + Node, you lose performance (Node.js is good for I/O, but not great for anything CPU-bound), plus combining Node.js and compile-to-JS is not too easy, if the compiler is not designed specifically for it (typically if it's not CPS-based). In addition, if you intend to use static typing on generated JS, I suspect that you are going to lose plenty of information.