Dec 29 2007
Functional Programming Language de Saison
Has anyone else noticed that there’s a new “hip” functional programming language every 3 months or so? The first one I heard of was Erlang, about a year ago. And then that fell out in favor of Haskell. Then OCaml seemed to have its turn. Now it’s looking like it’s Scala.
What gives?
Popularity: 8% [?]
Actually, I’m kind of not surprised. Haskell is great, but it’s pretty strong stuff if you’re comming directly from the C++/Java/Ruby world. Actually, it’s pretty strong stuff comming from the Ocaml world.
And I can see (and I hope that) Scala and F# will be the big break out Functional Languages- in some sense they’re to FP what C++ was to OO (except that they don’t suck). As they’re both well integrated into their environment, you can leverage both the existing Java/.NET library base and the existing skill set with those library bases. As they’re multi-paradigm languages in the style of Ocaml, you don’t to learn a whole new set of problem solving skills from the get go. And, if all else fails, you can drop back to Java or C# and get things done.
You, Robert Fischer, should really take a long hard look at F# (I recommend “Expert F#”, by Don Syme and co.). I swear to god that Don Syme has been personally spying on me an stealing all of my best ideas- including monadic asynchronous microthreads (he doesn’t say “monad”, however) with Cilk-style work-stealing worker queues. No kidding, when he was out here last month, he explicitly mentioned Cilk. The man’s been stalking me- that’s the only plausible explanation. It’s inconceivable he could have come up with all of that on his own. Inconceivable, I say!
My biggest issue with F# is that you’re careening back into the world of Microsoft, and as much as they (and Jon H) may claim otherwise, that means that you’re stuck with their proprietary tool set and closed implementations. C# is a better language than Java, hands down, but the bad common library and the one-size-fits-all set of enterprise magic really turned me off quickly.
I don’t know about F# on mono, but nemerle is developed on and for mono, and just happens to work with microsoft’s .net runtime as a result. So there’s no getting stuck with MS there. Its got a rather nasty C style syntax, but its an ocaml inspired functional language still.
Also, I don’t think functional languages have had much of a passing fad cycle. There’s still all the same erlang people trying to convince everyone how great it is, it just only gets posted to all the “we post any random programming stuff even though we don’t understand it” blogs the first time those bloggers hear about it. Hell, even lisp weenies are still trying to sell their parens. I think perhaps lisp was/is in a bit of a fad phase largely due to Paul Graham, but it will pass. I think you’ll see a real fad phase for haskell eventually, much like ruby’s current status, when someone develops something interesting in it (just like how rails made ruby popular).
I don’t know nemerle — got a cite for it?
As for mono, I don’t much trust Mono to exist too long into the future (see what they did to TestDrive.Net for an example).
I suppose you’re looking at a bigger fad than I am, and maybe it’s just the fad of programming.reddit.com or Ruby.MN
I’m with Robert on Mono. The least that Microsoft will do is use Mono as an example of how all open source can do is follow Microsoft’s tail lights- because all Mono can do is follow Microsoft’s tail lights. And I personally don’t trust Microsoft to not have a submarine patent or six kicking around somewhere- if not in the core language and libraries, than in one of the libraries that isn’t technically in the standard but that you can’t do much programming in the language without (for example, the GUI libraries). Take a long hard look at what Microsoft did to Digital Research, and remember that the same people are in charge of Microsoft now as were then.
As for wether functional programming is a fad or not, I’m not sure. Real paradigm shifts don’t happen just because, they’re driven for a reason. OO was around for years, decades, before it became hot- Simula 67 dates from 1967, and Smalltalk from the late 70’s. But I didn’t start hearing about OO until the late 80’s, and even then it didn’t become the standard until the 90’s.
What drove OO adoption was GUIs, I beleive. Frankly, GUI programming pre-OO was a pain and a pest. Try programming one of the “advanced” pre-OO GUI toolkits, like Motif some time. Today, pretty much all GUI toolkits are OO, even those written in non-OO languages, like GTK. Well, except for the Haskell people, who are using arrows (think monads on steroids). And I’m not sure if they’re brilliant, or insane.
Before the OO adoption, the previous major paradigm shift was procedural programming- “Goto considered harmfull”, Pascal and C and all that. This was driven by the dual needs of portable code (or, at least, ported code) and the fact that programming anything major in assembler is even more maddening then using a pre-OO GUI toolkit. You simply could do things in procedural code that you simply couldn’t do in assembly. Also, it was the first real “paradigm”, and thus wasn’t supplanting an already working paradigm. And that was back when the theoreticians and the practitioners exchanged ideas and information, and not just sporadic gunfire.
Note that there are several interesting trends here. First is that it takes a long while (if ever) for the new paradigm to completely supplant the old paradigm. The first OO language to really catch on in a big way was C++, primarily (I beleive) because it has C as a proper subset. When all else failed, you could skip the OO stuff and get things working in good ol’ fasioned procedural C. Trust me, I’ve seen a hell of a lot of C++ code that, with minor edits, would compile with a C89 compiler. Then came Java, which was more OO, but was still proud of it’s C/C++ heritage. Only with the rise of Ruby and Python has “real” OO languages in the style of Smalltalk-80 became popular (see Ruby is-a Smalltalk for proof of this.
Another interesting trend is that a new paradigm is only adopted if it allows you to do something you simply couldn’t do (in a sane way) before. Just being able to write more and better code isn’t enough. You need to be able to do something you simply couldn’t do before. For example, you can’t port assembly language. If you want to take any advantage of the work you did on platform A on platform B, you can’t be working in assembly. Or it is very hard to do GUIs in a sane way without OO. For functional programming, I beleive that something to drive adoption is parallel programming- but I’ve expounded on this before.
There is a downside, however, that could cause funcitonal programming to be “just a fad”. Functional programming is, at it’s heart, radically different from OO, or procedural, or assembly language programming. For one thing it’s based on a different computational model- it’s based on the lambda calculus, not the Turing machine. This has all sorts of implications- for example, data structures change. When programmers moved from one paradigm to the next, they kept their old data structures- people implemented hash tables in assembly language, then procedural languages, then OO languages. Slightly different APIs, granted, but the same idea. Then comes functional languages, and say goodbye to Hashtables and hello to immutable tree-based maps! Say goodbye to doubly linked lists and extensible arrays, and say hello to lazy dequeues! Etc.
Even if functional programming is (eventually) adopted, I excpect there to be a lot more wailling and gnashing of teeth. And, I can see the industry not accepting functional programming, of having it never “cross the gap” into mainstream adoption. For web servers you probably don’t need it- you get massive parallelism just by serving lots of connections simultaneously, but each connection is it’s own single-thread of control communicating (rarely) via the database. As for the desktop? Things have stagnated in the last decade. Really, other than updated drivers and some eye candy, what is there that Vista does that Windows 98 doesn’t? Microsoft has killed off everyone on the desktop except games and themselves- all the action is on the web these days (talk about “hoist on your own petard”, but that’s a different post).
I could easily see the programmers looking at the hardware engineers and saying “give us all the cores you want- we’re only going to use one, maybe two of them.” If the latest and greatest chips aren’t faster than the old stuff, who is going to be blamed by the customer?
I’m not sure what the hardware engineers would do in that case- we might witness the effective end of Moore’s Law even while Moore’s Law still held true- transistors would shrink, but CPUs would not get any faster. On the other hand, this causes other problems with the software engineers, who are used to Moore’s Law covering their bloat. If you don’t have CPUs getting faster to cover for the fact that programs are getting slower, then adding new features without slowing the software down becomes a real trick, and the customer might start wondering why they’re bothering to buy new software as well as not buying new hardware. Welcome to Mutually Assured Destruction in the digital age.
Life will get interesting, in either case.
http://nemerle.org/Main_Page
Brian: Yeah, I’m sure MS has lots of patents that would be a problem for mono. And for every programming language and operating system on the planet too. The irrational fear of MS suing over patents is pretty silly. Its open source. If MS tries to sue, just move development to a free country. Just like they would do if MS tried to crush ghc (MS research is pretty big into haskell), or anyone else.
The control over Mono is a bit more direct than their other patents: after all, Mono is explicitly designed to be a rip-off of their CLR, and now that the CLR code is available, there’s a nice SCO-style trap just waiting to be sprung (cite).
If MS were to sue Sun over Java or Apple over OS-X, industry might just flinch. If MS starts to hunt down businesses and contributers on Mono (or any other .Net-platform library), it’ll be all over.
I’ll spend my time one something that’s actually free-ish, thanks.
“Mono is explicitly designed to be a rip-off of their CLR”
No it isn’t. Its a VM designed to run the ECMA standard CIL byte code. It also has a compiler to generate ECMA standard CIL bytecode from ECMA standard C# source code. That’s like being afraid of javascript because netscape made it. Who cares? Its still a standard that anyone is free to implement.
I hate MS more than most, but this is just ridiculous. Why is it that everyone insists on making up nonsense about .net (especially people who use java)? Why do you think MS shooting themselves in the foot (face would be more accurate really) would hurt mono at all? It wouldn’t even hurt the individuals involved, much less assorted end users that have nothing to do with it.
Are you afraid of using IBMs JVM, or jamvm, or jikes? Sun has control over java, and its not even a standard. So why is nobody freaking out over that? Its pretty pathetic to talk about spending time on something “actually free-ish” while using java (a closed source implementation of a closed proprietary language), which is much further away from free than mono (which is a fully open source implementation of an ECMA standard).
Joe: people did freak out over Sun’s control of Java. Which is why Java is (effectively) dead as an open source language. The only project I can think of which is not targeted at helping Java developers develop Java is Open Office- which, coincidentally, is being mostly done by Sun. C# and mono, however, are being adopted as the main language for Gnome development.
So the question I have is: why follow Microsoft’s footsteps? What does “being a standard” buy ys? Not being a standard doesn’t hurt Perl, Python, or Ruby. And it’s not like open source can’t develop a decent VM, as LLVM demonstrates. After all, it’s not *that* hard. The knowledge is out there.
The only advantage I can see is portability- the ability to write code that runs (without recompilation) on both Windows and Linux.
There are two problem with this. The first is that to acheive portability for real programs requires supporting a heck of a lot more than just the core language and a few libraries. At a minimum it requires a real GUI library, and probably lots more. Sun recogonized this with Java, which is what begat the AWT and later Swing. It’s not in the core language or libraries where the trap lies, it’s in these extended non-standard (but commonly used) libraries.
And second, this triggers Microsoft’s old paranoia. And with good reason- it threatens their profits. If the same program can run on both Windows and Linux, then there is less reason to use Microsoft, and more reason to use Linux. Basically half of their profits come from the sales of Windows (the other half from the sales of Office, everything else is basically noise).
Can you name a company Sun has killed with Java to protect it’s revenues? I can name two that Microsoft has to protect their OS revenues- Digital Research and Netscape. So either the leopard has changed it’s spots, or it’s just waiting for the opportune moment.
Which is not to say we should be all jumping on the Java bandwagon. As far as I’m concerned, Java is Cobol for the 21th century. While the community itself may be a ghetto, the Ruby language itself is pretty nice. Put it on LLVM, give it a decent garbage collector, compile it to native, and I would bet it could faster than Java or C# on their VMs. The parts are already there- and instead of having open source follow, open source could lead.
“So the question I have is: why follow Microsoft’s footsteps?”
You suggested F#, not me. I just pointed out that there’s nemerle too.