157 points · by oumua_don17 · 5y ago · 169 comments
Writing a C program that generates and compiles C code is a major pita in comparison, same goes for most other languages.
Even if you slap a different syntax on top, it's still a Sunday walk in the park to write a custom compiler.
That would also explain why not Lisp: First, libaries are the new important tool for productivity, and any language can have that. Second, a shared understanding is very important, either for building programs, or building the libraries. Writing your own compilers may reduce that shared understanding. You can see this in some ecosystems where there is a split between people using the language in different ways (OCaml with Async and Lwt, the few alternative standard libraries; Scala with Zio, Cats, the base language; C++ with C with classes, the standard library and probably a lot of other styles that I haven't met yet; JS with the "classic JS", the frontend framework people, the functional/immutable people; many language with the FRP). Shared understanding is important for building and maintaining software. You could also argue that it's important to make programmers more replacable.
Another interesting thing is that some ecosystems are getting their macros: JavaScript has Babel, Coffeescript, Typescript.
I think this is where Go (the language) really shines. Go is "boring" -- there are no macros, no operator overloading, no default arguments, none of that sort of thing. But if your goal is shared understanding, "boring" is a compliment. "Boring" means "after using the language for a few years, I can be confident that I will never be surprised by a piece of Go code again." (This has been true for me for at least 4 years.)
In the same vein, Go famously doesn't support user-defined generics; the only generics it has are reified "builtins," baked into the language. People gripe about that, but the upshot is that every Go programmer understands the semantics of those builtin functions. They're Schelling points! When user-defined generics are added in the next version of Go, I worry that we'll lose some shared understanding. It will be a subtle shift, but the language will feel a bit less "cozy." :/
Lines of Go in isolation are easy to understand. However, Go is so lacking in expressiveness, that Go code-bases are hard to follow for any complex domain. The language doesn’t give you enough tools to tame complexity.
I think one of the most important points is the standard library rather than macros, operator overloading, default arguments and details like that. What makes a simple Go http server easier to understand than one in pretty much every other language is that most of the time it will be from the standard library. With Python, Java, C++, C#, Ruby, JS, TS, Kotlin, C and pretty much everything else, you're going to have to understand a framework/library first.
> "Boring" means "after using the language for a few years, I can be confident that I will never be surprised by a piece of Go code again." (This has been true for me for at least 4 years.)
That's a good definition, and whether you consider this good or bad is a great way to know if you will like Go.
> In the same vein, Go famously doesn't support user-defined generics; the only generics it has are reified "builtins," baked into the language. People gripe about that, but the upshot is that every Go programmer understands the semantics of those builtin functions. They're Schelling points!
User-defined generics are one point, no support for inheritance is another, almost no iterators is still another, no support for map/reduce/filter or list comprehensions is probably still another, one way of doing concurrency is again another, no support for FP is another.
> When user-defined generics are added in the next version of Go, I worry that we'll lose some shared understanding. It will be a subtle shift, but the language will feel a bit less "cozy." :/
I can see why. Right now I would love to add a custom < operator to a JS codebase, I can't, and it's a bit frustrating. But on the other hand, I'm a bit glad other people can't add it too. Some people will call this humility, some others will call it a race to the bottom. Maybe there's something to say about optimising for your "best" days or your "worst" days.
This is a huge selling point for me personally. lisps allows you to have a solution AND its compiler in lisp, without a need for another language. As far as I know Common Lisp is the only industrial strength dialect of lisp to allow this, and with an unmatched interactive development environment
> Shared understanding is important for building and maintaining software. You could also argue that it's important to make programmers more replaceable
in a business sense, if i wanted to hire for a large team of 'developers' i would hire for java / python / js. if i wanted to hire for a small team of 'hackers' i would hire for common lisp / haskell
Clojure seems to have this (I have not used Clojure much, so I don't really know). Elixir definitely has this. I think Elixir is the language ecosystem to look at in terms of having a solidified core language that is essentially done, and now the goal is to continue to flesh out the ecosystem with things like Nx, Axon, Livebook, Liveview, Mix improvements, Phoenix, etc. Elixir is pretty similar to Lisp/Scheme anyway given its macros, ability to live update, dynamically typed programming, but it goes well beyond any Lisp/Scheme (and many modern languages) in terms of having a practical but expansive ecosystem with a strong set of idiomatic conventions.
Does it, really?? Common Lisp is an ANSI Standard, I don't know how you get a more "strong set of idiomatic conventions" than that. And it's been "done" for 20 years now! People continue to use it just as it is, and there's very little pressure to change it because it simply works!
You're trying to justify a new wave of "modern" languages with a very weak argument... just call it for what it is: you want "cool", hyped languages to succeed despite the fact they offer nothing that the CL standard did not 20 years ago.
Having a standard has little to do with how people write code, which is what I meant by idiomatic conventions.
Elixir is not a “cool, hyped” language in the sense that you mean. Elixir is basically a wrapper around Erlang and OTP, which is an old technology (much older than ANSI Common Lisp), that provides several improvements in terms of developer tools and frameworks. It’s not just the next “cool” thing. It’s an incremental improvement on an old and tested technology to bring that technology to more developers. It has also been embraced by the Erlang community.
What does a response from a blunt commenter like me has to do with the success of CL? Do you mean CL users are prone to responding like me? I would say users of any language that's being dismissed as being old would react similarly.
> Elixir is basically a wrapper around Erlang and OTP
Yes, I know, I was going to say that Elixir itself is nothing new as it's just Erlang with a more palatable syntax on top... nothing really new, Erlang is about as old as Common Lisp.
Obviously, CL is still blazing fast compared to Python, but it can't easily do the kind of things that Julia or even C++ can when it comes to numerical programming. You can write a lot of macrology to get around it, but there's a point where you want actual compiler writers to be doing this.
this is not the job of compiler writers (although writing macros is akin to writing a compiler but i do not think that this is what you mean). in julia the numerical programming packages are not part of the standard library and a lot of it is wrappers around C++ code especially when the drivers to the underlining hardware are closed-source [0]. also here is the similar library in common lisp [1]
Versus Python, I didn't even get to use Python 2 before I started getting nagged and harangued by various exceptions in the terminal about how I had to migrate to Python 3.
And it depends what you're doing with CL, how well it works for you. As an algorithm designer, I use literally no libraries. I don't glue anything to anything. I just use the batteries that come included with Common Lisp (SBCL is great), forget about connecting to the internet, forget I/O, forget graphics and GUIs and OOP, and just focus on coming up with as many ideas as I can per minute, until I crack the algorithmic problem. Just with the austere tools that come included in SBCL: xor (#'logxor), popcount (#'logcount), #'sort, #'svref, #'pop, #'push, #'make-array, #'dotimes, 'lambda, 'labels, 'let, 'do, the basics.
I also find the idea of using no libraries a big thing in more advanced users of CL. The more advanced of a user the more it makes sense that you can just implement it yourself (with only the functionality required) and know it works without having to leverage a library. Then again, the idea of CL is that things that tend to be bigger/harder to solve problems in other languages can be done simpler in CL because you can break the problem up different and have an easier to understand or implement solution.
CL's ecosystem might be better than one thinks: https://github.com/CodyReichert/awesome-cl & https://lisp-journey.gitlab.io/blog/state-of-the-common-lisp...
The ELS community is still going strong. They have done a great job with continuity and moving forwards. That's a related but different tribe though.
I'd use F# for writing compilers.
Interactive programming is probably better in Common Lisp and also Smalltalk descendants like Pharo. But Elixir has some great interactive tooling. I think this is an excellent presentation that summarizes the capability (not necessarily saying other languages don't) in terms of real world applications: https://www.youtube.com/watch?v=JvBT4XBdoUE
i don't know much elixir. i was asking because those things interest me and they are what drove me to common lisp. for my purposes i need an industrial fast interactive language that is self hosted and well tested in the wild. i want a fast language that is well suited to make custom symbolic computer algebra procedures, custom differential algorithms, custom probabilistic programs, and custom data processing solutions. i think that common lisp best fits the criteria for my use case
The companies that use lisp don't tend to talk about it. For example, a company I worked for only talked about their Ruby/rails and javascript stuff publicly. It was only after I hired that I found out that the mission-critical core software was written in Common Lisp.
mocl for android/iOS may still exist.
Last I knew, Scieneer (HPC variant of CMUCL) was also commercial (no idea if they're still around though).
https://github.com/search?q=language%3A%22Common+Lisp%22&typ...
My attempt at deadpan humor doesn’t work if that isn’t true, and I’m not qualified to make the argument since I’ve not used it professionally yet. I can say that picking up Clojure for fun has both reawakened my joy in programming and greatly informed how I write code in other languages. That tends to inspire prose.
We program in C#, we program in swift, C and C++, but we continue using so much Lisp as I did 20 years ago or way more.
With Lisp you don't need to write only Lisp, you can write swift or any other language in Lisp, as we do.
When people ask what programming languages we use, even competitors, we just tell them. They don't listen.
They just can't really understand. They probably believe we use Lisp because we depend on obsolete technology because they are under the influence. The influence of snake oil salesman that want to sell them their new shiny language.
For them anything new is shiny and old means dusty because things degrade over time, but computer languages do not.
If competitors can't "get it", much better for us. They probably believe that we try to deceive them and that in reality we are using this new language-paradigm of the week that solves all the problems. Let them.
Lisp guys have nothing to sell you but probably the software they create. And if they have a powerful tool, they are not that interested on you knowing their secret.
This level of claim is indistinguishable from fiction.
> I really like the Common Lisp world. *I would like it to be more popular, but at the same time, it is a differentiator for us*.
they reached to us so we add Kina on awesome-lisp-companies. But how many more think the same? And still, they evidently put little effort in making CL more "popular", because they have no interest. They found enough open-source libraries, they work on a hard problem, they form their developers and operators in-house, they develop their own Lisp-like language for the browser… and they silently use the power of SBCL.
I say all this because I would really like some great examples and use cases which would sort of highlight what LISP has to offer over the, for the lack of a better word, non-LISP languages. All of the articles that pop up in hacker news or other portals only seem to highlight the fact that LISP presents a new paradigm (?), enhances intuition (?), and that LISP macros are the best-thing ever. I would like to share the sentiment but ideally via a few digestible examples in lieu of a serious commitment required to basically learn an entire language. I would appreciate a few concrete examples (very much like [::-1] and 100**100) that would allow me to get what LISP really is about.
Roman: what's so amazing about the decimal system? I can do addition just fine with X + X = XX.
Modern human: Well... you can do negative numbers easily, irrational numbers, you can show zero easily.
Roman: bah! I don't know what you're talking about. Half those numbers don't even exist.
Mathematician: actually have you heard about complex numbers?
The point is: you have to learn a new way of thinking compared to procedural/OOP style programming. And it might be the case that the problems it solves are not practical for your use-case.
I tell you, as a non-Lisp programmer, what I find amazing about Lisp. Disclaimer: I may be partially or completely wrong. I'm really not the one who should be writing this, but since our knowledge of Lisp isn't that far apart, I might be able to empathize with your perspective a bit more since I have been in it.
* Your code is the abstract syntax tree! Don't know what an abstract syntax tree is? It's a data structure that compilers use in order to generate code. In normal languages you have to first parse the language, compile it to the abstract syntax tree and then generate machine code from it. However, in the case of Lisp, it's already there. So this means that you can write compiler-esque programs much easier.
* One of the nice things that a direct AST provides that it allows partial live reloading of code. Imagine this:
``` myAge = 17 if (myAge >= 18) { print("Nice!") } else { print("Hello youngster!") } ```
With Lisp, you can basically swap out the first print function for another function while the program keeps running.
One simple example I can describe is from the book Practical Common Lisp and it is talked about to some degree in the SICP videos. The idea of the environment being captured as well as what it points to is a big idea. At the risk of not getting it explained 100% to everyone's satisfaction I would suggest reading about it.
I also would suggest the problem of the N queens board. It is a pretty good starting point into how this problem can be solved in lisp. I suggest the MIT SICP lecture on it because it is well paced and interesting. Also it shows off some, for the time, advanced language features.
Another good read is Norvig's PAIP book that you can read on Github. Lots of problems you can jump to with pretty good explanation in my opinion.
I'm sure there are more interesting things I could point to. However, I still consider a read of Practical Common Lisp a good starting point. The book is fairly well paced and not bogged down with learn all the language first-isms. Also, the SICP videos are pretty good to watch. I hope these points are helpful to you.
useful link:
https://github.com/norvig/paip-lisp
https://emacs.stackexchange.com/questions/5465/how-to-migrat...
You mean like (reverse "asd") and (* 10000 10000)? That's not really what gives you an impression of Lisp, rather a bit of syntax ([::-1], the paragon of readability) and large integers. :P
This article might help: https://www.defmacro.org/ramblings/lisp.html
Also, if you really want to see what it's about you can read SICP: https://xuanji.appspot.com/isicp/ https://github.com/sarabander/sicp
Will you be able to understand how to play the guitar if I show you a passage from a song ? You can play it with any other instrument, so it still won't be motivating enough for you to put in the time and effort required to learn it.
If I were to take you to a Led Zeppelin concert to see Jimmy Page playing, that still might not be motivation enough for you to pick up the guitar, but you'll be able to better understand what it can do to people :).
Back to LISP - it's a tool. The difference between other tools, is that you can program it too. The power lies in its simplicity and your ability to build programs iteratively while running them.
For a while in the development of Common Lisp, a sort of joke acceptance test for implementations was in three parts: 1) you type T and enter into the REPL, it responds T 2) you define the factorial function and calculate (/ (factorial 1000) (factorial 999)) and it responds 1000 3) You try (atanh -2) and if it returns a complex number it passes (extra credit for the correct complex number). Lisp has a great numerical tower. Besides being able to deal with huge and complex numbers, you also have convenient syntax for specifying numbers in base 2 and 16, and you can do things like bitwise operations on bit-vectors:
(bit-and #*00110100
#*10101010)
-------> #*00100000
For macros, there's a lot of cool ones. Unlike C macros that just do string substitution, Lisp macros let you use the full Lisp language to write code that does something with expressions passed to the macro. A nifty one that's part of basically every implementation with uiop:nest is described here https://fare.livejournal.com/189741.html The problem it solves is that sometimes in Lisp you'll have a lot of nested forms, and your code begins to attack the bottom right corner of your screen. e.g. (multiple-value-bind (a1 b1 p1) (foo1)
(with-open-file (f1 p1 ...)
(let ((x1 (read f1)))
(when x1
(multiple-value-bind (a2 b2 p2) (foo2)
...
The macro lets you rewrite that as (nest
(multiple-value-bind (a1 b1 p1) (foo1))
(with-open-file (f1 p1 ...))
(let ((x1 (read f1))))
(when x1)
(multiple-value-bind (a2 b2 p2) (foo2))
...
The macro definition is really straightforward: (defmacro nest (&rest r)
(reduce (lambda (o i) `(,@o ,i)) r :from-end t))
(The list of forms are passed, unevaluated and at compile time, to nest, which rewrites them using a right fold to nest things properly.)Somewhat similar is the arrow macro that Clojure popularized, which lets you get rid of (deep (nesting (like (this ...)))) where you have to remember evaluation order is inside-out and replace it with a flatter (-> (this ...) like nesting deep). Or (loop (print (eval (read)))) -- which will indeed give you a primitive REPL within Lisp -- with the more readable (-> read eval print loop). Its implementation is also easy -- many macros are easy to write because Lisp's source code is itself a list data structure for which you can write code to process and manipulate just like any other lists.
Another cool macro that's been around since 1993 is https://github.com/quil-lang/cmu-infix which lets you write math in infix style, e.g. #I( C[i, k] += A[i, j] * B[j, k] ) where A, B, and C are all matrices represented as 2D arrays. It's a lot more complicated than the nest macro, though.
There are some other things that still make Lisp great in comparison to other languages, but they don't exactly have one-line code examples like [::-1] and so I'll just describe them qualitatively. Common Lisp has CLOS, the first standardized OOP system. It's a lot more powerful than C++'s system. It differs from many systems in that classes and methods are separate; among other things this gives you multiple dispatch (you can define polymorphic methods that don't just dispatch to different code depending on the first argument (the explicit 'self' in Python, implicit 'this' in other langs) but all arguments). One thing it can be useful for is to get rid of many laborious uses of the Builder and Visitor patterns. e.g. the need for double dispatch is a common reason to use the Visitor pattern, but in Lisp there's no need. CLOS also does "method combination", which lets you define :before, :after, and :around methods that operate implicitly before/after/around a call. This gets rid of the Observer pattern, supports design-by-contract, and jives well with multiple inheritance in that you can create "mixins" that classes can "inherit" from with the only behavior being some :before/:after methods. (e.g. logging, or cleaning up resources, or validation.)
Everything is truly dynamic -- an object can even change its type at runtime, which may be an acceptable solution to the circle-ellipse problem, or just super convenient while developing. More fundamentally, "compile" is a built-in function, not something you have to do with a separate program. "Disassemble" is built-in, too, so you can see what the compiler is doing and how optimized something is. You have full flexibility to define and redefine how your program works as it's running, no need to restart and lose state if you don't want to. Besides being killer for development (and all the differences in development experience comprise a big part of why I still think Lisp is great compared to non-Lisp), this gives you a powerful way to do production debugging and hot-fixing too -- a footgun you might not necessarily want most of the time, but you don't have to do anything special for it when you do want it. It can be very useful, e.g. if you've got a spacecraft 100 million miles from Earth https://flownet.com/gat/jpl-lisp.html I've also put some hobby stuff on a server, just deployed as a single binary, but built so that if I want to change it, I can either stop it, replace the binary, and start again, or just SSH in and with SSH forwarding connect to the live program with my editor and load the new code changes just like I would when developing locally, and thus have zero downtime.
Lastly, Lisp's solution to error handling goes beyond traditional exception handling. Again this ties into the development experience -- you have some compile-time warnings depending on the implementation (e.g. typos, undefined functions, bad types) but you'll hit runtime errors eventually, Lisp provides the condition system to help deal with them. It can be used for signaling non-errors, which has its uses, but what you'll see first are probably unhandled errors. By default one will drop you into a debugger where the error occurred, the stack isn't immediately unwound. Here you can do whatever -- inspect/change variables on different stack frame levels, recompile code if there's a way to fix things, restart computation at a specific frame... You'll also be given the option of "restarts", which might include just an "abort" that unwinds to the top level (possibly ending a thread) but can include custom actions as well that could resolve the error in different ways. For example, if you're parsing a CSV file and hit a value that is wrong somehow (empty, bad type, illegal value, bad word, whatever), your restarts might be to provide your own value or some default value (which will be used, and the computation resumes to parse the next value in the row), or skip the whole row (moving on to the next one), or skip the whole file (moving on to the next file, or finishing). Again this can be very useful while debugging, but in production you can either program in default resolutions (and a catch-all handler that logs unhandled errors, as usual) or give the choice to the user (in a friendlier way than exposing the debugger if you please).
I don't think I've ever used the fact it's a homoiconic language in my programs
But I do suspect it's helping me indirectly it does make it easier to write static analysis tools for Clojure
It does make it easier for IDEs to identify what expressions I'm sending to the repl
And if I ever make a macro it will be helpful there
For me the question of why lisp or why Clojure the answer would be much more broad
A lot of the comments in this thread and the original article don't apply to all lisps
Getting Lisp to run as fast as C takes major effort when at all possible.
Resources:
Lisp needs a lot of space to do it's thing; and while it's certainly possible to downsize it, you're left with something that's not really Lisp anymore.
Ecosystem:
Finding solid libraries is tricky since it's not very popular professionally.
Power:
Unleashing the full power of Lisp in a diverse team is a recipe for an adventure, if not disaster.
The Computer Language Benchmarks Game shows Lisp Code as generally being between 2x and 10x slower than C++[1]. As fast as C? No. Way faster than Python, and more than fast enough to be used in almost every single application, modulo hard-real-time systems and AAA video games? Yes.
> Lisp needs a lot of space to do it's thing; and while it's certainly possible to downsize it, you're left with something that's not really Lisp anymore.
Again, while a 13MB SBCL image might be significantly larger than a 100KB C program, given that that's the entire compiler and runtime bundled in, and the size of additional code scales also like C/C++, that still makes it viable for almost every kind of program (and still an order of magnitude smaller than Electron). Same deal with memory usage.
> Finding solid libraries is tricky since it's not very popular professionally.
This one is so true it's not even funny. (although there are C, C++, and Python FFI's that cover most of the stuff that you want, although that's kind of cheating)
> Unleashing the full power of Lisp in a diverse team is a recipe for an adventure, if not disaster.
The list of companies using Clojure[2], in addition to the commonly-cited Viaweb/Orbitz/Grammarly, beg to differ. Anecdotally, most Lisps have less footguns than C++ - if people can figure out how to use Stroustrup's monster in massive video games, Lisp is easy.
[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
One of my favorite stories of the ideas of lisp commercially is a dialect that Naughty Dog developed for their game development.
It started as being developed for Crash Banicoot on the PS1.
Which is really interesting given how limited the system was (1mb to 2mb of ram depending on what you were doing with the system!)
They later iterated on it for Jak and Daxter on the PS2. To quote the wikipedia page:
> GOAL does not run in an interpreter, but instead is compiled directly into PlayStation 2 machine code to execute. > ... > GOAL has extensive support for inlined assembly language code using a special rlet form,[1] allowing programs to freely mix assembly and higher-level constructs within one function. > ... > It supports a long term compiling listener session which gives the compiler knowledge about the state of the compiled and thus running program, including the symbol table. This, in addition to dynamic linking, allows a function to be edited, recompiled, uploaded, and inserted into a running game without having to restart.
[https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp]
I almost don't believe it, honestly.
In most modern engines I've used we STILL struggle hard for a perfect live-reload system.
I've implemented many types of custom interfaces that let you tweak things on the fly in my games, and it's almost criminal how much better/productive it feels vs. the 'tweak, compile, test' loop we're usually stuck with.
All that said, I see the same reason of why companies always transition away from lisp all the time:
> In all honesty, the biggest reason we're not using GOAL for next-gen development is because we're now part of Sony. I can only imagine Sony's shock when they purchased Naughty Dog a few years back, hoping to be able to leverage some of our technology across other Sony studios, and then realized that there was no way anyone else would be able to use any of our codebase.
It really makes me wish some big company would make a python clone in lisp, but put a tiny escape hatch in to fully utilize the lispy parts.
If we're considering Clojure, then I would argue this point isn't true. Java interoperability in Clojure is really well supported and easy to accomplish, so leaning on the massive Java library ecosystem is possible. Also, anecdotally, a lot of Clojure libraries appear to be defunct, but just actually haven't been updated in so long because of the strong backward compatibility across Clojure versions.
> This one is so true it's not even funny
I'd say that's a bit out of date as Quicklisp has made a huge difference for CL. Obviously it's still not the most library-rich ecosystem but it's come a very long way.
But Lisp is faster than almost every widely used language that's not C/C++/Rust, around Java speed.
> Lisp needs a lot of space to do it's thing; and while it's certainly possible to downsize it, you're left with something that's not really Lisp anymore
Dunno, by modern standards it seems pretty small.
> Finding solid libraries is tricky since it's not very popular professionally.
Ish. Because it's so mature, lots of code works even it it's not updated constantly. There's code out there for most use cases, at least for back-end-y things.
> Unleashing the full power of Lisp in a diverse team is a recipe for an adventure, if not disaster
So enforce coding standards. This isn't a negative and lots of us work alone or in small teams.
Honestly, the only reason I don't mainly use Lisp is because I use an even slower/easier language because I don't really need a performant language. But if I find a problem where I want more performance Lisp is probably the next stop.
I'm not sure about that. These days in the backend you need a lot of libraries for cloud providers and new databases/services. For example, is there a Common Lisp library for AWS/Azure/Google cloud? Is there one for Clickhouse?
I think a lot of lispers like handling various paradigms in their head and start with basic lisp, and resort to edsl to reach more appropriate semantics/mechanical sympathy. Just like people call out to C wrappers mostly.
The social side of lisp I can't say for sure but I'm sure it's fuzzier than it seems. I've just talked to a dude saying his new guy was a clojurist and his thinking is way finer than the current team.
Java has hundreds (thousands?) of developers working on it.
SBCL has a handful of part-time devs.
What could SBCL become with all those man-years behind it?
Custom syntax is hardly the big issue when using Common Lisp. I'll take that any day over the dozens of layers of useless abstraction in Java projects. I'll take it over the C code golf or "what does this undefined behavior do?". I'd even take it over the piles of garbage JavaScript I've waded through over the years.
Whatever stopped that happening in the past, still stops that happening, and will continue to stop that happening in the future.
I came to Clojure from F#/ReasonML/C#/PHP/JavaScript so I understand the comfort in specifying something with a type system and what it's like to not have one and what it's like to have a weak/strong one
Compile time for Clojure is when you inject new code into your running program
Imagine you have a large codebase with lots of interconnected types and then you tasked the computer with checking all those types everytime you injected
Would that slow down the code injections for you and every other developer? Yes maybe, what about checking for probable errors? Again yes but slower, the feedback loop in lisps are what make them feel magic so this would be a problem
What could we do to maintain dev speed and confidence?
This is my current approach:
First is clojure-lsp (clj-kondo) this will check for silly Monday morning mistakes and do it in a separate process so I can code inject unhindered but still spot errors via my editor
Second is a new library called hyperfiddle/rcf they are inline tests that run on code injection so any static assertion I want to write about data or functions I can
They will run under "compile"/code injection time and can be solidified into "real" tests at any time and maybe more importantly serve as great communication for how to use functions and what kind of data you can expect to flow through them close to the original definitions
For me those things combined with TDD, the repl and the static analysis from intellji and writing real tests every now and again is enough confidence for me and I'm in control of the "compile" time cost not the language
So when it comes to green/red cycles in TDD the repl (code injection) is great for creating code/solutions and hyperfiddle/RCF is great for creating the safety harness required to fearlessly refactor all triggered from inside the editor it's really addictive
Barring that, Julia is a lispy language with great support for optional typing.
Both of the above will get a potentially better performance when you add types (the checks are (mostly?) done at compile time). Racket also has optional types, but I think these contracts are checked at runtime? I am not sure.
I'd think out of any language lisp would shine here.
You could write as complex of a type system as you wanted that compile time checks, so it's surprising someone hasn't written one that mimics at least java/c++/whatever style types.
I do think that is one of the down sides to lisp though. When you can do almost anything it's very hard to agree on what to actually do.
There's at least typed racket.
> I have 0 experience here but that's really surprising to me.
> I'd think out of any language lisp would shine here.
I don't think you should be surprised that people don't want to write their typecheckers as macros. A few people might want to do that, but most people don't. And at this point you're not far from just creating a new language, that you could create in ML or a descendant, which have always been one of the most popular options for that.
I love lisps, but Racket, for example, feels more modern than Common Lisp to me. And for shallow people like me, feel and ergonomics are very important when writing code.
Of course C counts. IMO it is a language that should have stayed in the last century.
> feel and ergonomics are very important when writing code
This is the reason why I can't stomach languages like Java, C++, etc.I feel like I'm fighting a very constrained interface.
Please, do not compare Java and C++ against C, C++ is a monster it should never have born, and Java it's a shitty TCL "alternative" from its era.
Curious because I'm on the same boat.
I was annoyed for a while how ruby convention uses '?' characters at the end of method names that return a boolean.
I'm not even that old and I still want to yell `[a-zA-Z0-9_]+` identifier names or get off my lawn.
It's not. It's like mentioning C++ in a conversation about OOP which is why Lisp is the appropriate umbrella term. For me, CL means Common Lisp.
Likewise, if you're using Lisp within the context of some other language for scripting, it's fucking phenomenal. If you try to use it on its own to build a whole project from 0 to 100, you're going to be confused as to why you're not using a different language.
Beginner friendly, lots of batteries included, large community with lots of libraries.
Here's an example of a simple webserver using the standard library: https://docs.racket-lang.org/web-server/run.html#%28part._se...
I'm also a fan of the first tutorial on the site. Instead of the boring stuff like hello world, 2+2, print your name etc, they use a built in library for drawing shapes to the console, and learn how to build up procedures for drawing more complex objects.
It feels like learning to code with logo (which they also have a clone built in of https://docs.racket-lang.org/logo/index.html)
All the good stuff said, I've never used it for system plumbing scripts like I do with python. I'd imagine it's worse for that due to the sheer popularity python has.
Clojure is great if you don’t care about the startup time, as it has good emacs support, and you can fall back on the JVM ecosystem. It’s the most concise of all the lisps I have tried, but also a tad opinionated.
Caveat: I'm still working towards being able to recommend Bel _unconditionally_, not just for small programs. Right now you'll experience unreasonable slowness, terse/uninformative error messages, and missing documentation -- probably in that order. All of those are being addressed. But already today, it's fun to play with.
Here is an example of scripting a small task:
https://gist.github.com/atomontage/64b767731b5896f1c6113adb9...
They both work really well for little scripts and tools where i found clojure startup time annoying.
This is the TXR Lisp interactive listener of TXR 271.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
1> '#J{"foo":[1,2,3,"bar"]}
#J{"foo":[1,2,3,"bar"]}
What is that literal syntax? 2> (typeof '#J{"foo":[1,2,3,"bar"]})
cons
cons-cell based object under the hood. 3> (car '#J{"foo":[1,2,3,"bar"]})
json
4> (cadr '#J{"foo":[1,2,3,"bar"]})
quote
It has a (json quote ...) structure. 5> (caddr '#J{"foo":[1,2,3,"bar"]})
#H(() ("foo" #(1.0 2.0 3.0 "bar")))
Followed by a hash table object. We can convert that to a vector to see it all: 6> (vec-list '#J{"foo":[1,2,3,"bar"]})
#(json quote #H(() ("foo" #(1.0 2.0 3.0 "bar"))))
Now actually eval it instead of quoting 7> #J{"foo":[1,2,3,"bar"]}
#H(() ("foo" #(1.0 2.0 3.0 "bar")))
The embedded hash table denoted by the literal is regurgitated.We can quasiquote JSON:
;; ^ is quasiquote in this dialect not `
1> ^(,(+ 2 2) ,(list 1 2 3))
(4 (1 2 3))
;; cannot use , in JSON for unquoting, so ~ is used:
2> ^#J["foo", ~(+ 2 2.0)]
#J["foo",4]
The quasiquote can be pattern-matched: 3> (match ^#J[~x, ~y] #(1.0 "foo") (list x y))
(1.0 "foo")
Or, using JSON syntax on the right side, which produces the same vector: 4> (match ^#J[~x, ~y] #J[1.0, "foo"] (list x y))
(1.0 "foo")TCL is also very stable between releases, it has industrial strength and threading support.
But it lacks advocacy. It could get one tenth of what Lisp gets...
No it isn't. Tcl has had dual-ported objects and a bytecode interpreter for over 20 years.
If you look at mathematical notation, written with quill pens and paper…it’s even more concise. Functions are like lisp, f(x). Vectors are laid out on the page in an array and surrounded by two strokes. Matrices are a 2d array surrounded by two straight lines.
This whole approach seems as archaic as Roman numerals is for representing numbers (they were based on lines and slashes like a tally system).
Maybe there is an even better notation for representing code which will be as much a leap forward as the positional number system (which represents every number as a power series with base 10) was to numbers.
The advantage [of the prefix notation for algebraic expressions in LISP] is like that of binary computers over decimal - but larger.
Yes, but now mathematics publishing predominantly uses a typewriter-era language for achieving it:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
M=
\begin{bmatrix}
1 & 2 & 3 & 4 & 5 \\
3 & 4 & 5 & 6 & 7
\end{bmatrix}
\]
\end{document}
Most programming takes place with what is more or less typewriting. (documentclass article)
(usepackage amsmath)
(begin document)
;; [...] read syntax for displayed math
[(= M (bmat (1 2 3 4 5) ;; case-sensitive treatment: M
(3 4 5 6 7))]
(end document)chapter 9, roman numerals: a vestige of primitive origins? starts like this:
——————————
I V X L C D M
They are obviously letters of the roman alphabet, but this does not mean they have an alphabetic origin. The signs L, C, D, and M are not the original forms of the numerals 50, 100, 500, and 1000; they are altered forms of much older numerals. known instances of the use of L, D, and M as numerals do not go back much farther the the first century AD […]—————————
The chapter goes on to illustrate the resemblence with etruscan numerals and the tally marks of ancient shepards counting sheep, see the “tally marks” section of the wikipedia page, or borrow the book from archive.org, page 131 to 146 or so.
https://en.m.wikipedia.org/wiki/Etruscan_numerals#Tally%20Ma...
Now maybe there are better notations though. I'm all ears.
Far from a typewriter.