News for hackers. Stuff that matters.
Re:Choosing a Web Framework/Language Combo for the Next Decade by mtrimpe on Wednesday May 21, 2014 @07:23AM (#7777613)
I'm all for trying something unfamiliar, and I could even argue for Haskell that way, but from a different angle.

I would say that adopting a language for the next 10 years that doesn't have purely functional data structures at its core is a fool's errand.

Persistent data structures, i.e. efficiently storing every version of your data structure, is the natural reflection of the new reality in computing where:

  * storage is cheap
  * random reads are cheap
  * random writes are expensive
  * serial writes are cheap
Whether you adopt this through Haskell, Clojure, scala or even Bloom e.a. is fairly inconsequential.

What will matter is that persistent data structures will inevitable become commonplace over the next decade and that techniques for leveraging it (such as functional reactive programming) will be adopted in one form or another.

@jacquesm: I live in Amsterdam so I can try to explain it to you in person once; virtually everyone still underestimates the impact this will have and (or perhaps because) it's very difficult to get that across in writing.

Re:Choosing a Web Framework/Language Combo for the Next Decade by jacquesm on Wednesday May 21, 2014 @07:40AM (#7777670)
Living in Romania right now, but I'll ping you when I'm back in NL (I go there at least once every few weeks), Clojure seems to be the most approachable from the languages you list.

Besides your listed reasons mutable state is becoming a bigger and bigger bottle neck as the number of cores goes up and that's why functional programming is becoming more and more important. It also makes programs much harder to write in a bug-free manner and it makes testing much more difficult (if not impossible).

It's one of the core reasons why I felt so bad about dropping Erlang from the list because I feel that it gives me that plus a battle tested environment to work with.

Still tempted to put it back in. Your reasons add weight to an already very difficult decision, whether or not to pursue this opportunity as a way to get more into functional programming or to stay in my 'comfort zone'.

I've been toying around with FP on and off for the last couple of years and it is one of the most important revivals the computing world has seen to date (imo of course).

Re:Choosing a Web Framework/Language Combo for the Next Decade by lmm on Wednesday May 21, 2014 @07:59AM (#7777732)
This may be my biases speaking but I'd say Scala is a more approachable option than Clojure (and more popular, and has a first-class web framework in Play). It keeps more of the traditional OO style and syntax - you can use scalaz and write scala that looks like Haskell, but you can also write code that corresponds line-by-line to java, whereas with Clojure you're forced to make a more immediate leap to the lisp-style syntax, immediately stop using inheritance, and so on.
Re:Choosing a Web Framework/Language Combo for the Next Decade by ctdavies on Wednesday May 21, 2014 @03:30PM (#7780236)
That's a major appeal of Clojure, the Lisp (not Lisp-style) syntax, the functional paradigm (and the idioms are great). I really don't want to write code that corresponds line-by-line to Java. If I wanted to do that, I'd just write Java. However, Java interop with Clojure is straightforward. Furthermore, Clojure allows one to solve problems with an "orientation" toward objects, but as one learns to write Clojure well, the language guides one toward sublime and elegant functional solutions. An important thing about Clojure, however, is that it is not tied to the JVM; The original and most well-known implementation is for the JVM, but not only is there also Clojurescript, there are implementations that compile to CLR bytecode, Python, Ruby, and Actionscript. And with EDN, the extensible data notation, not only can you have your front-end and back-end codebases entirely in Clojure, you can transfer and store your data as Clojure too. I know not everyone has the same aesthetic tastes as I do, but I do like to think that there is something beautiful about this.

Finally, I must say that while Scala does indeed have a first-class web framework in Play, web frameworks are first-class objects in Clojure. Joke. Sort of. I personally do not want to have a monolithic pre-packaged web framework to bow down to; the Clojure community is a community of hackers, we like to make things out of other things, and to take things apart. Clojure and the work of its community allows me to compose my own web framework as needed very very quickly–and to drastically change it just as fast. I'm not saying you should stop doing what you like to do, but if you gave Clojure a chance...dude: it's addictive.

Re:Choosing a Web Framework/Language Combo for the Next Decade by lmm on Wednesday May 21, 2014 @04:52PM (#7780705)
> I really don't want to write code that corresponds line-by-line to Java. If I wanted to do that, I'd just write Java.

The code I write now is nothing like Java, but it's a question of how you get from there to here. When I started Scala I wrote what I'd write in Java. In the first week I removed the semicolons. In the second week I started to use function literals. Then I started using match/case. Later I found out about for/yield with futures. And so on. I learnt the language at my job, and I was delivering real, user-facing features in it from day 1. I don't think I could've done the same with Clojure.

(Reasonable people can disagree on syntax; I find that Scala's lets you get very close to the language of the domain (e.g. see the Spray "routing DSL") and that's worth the cost it imposes on the macro system)

Re:Choosing a Web Framework/Language Combo for the Next Decade by seanmcdirmid on Wednesday May 21, 2014 @08:00AM (#7777734)
Persistent structures are almost always O log N (because they have to be trees). You can fix your branch out for better performance at the cost of more wasted space. You will never be as fast as an array.

Also, sometimes you want your updates to a data structure to be seen via an alias (happens often actually), then we are back at square one again.

Systems people are much more pragmatic about this: they see the trends in hardware before we PL people do, and their solution has never been functional programming. Ok, well...maybe once with MapReduce (but Jeff and Sanjay are both systems PL people).

Re:Choosing a Web Framework/Language Combo for the Next Decade by mtrimpe on Wednesday May 21, 2014 @11:00AM (#7778585)
At n=32 the performance costs are as negligible as dynamic typing once was (even less I'd argue.) As far as I can tell that very much puts us at the point in time where mutable state is usually a premature optimization.

Adopting it successfully does require separating essential from accidental state which naturally leads to some variant of FRP being adopted to manage (re-)derivation of accidental state; which is usually the hard to explain part.

I am wondering what you do see systems people doing by the way? I'm always interested in broadening my perspective on this.

Re:Choosing a Web Framework/Language Combo for the Next Decade by seanmcdirmid on Wednesday May 21, 2014 @09:09PM (#7781619)
n=32 leads can lead to lots of sparseness, memory pressure, bad locality (given sparseness); its not going to fly easily as the default. The shared memory aspect is even a bigger hurdle: people share memory for a reason, its not very often accidental. FRP is hardly the answer, but I work on a competing paradigm so mark me as biased.

The systems people I work with do a lot of key value stores (sharded NoSQL-style databases), there is a lot of pipelining for data parallel processing (MapReduce, Pig), and there is still a lot of classic locking going on, throughput is important. Oh, and lots of Paxos, logging, state replication, etc... The normal stuff you could find at Google (note I don't work for Google).

On the HPC side, the people that really care about performance, there is some map reduce via MPI, but most of the big gains are to be had in CUDA, which is an extremely imperative programming model with very synchronized core executions and memory accesses.

I've learned that whenever the FP people talk about high performance, they usually mean something else (like concurrency that isn't so slow), rather than the real high performance stuff that the big kids (systems and HPC communities) are doing.

Re:Choosing a Web Framework/Language Combo for the Next Decade by mtrimpe on Thursday May 22, 2014 @06:49AM (#7783135)
I never meant to imply FP is already the right choice for big data (which is what I think you refer to by 'systems people') or high performance computing.

The reality though is that well over 99% of the market works with data sets for which, with current hardware, the performance costs of these persistent data structures are very much irrelevant.

When you add FRP on top of that so that you can keep your managed state minimal you can actually often achieve quite dramatic performance improvements over the traditional hand-written data-to-UI synchronisation.

For persistent data structures to come into their own for big data quite a few more things are needed of course; but if you look at Nathan Marz's Lambda Architecture for example it's little more than a handwritten system for making large scale persistent data structures manageable with today's systems already.

I'm fairly sure that tooling for that will only improve over time until the very thought of manually managing derivation pipelines becomes as quaint as manual memory management.

As for HPC; yes... I would not be surprised at all if at that level mutable state no longer is a premature optimization. Even there I could imagine many of the more high-level control structures benefitting from persistent data structures though.

About the FRP part; which competing paradigm are you working on? I wouldn't be able to name a 'competitor' so I'm quite curious.

Re:Choosing a Web Framework/Language Combo for the Next Decade by seanmcdirmid on Thursday May 22, 2014 @03:01PM (#7785683)
It actually involves versioned data structures (similar, but a but more complicated than persistent data structures, and outwardly they appear mutable):

http://research.microsoft.com/pubs/211297/managedtime.pdf

Re:Choosing a Web Framework/Language Combo for the Next Decade by mtrimpe on Thursday May 22, 2014 @03:40PM (#7785956)
I already had a feeling we were essentially arguing the same thing...

Yes; the managed time approach in Glitch is very interesting and indeed a competitor towards addressing the same problem I originally raised.

The core of my original statement/problem definition was that real mutable state, i.e. throwing away history by default, was no longer the smart thing to do given current hardware.

From what I can tell you would also agree with that...

Re:Choosing a Web Framework/Language Combo for the Next Decade by seanmcdirmid on Thursday May 22, 2014 @06:25PM (#7786929)
I would, but it doesn't necessarily have to happen with persistent data structures, and I would also argue that they aren't really sufficient (the history has to be useful, after all). They are convenient, and I'm using trees in my current implementation.
Re:Choosing a Web Framework/Language Combo for the Next Decade by oskarth on Wednesday May 21, 2014 @08:22AM (#7777795)
> virtually everyone still underestimates the impact this will have and (or perhaps because) it's very difficult to get that across in writing.

Why is it hard to get across in writing?

Re:Choosing a Web Framework/Language Combo for the Next Decade by mtrimpe on Wednesday May 21, 2014 @08:38AM (#7777870)
I'd say because of two reasons:

a) it requires putting together a fairly large number of concepts of moderate complexity (and you never know which ones your readers already understand.)

b) many of the concepts sound trivial and people usually don't grasp their power until you've listed X amounts of things it would enable.

And to be clear; it's hard for me to put in writing for now ;)

Re:Choosing a Web Framework/Language Combo for the Next Decade by nwmcsween on Thursday May 22, 2014 @04:00AM (#7782649)
Persistent structures do not map well with how computers work in reality.