I did indeed have a chuckle, but also, this shouldn't be too foreign compared to other, more-popular languages. The construction of func param1 param2 can be found in POSIX shell, with Bash scripts regularly using that construction to pass arguments around. And although wrapping that call with parenthesis would create a subshell, it should still work and thus you could have a Lisp-like invocation in your sh script. Although if you want one of those parameters to be evaluated, then you're forced to use the $() construction, which adds the dollar symbol.
As for Lisp code that often looks like symbol soup, like (= 0 retcode), the equal-sign is just the name for the numerical equality function, which takes two numbers. The idea of using "=" as the function name should not be abnormal for Java or C++ programmers, because operator overload allows doing exactly that.
So although it does look kinda wonky for anyone that hasn't seen Lisp in school, sufficient exposure to popular codebases and languages should impart an intuition as to how Lisp code is written. And one doesn't even need to use an RPN calculator, although that also aids understanding of Lisp.
Addendum: perhaps in a century, contemporary programmers will find it bizarre that C used the equal-sign to mean assignment rather than equality, when the <= arrow would more accurately describe assignment, while also avoiding the common error of mixing up = and == in an if-conditional. What looks normal today will not necessarily be so obvious in hindsight.
perhaps in a century, contemporary programmers will find it bizarre that C used the equal-sign to mean assignment rather than equality, when the <= arrow would more accurately describe assignment
Maybe they'll find a better symbol than the one we already use for less than or equal to.
It's quite obviously := a.k.a ≔. Already used by Go and others.
They could use the small arrow <-
Sorry for nitpicking, but, Java doesn't have operator overloading.
Notice that they have the same number of parenthesis. People say that lisps have a lot of parentheses, but they have the same number as any other language that uses parentheses to make function calls.
This is false. Lisp uses parentheses where other languages use (), [], {} or nothing at all. For example, in C I can write int i = 0, but the equivalent Lisp code involves three pairs of parentheses. Or take something like a[i] = f(i + 1) / 2 + p. The equivalent Lisp code is something like (setf (aref a i) (+ (/ (f (+ i 1)) 2) p)), and you can't tell me that's not a lot of parentheses.
This is false, Lisp is a family of languages. Clojure is an example of a Lisp where you have different types of literals using () for lists, [] for vectors, {} for maps, and #{} for sets. Furthermore, there are plenty of libraries for doing infix syntax which can be trivially expressed using macros. For example, infix library in Clojure lets you write math using infix syntax. That said, it's pretty rare that you're actually writing a bunch of math expressions in regular code unless you're working in a specific domain, so this hardly comes up in practice.
I find one huge advantage of Lisp syntax is that you can visually see relationships in code by following the nesting. It's like having a diagram embedded for free once you get used to reading it.
Sniffs in Haskell. Or Forth, lol.
I mean, which one did you learn in math class? Not saying it's better, but it's way more common.
If anything, I'd argue that superficial similarity to math notation is just more confusing when you're learning imperative languages.
the fuck is lisp and this syntax?
Lisp is a programming language and the syntax is (normal) polish notation.
I did indeed have a chuckle, but also, this shouldn't be too foreign compared to other, more-popular languages. The construction of
func param1 param2
can be found in POSIX shell, with Bash scripts regularly using that construction to pass arguments around. And although wrapping that call with parenthesis would create a subshell, it should still work and thus you could have a Lisp-like invocation in your sh script. Although if you want one of those parameters to be evaluated, then you're forced to use the$()
construction, which adds the dollar symbol.As for Lisp code that often looks like symbol soup, like
(= 0 retcode)
, the equal-sign is just the name for the numerical equality function, which takes two numbers. The idea of using "=" as the function name should not be abnormal for Java or C++ programmers, because operator overload allows doing exactly that.So although it does look kinda wonky for anyone that hasn't seen Lisp in school, sufficient exposure to popular codebases and languages should impart an intuition as to how Lisp code is written. And one doesn't even need to use an RPN calculator, although that also aids understanding of Lisp.
Addendum: perhaps in a century, contemporary programmers will find it bizarre that C used the equal-sign to mean assignment rather than equality, when the
<=
arrow would more accurately describe assignment, while also avoiding the common error of mixing up = and == in an if-conditional. What looks normal today will not necessarily be so obvious in hindsight.Maybe they'll find a better symbol than the one we already use for less than or equal to.
It's quite obviously
:=
a.k.a ≔. Already used by Go and others.They could use the small arrow <-
Sorry for nitpicking, but, Java doesn't have operator overloading.