News for hackers. Stuff that matters.
Re:Fable 3: F# to JavaScript compiler by sp33der89 on Friday December 04, 2020 @02:10PM (#25306365)
How does Fable 3 stack up against ReScript or Scala.js?

Is the only difference the ecosystem around the toolchains?

Re:Fable 3: F# to JavaScript compiler by jordwest on Friday December 04, 2020 @05:31PM (#25309167)
I haven't tried Fable 3 yet, but I can speak to Fable 2 (F#) vs ReScript/ReasonML (OCaml).

F# was heavily inspired by OCaml, it was originally intended as "What would OCaml look like running on .NET?" so the languages themselves share a lot of similarities.

ReasonML pros:

  - ReasonML compilation times were much faster than Fable 2, but Fable compile times weren't bad. OCaml is ridiculously fast.
  - OCaml has an interesting module system that's missing from F#.
  - The toolchain feels a lot more lightweight than the whole .NET toolchain.
Fable pros:

  - I found interop with JS and OOP stuff much easier in Fable than in ReasonML
  - Fable has a tool for converting TypeScript definitions to Fable definitions - though it hasn't always worked for me for more complex type definitions
  - I prefer F#'s whitespace sensitive syntax over OCaml, but that's just personal preference
  - F# type providers are pretty cool
  - F# has an interactive mode, and you can write standalone scripts (eg. for devops)
  - If you want to write a web backend in the same language, F# on .NET is much more mature in the web space than OCaml.
Re:Fable 3: F# to JavaScript compiler by dfgdghdf on Friday December 04, 2020 @06:48PM (#25309890)
I think you are missing the biggest advantage of F#: computation expressions.

Computation expressions are like do-notation and list comprehensions in one feature. Now that I have tried them, I don't want to go back to a language without!

Re:Fable 3: F# to JavaScript compiler by jordwest on Friday December 04, 2020 @08:48PM (#25310842)
Oh yes! These are amazing. Took me a while to understand what they do, but now the simplest way I think of it is that they're powerful enough to let you build your own async/await (though you don't need to - async await computation expressions are already included)
Re:Fable 3: F# to JavaScript compiler by nsonha on Saturday December 05, 2020 @01:37AM (#25312358)
This is just monadic bind, every functional language has this
Re:Fable 3: F# to JavaScript compiler by drs444 on Saturday December 05, 2020 @03:04AM (#25312746)
F# computation expressions go well beyond notation for monadic bind, see the section in https://fsharp.org/history or other technical descriptions.
Re:Fable 3: F# to JavaScript compiler by KurtMueller on Friday December 04, 2020 @07:14PM (#25310151)
Computation expressions seem like one of F#'s unique features. I assume there are corollaries in other languages - but damn do they make code readable.
Re:Fable 3: F# to JavaScript compiler by galaxyLogic on Saturday December 05, 2020 @01:03AM (#25312204)
Interesting. But is it true that that is nothing like that in other languages?
Re:Fable 3: F# to JavaScript compiler by dfgdghdf on Saturday December 05, 2020 @07:45AM (#25314130)
They are a bit like do-notation in Haskell, but with a few extra things. They are also like a more restricted / opinionated version of Clojure macros.

What's really cool is that things like ```async function *``` from JS can be implemented as libraries in F#.

Re:Fable 3: F# to JavaScript compiler by banjomet on Friday December 04, 2020 @02:54PM (#25306922)
A better question is about ReasonML/ReScript.
Re:Fable 3: F# to JavaScript compiler by smt1 on Friday December 04, 2020 @04:41PM (#25308479)
Another Ocaml-ish option is of course, Rust. One thing it has additionally going for it is a complete node.js JS reimplementation (with deno.js, the runtime is mostly go inspired), a client side web browser JS/Webstack impl with bleeding edge webgpu, webasm, CSS support (servo, which was hoisted up to the Linux Foundation - https://servo.org). I think the ethos of servo is interesting since it should allow the web to more interesting dynamic web pages tailored for bandwidth, internationalization, and localization issues, thanks to the (years) of hardwork by IETF and w3c.