3 ms·
"You cannot change the state of a variable once it has been set" http://www.onlamp.com/pub/a/onlamp/2007/09/13/introduction-to-erlang.html?page=2 http://www.onl
by nootopian 19y ago
"You cannot change the state of a variable once it has been set"
http://www.onlamp.com/pub/a/onlamp/2007/09/13/introduction-to-erlang.html?page=2 http://www.onlamp.com/pub/a/onlamp/2007/09/13/introduction-t...
Im not a cool kid.
- Xichekolas 19y agoIt sounds weird at first to have variables that don't really vary, but it works out quite nicely.
- jward 19y agoIt's sad. After coding in Haskell and Erlang I moved back to Python for a project and my code was just littered with extra variables. I had become so used to the functional way that varying variables just seemed so wrong and foreign.
- dpapathanasiou 19y agoIt's not a question of cool or not; it just seems you haven't been exposed to functional programming yet. Here's an introduction if you've got an imperative/OO background: http://www.defmacro.org/ramblings/fp.html http://www.defmacro.org/ramblings/fp.html
- Tichy 19y agoI thought LISP is functional, and it lets you change variables. So I don't think that is specific to functional programming.
- paulgb 19y agoLisp is not purely functional (few languages are). Purely functional languages do not let you modify variables. Edit: Also, programmers in non-pure functional languages will often still minimize their use of mutation (changing variables) for a number of reasons.
- Tichy 19y agoIn any case, when evaluating Erlang, I found the immutable variables to be rather unpractical. I can see why they might help to avoid errors with multi threading, but I don't see a reason to be excited about it? At the end of the day, it is another limitation of the language. With Java, that is what people complain about, the constraints, why wish for it in other languages? If you think that immutable variables reduce programming errors, you are free to just not change your variables anyway, I guess. No language constraint required.
- dpapathanasiou 19y agoAs paulgb said, Lisp is not purely functional, unlike Erlang or Haskell. And actually, you could ignore functional programming and write code in an imperative style in Lisp (though it's not recommended, since you'd be missing out on the benefits of using Lisp). Take a look at "Imperative Outside In" (chapter 3, section 2) in "On Lisp" (http://lib.store.yahoo.net/lib/paulgraham/onlisp.pdf http://lib.store.yahoo.net/lib/paulgraham/onlisp.pdf) for an example.