What are the practical benefits of LISP like syntax which Clojure uses over Java like syntax of Scala

clojurelispscala

I spent couple of months learning Scala and got overwhelmed by number of different constructs it had,
After looking at partial functions, partially-applied functions, pattern matching, actor syntax,
I gave a thought to learning Clojure which doesn't have too much in terms of syntax but looking at the how Java inter-operability is handled, it looks very difficult to get use to.

for example: things like doto, new and .

Every time I start typing a function, there are times I write (1 + 2) instead of (+ 1 2).

It looks like I will have to completely forget how I write regular programs to get use to this syntax.

Also finding it difficult to deal with side-effects that do and let form have.
Aren't they similar to what functions with void type are ?

Things like registering a callback,things normal I/O, how can such things be side-effects free.

Till now all I really liked about Functional Programming is that,
immutability makes concurrency easier when dealing with shared data,
functions as first class objects and having higher-order functions,
apply,map and reduce with functions and lists
.

I wanted to know, are there practical benefits I will get once I am use to this syntax ?
I f I continue to learn Scala and avoid using var, and always use recursion instead of loops.
I can do all the above things and still write understandable code.

Best Answer

Lisp syntax is just that: syntax. It has nothing to do with semantics. In other words, the syntax (ideally) shouldn't affect how you write programs; if you feel like you have to "completely forget how you write regular programs", it sounds like you're having difficulty with the semantics, not with the syntax.

Practical benefits of Lisp syntax include:

  • consistency. Function/macro/special-form followed by its arguments. No operator precedence issues. Grouping is usually explicit.

  • easy to parse and unparse. This makes it easier to write source code tools, such as static analyzers and code browsers.

  • extensibility

    • user-defined macros. Users can extend their Lisp system's syntax.
    • system-defined syntax. New special forms can be added to a Lisp system without having to worry about how their syntax interferes with existing forms.

You also threw in a couple of questions about side effects and functional programming. Those aren't related to Lisp syntax and should really be asked in a separate question.