5 ms·
Once you've learned Haskell, actually, you can be far more productive in it than most other languages. The only piece of your statement that I'll agree with is
by ixmatus 12y ago
Once you've learned Haskell, actually, you can be far more productive in it than most other languages. The only piece of your statement that I'll agree with is that Haskell doesn't really have any great numerical or scientific tooling (like Python).
As languages go, Haskell out paces (not just in elegance but pragmatism too) most of the mainstream imperative languages.
The tooling for scientific computing does need to catch up though.
- tormeh 12y agoCan the typechecker ensure that your matrices (constructed from files) have compatible dimensions to be multiplied together? No? None of the compilers I've tried are much good for numeric computing. Since the error-prone parts of writing your code are not made easier by the typechecker, a dynamic language works just as well and has much lower cognitive overhead. Remember that scientists don't care about the quality of their code. In many cases, once the code is complete, it will only run once and then be thrown away. There is no maintenance. Things like technical debt don't exist. And pragmatism? Haskell doesn't even have loops. Loops with mutable variables inside are a very intuitive way of thinking about things and often a better fit to a problem than recursion. Sure, you can use tail recursion (which is just ugly looping) instead, but you're adding unwanted cognitive overhead. What I would like is a functional language with enclosed, sealed off loops. Syntactic sugar for tail recursion, basically, but Haskell isn't built with programmers in mind; it's built for CS researchers. Computer language researchers, more specifically.
- codygman 12y agoI believe you could enforce something like compatible dimensions in Haskell in a library, but I could be wrong. If not, I wonder if you could do it in idris.
- Ixiaus 12y agoIdris is a wonderful language but the tooling there is even more immature for numerical computing than Haskell.
- Tuna-Fish 12y ago> Can the typechecker ensure that your matrices have compatible dimensions to be multiplied together? In any dependently typed language, absolutely yes.
- tormeh 12y agoSorry, I forgot to specify that I meant matrices you read at runtime, for example from a csv.
- DerpDerpDerp 12y agoHaskell has a very neat interface for this, in that you build a special type which remembers the dimensions of a matrix as you build them, and then return either the result or a failure. It's very simple to build a function which doesn't have to understand the possible dimension conflicts and lift it to work on this new type, returning an either (or a maybe, if there's only one failure mode) in place of a definite value. It's also very simple to propagate such errors forward, so they'll short circuit a computation when you have non-matching matrices used in a calculation that's multiple steps. In Haskell, I don't have to remember to write special functions which guard against this: I write functions that operate on the matrices and add the guarding at the very end. I can ensure that all my calls use the guarding functions, because they have a different type signature. Trying to do this same thing in Python require that I remember to always use the guarded calls, and doesn't have as clean of an interface to create the guarded functions from standard functions.
- Dewie 12y agoWhat does it matter? No type-system will magically know ahead of time what the contents of the file will be before you run the program, but it can force you to do the appropriate checks when you do read it from the file.
- chriswarbo 12y ago> No type-system will magically know ahead of time what the contents of the file will be before you run the program. Yes they can, it's known as 'type providers'. http://blogs.msdn.com/b/dsyme/archive/2013/01/30/twelve-type-providers-in-pictures.aspx http://blogs.msdn.com/b/dsyme/archive/2013/01/30/twelve-type...
- pash 12y ago> Can the typechecker ensure that your matrices have compatible dimensions to be multiplied together? No? Yes. In fact this is one of the earliest examples [0] of what you can do with the ever more numerous extensions to Haskell's type system. There are BLAS bindings [1] and several native linear-algebra libraries in Hackage [2] that enlist the type-checker to enforce shape constraints at compile time. 0. See McBride (2001), "Faking It": http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.2636 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.2... 1. http://hackage.haskell.org/package/blas http://hackage.haskell.org/package/blas 2. Repa, for instance: http://hackage.haskell.org/package/repa http://hackage.haskell.org/package/repa, http://hackage.haskell.org/package/repa-algorithms http://hackage.haskell.org/package/repa-algorithms
- Dewie 12y ago> Can the typechecker ensure that your matrices (constructed from files) have compatible dimensions to be multiplied together? It seems so http://stackoverflow.com/questions/8332392/type-safe-matrix-multiplication http://stackoverflow.com/questions/8332392/type-safe-matrix-...
- gus_massa 12y ago> Remember that scientists don't care about the quality of their code. In many cases, once the code is complete, it will only run once and then be thrown away. There is no maintenance. Things like technical debt don't exist. The code is usually used once, but it’s modified and “improved” for the next paper. So you add a few new routines here and a few files to read or write there, ... And one day you have a 95 pages fortran 77 program (it’s does’t even follow the fortran 90 standard).
- enupten 12y agoCan you cite that ? Have you tried doing Numerical (or Symbolic) computation in Haskell ?
- Ixiaus 12y agoLook, asking people to cite opinions is a dumb way of having casual discussion. If you need any more input from me to convince you to learn something new, then it's not worth my time or yours. Like I said the tooling isn't as mature but the language enables me to produce results faster with fewer bugs that is much easier to maintain down the road. The only numerical computing I've ever really programmed for was manipulation of time series data and some standard statistical methods. I did it at first in Python with Pandas and numpy. Then moved to Haskell. The language was better but the tooling I had to shore up in places. Take that if it's useful to you :)
- stephencanon 12y ago> Once you've learned Haskell, actually, you can be far more productive in it than most other languages. Not when you're doing mathematical research. You can write x86 machine code and the time spent programming is still completely dwarfed by the time spent doing math. Mathematics is full of renowned professors who write F77 by hunting and pecking with one finger. There's no reason for them to use anything "more productive" because they can already code far, far faster than they can think of what to code. There are extreme outliers for whom this doesn't hold, but they are few and far between.
- Iftheshoefits 12y agoOnce you've learned Haskell, actually, you can be far more productive in it than most other languages. Productive in what sense and at what cost (in time, especially, but generally)? What benefit is there to learning Haskell when the existing "tooling" in FORTRAN77, C, or C++ is quite adequate for the purpose of research? I mean for the specific purpose of applying it in a research context; not the general sense (i.e. this isn't meant to question the worth learning something new in general).
- sampo 12y ago> FORTRAN77, C, or C++ Some people also use Fortran 95/2003/2008.
- GFK_of_xmaspast 12y agoI've been a mathematician programming in a variety of languages over the last 20 years, and I can say that if it "doesn't really have any great numerical or scientific tooling" then I won't even give it thought number one for doing computations.
- Ixiaus 12y agoAnd you know, that's totally fair. I'm not a mathematician so my perspective is limited only to producing production software. I'm simply relating my own experience in the hope that people will stop judging Haskell as a "research language" with little to no industrial value. That's the funny thing about researchers, some seem extremely obstinate (I suppose in many ways that's a required attribute otherwise they might give up). I wonder if this is why we still have Fortran code around...
- otikik 12y agoOnce you learn how to play the piano, you can play wonderful pieces. But that takes years. It's not cost-effective if humming is just good enough.