News for hackers. Stuff that matters.
Re:What is a Source Map by vog on Wednesday November 15, 2017 @04:55AM (#15702670)
This is an interesting case for languages with strict type systems. Maybe you can get away without source maps and still not loosing much?

Some time ago I took a look at various transpilers for ML-like languages: OCaml->JS, Elm->JS, Haskell->JS, etc.

I worried about how good the source maps would be, because good source maps are non-trivial, and it is no fun to debug in a different language than your source.

To my astonishment, those transpilers provide either rudimentary source maps, or no source maps at all! And I didn't find any significant push towards better source maps. I wondered how this is possible, given that the communities around ML-like languages place great emphasis on high-quality code with as few bugs as possible.

Then I got it: This is just another instance of "If it compiles, it almost always works". Imagine client-side code where no type of server response can be ignored, no unexpected null or undefined can slip into your data structures, every function or method you call will 100% surely exist, and so on. Think of TypeScript or Flow, but on steroids. That's what these languages and their transpilers offer.

Well, at least that's the theory. It would be interesting to have reports from people actualitty writing larger web applications that way, and in how far these promises hold.

Re:What is a Source Map by Drup on Wednesday November 15, 2017 @05:37AM (#15702809)
This is true as long as you stay in the language.

When you start binding to JS libraries, all hell break loose and you have to track down undefined and nulls that slip into places they shouldn't, because most JS libraries are poorly written.

I only have experience with js_of_ocaml, which has fairly good support for source maps .... after a painful setup phase. It does help a lot for bindings though.

Re:What is a Source Map by vog on Wednesday November 15, 2017 @06:03AM (#15702923)
> js_of_ocaml, which has fairly good support for source maps

Wow. That must have changed in the meantime.

Bucklescript seems to be the way forward, and much better than js_of_ocaml. But that's hearsay. Anyone with actual experience in bucklescript?

> you start binding to JS libraries, all hell break loose and you have to track down undefined and nulls that slip into places they shouldn't, because most JS libraries are poorly written

If the interface to that JS library is not performance critical, couldn't you just setup a thin wrapper and communicate to the library via JSON structures? Then, your OCaml code could treat it like any other (potentially buggy) external source.