Learning Haskell with a view to learning Scala

前端 未结 6 760
花落未央
花落未央 2021-01-31 07:57

I\'ve read a few questions such as Scala vs Haskell discussing the merits of both languages or which to learn, but I already know that I\'d like to learn Scala. I was a Java pro

相关标签:
6条回答
  • 2021-01-31 08:26

    I learned Haskell first and then Scala and never regretted. You will gain a much deeper appreciation of FP if you learn Haskell first. Your understanding of the concepts behind FP and why they are important will be seared in. Much of Scala is taken from Haskell (IMHO). It will make more sense when you have the Haskell background. Don't shy away! Your efforts will be rewarded.

    0 讨论(0)
  • 2021-01-31 08:27

    For me, I want to learn Scala and functional programming; and, thus simply, I am learning Scala. My study material is Programming Scala. After I have read the early chapter on syntx and stuff, I have skipped chapter covering OO stuff and jumped to Chapter 8 which cover the functional programming stuff. There I let myself struggle with FP.

    I read this scala code, which is written in FP way and analyze it. You want to learn Scala for "...an improvement on Java for personal projects." and Haskell for FP intro. So, it seems that first of all, you want to be productive with your java project and then grasp FP as a side effect. To be productive, you have to master the language. There are much to learn and master the language and the only way to master the language is that you have to write the code in that language. As you learn/use Scala, you can't avoid FP out right even if you want to. I have been reading the Scala blogs(the book too) and the authors always go out of their way to do explanation when it comes to FP concept. You don't have to worry about not grasping FP by going Scala route. Yes, you can draw inspiration from Haskell like this when you are learning Scala. Or as Chris Turner above have pointed out, you can delve into more FP when you are already productive with Scala.

    You wanna go to point A, why not go to point A directly? If you go via the route of point B (Haskell), you will have to postpone your productivity as Pere Villega mentioned.

    0 讨论(0)
  • 2021-01-31 08:32

    I came to Scala from a Java background. Initially I just focused on Scala as a better Java. As time went on I started to use more and more functional concepts in Scala. Eventually I reached a point where I felt I needed a purer understanding of functional programming. It was at this point that I went away and learnt Haskell.

    When I cam back to Scala I found it much easier to use a functional style and some of the the concepts I struggled with previously made much more sense.

    You don't have to learn Haskell to become a good Scala developers, but I think once you get to a certain level in Scala that having a deeper understanding of functional programming concepts really helps.

    0 讨论(0)
  • 2021-01-31 08:34

    Speaking as someone who came from Java, and for whom Scala was a gateway drug to Haskell, I happen to think this is a great idea (learn Haskell first)!

    Haskell is conceptually a much simpler language than Scala, and if your goal is to learn how to program functionally, you can't help but do so if you start with Haskell. By design, Scala supports a kind of "legacy mode" of coding in which you don't really have to change your Java (or PHP) habits too much if you don't want to. I think this is a strategic decision--and a good one!--meant to increase adoption amongst crusty Java stalwarts.

    But that's not you! You're actually interested in learning something new... so why not go all-out? Learning functional programming in a pure setting, without the clutter and the temptation to regress into old habits, will crystallize the concepts in your brain.

    Then by all means return to Scala and learn how it differs from Haskell; it is both weaker in some respects and stronger in others, but you will then be on a much better foundation to appreciate these differences.

    0 讨论(0)
  • 2021-01-31 08:35

    I wouldn't do that. If you go straight to Scala (your final aim) you save time. You'll learn functional programming anyway, but as Scala is "less pure" you'll be able to start writing programs in Scala usign some Java-like constructs, which will make the transition simpler.

    Even if you go into Haskell, your first programs will be of less "functional quality" than later ones, as only practice improves that. Starting Scala your first programs will be of "less quality" as your first programs in Java or PHP were, but with practice you'll improve. Spending time in unrelated tasks hoping they MAY help, it can result in you wasting that time.

    Focus on your aim. If that's Scala, go for it.

    UPDATE: I believe this may be relevant to the question. It raises a point on productivity (deliver software) vs seeking "pure knowledge".

    0 讨论(0)
  • 2021-01-31 08:35

    The risk of starting directly from Scala, without having played any purely functional programming language first, is that you'll probably be drawn to the procedural solutions a bit too often.

    I wouldn't try Haskell as an intro to functional programming, though: not that it's particularly hard - its syntax is amazingly terse - but it's definitely very peculiar (even in the peculiar world of functional programming) and I think you should try with a language you can port more easily to Scala, like Racket or plain Scheme.

    To better understand what I mean, look at list comprehensions in Haskell, Scala and Scheme.

    0 讨论(0)
提交回复
热议问题