By using haskell, you mainly learn about the benefits of purity, and how to rightwrite pure code.
By using haskell, you mainly learn about the benefits of purity, and how to right pure code.
By using haskell, you mainly learn about the benefits of purity, and how to write pure code.
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.
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.
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.
Edit
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
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 code is data and data is code motto.
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
(defroutes app-routes (GET "/" [] view/page) (GET "/api" [] (wrap-aleph-handler api/socket-handler)) (route/resources "/static") (route/not-found "page not found")) Another nice exemple is the hiccup templating framework:
(html [:ul (for [x (range 1 4)] [:li x])]) As you can see, the result is as terse as in DSL like mustache, but allows you to use the language features such as (for [x (range 1 4)] block). Even nicer, you have all the tools to abstract and structure your code.
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.
Haskell
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 main value of a haskell program is a IO transaction executed when you run the program.
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:
length :: [a] -> Int (function from a list of a's to an int)
map :: (a -> b) -> [a] -> [b] (function that takes a a to b transform and a list of a's, and returns a list of b's)
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 right pure code.
Edit
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
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 code is data and data is code motto.
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
(defroutes app-routes (GET "/" [] view/page) (GET "/api" [] (wrap-aleph-handler api/socket-handler)) (route/resources "/static") (route/not-found "page not found")) Another nice exemple is the hiccup templating framework:
(html [:ul (for [x (range 1 4)] [:li x])]) As you can see, the result is as terse as in DSL like mustache, but allows you to use the language features such as (for [x (range 1 4)] block). Even nicer, you have all the tools to abstract and structure your code.
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.
Haskell
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 main value of a haskell program is a IO transaction executed when you run the program.
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:
length :: [a] -> Int (function from a list of a's to an int)
map :: (a -> b) -> [a] -> [b] (function that takes a a to b transform and a list of a's, and returns a list of b's)
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 right pure code.