Anyway, i know this is HN i'm asking, but can you give me at least one compelling reason why I should study lisp,scheme or clojure ?
Anyway, i know this is HN i'm asking, but can you give me at least one compelling reason why I should study lisp,scheme or clojure ?
I was trying to come up with examples to demonstrate the value of lisp in my own work, but I think this one captures it better. Imagine being able to use your language to create a language, that still interacts with everything else, and express it so clearly that people can translate that into dozens of other languages.
If you were to write that initially in Java or C or something it would be hard to separate the essential complexity (the problem of solving relational problems) from the accidental complexity (managing the underlying language's semantics and data structures and such) while keeping the entire code base clean and clear.
Lisps do a better job of eliminating or reducing accidental complexity compared to many mainstream languages, especially the enterprise-y ones like Java and C#, which are commonly used in CS education unless you're at a unique school or one of the top schools in the US (without experience, I can't comment on what non-US schools teach).
Those kind of languages are harder to learn, and probably for most things you can still do them just fine in the more mainstream languages without much trouble. And so it is easy to not bother to learn them.
If you are still doing this 40 years from now, though, I bet you'll look back and see that there were enough of those times where those other languages could have really made things easier for you that you will wish you had taken the time.
I think there is an implicit assumption we make about programming: we aren't going to be doing it long term. We'll be code monkeys for a few years, then move on to management, or ownership, or take our IPO money and go pursue some non-programming passion and leave the cranking out code to someone else. We don’t learn the harder but more powerful stuff because we don’t expect to be programming long enough for that to pay off.
I get the vibe from this comment that you think people are doing entirely unimpressive work in Python, PHP, JS, and C#. PHP seems to more or less be WordPress + extremely vulnerable packages if you don't update with great regularity, so I'll reluctantly agree. What about Python - machine learning, neural networks, and a common interface for scientists and more SWE types. C# - Unity games is an obvious example, but dotnet core looks very nice too.
I guess a better question would be, what _do_ you find impressive?
If I'm just told what the problem is, and not the algorithms used and shown the code that solves the problem I might not understand what is going on until I figure out the algorithm from the code, but all the statements in the program will make sense at least as far as what they do--I might not get why they do it until after I've figured out the algorithm, but I'll understand what.
So the most compelling reason I have is because learning new things should be something that you find exciting. What makes Lisp unique is that it is a lot different than other languages out there. If you know one imperative language, learning another may expand your horizons but not in the same way something from a different paradigm would.
If you already know a functional language or two, then it might not be worthwhile. That is very much up to you. But even though I have never used Lisp I enjoyed learning it immensely. Although I'd say I enjoyed Haskell more.
I will say back in the day I watched these lectures and found them incredibly satisfying and thought provoking.
This is really unhelpful gate keeping. You're respond to someone who literally just said they spend excessive time studying the field already.
I don't think it is. If you don't have time to learn interesting stuff because you "have to write blog articles to make yourself more employable" then you will probably lose motivation or interest in CS.
I've written and read a bunch of lisp and I'm slowly working my way through SICP at a leisurely pace, but I totally understand what these OP means. Some talk about lisp as something magical (it appears on xkcd as a sort of "god's programming language" - https://xkcd.com/224) yet often seem cagey about actually sharing exactly why they think so. A great example of what I mean is this pretty famous essay by pg: http://www.paulgraham.com/avg.html.
In fact he says "Lisp is so great not because of some magic quality visible only to devotees, but because it is simply the most powerful language available" - which seems to dispel the "magic" bit ... but then throws out the tantalising "most powerful language" without (in my opinion) giving a compelling argument. He mentions how lisp macros are more powerful than those in C and does say "Lisp code is made out of Lisp data objects" and a few other bits and pieces about how it was higher-level than other popular languages at the time (the mid-1990s). It certainly made me curious to explore the language, but definitely left me with unanswered questions.
My opinion is that this phenomenon is a result of a number of things, including:
1. some people went through a transformative experience through learning lisp, and are deliberately vague to entice others into exploring it without ruining some of the fun of self-discovery
2. some people had the same, but think that it's enough to declare these things and don't care if you believe them or not
3. some people parrot what they have read some smart folks say and simply can't formulate a good explanation even if they wanted to
For example, "code is data" is true in the most trivial sense for machine code, yet having code as structured data makes it much easier to manipulate. Having easy to manipulate code gives you the power to manipulate code at compile-time. Having code run at compile time inside the compiler, which is also an interpreter running the same language that you are compiling is kind of magical and mind-bending.
In fact, more recent research into this has gone down the rabbit hole even deeper, and it turns out you can have an entire tower of meta-levels (see for example http://www.phyast.pitt.edu/~micheles/scheme/scheme22.html). This is all continuing on the same basic ideas which were present in early Lisps, just crystallized and refined further and further.
Also, as research into macros has gone on over the years, hygienic macros were discovered, which Rust has adopted as well (and there are other languages which have them as an add-on, like Sweet.js). Deeply understanding how this stuff works gives you a better grip on the issues with macros in older languages (notably C).
And that's just macros (and homoiconicity). There's also lexical versus dynamic scoping. This is a lot less "magical" now than it was 10 years ago, when almost no mainstream language even had closures.
There's just tons of research which went into Lisps, because it's such a nice vehicle for language experimentation. There's half a century of research going into Lisps. Other languages haven't been around for that long, so I suppose there's something to find in Lisp history for everyone, but it might not be the same thing for everyone!
There are two major kinds of macros in Rust. One of them, macro_rules, is vaguely similar to Lisp macros. It was partially designed and implemented by some big Racket fans, in my understanding.
> Can you re-write the syntax of Rust with Rust macros?
Within limits.
> Or are they more like C/C++ macros?
Neither kind of Rust macros are like C or C++'s macros.
It starts with some really simple stuff like (+ 2 2)
Then introduces some concepts like recursion along the way. Next you get data structures and recursive data structures before they pull off the greatest recursive magic trick to show that your code is data itself.
Along the way you get a pretty accessible intro to functional programming without having to get bogged down in types, proofs and monads because Scheme is actually imperative.
With my teacher hat on, this is a masterwork for pulling together so many concepts into one (relatively) tiny standalone course.
With my student hat on it is profound on so many levels. I learn something new each time, even if only to appreciate names like Church and Curry being namedropped as bits of history because I'm not thinking a million miles an hour to process all the new information. The passion Sussman and Abelson bring the the course is authentic, endearing and unfakeable - you know they really felt it.
In terms of what you do day in day out, SICP would be my go to for covering most the fundamentals of "computational thinking". You learn how basic algorithms and space/time complexity, recursion and iteration, functions and objects, data structures and finally program language construction (with some teeny peaks at the machine itself). And I was able to learn all this without a computer - using just pen and paper because Scheme is so simple. This freed me up from the distraction of trying to make a computer do something and actually using my mind to reason. As someone who did not do a CS degree there are not many other resources that are that high up for grounding you in all those subjects to get you ready for the job or put you on the path for further reading.
Homoiconicity itself is such a mind bendingly pleasing thing to encounter the first time round, the only thing that came close was the stack machine - presumably because the list and the stack encapsulate something primitive to computation and language.
I remember the first time the penny dropped when I realized that the cons operator for a list was also the spread operator for arguments in a function signature and thinking whoaaaaa
You can't learn everything though. You absolutely should contemplate whether something is worth learning before embarking on that process -- otherwise you fill your head with useless new things.
Nobody is saying that I need to learn COBOL to stay relevant in the job market today, even if that would be a new language for me.
Why?
The #1 reason: The lisp people have a lot of cool things to teach.
One of the most obvious examples:
https://www.infoq.com/presentations/Simple-Made-Easy/
So, you can learn enough of Lisp or APL or oCalm or Haskell to tag along with somebody smart on the field (that use certain lang, maybe for very good reasons, maybe is just what he like) and understand stuff.
Most of the real gems are kind of easy to learn with the most basic understanding of a language.
---
A lot of times, is THAT kind of people that have the better insights of why certain lang matter.
Continue with the example of Rich Hickey:
https://dl.acm.org/doi/abs/10.1145/3386321
---
You can translate a lot of ideas from a lang to other, as the most basic and simply benefits.
Is just the case that certain langs fit the minds/goals/niches better, so is there where to look for better answers...
Lisp is very close to the Tao, and the Tao that can be spoken of is not the true Tao. That's why no one can tell you in concrete terms the greatest benefits of Lisp's eldritch power, and they all end up in spirals of circumlocution about "lack of syntax" or "homoiconicity" or somesuch. You have to experience it for yourself before you "get it".
The fact that McCarthy devised (or discovered) a powerful, high-level language with an extensible, morphable syntax that's definable in terms of itself in seven functions (and those functions were themselves readily convertible by hand to machine code) should be a massive clue, though.
> but on the other hand, life's too short and I'm already spending so much time in front of a PC to get my degree, learn a couple of more languages, make side projects on github, personal blogs etc to make myself more employable.
That's part of your problem. You are too busy chasing good-boy points from the job market to really sit down and study this stuff. My suggestion is to focus on your collegiate studies for now. If you have time, study an additional language/CS topic or two, but only stuff you can get really interested or engrossed in. There's a good chance that eventually, Lisp will call to you. It's one of those ideas in CS that are so profoundly good that if you are interested in CS, you will be interested in Lisp, at least the history of Lisp and what it brought to the table.
If you are just looking for practical reasons to learn a language that translate directly to résumé padding and more zeros on your starting salary, then JavaScript is an acceptable Lisp and you may as well stick with something like that.
So writing code to manipulate abstract syntax trees becomes easy, since you're using to writing & thinking about programs in that form, and it's just manipulating lists, which is easy. For example, it becomes easy to write a program to symbolically differentiate an input expression.
You also think about functions as something easy and natural to pass around.
They also encourage pure functions, which allow lazy evaluation, easy memoization, and other fun things.
I'd encourage you just go and try it out. Spend an evening or a Saturday reading a book / working through a tutorial to see for yourself. You cannot lose anything. At worst, you find out you don't like it, but at least you will have some first-hand opinion and an idea of what everyone is talking about.
Good approach for all those things you've always been hearing/wondering about but never tipped in your toes.
"Yes, that was the big revelation to me when I was in graduate school—when I finally understood that the half page of code on the bottom of page 13 of the Lisp 1.5 manual was Lisp in itself. These were “Maxwell’s Equations of Software!” - lifted from [0]
[0] http://www.righto.com/2008/07/maxwells-equations-of-software...
Examples:
* Learn about type systems: advantages and disadvantages of various modern (or older) type systems: c++, java, typescript, rust, go, etc... Understanding pros and cons of various type systems would help you improve as a software engineer, and make you better at designing proper abstractions and apis in whatever language you are working in.
* Learn about concurrency primitives, asynchronous event loops, parallel programming, etc. In modern software engineering pretty much every type of work involves concurrency, understanding what type of primitives exist in different platforms and languages, and what are their pros and cons would make you much more effective as a software engineer overall.
* Learn about data structures in scope of data storage and data transfer in practice. Get understanding of network i/o, disk i/o, how things get stored in memory, how things get stored persistently. This stuff is way more complex and way more useful in practice than learning about slightly different ways of doing computation or calling functions in a programming language.
* and many more...
I would say in modern software engineering, part of "how to express basic computation" is really the least complex and least interesting of the bunch. You can skin that cat many ways but compared to many other challenges, it is in my opinion at the way bottom in terms of importance.
One of the most interesting bits which differentiates lisps in general are macros. This gives you a lot of power over the language. You aren't stuck waiting on the language designers to give you new language-level features -- you can write them yourself!
The first example which comes to mind is asynchronous programming. In Clojure, core.async is a library, not a language-level feature! Stop and really think about that.
Also illustrative is to download the Clojure source and 'grep -r defmacro src/' and look through the results. A lot of what would be keywords in other languages are simply macros in a lisp. That means you could have written them yourself!!! The "threading macro" ('->' and '->>') is the one I like to point to. Any user could have come up with that!
This is like being able to add list comprehensions to the Python language, but as a user!
(disclaimer: I haven't written Clojure in anger, yet!)
This. Is a divide between programmers. Some are thrilled by this. Others, like me, see the power and flexibilty and front disagree it can be good. But their day to day problems are not lacking the most expressive, efficient Lang. Its communication, process, deadlines, change, domain knowledge, etc.
I didn't and don't want to invest my limited mental power in learning and keeping up with all about compiler Lang design CS theory. I want to use a language people much smarter and experienced with compiler and language design and theory have made for me. I want to build a program using the domain specific knowledge I've invested in. Not build program to write other programs..
With this out of the way, what's so special about lisp? Where did it get this reputation for mind-expansion? Part of it is historical. 20-30 years ago, the industry was focused around _stricter_ (for lack of a better term) languages like C++ or Java, and lisp presented some features that were super powerful, like REPL, interactive debuggers, higher order functions, lexical scoping, lambdas, etc. Lots of mainstream languages have since adopted these features (python, perl, ruby, javascript, ...), making lisp a bit less exotic than it used to be.
Still, today, there're some things that are unique to lisp that might be worth studying. The most important thing is macros. Macros are only possible because of the (lack of) syntax of lisp. It's a programming technique that consists of _programming your compiler_, for lack of a better term. It allows you to define a language specific to the domain you're working on. Pretty unique technique, and like all the other techniques, sometimes smart, sometimes useless, sometimes abused. I still believe it's worth learning, because understanding how macros work will explain a lot of things about the other tools you're using as a programmer.
I hope this makes things a bit clearer.
TLDR: A lot of what made lisp special is now available in other languages. Learning lisp is still worth it to expose you to _macros_. Regardless of how well you know lisp, going through SICP will be massively beneficial.
What is "pseudo-intellectual" about that answer?
> i'm sooo curious to study all of this and see for myself
Good thing SICP is available online, and there are even recorded classes of it with two legendary professors available online somewhere.
> life's too short and I'm already spending so much time in front of a PC
Yet, here we are.
John McCarthy famously wrote a lisp interpreter in a half page of lisp in the lisp 1.5 manual. The simplicity of the interpreter makes it possible for SICP to really focus in on the essence of what programming languages are and how features can be incrementally added. Imagine trying to learn programming by building a java compiler. Lisp is a much simpler language for learning how languages work.
The lisp interpreter is so simple because the code of lisp is written in the data structures of the languages: a bunch of nested lists. So the parsed syntax tree is very similar to the code. This means that meta-programming on it is much easier to reason about. You can write macros in other languages to change the functioning of the language itself but it's much more complicated for complex syntax. This makes lisps languages for creating your own language. Some people probably love lisp because they're inspired by it but people who consider its power indispensable (pg) probably customize it a lot with macros.
Someday you may find yourself implementing a lisp unintentionally (https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule) . IMO this is because it's natural to start with some text based data structure format (JSON?) for some config file or something and then add features incrementally. Suddenly you're making a lisp. Understanding lisp can help you realize you're building a bad one. This has happened to me before.
Lisp is also very interesting if you want to write code that writes itself. For instance, if you were toying with genetic algorithms the fact that every piece of lisp code within matched parens is itself a valid lisp program is a nice feature to have.
In the end though, I don't think actually using lisp is as important as understanding lisp. I can see the insane power of meta-programming for creating higher abstractions for myself or a small team of like minded individuals. But whether it's lisp macros, scala implicits, annotation based byte code rewriting in java or method_missing in ruby, I think that meta-programming becomes a form of obfuscation for really large teams. If you take away meta-programming from lisp you still have some really cool languages. But I think many of those cool things about lisp can be achieved in more mainstream languages if you understand what you're trying to achieve.
After all, Brendan Eich was inspired by scheme when he created Javascript in ten days. But he was told to make the syntax "like Java". That's a bit ironic given that Guy Steele (one of the creators of Scheme) helped write the original Java specification. Neither language is very scheme-like in the end. But both authors contend that the languages would have been a lot worse if they hadn't been around to put a bit of lispiness into them.
So the last reason to learn lisp is that if you ever get asked to make a programming language for a large company with lots of stupid restrictions in a very short time frame you might be able to inject enough lisp into it that people will still use it under duress 25-30 years later.
Note that "write the specification" in this context meant creating a text to describe a design that had been done by other people before he joined. Guy made it quite clear at OOPSLA 2003 (which had become essentially a Java conference) that the language would have been different if he had been able to have any input.
In Common Lisp:
* (eql 'i 'I)
T
In Clojure: user=> (= '(lisp,scheme or clojure ?) '(lisp, scheme, or clojure ?))
true
Downvotes accepted for the grammar snark, I only mean it as a light ribbing (and casual warning that programmers looking at resumes are often, probably unfairly, going to penalize such mistakes more harshly than they reward complex side projects).More seriously: do you like programming? And furthermore, are you interested in studying programming itself, not (just) programming as a means to other things? Are you perhaps interested in studying CS itself, not just exam material of whatever collection of courses that grants you a CS degree? If no, then you probably won't be compelled by any one reason to study anything beyond that which might let you get a well-paying programming job (perhaps as a gateway to getting a management job in tech), and lisp is not such a necessity. Nothing wrong with that, but inspect your motives carefully and plan accordingly. If yes to any of those, studying new languages will be rewarding, and lisps have a lot to offer. For instance, if you studied Common Lisp, you would have an environment suitable for practical programming of applications in any domain, you would not want for language features either because Lisp supported them anywhere from recently to 50+ years ago (realize it took until Java 8 for Java to get anonymous functions, and even then you're better served by SICP to learn tasteful application of programming with them, just as you're better served by Clojure to learn tasteful application of immutable data structures) or you can add them yourself without awaiting a new version, you would have a language good for researching CS topics such as new languages (and compilers), data structures, garbage collectors, type systems, theorem provers, AI, etc., and you might save future-you some hours or anxiety when it comes to "unrelenting, constant learning" because you can frame this week's fad into concepts you already know from Lisp.
Maybe the most compelling reason to study though is that of there not being a better time. If you are so curious, just go study already! And if several hours of study makes you lose interest, or decide it's all fluff evangelized by lisp zealots not worth pursuing further, then go ahead and study something else that interests you. But the time is now. Post-college, you'll likely have less opportunity, less desire, and less time to satisfy your curiosities, so indulge while you can.
And since this is HN, a recent pg twitter thread to contemplate: https://twitter.com/paulg/status/1274632047303315456