Are you sure?
Reading a file in Go
func read(f) {
var text string
var scanner *bufio.Scanner
var err error
file, err := os.Open(f)
if err != nil {
log.Fatal(err)
}
scanner = bufio.NewScanner(file)
for scanner.Scan() {
text += scanner.Text()
}
err = scanner.Err()
if err != nil {
log.Fatal(err)
}
fmt.Println(text)
}
in Common Lisp (defun read (filename)
(with-open-file (input filename)
(loop for line = (read-line input nil)
while line do (print line))))
Now tell me which one is easier to read. And the lisp example you can understand what it does without even knowing any kind of Lisp language; it is almost english.Perhaps a lisp with python-style indentation for blocks would be more easily read?
def read (filename)
with-open-file (input filename)
for line in (read-line input nil)
while line do
print lineGranted, the bike shedding that goes on in our industry is hilarious. I think many people blame semicolons as one of the major hurdles to learning c nowadays. The things we fixate on...
Secondly, parentheses are a non-issue in lisp. Its almost like reading english text with spaces. After a while(quite quickly in-fact) they are a total non issue.
>>New programmers and developers look at that and compare it to something like Go, Python, or JavaScript, and all those look easier to write
Arguably the biggest problem today is programmers who are stuck at early intermediate level all life.
> if the next line is indented, anything from the beginning of the current line starting at the indent till a dedent matching the current line indent is wrapped in one set of parentheses.
Seriously, what about this?
defmacro deftag [name]
list 'defn name ['& 'inner]
list 'str "<" (str name) ">"
'(apply str inner)
"</" (str name) ">"
deftag html
deftag body
deftag h1
deftag p
Now what about the DSL that now downright looks like slim-lang?: html
body
h1 "Hello World"
p "How's it going?"
Or look at that: defn qsort [coll]
if (empty? coll)
coll
let [pivot (first coll)
remainder (rest coll)]
concat
(qsort (filter (partial > pivot) remainder))
[pivot]
(qsort (filter (partial <= pivot) remainder))
(even the qsort ones could be removed, but they balance [pivot] somehow)I'm perfectly happy with writing (+ 1 2 3) or whatever, the only parentheses that bother me are those that are perfectly delineated by indentation already, just as newlines perform the same duty as semicolons. They're just duplicated noise††.
† Other languages perform similar semicolon insertion, with varying degrees of success and ambiguities (JS==terrible, Go==terrific).
†† I know, you're supposed to get used to it and "unsee" them. I know, "paredit!". But seriously if you have to write a tool solely to produce noise, and you have to get accustomed to ignore said noise, well, somehow, something's off.
Modern incarnations of the same like F# are attractive too.
But Lisp is what it is, List processing.
For example, see https://gist.github.com/coding4food/1248505
Part of this is because lisp tends to be more concise, so there are fewer expressions required. There are relatively few places where lisp adds parentheses, rather than just moving them - mostly just basic operator expressions: (+ a b) vs a + b. Adding parens (a + b) doesn't make it any harder to read.
For function calls, Algol-descended languages already use parentheses and prefix notation, they just put the parens around the arguments instead of the whole expression:
(function argument list)
vs function(argument, list)
I think the concepts are great, and it's a great language for certain task, but my right pinky finger hurts just looking at it.
New programmers and developers look at that and compare it to something like Go, Python, or JavaScript, and all those look easier to write (although deceptively complex in places) and are 1000x easier to read.
A prettier lisp would do the world good, but things like sweet expressions are confusing for absolutely new devs to implement and veterans feel like they don't need them.
Short version: Lisp wallows in obscurity thanks to it's "look"