What are some good Erlang Primers/Tutorials for beginners? - functional-programming

What are some good links for diving into Erlang and functional programming in general?

this might be a good one to look at http://learnyousomeerlang.com/

Here's the first half of Concurrent Programming in Erlang [PDF], free.

I think the language itself is surprisingly easy to learn. I recommend http://www.erlang.org/download/getting_started-5.4.pdf

Let me suggest that Erlang is not necessarily typical of "functional programming in general". If you want a good balance, I'd combine reading some of the Erlang-specific sources already cited (or Joe Armstrong's book, Programming Erlang: Software for a Concurrent World) with some of the tutorial links from the Haskell web site.

Related

Clojure for a lisp illiterate [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am a lifelong object-oriented programmer. My job is primarily java development, but I have experience in a number of languages. Ruby gave me my first real taste of functional programming. I loved the features Ruby borrowed from the functional paradigm such as closures and continuations. Eventually, I graduated to Scala. This has been a great way to gradually learn to approach non-trivial problems in a functional manner.
Now I am interested in Clojure. I know all the sexy features that make it enticing (software transactional memory, macros, etc.), but I just can't get used to "thinking in lisp". I've seen Rich Hickey's screencasts aimed at java programmers, but they are geared towards explaining language features and not approaching real world problems.
I am looking for any advice or resources which have made this transition easier for others.
Its now 11 months after I originally asked this question. I've just started a new project to help beginners make the transition to clojure. Its called 4clojure, and it challenges you to solve fill-in-the-blank style interactive problems.
4Clojure.com
My first introduction to Lisp was: Paradigms of Artificial Intelligence Programming of Peter Norvig. It is a very readable and gentle introduction to many features of Common Lisp and functional programming concepts.
Starting directly with some Clojure books could be preferable for you, because there are several differences between Common Lisp and Clojure which may become confusing if you're trying to learn both at the same time.
At the same time, try to get hands on experience messing with the Clojure REPL, doing some exercises like Project Euler which you then can contrast with other Clojure and imperative Java solutions.
Furthermore, if you have any questions on Clojure programming and idiomatic style, do not hesitate to discuss your code with other Clojurians. There are several options to do this, such as: Clojure on Google Groups, the #clojure IRC channel on Freenode, Twitter via hashtag #clojure, and of course here on Stackoverflow!
Going right to Clojure from OOP, I'd only recommend the excellent Programming Clojure by Stuart Halloway.
I love it, and it does a great job of covering a lot of Clojure and a fair bit of funcational programming in the process.
The Little Schemer and SICP are great, but they're not so relevant for Clojure, if that is what you want to learn.
I'd recommend getting the MEAP version of The Joy of Clojure. I have it, and right now the MEAP offers a total of 12 chapters. So far, it's by far the best book I've ever read on a programming language. Those 12 chapter are plenty to get you started with Clojure, all the way up to some advanced topics. The current MEAP (which gets updates with new chapters quite frequently) combined with the ociweb Clojure tutorial, stackoverflow.com, and the #clojure IRC channel on freenode, I think you'll be fine.
While I agree that Programming Clojure is a great introduction to Clojure, and does a very good job, we can't deny the fact that it gets more and more outdated every week. You have to keep in mind that Programming Clojure was written for Clojure 1.0. Right now, we are fast approaching the release of Clojure 1.2. For example, with the inclusion of defrecord, structs are going to be obsolete.
I really like Brian Twill's series of Clojure videos on youtube as a painless introduction to some of clojure's ideas. They don't assume any great knowledge of Lisp or functional programming languages.
As far as books go, I agree with Isaac that Programming Clojure is an excellent resource. You might also consider some forthcoming books on clojure:
The Joy of Clojure
Clojure in Action
Both have early access available online if you buy now. Also I think both have discounts available -- try looking on clojure.org.
The Lisp books that Peter and Norman mention are probably good choices (I like SICP, but haven't read the others). But the differences in syntax with Clojure might get a bit frustrating if you're just starting out. For that reason I recommend starting with Clojure-specific books at the beginning.
(Edited to fix link.)
For a raw beginner, How to Design Programs will get you thinking like a Lisper. If you get impatient, go faster :-) Another good book is On Lisp by Paul Graham, which as a bonus is now free online.
I don't care for Structure and Interpretation of Computer Programs; if you know Lisp or Scheme, already, it's a great intellectual tour de force and very satisfying—but my students and I have not found it a good book to learn from. The Little Schemer has lots of good information if you can stomach its dialectical organization and cutesie-pie style. I can't.
All the answers so far are great. I would add:
Purely Functional Retrogames is an excellent series on how to design old school video games in a functional, side effect free manner. If you go through this and grasp how to write Pac-Man without side effects, then you will have gone a long way to inducing the mindset necessary to solve many/most other problems functionally.
Halloway's Programming Clojure is the best general introduction to Clojure, and gives some idea of how to think about problems in a functional rather than object-oriented way, particularly the snake game example.
Seibel's Practical Common Lisp is an excellent practical guide to solving real-world problems functionally, such as building a database. Though written for CL rather than Clojure, which allows mutable data, the concepts carry over without much modification, and the full text is available online for free from the author's website. Worth at least a glance.
If you're looking for an introduction to "Lispy thinking", I'd recommend Practical Common Lisp . It's a good read and IMHO perfect for seasoned programmers coming from a non-lisp background.
The downside is that it targets Common Lisp, not Clojure; the main reason being that Clojure is much more functional in its approach. You'll probably want a Clojure specific book too.

Learning functional/Clojure programming - practical exercises? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm learning functional programming with Clojure. What practical exercises can you recommend? Online repositories with solutions would be perfect.
One idea I can think of is going through all the popular algorithms on sorting, trees, graphs etc. and implementing them in Clojure myself. While it could work, it may be pretty steep and I'm likely to do it inefficiently (compared to someone who knows what she's doing).
4clojure was launched recently. It takes a lot of inspiration from Functional Koans, and several of the puzzles from 99 Lisp Problems; but it improves on both by providing a learning experience for which you need only your browser.
Problems vary in difficulty from language tutorials like What is the second element of this list? to thought-provoking questions like Is it possible to arrange these N words so that each differs from the preceding one by at most one character, and more problems are being added every day.
I would recommend doing the Project Euler exercises:
http://projecteuler.net/
Project Euler is a series of
challenging mathematical/computer
programming problems that will require
more than just mathematical insights
to solve. Although mathematics will
help you arrive at elegant and
efficient methods, the use of a
computer and programming skills will
be required to solve most problems.
Because many programmers are solving Project Euler exercises, you can compare the solutions to other (non-functional) programming languages, but also Clojure solutions are available: http://clojure-euler.wikispaces.com/, so you can contrast imperative vs. functional/idiomatic Clojure.
Of course you will learn the most by first doing the exercises yourself, without consulting any of the solutions.
Try 99 Lisp Problems. The solutions aren't in clojure, but it should be easy to translate.
I recently started learning Clojure myself, and found labrepl useful.
It lets you get familiar with the basics and the REPL, contains a number of exercises and describes quite a bit of non-obvious stuff that is hard to find in the documentation since you don't yet know what you are looking for.
Recommended.
Edit
Also the Python Challenge, a series of puzzles that can be solved by a few lines of programming; the solution to a puzzle gives you the URL to visit for the next puzzle.
Although not specifically Clojure, the puzzles are quite entertaining and a good way to get your feet wet with any new language IMHO. (There are a couple of puzzles that are specific to Python, but the majority are not. See the forum for Python Challenge Hints when stuck.)
The Python Challenge differs from the Euler tasks in being more practical and less math oriented; tasks include things like filtering the bytes of an image and following hyperlinks programmatically.
There are some Functional Koans for Clojure: https://github.com/functional-koans/clojure-koans
I have not gotten round to trying these, but have heard good reviews.
As a once-upon-a-time LISP programmer, I found Clojure Koans https://github.com/functional-koans/clojure-koans extremely efficient and methodically sound.
Use a three window arrangement (editor + evaluator + repl) for instant feedback, documentation reference and on the fly experimenting.
The topics of the "tutorial" are well organized and gradually introduce more complex material. Certainly a good starting point if you have at least some LISP experience.
I would recommended studying the code in clojure.contrib on github.
As an exercise for learning FP I would recommend just writing the apps you're currently working on in Clojure, but try not to use any Refs or loops. Be dedicated to solving your problems functionally using recursion. If you think you have to use a Ref or a loop make sure you can explain why that is.
http://exercism.io/ has several not-so-trivial exercises, they give you a test and a description, you submit a solution and you refactor by looking at other people's code I highly recommend it, plus it's polyglot you can do the exercises in any programming language they support.
As others have mentioned Project Euler is a great place to start. But pick a good book that will teach you the fundamentals and the rationale for clojure's implementation, Programming Clojure by Stuart Halloway comes to mind.
Once you're done with that Timothy Baldridge offers several video tutorials where he dissects core.async, transducers, logic programming and lots of other fun stuff to play around with at: https://tbaldridge.pivotshare.com/
I strongly recommend Hackerrank, it has functional programming domain: https://www.hackerrank.com/domains/fp/intro
You may check your skills not only with clojure, but haskell, scala, erlang and many more

