I know Lisp and Haskell are functional and logic programming languages respectively, but what exactly does this mean? How do they differ from other languages? I've heard that learning these will make you a better programmer and improve your logic. Is this true, and if I go learning Lisp or Haskell to a competent level will my programming improve and will I be better at handling any problem in any language? I just wanted to know to see if they are worth the effort of learning. Also are these languages useful in areas such as GUI and graphics or are they just useful for console applications?
closed as off-topic by gnat, Jimmy Hoffa, Telastyn, Ross Patterson, JeffO Sep 9 at 21:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – Jimmy Hoffa, JeffO
It is very much like learning math will improve your analytic skills and learning latin/classic literature will improve your writing skills.
People who designed those languages have thought hard about what does writing a program means. And those languages are the results of those researches.
That said, learning Java will also make you a better programmer. And learning C. The real benefits comes from learning languages with different philosophy. Then you can have your own opinion about the way a program should be written.
I realize this answer is not so useful for people who have not yet learn haskell and/or lisp. Here are some examples to explain further what I mean
Lisp believes that syntax should be minimal, and that everything should be either a list or a primitive (Lisp stands for List Processing). Even programs are mainly list containing other lists and symbols. Lisp allows you to manipulate programs as list, and to generate new programs on the fly. Hence the whole
The direct consequence is that the Lisp languages allows you to define any interface you want. A nice exemple is compojure which is a clojure web framework. Here is what a routing function look like
Another nice exemple is the hiccup templating framework:
As you can see, the result is as terse as in DSL like mustache, but allows you to use the language features such as
In other languages, the syntax is more complex. You cannot read a Java program as a bunch of lists. But by using Lisp, you get a better idea about what an ideal interface should look like, and what in your code can be abstracted away as data. It also helps you to see your favorite language as a big data structure, and to better understand its semantics.
Haskell believes in strong static typing and purity. Pure functions are like mathematical functions: they are defined on a set of values, and map them on another set. Function don't have side effects, and values are immutable. Purity is interesting because it is not something a multi-paradigm language can have. A language is either pure or not.
One consequence is that you cannot perform IO action whenever you want (haskellers believes that this is a good thing). IO actions are defined as transactions, which are themselves pure values. The
You have to deal explicitly with the data flow in your program. You cannot make two component communicate by writing & reading stuff in a global variable. You have to build and pass values.
Another feature mentioned by Jimmy Hoffa is the rich type system. While other languages have static typing, in haskell you can have things like:
The nice thing is that I don't need to explain what those function actually do: you already understand their behavior. What's more, functions with those signatures cannot really anything but compute the length of a list and map a transformation over a list.
In other typed languages, class hierarchies combined with the mutability make dealing with those types a nightmare. You have to understand things like covariance and contravariance, which are impossible to get right from a language perspective (ie simple, powerful and safe).
Either you take the safe path (like scala) and end up with a really complex language, or you take the simple path and get something which is either limited (google go generics limited to list and maps) or unsafe (dart generics which are always covariant).
By using haskell, you mainly learn about the benefits of purity, and how to write pure code.
|show 6 more comments|
tl;dr Learning new stuff can only make you a better programmer, but being a better programmer is not about the languages you can write code in.
What are the advantages of using LISP and Haskell?
From: Why is Lisp useful?
You can read there a description of Functional vs imperative
Will they make me a better programmer?
Yes, of course, knowing more languages and paradigms can only make you a better programmer, but get this straight:
There is not a single tool, a single book, a single programming paradigm that will make you a better programmer.
Learning different programming languages with different paradigms definitely help you to be a better programmer, learning to solve problems with different aproaches also benefit your logical thinking greatly.
Being a good programmer is not much about the language, but about having the ability to solve any problem in any language. And when you don't know the language, the ability to learn that language quickly and use it effectively.
Disclosure: This is shameless advertising of the worst kind, because it is from my blog.
|show 12 more comments|
When you learn languages that are outside of the paradigm that you usually operate, it will open your mind to alternative solutions in your day to day and may even help you understand some features in your language of choice better. Just knowing those languages aren't going to make you a better programmer unless you can take the lessons you learned from those languages and apply it to situations you see everyday.
That being said, it isn't limited to languages. When you read up on various data structures that you haven't seen or used before, it can help broaden the scope of you knowledge so the next time you encounter a problem you have one more possible solution.