3 ms·
>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 deceptivel
by flavio81 9y ago
>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.
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.
- mixmastamyk 9y agoNot very convincing. Yes the words are simpler, but the density and mental paren parsing are roadblocks. 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 line