6 ms·
F# is a real breath of fresh air in comparison to something like Scala. It's direct ML heritage really shows, also just diving in with an IDE (like Xamarin, or
by nutate 11y ago
F# is a real breath of fresh air in comparison to something like Scala. It's direct ML heritage really shows, also just diving in with an IDE (like Xamarin, or I suppose Visual Studio) is super easy.
I see it as the future of pop-functional programming. For example look at the way it handles type inference w/ JSON parsing. Compare that to what you have to do to parse JSON in Scala. It's subtle, but a major usability win.
- cannam 11y agoI did a toy comparison of ML-derived languages running on Linux the other day (http://thebreakfastpost.com/2015/04/22/four-mls-and-a-python/ http://thebreakfastpost.com/2015/04/22/four-mls-and-a-python...) and found F# already simple to get along with and fast to run, at this beginner level. It could become a really interesting option.
- andor 11y agoThanks, very interesting. Do you happen to know how large OCaml binaries get if you use Core.Std?
- cannam 11y agoNo, I haven't even downloaded Core. I am more ignorant about OCaml than any of the others. I'd love it if someone else here could weigh in on the pros and cons.
- lobster_johnson 11y agoGood writeup. I posted it to HN: https://news.ycombinator.com/item?id=9463254 https://news.ycombinator.com/item?id=9463254.
- Zolomon 11y agoMaybe you could try out Haskell also? I would gladly assist if you'd be in need of any.
- vezzy-fnord 11y agoYou would think something like OCaml would fill in that niche with its wider availability.
- cannam 11y agoThey do seem like very similar languages. I imagine in most cases your choice would have effectively already been made for you by the context -- e.g. whether you wanted the option of fast native binaries (OCaml) or deep .NET integration (F#).
- pron 11y agoThere's a very cool implementation of (multi-threaded!) OCaml for the JVM: http://www.ocamljava.org/ http://www.ocamljava.org/
- seanmcdirmid 11y agoOCaml doesn't come with the ecosystem that F# does. It isn't about availability, but APIs to play with.
- s_kilk 11y agoI'm not sure I buy the ecosystem argument. We've recently seem other languages come from out of nowhere, with no ecosystem, to become major languages (Golang, for example). I don't think there's really anything stopping OCaml from being more widely adopted, except for lack of attention from trend-setters.
- narrator 11y agoScala is getting really interesting lately though with projects like Spark and SparkSQL. Spark takes a Scala AST tree and computes a plan on it in order to distribute it to a cluster of possibly thousands of nodes and then uses transformations on that plan, similar to how an SQL query optimizer works, to make the plan more efficient. The cluster compute benchmarks on it are crazy good. The only problem I have with Scala is that it has so many features that it tends to have a steeper learning curve than most languages. However, this is mitigated somewhat in that it lets one switch between object and functional depending on what's more convenient or performant, thus making it easier for programmers who are not highly skilled in functional programming to pick up.
- ericmo 11y agoWould there be a F# equivalent to that Scala/Spark thing?
- reubenbond 11y agoI'm not in the know here, but maybe M-Brace is vaguely similar. Unsure about the optimization part. http://www.m-brace.net/ http://www.m-brace.net/
- nutate 11y agoso I googled and saw this. one could say they're... looking into it... https://careers.microsoft.com/jobdetails.aspx?jid=170944&pp=VR https://careers.microsoft.com/jobdetails.aspx?jid=170944&pp=...
- rattray 11y agoextract: > Inspired by Spark, we are building OneNet, a distributed functional programming platform based on F# that allows programmer to build distributed system at >3x productivity. OneNet offer similar programming model and extensibility of Spark, but goes much beyond in distributed functional programming to offer additional capability and performance (e.g., in-memory sharing of instantiated object with concurrent operation, use of both managed code & unmanaged code in functional programming, use of model and/or key value store, multi cluster with EDGE + cloud, private + public cloud compute, use of GPGPU/FPGA in cluster)
- dicroce 11y agoDid you just invent a term? "Pop-Functional"... I like it!
- lultimouomo 11y agoStarts singing make my func the p-func / I want my func uncut...
- nutate 11y agoI hope so.
- typish 11y agoAlso interesting is their F* language: http://fstar-lang.org/ http://fstar-lang.org/ "F* is a new higher order, effectful programming language (like ML) designed with program verification in mind. Its type system is based on a core that resembles System Fω (hence the name), but is extended with dependent types, refined monadic effects, refinement types, and higher kinds. Together, these features allow expressing precise and compact specifications for programs, including functional correctness properties. The F* type-checker aims to prove that programs meet their specifications using an automated theorem prover (usually Z3) behind the scenes to discharge proof obligations. Programs written in F* can be translated to OCaml, F#, or JavaScript for execution. " It's open source too: https://github.com/FStarLang/FStar https://github.com/FStarLang/FStar
- zaszrespawned 11y agoI'm going to write a package manager and call it F* ck
- SideburnsOfDoom 11y agoThere's already a mocking lib called Foq: http://trelford.com/blog/post/fstestlang.aspx http://trelford.com/blog/post/fstestlang.aspx
- nutate 11y agoGotta love automatic theorem proving. I read the Shen language book on "logic, proof and computation" which got me into the idea of a theorem prover inside of your normal language.
- runT1ME 11y agoHave you worked with it? I love the idea of a fully powered F# without the kiddie gloves. F* looks pretty neat.
- ghuntley 11y agoIf F# is of interest to you then check out http://www.fsharpworkshop.com/ http://www.fsharpworkshop.com/ + https://github.com/ghuntley/fsharp-workshop https://github.com/ghuntley/fsharp-workshop and finally http://fsharpforfunandprofit.com http://fsharpforfunandprofit.com
- justthistime_ 11y agocase class Fruit(name: String, variants: Set[String]) val fruitJson = Json.parse( """{ "name": "apple", "variants": ["cox", "braeburn"] }""") val fruit = fruitJson.as[Fruit] Doesn't seem to be too painful to me. I agree that F# is syntactically closer to ML (though Scala is closer to ML with its module system which F# gave up completely).
- nutate 11y agoTell me what happens with that technique when your json has > 22 keys. ;) (Edit) this is apparently working in the latest scala 2.11 But it killed my adoption of scala for real work early on. https://issues.scala-lang.org/browse/SI-7099 https://issues.scala-lang.org/browse/SI-7099
- justthistime_ 11y agoIt works without issues. I never have seen a use-case where this would have been an issue. Sure, it "looks" unfortunate, but there is only so much you can do when running on a completely uncooperative runtime. If devs need a typed representation of unlimited length, they provide a HList and move on. Such a representation will replace the length-limited tuples in a future version of Scala.
- bunderbunder 11y agoIn this base case, no, it isn't too painful. But once you get to larger and more complicated structures, F#'s type provider system can be a tangible timesaver. Especially if you're doing exploratory programming. TBH, I think the JSON example might underrate things a bit anyway. Where type providers really start to feel impressive is when you get to tricks like being able to noodle around inside undocumented (or poorly documented) COM interfaces with the help of CodeSense, or getting red squigglies in your editor (and compile time errors) when there's a problem with an SQL query. F# isn't all roses, of course. I really wish it had typeclasses, and discriminated unions are less powerful than Scala's case classes in some tangible ways. But from a purely pragmatic perspective, my (almost certainly biased) sense is that I can usually Get Things Done™ with less ceremony in F#, and type providers are a shining example of that pragmatism.
- ericmo 11y agoI know it doesn't say much, but having never coded in ML and having tried F# briefly (I code mostly C#, and it'd be easy to have mixed F#/C#), I think Scala has much clearer syntax, or perhaps it's just more familiar for someone who's coming from imperative languages like C++ or C#.
- d4rkph1b3r 11y agoI don't agree, it's 'direct ML heritage' is quite superficial, as it omits ML's most powerful feature, functor modules. Scala however has all kinds of super powered functional programming features that F# is missing, implicit parameters for type class constraints, ADTs, higher kinded types, etc.
- scaladdin 11y agoLearn Scala before you say something about it.