News for hackers. Stuff that matters.
Re:Why Use F#? by kazinator on Thursday December 13, 2018 @12:24AM (#18670038)
It strikes me as nonsense. Let's take the paragraph and replace "F#" with "C", ".NET" with "PDP-11", and "Core" with "V6 Unix".

Come on, surely you can make a non-.NET dialect of F#. Sure, not every .NET F# program will be portable to it. There must be some considerable abstraction in F# that isn't tied to .NET.

Re:Why Use F#? by piaste on Thursday December 13, 2018 @07:35AM (#18671852)
https://fable.io/repl/

This is a F# -> Javascript compiler and environment, itself running in your browser (in Javascript, obviously).

https://github.com/kjnilsson/fez

This is a project running F# on BEAM (Erlang).

So yes, of course you _can_ write a compiler from F# to whatever platform you choose. It's just a really major effort, in no small part because F# is a way, _way_ higher-level language than C (you'll remember 'worse is better' - a big deal with C is that it's easy to write a compiler for).

Re:Why Use F#? by kazinator on Thursday December 13, 2018 @01:05PM (#18674501)
> a big deal with C is that it's easy to write a compiler for

We are still feverishly at it in 2018 and there is no end in sight.

> It's just a really major effort

That is neither here nor there.

Re:Why Use F#? by bonesss on Thursday December 13, 2018 @03:04AM (#18670630)
Can you make a language that looks like F# and compiles? Sure.

Can you make F# the language meaningful on other VMs? Not really, as F# is a deep, deep, .Net language.

This isn't about abstraction or syntax, it's that every concept, feature, and element of the toolchain bases itself on .Net capabilities and considerations. From referencing libraries, to scripting, to type generation at specific points in the compile cycle to support Type Providers... Async computation blocks...

Remember, F# came from MS research based on the established working .Net framework, and was tighly tied to fundamental framework improvements (like generics and dynamics). It was built by hardcore .Netters, it's the first "true" .Net language, and it bases major language features on deep-down .Net capabilites not found in other VMs.

The point of the quote is that if you were to try this, at best you'd get "OCaml Over There", not "F#", since F# without .Net is "OCaml". It's not the syntax, it's the deeply intertwined nature of everything else.

Re:Why Use F#? by vram22 on Thursday December 13, 2018 @04:05AM (#18670925)
>Remember, F# came from MS research based on the established working .Net framework, and was tighly tied to fundamental framework improvements (like generics and dynamics). It was built by hardcore .Netters, it's the first "true" .Net language,

What are "dynamics" in this context?

>and it bases major language features on deep-down .Net capabilites not found in other VMs.

Can you give some examples of that?

Re:Why Use F#? by profquail on Thursday December 13, 2018 @01:32PM (#18674738)
“Dynamic” in GP’s answer is referencing .NET’s support for dynamic typing (which works in both C# and F#): https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
Re:Why Use F#? by vram22 on Thursday December 13, 2018 @01:48PM (#18674881)
Thanks, will check that out.
Re:Why Use F#? by kazinator on Thursday December 13, 2018 @01:59PM (#18674993)
That just looks earth-shatteringly non-portable; it cannot possibly exist anywhere but .NET.
Re:Why Use F#? by loeg on Thursday December 13, 2018 @10:48PM (#18678313)
Re:Why Use F#? by sparkie on Thursday December 13, 2018 @04:55AM (#18671135)
F# without the .NET platform is essentially OCaml.

The differences between the two languages are primarily in the way it integrates with the .NET platform and many assumptions on it.

If you wanted something similar on say, the JVM, starting from OCaml, you would make many different design choices and the result would be a very different language.

Re:Why Use F#? by kazinator on Thursday December 13, 2018 @01:49PM (#18674902)
So F# is the name of an OCaml implementation for .NET, which adds nothing but very .NET-specific extensions that don't make sense anywhere else?
Re:Why Use F#? by sparkie on Thursday December 13, 2018 @02:31PM (#18675230)
Mostly. It does add some novel new features which could be reused on other platforms, but many of the features are tightly linked to the .NET base class library, and would not translate cleanly over to other platforms (certainly possible to simulate them, but you would probably want something which integrates better with your VM)

For example, the whole type system is based on .NETs type system. interfaces, subtyping and generics, properties and indexed properties, which are quite different on the JVM and other platforms.

F# usually relies on having attributes (annotations in Java) for compatibility with other .NET languages like C# where certain features did not fit into the OCaml syntax and semantics cleanly. These also wouldn't transfer over to other platforms very well.

Some features which F# has that could transfer over to other platforms include measure types, active patterns, and type providers. I believe some of these have already made it to other languages. Gosu, for example, on the JVM had a feature similar to type providers before F# got them, so you could argue that F# borrowed that feature.