by calopetreep · 13y ago · 0 comments
I've found this to be totally the opposite: my time in Java is much less productive. There are many libraries in Haskell which aren't even possible to write in Java (automatic differentiation, parser combinators, lenses, etc.)
> very few haskell programmers that are interested in doing boring work
Nobody is interested in doing boring work, or it would be interesting work. Nothing to do with Haskell programmers.
Hiring (good) Haskellers is easy because there's a demand for jobs. It's as simple as that.
So you're saying Alan Turing was wrong? Publish your finding, win a Nobel Prize.
You didn't say it would be difficult, you said it wasn't possible.
Here's the breakdown:
1. Haskell is compiled into machine code.
2. Machine code doesn't care or reveal where it came from.
3. Points (1) and (2) demonstrate that any algorithm that can be written in Haskell, can also be written in machine code.
4. Therefore the claim that Haskell's libraries cannot be written in Java is false.
It's completely possible to have a Turing-complete method of computation that does not allow the equivalent of self-modification, for example. And then you won't be able to write a library for self-modifying code!
You can't retrofit Java with a macro system without writing a preprocessor, for example. So it is impossible to have a whole bunch of useful constructs in a library.
Essentially, as soon as you consider "self-reference"--that is, programs that depend on details of the machine itself--Turing-completeness stops mattering. And this is still important; programmers care about more than just what the program does, after all!
No, as a matter of fact, it's the point. A Turing-complete system can compute anything that any other Turing-complete system can.
> It's completely possible to have a Turing-complete method of computation that does not allow the equivalent of self-modification ...
Speaking of red herrings?
The point is that libraries do more than just compute stuff. If all we cared about was what you could compute, there are plenty of interesting libraries that wouldn't count for anything! Any library exporting new types of control flow, for example.
The argument is that there are libraries you can write in Haskell that you can't write in Java. And since libraries can do meta-programming which is possible in Haskell but not in Java, this is accurate. Similarly, since self-modification is something a library can do, possible on one model but not another, it isn't a red-herring.
Hmm, how can I make my point clearer? Let me give you a very specific example then: a library with new syntax sugar would be impossible to write in Java. Sure, this does not allow you to compute anything different, but it's still very important and has a practical effect. Let's take a very trivial library of this sort: a library only providing an "unless" statement like Perl's. Possible in some languages, not possible in others.
Some of the examples in the original post also fall into this category. The lenses library, for example, just allows you to write composable accessors and mutators. It does not compute anything new. But it's still very useful because it makes your code simpler and gives you new ways to express yourself. You could not write anything like it in Java.
Hopefully that cleared things up a bit.
Nope! The Turing-completeness of Haskell and Java means they can both compute the same functions. However, there are certain things which are just not possible to express directly in some languages. Possible to compute, but not express directly.
Instead of Java, consider Brainfuck. It's a turing-complete language and certainly has no notion of what a function is. There's simply no way in Brainfuck to directly express that idea.
Another example, this time with Java and Haskell. In Haskell, I can write a function to add any two numbers (regardless of their type) like this:
add' :: Num a => a -> a -> a
add' x y = x + y
As far as I'm aware in Java, there's no way to write a function with a signature that says "Take two numeric arguments of any type". Certainly pre-generics, this is impossible.
Edits: markup
It was, before I got carried away: I was going to say that Turing-completeness does not translate to practice. And whoever chooses a language according to its Turing-completeness is missing the big picture.
This is not to suggest that someone would want to use Java for anything sufficiently sophisticated, unless one is a masochist, but then, that wasn't your claim.
> As far as I'm aware in Java, there's no way to write a function with a signature that says "Take two numeric arguments of any type". Certainly pre-generics, this is impossible.
A separate claim with no meaningful relation to the original one. This claim is that it would be inconvenient, not impossible.
Yes, I'm not disputing this- I'm fully in agreement that all turing-complete languages can compute all turing-computable computations. I've never been trying to argue against that. I'm sorry if I haven't explained myself clearly enough- let me give it another shot.
In Haskell, I can write a function operating on numbers like this:
f x = x**2 + x + 1
The AD library means I can do this: g = diff f
and g will behave as if I'd declared g x = 2 * x + 1
As far as I'm aware, it's not possible to write this code in Java- you can't get the differentiated version of a Java function this way.You can compute the same results, of course. You just can't write a library that will accept a function and give back its differentiation.
You can write a function that takes some representation of a mathematical function, for example as a string, and build a function from that to compute the same results, but you can't pass in an actual Java function- so you can't write the library. You can write a library which differentiates string-representations-of-functions, but you can't write one that differentiates first-class-Java-functions (well, objects with functions on, but you get the idea. I hope.)
But can average Java programmers produce any result that average Haskell programmers can produce? I'd bet they can't. Haskell programmers are self-selecting: if you can grasp Haskell and be productive in it then you are an elite programmer. Not so if you can grasp Java.