News for hackers. Stuff that matters.
Re:What I wish I knew when learning F# by eatonphil on Thursday October 14, 2021 @09:37AM (#28864045)
I've had good experiences running F# on Linux. I used it to build an API generator from database schemas [0]. Similar to Go you can get a single static binary you can copy anywhere.

It's very convenient and you've got a massive number of .NET APIs to fall back on.

The language is a little complex though. That you cannot call interface methods on an object implementing the interface without explicitly casting to the interface [1] is pretty weird. And getters/setters are a little complex.

If you want an easy introduction to the ML family for educational/historic sake I'd always recommend Standard ML. But if you want a highly pragmatic, mature, strictly typed, compiled, cross-platform language F# is pretty compelling.

[0] https://github.com/eatonphil/dbcore

[1] https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...

Re:What I wish I knew when learning F# by phillipcarter on Thursday October 14, 2021 @12:55PM (#28866782)
The language, in general, wants you to be explicit about what you're working with. So implicit access to interface members isn't a thing, you need to say that "x is this interface type" or cast.

In F# 6 things are changing a bit, and may possibly change in the future. There are various classes of cases where the type information is known, but the compiler still required you to explicitly cast things to be happy. That's no longer case. This link[0] has 3 examples that don't compile with F# 5 but will compile with F# 6.

[0] https://sharplab.io/#v2:DYLgZgzgNALiBOBXAdgHwPToAQFMAeAhgLYA...

Re:What I wish I knew when learning F# by TravHatesMe on Thursday October 14, 2021 @01:08PM (#28866984)
> implicit access to interface members isn't a thing, you need to say that "x is this interface type" or cast.

If the compiler already knows that it implements interface X Y and Z, it seems unnecessary to require it (unless those interfaces have conflicting names, in which case you would have to be explicit due to ambiguity).

I feel like many languages are walking away from being so explicit, in particular I've noticed C# becoming more implicit over the years.

Re:What I wish I knew when learning F# by Dayshine on Thursday October 14, 2021 @01:01PM (#28866870)
Implicit upcast? That's amazing, I feel like that's going to help a lot with many branched functions.
Re:What I wish I knew when learning F# by phillipcarter on Thursday October 14, 2021 @01:08PM (#28866985)
Yeah, it's a good feature. It's been done carefully -- there's room to do more of this kind of upcast conversion in the future -- but there's also a danger of creating code that behaves weirdly, too. See here for some of the dangers in Scala 2: https://latkin.org/blog/2017/05/02/when-the-scala-compiler-d...
Re:What I wish I knew when learning F# by odersky on Friday October 15, 2021 @03:32AM (#28875310)
It's worth mentioning that 4 out of 5 puzzlers in this article are fixed in Scala 3. The one that remains behaves arguably as it should.
Re:What I wish I knew when learning F# by nextos on Thursday October 14, 2021 @01:23PM (#28867212)
It's also important to add F# is an inspiration for an amazing MS Research effort, F* [1].

Furthermore, it is also worth checking Dafny [2] (Spec#'s successor). The relationship between Dafny and C# is equivalent to the relationship between F* and F#. Both languages try to refine their predecessors semantics and augment them with practical constructs to prove program correctness.

Some of the largest software artifacts ever verified have been implemented in Dafny [3], and F* is also looking quite promising.

[1] https://www.fstar-lang.org

[2] https://dafny-lang.github.io/dafny/

[3] https://www.cs.columbia.edu/~junfeng/17sp-e6121/papers/ironf...

Re:What I wish I knew when learning F# by 7331 on Friday October 15, 2021 @02:20AM (#28874888)
Why oh why are people still putting special characters in the names of programming language?

# . + are bad enough... but * ?!? It can't even be used in filenames at all.

And while Google might be ok at indexing it... pretty much every other fulltext search engine will be useless. Not to mention it can't be used in package names, domain names, filenames, and a heap of other things.

Even an emoji (while still terrible) would be better under some circumstances.

"Go" was ridiculous enough, ironically from somebody who works at Google. But these people still putting special characters in the names must really not care about findability/disambiguation at all.

PHP might have got a lot wrong... but the name is great... it's just "PHP" everywhere, even the filename extension.

Re:What I wish I knew when learning F# by amw-zero on Thursday October 14, 2021 @09:40PM (#28872939)
What makes you say that F# is an inspiration for F? I recently went through the F tutorial and saw no mention of that. Obviously F* is an ML, but it seems more like Ocaml than F#.
Re:What I wish I knew when learning F# by phillipcarter on Thursday October 14, 2021 @11:13PM (#28873763)
Might be referring to the fact that quite a bit of f-star is written in F# and that F# is an emit option?

That said, the F# code that you see in the compiler source looks syntactically more like OCAML and makes little use of .NET.

Re:What I wish I knew when learning F# by psd1 on Friday October 15, 2021 @03:02PM (#28881712)
Excellent illustration of 7331's sister-level comment... your two *s have turned into markup
Re:What I wish I knew when learning F# by alexvoda on Friday October 15, 2021 @05:55AM (#28876044)
How does Dafny compare to M#, the unreleased language used for project Midori?
Re:What I wish I knew when learning F# by foepys on Friday October 15, 2021 @02:15AM (#28874864)
> That you cannot call interface methods on an object implementing the interface without explicitly casting to the interface [1] is pretty weird.

That's probably because in C#/.NET you can specify methods that are only valid when being used as this exact interface. Those are called explicit interface implementations and can contain completely different code than the class method.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...

Re:What I wish I knew when learning F# by beecafe on Thursday October 14, 2021 @05:09PM (#28870151)
at least they picked cute bird face emoji for it :>