News for hackers. Stuff that matters.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Wednesday April 29, 2015 @01:33PM (#9460035)
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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by narrator on Wednesday April 29, 2015 @02:23PM (#9460539)
Scala 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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Thursday April 30, 2015 @01:06AM (#9463442)
Yeah, I did a presentation at the DC Area Apache Spark meetup... slides: http://www.slideshare.net/RichardSeymour3/2015-0224-washingt... associated blog post: https://www.endgame.com/blog/streaming-data-processing-pyspa...

I've done a bit of scala spark as well, and my initial thought was prototype in pyspark and then rewrite in scala if necessary. Just this week DataBricks announced they are working on changing some of the data structures behind RDDs to save on unnecessary java object creation hubbub https://databricks.com/blog/2015/04/28/project-tungsten-brin...

That and the SQL compiler thing seems pretty darn awesome. Spark has the nice benefit of being plug and play (w/ a joyful time of compiling and deploying) with legacy HDFS/Hadoop systems. That alone will keep it in toolboxes for a long time to come.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by iskander on Thursday April 30, 2015 @01:58AM (#9463538)
>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

Unless Spark has changed dramatically in the year since I used it, that's not really how it works. You lazily construct an expression graph of RDD operators but the actual Scala code (the functional payload of e.g. flatMap) doesn't get analyzed. Are you talking specifically about Spark SQL's code generator?

>The cluster compute benchmarks on it are crazy good.

...and also carefully chosen to show off the niche cases where Spark shines. More commonly, you'll encounter crippling garbage collector stalls leading to mysterious and undebuggable job failures.

Spark has a very clean API but the implementation (at least for Spark versions 0.8-1.0) is still prototype quality.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by devonkim on Thursday April 30, 2015 @12:16PM (#9465994)
So basically you're talking about the design and limitations of https://databricks.com/blog/2015/04/13/deep-dive-into-spark-... I take it?

The implication of this work I thought is that it could be further expanded to other languages and DSLs. However, Spark's SQL generator still being very JVM-dependent and this optimizer generating bytecode kind of makes it pretty specific to JVM-supporting languages only. This would probably leave out Haskell and Erlang / Elixir in the short term, which is probably where I'd expect to see a different perspective on the whole data analytics front. We have Datomic, sure, (and I guess Clojure is enough for a lot of folks) but it'd be nice to have something other than "we want to make Hadoop... BUT BETTER" as a lot of the motivations.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Thursday April 30, 2015 @02:13AM (#9463570)
Yep!
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by ericmo on Wednesday April 29, 2015 @10:23PM (#9462986)
Would there be a F# equivalent to that Scala/Spark thing?
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by reubenbond on Thursday April 30, 2015 @01:03AM (#9463437)
I'm not in the know here, but maybe M-Brace is vaguely similar. Unsure about the optimization part. http://www.m-brace.net/
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Thursday April 30, 2015 @01:12AM (#9463449)
so I googled and saw this.

one could say they're... looking into it...

https://careers.microsoft.com/jobdetails.aspx?jid=170944&pp=...

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by rattray on Thursday April 30, 2015 @03:53AM (#9463801)
extract:

> 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)

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by cannam on Wednesday April 29, 2015 @02:12PM (#9460425)
I 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...) and found F# already simple to get along with and fast to run, at this beginner level. It could become a really interesting option.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by lobster_johnson on Wednesday April 29, 2015 @11:53PM (#9463261)
Good writeup. I posted it to HN: https://news.ycombinator.com/item?id=9463254.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by Zolomon on Thursday April 30, 2015 @06:43AM (#9464238)
Maybe you could try out Haskell also? I would gladly assist if you'd be in need of any.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by andor on Wednesday April 29, 2015 @03:25PM (#9461037)
Thanks, very interesting. Do you happen to know how large OCaml binaries get if you use Core.Std?
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by cannam on Wednesday April 29, 2015 @03:37PM (#9461111)
No, 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.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by typish on Wednesday April 29, 2015 @07:06PM (#9462401)
Also interesting is their F* language: 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

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Thursday April 30, 2015 @01:10AM (#9463445)
Gotta 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.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by zaszrespawned on Wednesday April 29, 2015 @11:36PM (#9463221)
I'm going to write a package manager and call it F* ck
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by SideburnsOfDoom on Thursday April 30, 2015 @04:05AM (#9463835)
There's already a mocking lib called Foq: http://trelford.com/blog/post/fstestlang.aspx
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by runT1ME on Friday May 01, 2015 @01:51PM (#9473234)
Have you worked with it? I love the idea of a fully powered F# without the kiddie gloves. F* looks pretty neat.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by ghuntley on Wednesday April 29, 2015 @07:11PM (#9462435)
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by dicroce on Wednesday April 29, 2015 @04:04PM (#9461320)
Did you just invent a term? "Pop-Functional"... I like it!
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by lultimouomo on Wednesday April 29, 2015 @05:26PM (#9461920)
Starts singing

make my func the p-func / I want my func uncut...

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by TheSmoke on Wednesday April 29, 2015 @05:47PM (#9462053)
and i even hear marilyn manson doing a dirty version of it.

"tainted func"

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by jacquesm on Wednesday April 29, 2015 @08:36PM (#9462712)
Marc Almond maybe.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Wednesday April 29, 2015 @10:24PM (#9462988)
I hope so.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by vezzy-fnord on Wednesday April 29, 2015 @02:19PM (#9460495)
You would think something like OCaml would fill in that niche with its wider availability.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by cannam on Wednesday April 29, 2015 @02:30PM (#9460587)
They 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#).
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by seanmcdirmid on Wednesday April 29, 2015 @03:36PM (#9461109)
OCaml doesn't come with the ecosystem that F# does. It isn't about availability, but APIs to play with.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by s_kilk on Wednesday April 29, 2015 @04:32PM (#9461524)
I'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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by cwyers on Wednesday April 29, 2015 @04:56PM (#9461720)
Well, one is sponsored by and used in production by Google, and the other is maintained by the French Institute for Research in Computer Science and Automation.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by s_kilk on Wednesday April 29, 2015 @05:02PM (#9461765)
Good point.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by GFK_of_xmaspast on Wednesday April 29, 2015 @05:49PM (#9462068)
Go gets a lot of buzz on places like HN, but that's a long way away from being a major language.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by seanmcdirmid on Wednesday April 29, 2015 @06:01PM (#9462130)
Rob pike and company are also systems folks; the language supports the ecosystem they are building, not the other way around.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by pron on Wednesday April 29, 2015 @03:02PM (#9460853)
There's a very cool implementation of (multi-threaded!) OCaml for the JVM: http://www.ocamljava.org/
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by ionforce on Wednesday April 29, 2015 @07:17PM (#9462459)
I'm upset this wasn't called Joe Camel. And marketed towards children.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by pron on Thursday April 30, 2015 @12:49PM (#9466184)
Yeah, but that's because there already is a JoCaml: http://jocaml.inria.fr/
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by d4rkph1b3r on Thursday April 30, 2015 @01:10AM (#9463446)
I 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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by ericmo on Wednesday April 29, 2015 @10:20PM (#9462978)
I 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#.
Re:Microsoft Launches Its .NET Distribution for Linux and Mac by justthistime_ on Wednesday April 29, 2015 @07:26PM (#9462495)

  case 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).

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by bunderbunder on Wednesday April 29, 2015 @11:51PM (#9463255)
In 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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by justthistime_ on Saturday May 02, 2015 @08:16PM (#9479140)
Well, then I think JSON is a petty bad example, because pretty much no service provides some schema-like specification of their protocol in JSON.

If there is one thing I learned using type providers it is that maintaining your own "description"–be it as sample data or a schema file–loses most benefits of using type providers in the first case.

On the other hand, want a type provider for X in Scala? Just write it.

Stuff is still moving around because Scala devs want to get the meta APIs right first, but if adapting things from time to time is not an issue, then go ahead.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by nutate on Wednesday April 29, 2015 @10:25PM (#9462992)
Tell 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

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by justthistime_ on Saturday May 02, 2015 @08:28PM (#9479179)
It 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.

Re:Microsoft Launches Its .NET Distribution for Linux and Mac by scaladdin on Thursday April 30, 2015 @04:17AM (#9463863)
Learn Scala before you say something about it.