Has Haskell references like OCaml

Schema vs Haskell for an introduction to functional programming?


I am familiar with programming in C and C # and will explore C ++ in the future. I might be interested in examining functional programming as another programming paradigm. I do this for fun, my job doesn't involve computer programming and is a little inspired by the use of functional programming that is taught fairly early on in computer science courses in college. The lambda calculation is certainly beyond my math skills, but I think I can handle functional programming.

Which one of Haskell or Scheme would serve as an introduction to functional programming? I use Emacs as a text editor and I want to be able to configure it more easily in the future, which is what learning Emacs Lisp would entail. However, my understanding is that Emacs Lisp is quite different from schema and is also more procedural than functional.

I would probably use the book "The Little Schemer", which I have already bought, if I am following the scheme (seems a little strange to me because I have limited scrolling through it). Or I would use "Learn You a Haskell for Great Good" when following Haskell. I would also like to see the intro to Haskell videos by Dr. Watch Erik Meijer on Channel 9.

Suggestions, feedback or input appreciated.

Many Thanks.

PS BTW I also have access to F # as I am using Visual Studio 2010 which I use for C # development, but I don't think that should be my main criterion for choosing a language.






Reply:


I would recommend OCaml.

From my personal point of view, higher-order functions, a static type system as well as algebraic data types and pattern comparisons are the main basis for modern function programming.

Between a schema, an ML and a Haskell, I would choose the ML because I think it is the most relevant to this definition. Scheme doesn't have static typing (there is Typed Racket, but it's not for schema beginners), and Haskell has too many other things (monads, lazy valuation ...) that, while interesting, divert attention from the important base can .

SML and OCaml are equally interesting. I'm more used to OCaml, and it has a more "practical" feel to it, which is nice (but if you really want to be "practical" to losing your soul, you can choose F # too).

Schema and Haskell are also very interesting languages. The schema’s emphasis on macros is interesting, but not directly related to functional programming (this is another point in the world that is definitely something to try, as is logic programming, stack-based languages, and performance-oriented E).

Haskell is definitely a great language and, in my opinion, a must for the aspiring to learn Gurus functional programming. Since the main languages ​​of OCaml and Haskell are very similar (with the exception of the lazy evaluation that is distracting for beginners), it's easy to learn Haskell once you know the basics of OCaml. Or rather, you can focus on the weird things and not have to deal with the basics at the same time.

Likewise, if you've seen OCaml and possibly Haskell and want to learn more, be sure to check out Coq or Agda. Still, few would recommend Coq or Agda for an initial introduction to functional programming ...

To be clear, I think learning OCaml (or SML) and then Haskell makes you a programmer that works just as well as learning Haskell directly, but easier (or less painful).
Also, OCaml and Haskell both have good features that set them apart, and it's interesting to see the advanced features of the to know both . Just learning Haskell is poorer in this regard (although you could of course learn OCaml after Haskell; I think it's less logical and will frustrate you more).

For learning OCaml, I would recommend Jason Hickey's draft book (PDF).

¹ This definition is controversial. Some schema people claim that static typing has nothing to do with functional programming. Some Haskell people will argue that their definition of purity ("what Haskell does, but no more") is one indispensable The prerequisite for this is to be a functional language. I agree not to agree.







If you're interested in the advanced concepts of functional programming, go with Haskell. There is a suitable type system and a strict prohibition of mutations. Still, Haskell is not for the faint of heart.

If you just want an introduction to functional design, go for Scheme. The syntax is much easier to learn and read. While it allows procedural programming, be disciplined not to use a procedure with a at the end of the name.

Scheme also lets you read the structure and interpretation of computer programs, which is hands down the best introduction to programming paradigms. There are lectures about the book from MIT and Berkeley.




The correct answer is of course both! So it's just a matter of which language to deal with first. My situation is the same as yours. I really enjoyed The Little Schemer. You will definitely understand the basic constructs of functional programming by the time you've gone through these (and have a place to put your jelly patches!).

I'm about a quarter in Learn You a Haskell for Great good. I enjoy that too, but the two books couldn't be more different. Learning a Haskell has a very traditional approach to teaching a particular language. The little schemer is obviously specific to the schema, but is much more concerned with teaching the fundamentals of functional programming rather than the language of the schema.

I definitely recommend starting with The Little Schemer. It's less practical, but more basic.


My two main areas of focus in terms of functional programming are not to commit to a specific language, but rather to learn the key concepts of functional programming. I learned functional programming by being thrown headlong into a project where my boss insisted that all development be done in APL. APL is a functional array processing language and as far as possible from LISP, Haskell, or other popular programming languages. The real win came when I found that after "working through" the functional programming paradigm and mentally learning to automatically break a problem down into a functional program, I was no longer intimidated by the idiomatic aspects of other functional languages ​​like Haskell. OCaml, Scheme, Scala and Clojure. I'

