7 ms·
Hello Haskell, Goodbye Scala
- willvarfar 14y agoI find it unconvincing. That Haskell deemed is better for learning functional programming for the sake of learning functional programming does not really say much about general usefulness.
- koide 14y agoAnd the OP is talking only about learning FP, not about general usefulness. Not sure what you are unconvinced about.
- willvarfar 14y agoThe title and the first few paragraphs gave the impression that this was an article about the general utility of the two languages. Only half-way down did the truth out.
- koide 14y agoMaybe one shouldn't make general comments about a piece one hasn't read in its entirety. Especially for an 11 small paragraphs piece.
- willvarfar 14y agoI did read it fully. Then I commented that I found it unconvincing, which in my book is one step below misleading.
- koide 14y agoI then find unconvincing your usage of the word unconvincing.
- papsosouid 14y agoYeah, you are likely to find it unconvincing if you are hoping to be convinced about something the author isn't talking about. Perhaps the issue is your expectations, and your unwillingness to take the writing for what it says rather than what you want it to say.
- richo 14y agoI enjoyed the read, but I borked at your suggestion that not being purely functional, and the language barking at you if you break that convention stops you learning functional programming. Take most Lisps (I'll assume scheme, because it's what I'm most familiar with), which give you more than enough side-effecty rope to hang yourself with should you so desire- but you won't get far unless you're coding functionally.
- cageface 14y agoAll kinds of large Lisp codebases are written in an imperative style. There's no reason it's any more difficult to write that kind of code in Lisp than it is in any imperative language.
- Peaker 14y agoI haven't seen much functional code in elisp, which is the Lisp I most commonly read. Some Common Lisp code I saw was also very imperative. Scheme seems to be a more functional language, but I don't really see why people consider other Lisps any more functional than say, Python.
- lispm 14y agoCommon Lisp is a multi-paradigm language. The standard supports imperative, functional and object-oriented programming styles. It even tries to mix them. The Common Lisp Object System for example uses Generic Functions, and not the more usual message passing mechanism. The language is also traditionally extended by other paradigms: rule-based, logical, actors, agents, concurrent, ... Still Common Lisp uses mechanisms of functional programming widely. It supports lexical binding, many library functions are higher-order functions, etc. There are also some programs which are written in a very functional style and most implementations support tail call optimizations to further make a functional style useful. Common Lisp does not enforce a particular programming paradigm. As a start all three supported would be used by a programmer. He or she might even add some more, if necessary.
- Peaker 14y ago
- dkhenry 14y agoI can respect and applaud the man for wanting to learn, When I picked up scala I had the same experience he did. When I went to solve a problem I immediately fell back to the imperative style of programming since that's how my brain has worked for a decade. It has taken real time and effort to _try_ and solve problems in a functional manner. Turns out that's a really good and elegant solution for some problems and a skill that's worth developing. If another language makes that training easier then by all means use it. One of the real benefits of scala is you can be useful in it ( just solving the problem ) while you have all the tooling necessary to make those elegant solutions when you have the requisite skill set to implement them. It would be handy if scalac has a setting like -Werror in C land where non-functional constructs would be flagged in the codebase.
- deltasquared 14y agoNice choice! Learn You a Haskell for great good is an excellent book, I learned a lot reading it.
- werpon 14y agoI've invested a lot of time in trying to learn Haskell properly. On one hand, it's incredibly rewarding when a completely new and strange concept finally 'clicks', then you write a few lines to test your understanding and it just works. On the other hand, it's frustrating to realize that there are still a lot of concepts you don't fully grasp, several libs that are still out of your reach, yet another completely new way of structuring your code that you are yet to unravel. Essentially, that you are (I am) still a newbie. All in all, I find Scala better suited to learning FP and applying your newly-acquired knowledge to develop mildly useful apps, as quick results usually lead to more motivation. Just IMHO. (Not to mention there are many libs that aren't yet up to par with their JVM counterparts, but that's another can of worms.)
- Peaker 14y agoI personally find the "universe of knowledge" to attain an attraction, not a repellent.
- mercurial 14y agoI guess it depends in what context you're looking at it. What makes Java so successful is its simplicity. You can get fairly quickly up to speed on it, and you can have junior coders on it producing code quickly without shooting themselves in the foot too much or spending a couple of hours trying to find out how to update a tree efficiently. On the other hand, as a hobbyist, it's absolutely fantastic.
- Peaker 14y agoIn the case of Java, the simplicity of language leads to complexity of programs. The extra difficult-to-learn parts of Haskell makes for programs that are more practical, shorter and easier to work with. There's a trade-off between simplicity and power - and we don't really want to maximize simplicity only. And if we did, Java would not be a good candidate either.
- mercurial 14y ago
- aangjie 14y agoWhile i liked his gumption, I personally thought god i don't want to do that.. I have been playing around haskell on and off, in my free time, and have come to a conclusion that while it's a fun and cool language to play around, it may not be useful(as in career) hobby. It might be categorized as pure fun language learning.
- cduser 14y agoI learned F# as this guy learned Scala. I too dived into Haskell after a while and learnt a lot of new things. Having learned some great functional tips, I came back to my regular C#/Ruby and applying LINQ and Ruby's blocks seemed more natural to me. However, monads, monoids, functors still don't matter when you switch over. I've used Yesod to write a small app. A typical form in Yesod (for model binding) has this signature: newPostForm :: Html -> MForm Blog Blog (FormResult (Text,Text,Text), Widget) Even after learning Yesod for a while, I wasn't able to completely reason with that signature. Why bother with all the name of the application, sub site, formresult, widget when all you want is just three simple form fields? Rails gives it to you in params[:form]. It's just too easy in Rails with a lot of gems lying around for every task you decide to do. And when you're stuck, you're just a google away from getting your answer. So my question is: after learning Haskell, do you intend to stick to it? Did I make a wise decision in ditching Haskell?
- Peaker 14y agoWhy not define a type alias? type AppForm a = Html -> MForm Blog Blog (FormResult a, Widget) And then you get: newPostForm :: AppForm (Text, Text, Text)
- svachalek 14y agoThe real fun with type aliases is that GHC rarely uses them in error messages. So you get about 20 lines of type vomit whenever something refuses to compile and then you get to try to piece it back together into a level of abstraction that humans can handle.
- Peaker 14y agoWell, it isn't the case here, is it?
- mercurial 14y agoComparing a statically typed language to a dynamically typed language is silly when talking about type signatures. Of course you don't have type annotations in Ruby, it's a dynamic language. But it also means you don't get compile-time guarantees. Ask yourself what would be the type signature of a similar function in another statically typed language. You have a parametrized type with three parameters, which would give you something like: MForm<Blog, Blog, SomeFormResultWithWidget> And SomeFormResultWithWidget would have to be defined elsewhere. I'm not convinced it's clearer than the Haskell version. And you could easily remove the verbosity of the Haskell version with a type alias.
- amm 14y agoFor personal projects or for learning the principles of FP, there is nothing wrong with using Haskell. From personal experience however, I will not be using Haskell again for a larger professional project, because our team ran into too many time consuming issues and problems that have been solved successfully in other languages/environments (especially the JVM) like dependency management or reasoning over runtime characteristics before deploying the application on production systems. Especially memory consumption is very hard to predict. Of course, the language also has its benefits and even after some years it tickles your brain just the right way. I like programming in Haskell very much, but in real world projects (you know - when you work in a team not only consisting of PhDs) I prefer Scala or Java, because getting a war file deployed or profiling an application is just so much easier. YMMV, of course.
- Peaker 14y agoWhen did you use Haskell? The dependency hell situation has vastly improved (and there are plans to make it much better still). I agree that a downside of Haskell's very high level nature is difficulty to predict some runtime characteristics. This is just an instance of the general trade-off between low-level and high-level languages. Everyone is already comfortable with the loss of easily predictable performance incurred by GC, but people are still not comfortable with the same w.r.t laziness. I use Haskell for real world projects, and I find it more practical and more suitable than any other language I've ever used. Laziness rarely bites me, and has incredible real-world benefits such as easy refactoring and simpler code. I think the silliness about PhD's is very very silly. Of the Haskell programmers I know, the majority don't have a first degree... About profiling -- I have never profiled a Scala/Java application, but how much easier is it compared with: "cabal configure --enable-executable-profiling", and then running the program with "+RTS -p"? It may not be point-and-click, but it really is not hard at all.
- amm 14y ago>When did you use Haskell? Roughly two years ago. >I think the silliness about PhD's is very very silly. Of course it is. I just wanted to make a point that the "average programmer" has probably never seen a single line of ML-syntax before. >About profiling -- I have never profiled a Scala/Java application, but how much easier is it compared with: "cabal configure --enable executable-profiling", and then running the program with "+RTS -p"? It may not be point-and-click, but it really is not hard at all. I don't remember exactly what we tried, what worked and what didn't; we had no experts on the team, and just came to the conclusion that hooking up jconsole/yourkit/<insert jvm profiler here> to a running jvm process and see what's happening in real time on an app server was so much more comfortable.
- pohl 14y agoMy own approach to learning FP has been "Hello Haskell", "Hello Scala", "Hello ML", "Hello Clojure", "Hello Rust",... I don't know why you say goodbye, I say hello.
- DannoHung 14y agoMaybe you should actually learn something about FP rather than trying to learn a bunch of languages?
- pohl 14y agoI think you'll discover that languages are actually much smaller than they appear in your mirror.
- DannoHung 14y agoThat's my point. You're talking about jumping around from language to language, but Functional Programming techniques tend to be applicable across all of them. My personal angle is that Haskell puts up less bullshit in your path while you're learning stuff about type based reasoning at the cost of being much less like things you may have seen before. Regardless of that, going from Haskell to Scala to ML to Clojure ad naseum isn't going to get you any deeper understanding of techniques. At most you'll understand how some very basic concepts work in different languages.
- pohl 14y agoI wouldn't call opening myself to multiple languages "jumping", and it seems a bit of a leap that you assume so. (Note that I said nothing of the proportions invested in each.) The only point of my post was that one does not need to wall oneself off from one language in order to open oneself to another. Regardless of that, going from Haskell to Scala to ML to Clojure ad naseum isn't going to get you any deeper understanding of techniques. I suppose that's a fair view if one starts from the assumption that techniques are all that is worthy of pursuit. But there is also comparison of priorities implicit in different design choices. There is also an appreciation of history (ML is a good example of that) and an appreciation for industrial frontiers (Rust is a great example there: if you're not following Graydon Hoare you're missing out). Each language also has its own unique traits that don't readily map to others. Haskell's lazy evaluation and monadic IO are a great example there. Want to wield the sword of homoiconicity? Better learn a LISP. Moreover, learning Haskell prepares you to read a lot of literature. ML prepares one to read Chris Okasaki's book on purely functional data structures. (Yes, there is a Haskell appendix in the back of the book, but knowing both means you can compare them!). Scala is worth study as a case study in the tradeoffs of making on object/functional hybrid. The human brain is an associative machine, you know. Sometimes the act of broadening has the consequence of strengthening (or even deepening), because you're giving your melon more things to interrelate.
- happywolf 14y agoAnybody here has developed and deployed a Scala-based or/and Haskell-based project for production? I mean systems for business purpose where rubber meets the road with timeline to hit and budget to meet. Far too often the stories are shared by people who learned a new language for 3 months and implemented a pet system where only a few real users. Definitely I respect their zeal and curiosity, but I am more interested to know what the veterans are thinking
- joshdev 14y agoAt my company we started a Scala project a little over a year ago. Two of us had a Java background the other two had a C++ background. We targeted Scala 2.9, Akka 1.3, and ran it on JVM 1.6. For us the stack proved to be very easy to work with. The project spent about 5 months in development and has been in production for another 9 months with weekly updates. What the author calls old habits, I call productivity. A lot of us started off coding imperatively and slowly started adapting functional along the way. It allowed us to get the best of both worlds. Over the past year we've definitely stumbled a few times (mutable objects for akka messages are really really bad), but overall we've been very happy with the stack. One of the only real ongoing problems we are continuing to struggle with is limiting the impact of big GCs in production. Scala tends to generate more garbage then pure Java, so the GC has to work harder. Most of these objects are in the eden space, but we can run into memory fragmentation issues, which leads to eventual long compaction cycles.
- warfangle 14y agoFairly certain that twitter used scala at some point for message passing (back-end); At one point Foursquare was using scala/lift for their web platform. I'm not certain if this is still accurate; my information is pretty out of date.
- carterschonwald 14y agoI know of a few strong mostly Haskell places in NYC alone. Likewise I'm actually bootstrapping a biz where I've spent most of the past year building the tech where some of the things I'm doing are only tractable to build by using Haskell.
- rauljara 14y agoIf anyone wants an introduction to functional programming using Scala, I really recommend Martin Odersky's coursera course (https://class.coursera.org/progfun-2012-001/class https://class.coursera.org/progfun-2012-001/class). He restricts you to functional Scala; there isn't a mutated variable in the whole course. It isn't officially a course right now. You won't get a certificate for taking it, and I don't think the grader is turned on, but the other materials are still there. In my mind, the really mind altering thing was seeing not just that Object Oriented and Functional programming styles could be compatible, but that they were in many ways complementary. Good OO design, particularly the idea of small single responsibility classes, is kind of enforced by functional style. If you need to pass around fifty variables just to increment a counter, you'd go crazy. So writing functionally forces you to figure out ways to split things up. Similarly, its easy to convert well small, single responsibility OO objects into functional ones, and just a nightmare otherwise. I was just blown away at how much a course on functional programming helped me to understand OO design.
- kyllo 14y agoNot to mention, functional programming forces you to grok recursion and higher-order functions. Huge side benefit of learning FP that you can also implement in your OOP to write more elegant methods. Never write "for int i..." again.
- danieldk 14y agoAnd hope that your imperative language supports tail call optimization? ;)
- kyllo 14y agoAh. Well, yes, you wouldn't want a call stack overflow. I am starting to realize why people who know functional languages despise Java. I first started programming in Java, but now the more FP I learn, the uglier Java gets.
- mapleoin 14y agoIf anyone wants an introduction to functional programming using Scala, I really recommend Martin Odersky's coursera course (https://class.coursera.org/progfun-2012-001/class https://class.coursera.org/progfun-2012-001/class). He restricts you to functional Scala; there isn't a mutated variable in the whole course. It isn't officially a course right now. You won't get a certificate for taking it, and I don't think the grader is turned on, but the other materials are still there. That course does not allow registration right now.
- gesman 14y agoObsessive, compulsive, pure functional disorder. Now drop it all and go and build something.
- deleted 14y ago[deleted]
- digitalzombie 14y agoYeah I've tried learning Scala for a year. It was painful, real painful and I felt like I didn't learn much from it. Now I'm learning Erlang and I'm applying what I've learned from Scala to Erlang and wow. I'm glad I took at stab at Scala. Erlang is wonderful btw, it's so simple there are some minor drawback like no string primitive... I also love the fact that there is no loop, it forces me to think recursively. I guess because it's so simple I can just focus on learning the functional part instead of other stuff such as new objects paradigm (traits, etc..), design pattern ("pimp my whatever"), and type. I'm guess once I'm done with this I'll focus on type, thinking Haskell...
- owenjones 14y agoHaskel/Scala has Learn You a Haskell/Scala for Great Good! and Lisp has The Land of Lisp. Are there any _why-esque guides to Clojure and FP in general like these other languages have? I'm unaware of any and consider it surprising given the Clojure communities passion.
- SkyMarshal 14y ago>For christmas I bought myself a copy of Learn You A Haskell For Great Good by Miran Lipovača. Apart from being a great Haskell learning resource, it’s one of the best programming books I have ever read. I second that. Miran is a superb technical writer. He also annotates the book with little excerpts from all my favorite movies.
- vorg 14y agoPerhaps Scala was built for introducing functional programming gently to Java programmers, with the intention to make them switch to Haskell.