Which functional programming language should I choose as first functional programming language? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I would like to learn a functional programming language to see a different programming paradigm.
My background in programming: Java (I have just passed the SCJP exam), some ruby and very limited Rails. I use bash for basic sysadmin tasks. I use Ubuntu 9.04.
As a second goal I would like to use fp to show kids (14-18 years olds) how math and cs interrelated. The guys are very good at programing (they are learning Python and Java at politechnical high school from the first year). However as tests show, they have difficulties with math esp. basic concepts of discrete math. I think we can develop their math skills by using programming (and I possibly that can be the topic of my teacher training thesis). I think a language with very basic vocabulary would serve this project best.
I vote for Haskell, which has the following advantages:
In Haskell, the simple case is actually simple
The complex case is (usually) still comprehensible by ordinary human minds
It has an ordinary syntax that's not too different from other non-functional programming languages (unlike, say, Lisp)
I'm a big fan of Scheme, not least because the best book on it is freely available.
If your primary goal is to work with teens, it makes sense to use the functional-language pedagogy and technology that is proven to work with teens, and that is PLT Scheme (aka DrScheme) with the How To Design Programs book (also free online). These guys have got great results from middle school through 3rd semester university. They have resources for teachers as well.
Many respondents like SICP. It is a wonderful book—but not to
learn from. If you already know Scheme, it is a good book to admire, but SICP is less about functional programming and more about how to implement all known interesting computer-science ideas in Scheme.
If your primary goal is to learn a really new programming paradigm, then Scheme lacks some features that are very important to many functional programmers:
Programming with pattern matching
Partial application of curried functions
A polymorphic static type system
Pure functional computation
If you want exciting ideas, try Haskell; Haskell makes it a lot harder for you to program your old thoughts in the new language. Instead, Haskell forces you to think new thoughts. In addition to many other resources, Real World Haskell is free online.
Final note: SO has had many similar questions on learning functional programming.
Scala and Clojure both run the JVM so you might be more familiar with their environments.
I'd try Scala. It's not purely functional, it allows you to use a variety of approaches--but much of your java knowledge should port (It's JVM based) including the JDK libraries, and it's one of the most advanced languages I've ever seen.
If you're interested in learning language features and expanding your knowledge of how languages work, I couldn't imagine a better alternative.
My vote goes to Scala or F#, which are both freely downloadable at the moment.
The advantage here is that they are mixed paradigm languages -- Natively they are functional languages, but you can also use imperative and Object Oriented programming. They also have large standard libraries -- Scala rides on the back of Java and F# has all of .NET, so you can program something interesting fairly quickly.
Scheme and Haskell are both pure functional languages, but unfortunately their standard libraries are relatively small, so it's hard-ish to do relatively common things, like parsing XML or scanning web pages.
Since you're already familiar with Python, why not just use its functional capabilities? For more, see this (draft) HowTo.
My question is what approach is likely to be best for the teens you're working with. If they're willing to learn something new and different, Scheme is an excellent choice as a functional language. It's as basic as they come. If you want to keep to a more familiar syntax, Haskell might be your answer.
If you are doing this for learning, then definitely Scheme with SICP. It's going to be hard and frustrating and will blow your mind if you don't have experience with this stuff, but you will learn a lot.
If you want to use functional programming in practice then F#, Scala and Clojure are worth looking at.

Erlang: doing a good job

I've done a bit of functional programming, and I have a couple online references, so I'm finding basic Erlang programming pretty easy.
But since I've done far more procedural/object-oriented programming than functional programming, I expect my Erlang code isn't very well styled or efficient.
Can anybody recommend any resources that cover good, efficient, well-styled functional programming?
thank you!
Definitely try and get your hands on the erlang book:
http://www.pragprog.com/titles/jaerlang/programming-erlang
The first section of the book is available free online and would make an excellent companion when you are just learning the language:
http://erlang.org/download/erlang-book-part1.pdf
If you are looking for something more advanced, or wanting to learn tips and tricks about the language/OTP then I would recommend "Erlang in practice" screencasts:
http://www.pragprog.com/screencasts/v-kserl/erlang-in-practice
Although they are $40, they are high quality screencasts and I believe well worth the money.
If you think about architecture and design as about programing strategy and about coding style as about tactics than good sources are:
strategy - Making reliable systems in the presence of software errors
tactics - Programming Rules and Conventions
I think main rules are:
make short and readable functions
keep number of parameters, tuple members, record parameters and other low (less than 5) - structure your data
do and undo thinks in same function - make safe functions - avoid others to shoot themselves
KISS - Keep It Simple and Stupid (Stupid doesn't mean Dumb but don't make over-smart)

What's a good beginning text on functional programming? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I like to study languages outside my comfort zone, but I've had a hard time finding a place to start for functional languages. I heard a lot of good things about Structure and Interpretations of Computer Programs, but when I tried to read through it a couple of years ago it just seemed to whiz over my head. I do way better with books than web sites, but when I visit the local book store the books on LISP look kind of scary.
So what's a good starting point? My goal is to be able to use a functional programming language to solve simple problems in 6 months or so, and the ability to move to more advanced topics, recognize when a functional language is the right tool for the job, and use the language to solve more problems over the course of 2-3 years. I like books that are heavy on examples but also include challenges to work through. Does such a thing exist for functional languages?
The Little Schemer teaches recursion really well, and it's fun and simple to read.
I also liked The Scheme Programming Language for a broader introduction into the language.
Try Real World Haskell. It's free online.
SICP is a great book.
This is probably my bias, but I thought ocaml was pretty easy to get into. You have the option of programming in a few different styles until you're completely comfortable. I posted a bunch of links to Haskell and Ocaml references that are books, with examples et cetera that seem right up your alley.
If you prefer Lisp, you can try to power through the 99-problems in Lisp(which you can do in any language, really), or you can watch the lectures from the people who wrote SICP.
Further down the road, get a hold of "Purely Functional Data Structures", as it'll get into the hard-core deep design and considerations you have to take into account in functional languages --it uses ML (which ocaml derived from).
I really recommend "On Lisp" from Paul Graham.
It is concise and very readable even for beginners in functional programming (as I was when I read it). It contains a lot of very short examples, each which helps to understand one single thing.
I often thought reading this book: this is just the language containing exactly the features I ever wanted in other (nonfunctional) languages, but never got. :-(
And this is exactly the book to learn it, always comprehensible, sometimes even funny!
You may get it for free at the author's site!
I really like Thompson’s “Haskell: The Craft of Functional Programming” because it’s well written and Haskell allows an easier start than other functional languages while being completely pure (unlike Lisp or Scheme).
Since there are a bunch of different functional programming languages, it's hard to recommend books. But if you're interested in Common Lisp, recently I've been reading "Practical Common Lisp" by Peter Seibel, which you can check out online for free before dropping your hard earned cash on it. It's a pretty gentle introduction to CL, with great explanations and tons of examples. Seibel's a great writer (example: read the story of Mac,) he's good at keeping you engaged, which is really where SICP falls down, I think. It's just so dry! But while Practical Common Lisp is pretty example-heavy, it doesn't really have challenges to work through, although the examples are mostly designed to let you continue to work and build on them.
Another good book, this one Scheme-oriented: How to Design Programs. (Online)
I haven't had as much time with this book, being more of a Lisper than a Schemer myself, but it's well written, has good explanations and examples, and has lots of exercises to work on. It seems pretty popular in the Scheme crowd.
The Schemers Guide and related software - seriously good stuff
http://www.schemers.com/tsg.html
Check out Introduction to functional programming. It offers a different perspective.
I found The Little Schemer a great, great introduction to functional programming. It's entirely based on simple, bite sized examples which are built up upon as the book goes on.
I learned from Jeffrey Ullman's Elements of ML Programming, which is pretty good. It loses points for being about Standard ML, when OCaml, F#, and Haskell are (seemingly) more popular.
I feel Purely Functional Data Structures by Chris Okasaki is worth a look.
FYI http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
Haskell is a very good functional programming language for beginners. Someone had asked about good resources for Haskell, so I will point you there.
If you are looking for a good book on Functional Programming, I would recommend "Functional Programming: Practice and Theory" by Bruce J. Maclennan.
It is however required that you brush up on your Set Theory and Logic before giving it a read. It includes examples in LISP, Haskell and other languages.
If you have experience with .NET, Expert #F is good.
F# is derived from OCaml. Lisp is more pure as functional languages go.
Real-World Functional Programming (with examples in F# and C#)
I have heard good things about Haskell Functional Programming, but I also found this list of functional programming books at amazon that might be helpful to you.

Resources