News for hackers. Stuff that matters.
Re:Why Use F#? by Barrin92 on Wednesday December 12, 2018 @09:05PM (#18669356)
In my opinion it's honestly the best statically typed general purpose programming language.

f# and also Ocaml strike for me the right balance between practicality and correctness (strict by default, no insistence on purity), but still immutable, good concurrency story, functional first with the ability to write imperative code easily, great type inference etc..

Given that so many mainstream languages are piece by piece moving into the same direction and adopting the ML family approaches I have no idea why not more people are moving directly to F# or Ocaml.

Re:Why Use F#? by laylomo2 on Wednesday December 12, 2018 @09:17PM (#18669410)
I moved directly from Python to OCaml and I have to say, I’ve never been happier. Special shout outs to Jane Street, as their open source software is really solid and a pleasure to use. The community is small but really smart. Overall I think F# and OCaml really nailed the programming language design sweet spot of powerful and practical.
Re:Why Use F#? by grdvnl on Wednesday December 12, 2018 @09:42PM (#18669479)
Can you eloborate on what kind of projects you work on which has made the move easy from Python to OCaml. While I love OCaml I have not heard positive things about the library eco-system in terms of variety and maintenance. Perhaps, you could throw some light on that based on your experience, especially after giving up the eco-system Python provides you.

This is a sincere question and would love to find good excuses to adopt OCaml as my primary language of choice.

Re:Why Use F#? by ernst_klim on Thursday December 13, 2018 @02:34AM (#18670507)
>I have not heard positive things about the library eco-system

OCaml has quite a neat ecosystem, though. Especially in terms of quality. There are a few major and a bulk of minor groups that write libraries for different purposes, such as:

* MirageOS -- people behind a bunch of a high quality system libraries, there are tls (in pure ocaml) and various cryptography primitives, filesystem drivers, tar, zlib, full tcpip stack, http server, git (in pure ocaml, not a mere binding), irmin (a git-based key-store database with concurrent access), dns and some other [1].

* Ocsigen -- webdevs, authors of Lwt (monadic concurrency library), js_of_ocaml (ocaml to js compiler) and related stuff [2]

* Jane Street, Facebook, blumberg -- reason syntax, bucklescript (alternative npm-ecosystem-frienly javascript compiler), various libraries for serialization, containers etc.

* Others

Opam [3] has quite a comprehensive set of libraries pretty for every purpose: data serialization, interaction with other langs (python, R, beam Erlang/Elixir), servers, db bindings, stuff for system or web programming. Some stuff is absent, but it's definitely not a scorched field, and most of the time the benefits worth writing an absent binding or two.

[1] https://github.com/mirage

[2] https://github.com/ocsigen

[3] https://opam.ocaml.org/packages/index-popularity.html

Re:Why Use F#? by delhanty on Wednesday December 12, 2018 @09:58PM (#18669549)
I'm looking at Ocaml again because of the existence (and quality) of the Bucklescript backend for Javscript.

That makes Ocaml sound pretty attractive on the portability front.

A question for anybody here regarding portability: Is it viable to maintain a portable core using a subset of Ocaml (something like Standard ML maybe - no objects) and compile that in F# using Ocaml portability mode?

For context, I've read this question on SO from 2010 [0] but I'm looking for some more 2018 perspectives from HN people.

[0] https://stackoverflow.com/questions/4239121/code-compatibili...

Re:Why Use F#? by yawaramin on Wednesday December 12, 2018 @10:24PM (#18669650)
That answer hasn't changed, in fact as of today OCaml and F# have diverged more than they had back then.

BuckleScript and ReasonML are solid for the frontend, though. I would recommend them without hesitation. For the backend, F# could be nice but as I mentioned, you would share almost nothing between them. If you're looking for a universal (i.e. same language on BE/FE) stack there are many options today, but a classic one is https://ocsigen.org/eliom/

Re:Why Use F#? by delhanty on Wednesday December 12, 2018 @10:36PM (#18669690)
Thanks very much for that perspective and the link.

