← Back to context

Comment by JasonFruit

8 years ago

How about just biting the bullet and writing JavaScript?

If I decided I wanted to use Delphi, but I didn't like Object Pascal, so I implemented a Scheme over the top that gave weird deep backtraces with wrong line numbers whenever an error occurred, compiled to a single-line semicolon-delimited mess of unidiomatic Pascal, and often required me to write some Pascal anyway, you'd think I was nuts. Why do we think it's a good idea just because it's in a browser?

JavaScript has its problems, but it's far from the worst language out there. Just write JavaScript already.

I see your point, but I also think a smaller, more focused language can be useful for teams; in order to enforce best practices.

Think Elm: it's impossible to produce side-effects or mutate objects, cause the language simply does not have the facilities to do so. The guarantees Elm gives you would be hard to maintain if it was just a library which had to deal with JS's constant dynamicness.

Moreover this guarantees do not only improve developer experience; but also compiler optimizations.

The difference is that there's no other way to target the browser. With your Delphi example, you could just use a Scheme implementation that targets the same platform. With the browser, JS is the only way to run code. That's starting to change with WASM, but it'll be while before it can be used for everything JS is used for.

I think you just described ES6 compiled by Babel pretty well. Most people have gotten used to this disconnect.

  • Well, with Babel you at least have source maps so you can get the original source locations in your backtraces.

    • One of the benefits I've seen while using Elm is that you virtually never need browser-based backtraces. The Elm compiler catches everything and has much better error messages, in my opinion.

On the other hand, i could rewrite your comment about assembler, in the early days of C and B and the like. As source maps and debugging get better, we get closer to being able to ignore the javascript.

Unfortunately, that ship sailed long ago, and the javascript community has coalesced around avoiding direct contact with the language at any cost.

  • Why is it unfortunate that people improve their tools with things like Elm and Mint?

    And how is "just use Javascript" a response to that? Seems like yall should first try to understand why people use tools like Elm and Mint instead of assuming it's just some flippant aversion to Javascript?

    • You don't need compile-to-js languages to have the benefits that those languages provide. You could validate javascript for correctness and safety directly, or import js libraries which implement "types" which javascript doesn't support (because such types have to be to javascript anyway.)

      But I think the primary reason to use languages that compile to javascript, rather than tools that work on javascript, is to avoid writing javascript.

      1 reply →