News for hackers. Stuff that matters.
Re:OCaml 4.10 by polskibus on Saturday February 22, 2020 @07:31AM (#22390674)
What's your opinion on F# ? Does it share enough of OCaml goodness to be worth using in .Net world or instead of OCaml?
Re:OCaml 4.10 by gameswithgo on Saturday February 22, 2020 @08:38AM (#22390921)
F# is very much like a .NET port of OCaml. It is very nice to use and offers (usually) low effort interop with all of the worlds C# libraries.

We use it in production at Olo, and I used it in production at my last company.

Since learning F#, languages where if statements aren't expressions and that don't have option types feel broken to me =)

Re:OCaml 4.10 by polskibus on Saturday February 22, 2020 @11:19AM (#22391735)
I can see that F# still does not support GADTs. Did you find it a serious limitation?
Re:OCaml 4.10 by daxfohl on Saturday February 22, 2020 @12:53PM (#22392278)
Depends on what you're trying to do. I've never found it to be a limitation but I don't do anything terribly intricate. Just web dev for work, and I wrote a toy language parser and type inferencer in it. There are maybe three lines of code that GADTs might have let me avoid casting in the type inferencer, but oh well. Different use cases that use GADTs to a greater extent, of course, you might miss them. What is your use case, and how much are you reliant on GADTs in your existing daily life?
Re:OCaml 4.10 by amw-zero on Saturday February 22, 2020 @07:42PM (#22394341)
You can go an entire lifetime without ever even knowing about GADTs. I don’t find their absence limiting at all.
Re:OCaml 4.10 by Jorge1o1 on Saturday February 22, 2020 @08:37AM (#22390917)
I’ve used F# and USING it feels very similar to OCaml in all of the important ways.

The lightweight type structure where you can easily make Union types and the pattern matching are pretty much identical to how OCaml does it.

Of course, the big difference is going to be in how easily you can interop with the .Net stuff in each language, obviously much easier in F#. This is great if you happen to have some kind of weird C# code that generates an IEnumerable, just pop that into F# and start working with it.

For example, I have C# classes to read files to an IEnumerable of strings, you can just call List.ofSeq on it, and then start doing some really elegant things in F# with it. You can pattern match log files based on how the line starts and then run different functions whether it’s an error, info, debug, etc

Re:OCaml 4.10 by yawaramin on Saturday February 22, 2020 @11:55AM (#22391958)
If you are in the .NET world, then definitely prefer F# to C#. However be aware that it differs in some significant ways from OCaml. E.g., it does not have a separate module language (module types, functors, first-class modules). Its design is in a different, more object-oriented direction, with support for classes and interfaces.

Basically, if you do use F#, be aware that it has its own idioms that you must learn; it's not a drop-in replacement for e.g. OCaml/Haskell/etc.

Re:OCaml 4.10 by nestorD on Saturday February 22, 2020 @10:55AM (#22391594)
Having used both for years, nowadays I would recommend using F#.

The syntax is very similar but it solves many of Ocaml's pain points and you will get better tooling and more libraries thanks to .Net.

Re:OCaml 4.10 by polskibus on Saturday February 22, 2020 @12:34PM (#22392169)
Could you elaborate on the pros of F# vs OCaml?
Re:OCaml 4.10 by nestorD on Saturday February 22, 2020 @02:24PM (#22392770)
In no particular order: - significant whitespace and no `let ... in` which makes for a more streamlined syntax - no +. vs + - a solid standard library - much improved tooling (see the ionide plugin for vscode) - you can use all the .Net libraries - multicore support - list comprehension and iterators - object support with a minimalistic syntax (I don't include type providers as I never had proper use cases for them)

All of those either remove pain points (some of them arguably very small) or introduce improvements that are sensible in day to day life.

With that and the fast that Ocaml and F# can (for the most part) easily be transpiled into one another, nowadays I see very little reason not to use F#.

That being said, I find the fact that you basically never need explicit types in Ocaml very elegant (in F# the uniform syntax mean that you will need occasional types hints to disambiguate operations).

Re:OCaml 4.10 by yawaramin on Saturday February 22, 2020 @09:19PM (#22394667)
> list comprehension

Are you referring to F#'s computation expressions? If so, OCaml has a similar-in-power let-syntax now: http://jobjo.github.io/2019/04/24/ocaml-has-some-new-shiny-s...

> Ocaml and F# can (for the most part) easily be transpiled into one another,

Actually they can't. They are quite different languages in practice.

Re:OCaml 4.10 by nestorD on Sunday February 23, 2020 @03:19AM (#22395749)
No, I am referring to proper list comprehensions (as you would get in python): https://en.wikibooks.org/wiki/F_Sharp_Programming/Lists#Usin...

Its true that you can't literaly transpile very high order things such as GADT but the was majority of code is trivial to translate as both syntax and available constructs match.

I practice, I found translations between the two languages to be fairly easy (the same cannot be said for most language pairs).

(I was not aware of the new let-syntax, thats a nice addition (although computation expression did not make my list as they are more of an enabler for library authors than normal users). I will dig in to see what people build around it...)

Re:OCaml 4.10 by yawaramin on Sunday February 23, 2020 @10:31AM (#22397259)
> I am referring to proper list comprehensions

Oh cool, I'd forgotten F# had those (or maybe it got them recently?).

> Its true that you can't literaly transpile very high order things such as GADT but the was majority of code is trivial to translate

Would still have to disagree there; OCaml code heavily relies on modules/module types/functors, while F# code relies more on classes. In practice these are not trivially translateable.

> I will dig in to see what people build around it...

The major thing is getting an async/await-like syntax for concurrent operations. Super useful for literally everyone. E.g. my project https://github.com/yawaramin/re-web/blob/eb7ce8474d34c60f9f9...

Re:OCaml 4.10 by abhijat on Saturday February 22, 2020 @05:21PM (#22393734)
How do you transpile f# to ocaml? Does this mean you can get a native self contained binary out of f# code, by first converting it to ocaml code?
Re:OCaml 4.10 by nestorD on Sunday February 23, 2020 @03:23AM (#22395759)
I was mentionning manually translating a code base from one language to the other. I am not aware of a tool to do that (which, as others have said, would be tricky to do automatically for some constructs).
Re:OCaml 4.10 by yawaramin on Saturday February 22, 2020 @09:19PM (#22394670)
Re:OCaml 4.10 by Yoric on Saturday February 22, 2020 @07:57AM (#22390755)
I never seriously used F#, so I can't tell for sure, but it looks pretty good!