It certainly sounds more attractive than writing everything in Javascript and using Node!

I'm interested in writing a portable, commercial 3D CAD modeling library. F# has already been used commercially for some years for 3D CAD on Windows. So F#, when compared with Ocaml, is a relatively easy sell into that market as it doesn't add another dependency.

Re:Why Use F#? by kbd on Thursday December 13, 2018 @12:06AM (#18669965)
> but a classic one is https://ocsigen.org/eliom/

I didn't know there were any other attempts at a "universal" platform since Meteor. Thanks for sharing! Please let me know if there are others that you think are worth learning.

Re:Why Use F#? by yawaramin on Thursday December 13, 2018 @10:40PM (#18678274)
Sure :-) Another one I admire is http://opalang.org/ . It too is based on OCaml, funnily enough. The last commit is from last year, though, so this is not a project on the rise.

Here's one for Scala (and Scala.js): https://udash.io/ . It has a lot of cool concepts, like out-of-the-box push notification support with WebSockets. And I am more familiar with Scala than anything else so it is attractive. The only thing that gives me pause is that I've used Scala.js in the past, and its compile times are not something I want to deal with again after using faster transpilers like BuckleScript.

Finally, the one I'm keeping my eye on is https://dockyard.com/blog/2018/12/12/phoenix-liveview-intera... . The idea here is to serve static HTML with a minimal bit of JavaScript needed to maintain a live connection to the server, over a WebSocket, and drive dynamism that way. Think React+Redux, but driven from the server side. The client can be mostly a dumb client again. This one has a promising future, with lots of optimizations and benefits falling out of using the Erlang runtime properly.

Re:Why Use F#? by Bogdanp on Thursday December 13, 2018 @03:02AM (#18670619)
You may want to check out Ur/Web as well.
Re:Why Use F#? by ernst_klim on Thursday December 13, 2018 @02:39AM (#18670525)
>A question for anybody here regarding portability: Is it viable to maintain a portable core using a subset of Ocaml (something like Standard ML maybe - no objects) and compile that in F# using Ocaml portability mode?

Both F# and OCaml have a lot of great features and peculiarities, and it's not worth of ignoring them for the sake of portability unless you use F# and OCaml as an intermediate language, as F* people do. Just choose a more suitable language for your needs and use it.

Re:Why Use F#? by nv-vn on Wednesday December 12, 2018 @10:23PM (#18669639)
Most likely not. You could get away writing a lot of utility type functions between the two, but the libraries, async scene, module system, object system, etc. vary enough that it would be practically impossible to share any non-trivial piece of code. Which isn't to say that porting anything would be hard, most of the core code would stay there and you'd only really adjust the edges of your code so to speak--if you separate out access to libraries or try to port the APIs from one language to another (which would be easy in OCaml with it's module system) it would certainly be possible to share 90% or more of your core code.

But for example, you'd have to avoid using async/await in F# and instead opt for some library that has surface-level compatibility with OCaml's Async or LWT and working with .NET libs would require you writing wrappers for the OCaml standard library.

Re:Why Use F#? by delhanty on Wednesday December 12, 2018 @10:38PM (#18669695)
Thank you.

>it would certainly be possible to share 90% or more of your core code.

It sounds like maintaining parallel code bases in Ocaml and F# with the same basic design and file layout might work quite well for the core.

Re:Why Use F#? by nikofeyn on Wednesday December 12, 2018 @11:31PM (#18669856)
i agree. f# is really nice and is very practically designed. it has very clean and consistent syntax. i wish more python people tried it. due to oop being perfectly fine in f#, one could write code in f# just as they do in python, and it would be superior in nearly every way.
Re:Why Use F#? by knocte on Thursday December 13, 2018 @01:37AM (#18670316)
TBH I think F# wins over OCaml just because of its mobile deployment story. It doesn't seem that OCaml's ecosystem has mature solutions for iOS&Android deployment.