20 comments

[ 2.9 ms ] story [ 73.4 ms ] thread
Can anyone comment on Fable vs Elm?

I really like the idea of Elm; but I also really like the idea of using the same language for both the frontend and the backend, so I can share code, and I currently can't do that in Elm.

But I could do in with Fable, using F# on Mono on the server. The idea of using something as big as Mono doesn't really fill me with joy, but F# is supposed to be a thoroughly decent functional language (I've never used it myself). Except... Elm comes with all this value-added functionality that's ideal for web development. Unless Fable has something equivalent, I lose out on half the benefit.

Anyone?

I am not familiar with Fable but you might be interested n Haskelm[0] which helps you use Elm for the frontend and Haskell for the backend. I believe there are some other similar projects as well. I just recently started a new project in Elm (Clojure on the backend oddly enough... kind of opposite ends of the FP landscape) and I've got to say the experience has been fantastic so far.

[0] https://github.com/JoeyEremondi/haskelm

This hasn't been updated in two years and doesn't support the latest Elm version (0.17), sadly.
(comment deleted)
You can compile elm code and run it with nodejs on the server side using Elm.Main.worker()
If you're building a complicated dynamic UI want to take advantage of the latest ideas in front end data architecture (like om.next, or the the stuff in Elm), F# is still a bit behind when it comes to these ideas. The community has been very slow to embrace React-like UI technology, for example.

For general backend stuff it is awesome. I can't vouch for mono, however.

You could evaluate using WebSharper which is opensource and company backed project with good trackrecord at using F# on server and client with same semantics.

http://www.websharper.com/

Fable has made few choices on the semantics which make it not totally identical to F# on the server, although this shouldn't impact most of the code severely; but the mindset of Fable is different than websharper.

For F# on the server, Mono might not be lightest (if you compare to python or ruby which are already there by default) but is still the most suitable option right now until the OSS dotnet core eco system stabilizes and supports major libraries.

F# is definitely a fine functional programming language, able to blend with a tinge of OO where it makes sense while still being functional first. Relatively easy to pick-up if you have exposure to haskell or ocaml or sibblings.

I think support is still new, but F# runs on .NET Core which will give you much better performance and have more support going forward than Mono.

It also has "modern" node-style command line tooling and is hosted on Github for easy community contribution.

I can speak to F# being a joy to program in, though I have not yet taken the plunge into transpiling it to javascript yet. Websharper is another option you can look at for that, which may be more nicely integrated.

.NET Core is coming to Linux soon and will give you another option for compiler/runtime which will be good. Performance will be better, but mono has been working fine for me so far.

I am enjoying learning and using both Elm and F# at the minute, but finding a webserver to link them has not been straight forward. Suave, or Nancy seem to have a lots of opaque boilerplate, and I've not found anything with a similar learning curve to more familiar Python webservers.

Have you any suggestions for an F# webserver?

If your server is running Unix you might want to check Ocaml with js_of_ocaml (and maybe eliom), part of the ocsigen Web stack. Both languages are very similar but ocaml is a first class Unix citizen with native compiler backend.

http://ocsigen.org

If you aren't tied to .NET, you could always use OCaml and js_of_ocaml, a compiler that targets javascript.

Plus, you get a lot of functionality from the library too https://github.com/ocsigen/js_of_ocaml

The documentation is a bit confusing, but it has tons of features.

Also Bucklescript [0] now, although is still alpha quality according to the repo.

[0]: https://github.com/bloomberg/bucklescript

Yes, although I'm not sure that bucklescript is anything more than the compiler.

js_of_ocaml comes with library that lets you interact with the DOM and most of the browser APIs

Hi! I'm Fable's author, so you'll guess that my reply will be a bit biased ;) I'm not an expert on Elm but if you want to compare both, you should do strictly on a language and basic development tools (editor, compiler...) basis. Fable is designed to be a very lean F# to Js compiler and doesn't provide you with any specific tool for web development besides compatibility with most of F# core lib and some of .NET classes. Fable outputs clean JS which adheres to standard ES6 practices (modules, iterables...) and integrates in Babel's pipeline, so you can easily take advantage of current JS development tools, like Babel plugins, Webpack or React.

If you want a more complete and opinionated solution to develop web apps using F# both on the server and the client, Websharper is your best choice. However, Fable's community is already working on some libraries to make use of JS tools, like React for the web or Fuse for mobile development, in a more idiomatic way from F#. We're also planning to elaborate some guides for full stack development with Suave on the server (which already runs on .NET Core) and Fable on the browser.

Please take a look at Fable's website to know more about what's currently possible with the tool: http://fsprojects.github.io/Fable/

Incidentally, Indy Garcia has a simple but very nice Web Canvas app written both in Elm and F#/Fable so you easily compare both solutions side by side: https://github.com/Indy9000/noodle-soup

Any choice you make, have fun with functional web development!

(comment deleted)