by tomlin · 5y ago · 0 comments
If you care about semantics at all, or even want your code readable by someone who is in their early days of trying to understand and learn code - it's just ugly and hard to read.
I've been coding since I was 14, and I don't feel bad in saying that I can't tell you what this line does without looking it up. (reset! caret-location nil)))) I can't imagine how you could argue this is good and adheres to any philosophy of openness or readability.
ClojureScript is a Lisp language. If you’ve never learned one, I highly recommend it. It will make you think about programming differently.
As esr puts it in his (in)famous “How To Become A Hacker”:
“LISP is worth learning for a different reason — the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot.”
http://www.catb.org/~esr/faqs/hacker-howto.html#skills1
For myself, I learned Scheme (another Lisp-like language) in graduate school through the How to Design Programs curriculum (http://htdp.org/), which despite already being a professional programmer, I found enlightening. And then again in the online programming languages course from Brown: https://cs.brown.edu/courses/cs173/.
As for why it's not used more widely, same reasons Lisp like languages aren't used more often in industry: inertia, fear, worse-is-better syndrome.
You have to choose 1, it’s either easy to parse for machines or for humans, not both. Any kind of lisp is harder to parse for humans.
Take any Javascript or C program, and remove the line breaks so that it's just a linear string of tokens. It's no harder for the parse for the machine. Much harder for you.
Humans parse non-trivial examples of Lisp using indentation clues that the machine ignores, just like in the case of a large number of language families.
Not all structure in programs is indicated with indentation; sufficiently small chunks of programs are written on one line. The structure of those chunks is easy for humans to understand accurately if they are written in Lisp because there is no ambiguity.
Lisp syntax also has a way to break any expression, no matter how small, into multiple lines with indentation. Any two Lisp programmers will do it the same way:
(+ (* x
x)
(/ y
z))
there are no questions like "do I put the slash at the end of the previous line"?If you can't understand some one-line chunk of code, you can get it into a canonical indented form, and this can be automated.
This is something that you could learn in a single minute.
It's faster to learn than all the languages you know.
> (reset! caret-location nil))))
The C version is reset(caret_location, nil)
Or to be more precise, reset(caret_location, nil))))
Maybe null or NIL instead of nil, maybe not.
It's barely different. And the exclamation point is just part of the function's name. I'm not sure what's so confusing.
(Apparently it's a ClojureScript convention to put an exclamation point on impure functions.)
Swift allows unicode in symbols, so you can name functions with emoji. Thankfully that hasn’t caught on.
J has a similar idea–built into the language syntax vs using characters in function names–where a period can be used to inflect a primitive.
It's a Lisp. Takes 5 minutes to learn the syntax - but only if you have an open mind.
(My daily work is in a C-derived language, but I have zero problems parsing Python, Lisp, or even APL if I need to. )
If you don't have any interest in perspectives outside of your own then I can't imagine learning anything can be easy at all.
Since I come from a school where scheme was taught as a first language, I find clojurescript a hell of a lot easier to read than javascript. Half the time I feel like javascript just does things out in the aether with side-effects and I find the code really hard to follow when it does. Clojurescript has a much easier to follow flow for me.
That doesn't mean javascript is ugly and hard to read for someone else.
Zero people dropped out in HS. In college I'm pretty sure you're going to have people dropping out of the intro course for programming no matter what language you choose when it's taught in 60-100 student lectures with professors and TAs that have been steeped in CS so long they no longer remember what being a beginner is like.
Beauty is in the eye of the beholder, as they say. But, like I mentioned in another comment here, it seems odd to me to criticise on the merit of choice of language on a programmers forum.
I also do not write my blog for children to read. In fact, I don't even have a target audience - it's all "I had a problem and this is how I solved it", and perhap some Clojurian finds my posts on Google and finds it interesting. I certainly know there are Lisp-likers here on HN, as well.
What does "nice to read" mean? It means that I don't spend another 2 hours falling over myself trying to convince 7 year olds why being decisively pedantic is better than more expressive, semantic code.
You're still caught up in the idea that coding and programming is for an elite group of people, and that perspective is boring and old.
(-> ((have you written) lisp before) ?)
Make more sense to you?
Maybe you would like OO style?
(-> caret-location (reset! nil))