If I were to choose a first functional language, I would probably choose Haskell or Steel Bank Common Lisp (SBCL). For Haskell, I would Learn You a Haskell ... , Real World Haskell , Haskell Street to Logic, Math, and Programming and Pearls of functional algorithm design read . For CL I would " Land of Lisp " , Artificial Intelligence Programming Paradigms , and (if you are really hardcore) " Let over Lambda " read . You can combine all of these books to get a comprehensive overview of practical approaches and concepts in functional programming.

I would also consider studying Clojure and Scala as both are very good and very expressive functional languages ​​(regardless of what the FP purist might say).


I agree with the "learn both" point, but there are a few more points that have not been mentioned so far. First of all, if you are new to functional programming and choose Haskell, there are a few new things to keep in mind besides FP: you need to learn to live in a lazy environment that can be a significant hassle, and you need to get around with a " bypassing a real "type system, which can be very far from what you're using in C or C #.

Scheme, OTOH, has strange looking syntax, but there is no static type system to be learned and it is strict language for things to be more familiar. In addition, schema implementations are usually very flexible. Racket, for example, brings this to a minimum and offers a lazy and a statically typed variant. This means that you start with the "easy" part and find the linchpin of a functional language. Later, you can expand yourself and use the typed and lazy variants. They should be easier now because you only have to deal with one function at a time. To be clear that Conceptswill be new enough that the syntactic problem will be minor and largely irrelevant. In other words, once you start working on the new concepts, you are so busy that the syntax just disappears. (And if you're really into syntax, then Haskell's syntax is something I personally find very elegant - but that's because it's also very far from your average C / C # / C ++ syntax. )

But having said all of that, I think there is a good point for F # too - they say you do this as a minor matter, but when you learn FP you will soon want to use all that good stuff. Using F # means you can do more "real" things because it is likely easy to solve the same problems that you deal with in your day-to-day work. Ideally, you'll get to a point where you see the advantage of using that point over C # and using it in a particular project. So while you're right in not selecting just F # because it will be easier for you to access, you should look at it as there is nothing better than actually Withthese new concepts. On the other hand, if you use Scheme or Haskell and think of it as toy language for your purpose (even though you know some people use it for real world applications), you never take the whole FP thing too seriously. [But YMMV is largely based on subjective observation and can vary greatly from person to person.]


Is there a reason ML isn't one of your options? There is a full range of introductory materials, including books and courseware. If you like The Little Schemer, you might also like The Little MLer. Finally, you can easily switch to F # later. (Not that I knock on Haskell or Scheme - ideally, learn all three).

Also a word of warning against Emacs Lisp. I don't think Haskell or ML will prepare you for this. A Lispy language like Scheme will help, but there are still big differences, e.g. Variables with dynamic scope. Emacs extensions are by their nature mandatory rather than functional - it's just a matter of changing the state of the editor.




Write yourself a scheme in 48 hours (in haskell)

I really recommend this. You will learn Haskell through a real and interesting problem, and you will learn the best lesson of the scheme by playing with the interpreter you have created. If you choose this route, keep a few good Haskell introductions to remember. You will understand them better when you have a problem to solve.





I would go with Haskell. Scheme can be pushed into doing procedural things, and its kind of system is not nearly as helpful has Haskell, that is Great for a beginner as it pretty much checks that the code is correct during compilation.







I think it's easy to get caught up in debates about languages ​​and miss the point. For someone just looking to learn what FP is all about, the differences between Ocaml / ML / Scheme / Haskell aren't half as important as your comfort with the material (books, videos, tools) you use to get it started learn. And whether or not you have a friend to help you learn certain languages ​​trumps everything else.


If it's not pure, you can also use imperative language, Haskell said.


In one of the responses you got to your question, I found this link very interesting as it gives you a taste of Haskell and Scheme.

In addition to this great link, I want to answer your question.

If you have a compulsory programming background, you may go to great lengths to learn functional programming. I would make sure the learning experience isn't empty. That said, you can apply it to your current or next job, or it will help you in other ways.

There are many good languages. The Scala people would extol their language, as would the Clojure and CL people. Even pythonists claim laziness. Other people who replied to you suggested ML. Amit Rathore, who wrote Clojure in Action, might even suggest that you study Haskell.

You mentioned Windows and F #. Does that help you in your current position? I don't know about F #. Is it functional enough? I'm asking this because IMHO Python has functional constructs, but it's not like programming in Clojure.

In summary, you are learning a functional language that "really" works and makes the most sense for your situation.


From a relative beginner's point of view, I suggest not starting with SICP when deciding on a scheme unless your math is fairly mature. The book and videos are full of subtleties and not at all intuitive for beginners.

We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By continuing, you consent to our use of cookies and other tracking technologies and affirm you're at least 16 years old or have consent from a parent or guardian.

You can read details in our Cookie policy and Privacy policy.