10 ms·
Reasons to use Haskell as a Mathematician (2006)
- gone35 12y agoShamelessly off-topic, but I can tell the author is a legit pure mathematician: (1) Haskell is Functional (2) Haskell Insulates You (3) Haskell Performs Well [...] (3) Haskell is Declarative Not being ironic, by the way. From experience, often I can tell pure vs applied mathematicians by how hilariously bad/absent-minded they can be at basic arithmetic/algebraic manipulations. Same for theoretical- vs systems-oriented CS people, I've found --almost as if being a horrible programmer somehow gives you academic hipster cred. (EDIT - To clarify: I mean CS academics in grad school, not CS professionals in industry. Also it's just a silly anecdote only marginally correlated with reality: no offense intended to anyone.)
- moab 12y agoInheriting off-topicness, while that stereotype does apply to most mathematicians, a large number of the CS theory people I've worked/TA'd with were actually pretty good programmers, and a few had even taught multiple years of our intro systems course. Of course this is just one school, but I think computer science as a field is still young enough that someone can be an expert in one area and still be reasonably fluent in other areas. Don't think the last point is particularly true either: being a good programmer is valuable even for theoretical CS. Point in case, recently saw the work leading to a paper on SDD solvers: there was a ton of programming and exploration (albeit in Mathematica/Matlab) that led to the final paper. Also, people working on parallel stuff these days (even the theory guys) usually publish CILK/MPI along with the paper. It's great when you can do both :)
- gone35 12y agoYes: That's definitely the way it should be! I agree 100% that CS is still young and cohesive enough for dedicated people to achieve both breadth and depth, which perhaps means "grand" single-person revolutionary breakthroughs can still be achieved: Karp made a similar point during one of the Turing centenary talks (*An Algorithmic View of the Universe [1,2]), positing that the field is not yet specialized enough to prevent an Alan Turing-like figure today to have a comprehensive view of the state-of-art of the discipline (!). [1] http://dl.acm.org/citation.cfm?id=2322176.2322189 http://dl.acm.org/citation.cfm?id=2322176.2322189 [2] http://www.youtube.com/watch?v=f6df3s3x3zo#t=56m25s http://www.youtube.com/watch?v=f6df3s3x3zo#t=56m25s
- StandardFuture 12y agoIt is technically impossible to be a good 'CS People' and simultaneously be a 'horrible programmer'. It seems that what you are referring to are people who know basic CS concepts and even know the basic features of a language or two but do not have a 'Hacker' mindset. This does not make them a 'horrible programmer' -- just as a hacker who comes up with 'tricks', without actually understanding that the things he 'created' were already discovered in some 70s CS paper, is not a 'horrible Computer Scientist'. It's not a sufficient method to describe a person's strengths and weaknesses.
- elliptic 12y agoSo, basically, you think that there are exactly 0 CS professors who are horrible programmers?
- StandardFuture 12y agoHow can your comment completely disregard the entirety of my actual conclusion? >It's not a sufficient method to describe a person's strengths and weaknesses. So, there should be if your classifications are correct. You are assuming that 'CS Professor' is equatable to 'good CS People'. But, my classification may not be so rigid. EDIT: You also still have not defined what it means to be a 'Good Programmer' vs. a 'Horrible' one.
- gone35 12y agoSorry I wasn't clear: by 'CS people' I meant to refer to CS academics in graduate school (professors, post-docs, grad students), not CS professionals in industry --admittedly a sign of insularity, I recognize. And what I meant is that, anecdotally, academics working on CS theory (eg theory of computation, computational learning theory) are more likely than not to unmistakeably be what I think everyone on HN would agree to call point-blank "horrible programmers": no use of version control, no tests, little concern for organization/modularity/maintainability, etc. And in part it makes sense since they don't have to hack nearly as much as systems-type CS academics --in many ways their work is closer to pure mathematics than engineering/applied math. That's all. In all just a silly anecdote, although with a kernel of truth. See for instance Scott Aaronson's joke comments about his programming abilities [1]: On the spectrum of computer science, I'm about as theoretical as you can get. One way to put it is that I got through CS grad school at Berkeley without really learning any programming language other than QBASIC (!). [1] http://www.scottaaronson.com/blog/?p=266 http://www.scottaaronson.com/blog/?p=266
- nostrademons 12y agoHe was a pure mathematician at the time this was written. Now he works for Google, IIRC on self-driving cars: http://www.knowthecosmos.com/destember/destember-experiment-inside-the-mind-of-google-x-engineer-dan-piponi/ http://www.knowthecosmos.com/destember/destember-experiment-... He also won an Oscar this year, his second total: http://www.imdb.com/name/nm0685004/awards http://www.imdb.com/name/nm0685004/awards
- JoeAcchino 12y agoNice to know, if an oscar-winning pure mathematician working on science-fiction projects found difficult to learn Haskell, I can save myself the trouble.
- nostrademons 12y agoIf that's your goal. There are some people who do things because they are difficult, because whatever activity is most difficult is probably the most mind-expanding.
- Bahamut 12y agoI don't think you know enough pure mathematicians.
- gone35 12y agoYou are probably right --I haven't been spending much time of late with people from my own department. :)
- warfangle 12y agoI've always wondered why computational mathematicians/physicists end up using MATLAB/FORTRAN instead of haskell or similar.
- jbooth 12y agoBecause they're trying to do work with computers, rather than do research about computing. If the interestingness of the implementation doesn't matter and you just want results, go with MATLAB/FORTRAN/Numpy or whatever and a fast BLAS implementation. Mutable state everywhere, side effects everywhere, you got your results fast and can go finish your paper or your project or whatever.
- warfangle 12y agoYeah, but with Haskell the code would look more like the actual equations you're working from and not an implementation of the equations (thinking like differential manifolds etc).
- sampo 12y agoHow does matrix indexing look like in Haskell?
- codygman 12y agoI found this by looking at the repa docs: mmMult :: Monad m => Array U DIM2 Double -> Array U DIM2 Double -> m (Array U DIM2 Double) mmMult a b = sumP (Repa.zipWith (*) aRepl bRepl) where t = transpose2D b aRepl = extend (Z :.All :.colsB :.All) a bRepl = extend (Z :.rowsA :.All :.All) t (Z :.colsA :.rowsA) = extent a (Z :.colsB :.rowsB) = extent b http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_Tutorial#Example:_matrix-matrix_multiplication http://www.haskell.org/haskellwiki/Numeric_Haskell:_A_Repa_T...
- sampo 12y ago
- segmondy 12y agothere are a bunch of languages mathematicians should know, haskell is one of them, so is prolog, lisp, APL, FORTRAN, and C. They all have their advantages, and you just have to know which one will give you an edge in your problem domain.
- gizmo686 12y agoAs someone who has used Haskell for math, I would comment that the standard prelude (Haskell's standard library) can be quite obnoxious to work with depending on what you are doing. When I use Haskell for math, I normally switch to the numeric-prelude [0]. [0] https://hackage.haskell.org/package/numeric-prelude https://hackage.haskell.org/package/numeric-prelude
- gamegoblin 12y agoAt least #2 on their list of issues is currently fixed in GHC 7.8
- tdees40 12y agoI'm currently porting a Numpy project into haskell as a self-improvement project, and it's been 69% great. But then I find some library that I have to implement from scratch when I just had it in python. That's a pretty big problem, and I'm willing to put up with it, but most people aren't.
- PieSquared 12y agoJust out of curiosity, what libraries were these?
- tdees40 12y agoScipy optimization libraries primarily.
- iand675 12y agoA nice way to look at it: if you share what code you have had to reimplement, you're making it more than 69% great for the potential Haskellers that follow!
- tdees40 12y agoWould love to! But my employer probably wouldn't be so thrilled about it.
- cousin_it 12y agoI've slowly come to the opinion that laziness is not the best idea, even from a pure mathematical point of view. There are large mathematical benefits to using a strict language like SML. One important benefit to me is that strictness allows you to have an equality operation with a very strong mathematical guarantee, namely that the types for which equality can be automatically defined are precisely the types for which equality is decidable (always terminates). A lazy language throws that out the window. In a strict language you can define both a type of guaranteed-finite lists with decidable equality and a type of potentially-infinite streams, while in a lazy language you only have the latter. I wrote about it in more detail here: http://slepnev.blogspot.ch/2014/06/is-laziness-wrong-for-equality.html http://slepnev.blogspot.ch/2014/06/is-laziness-wrong-for-equ...
- wyager 12y agoBut mathematics is non-strict. One can define functions that terminate when evaluated lazily but don't terminate when evaluated strictly. These kinds of functions are prevalent in mathematics.
- cousin_it 12y agoDoes your belief that "mathematics is non-strict" go as far as saying that the type of natural numbers: data Natural = Zero | Successor Natural must include this member as well: omega :: Natural omega = Successor omega bool1 = (omega == Zero) -- returns False bool2 = (omega == Successor Zero) -- returns False bool3 = (omega == omega) -- whoops, infinite loop The moral is that some parts of mathematics may be lazy, but mathematical induction has gotta be strict. Since many functional programs rely on induction for proofs of termination, correctness and resource usage, that means they should be strict as well.
- wyager 12y ago>Since many functional programs rely on induction for proofs of termination, correctness and resource usage, that means they should be strict as well. Am I incorrect in thinking that any strict program proven to be correct and terminating is also correct as a lazy program?
- j2kun 12y agoI want to hear from people who do math all day every day, and not just programming language theory. I want to hear about algebraic geometers, topolgists, ring theorists using Haskell and saying "Yeah this is really helping me in my work."
- Sniffnoy 12y agoAs a mathematician I'll certainly endorse a number of the points in the linked post. Because what they mean is that it can be very quick to translate mathematics into code. Maybe it won't run fast or be understandable by anyone else, but I can express complicated ideas (relatively) compactly and quickly and get something working without huge amounts of tedium.
- j2kun 12y agoCan you give me some examples? What do you use Haskell to do? I am also a mathematician so I can handle the jargon.
- Sniffnoy 12y agoMostly not large things. (Or at least, mostly not things that are large in Haskell.) An example recently -- I wanted to consider, let's say you have two finite rooted trees, S and T, with T having more vertices; and you you have a bijection f from the set of subtrees of S (subtrees have to have the same root as the original) to the set of subtrees of T, with certain restrictions on it; and then to f you associate a system of linear equations; and if the solution set to this system isn't contained a hyperplane aligned with the axes, then (if there exists an f for which this is true) I'll say "S interferes with T". And then I want to check for various T whether there is any smaller S that interferes with them. Basically without something like Haskell, or at least something like Haskell-or-ML (I didn't need typeclasses and I don't know how much I needed laziness), it seems like that would have been a complete mess. Of course, the above example is perhaps not the best as it meant I had to [either look up a library, or, what I actually did] implement row-reduction in Haskell, obviously not a great language for it! But ultimately it wasn't too terrible. And the rest as I've said would have been terrible in another language.