Hacker News new | ask | show | jobs
by wsgeek 2341 days ago
I would like to ask a genuine question (not trying to provoke anyone!). Where is a good use case for Scheme these days (in any form?). I really love the idea of the language but I can't figure out where it really does a _better_ job that these things:

-- JavaScript/Typescript for in-browser or even some server-side stuff (e.g., NodeJS)

-- Python seems to be dominant for non-browser code that doesn't need to be fast (or which needs to call Python libraries)

-- C/C++/Rust/C# in the performance space

-- And then the workhorse Bash/ZSH etc for command-line script-fu

I am sincerely asking, what's the nice good fit for a Lisp these days? I know Emacs uses it as its internal language -- fair enough. But other than that.

Thanks and I did not mean to hurt anyone's feelings, I just really am curious.

6 comments

I'd say scheme fits into the python niche rather well. It's faster, easy to learn, and usually has good C interopt (or great interopt in the case of ones like chicken).

<stands on soapbox>

Scheme: fix your damn documentation

I have to know that SRFI (scheme request for implementation) is a thing. Then I have to look over hundreds of them to find the one I want (do I want SRFI 69, 90, 125, or 126 for hash tables?). Then I have to find that obscure doc somewhere that says which SRFI are supported. Then I have to read the specification doc as the only source of documentation on https://srfi.schemers.org/.

I once needed to get some complex data out of a very restricted interface (syntax trees from a compiler plugin, where the only communication channel was stderr). The AST nodes provided a generic-programming interface, so I made a dead simple tree traversal which spat out the node type followed by each child, wrapped in a pair of parentheses to disambiguate structure.

Since these dumps turn out to be s-expressions, it seemed like a good idea to do further processing using a Lisp. I picked Racket (a Scheme) and it was great: parsing was a no-op, and the language made recursing through the structure and pattern-matching on the contents really simple.

The only downside was that I wrote a lot of "contracts" (dynamically-checked types), since I'm more comfortable in statically-typed languages (Haskell, StandardML, etc.). Turns out that Racket contracts are REALLY slow, so I ended up using a macro to discard them unless we were running the test suite :(

Scheme has been the 50th most popular language for 50 years running. It has never been the best language for any particular use case, but it has been good enough to inspire a community to keep it running and relevant all this time.

If you made the same kind of list of 4 languages that dominate all use cases back in 1990 (say), Scheme wouldn't have made the list then either; BUT the 4 languages would be different than they are now. If you want the most frictionless and popular language for the tech stack of the moment, use the trendy language du jour, but you have to live with neverending churn. If you want a language that is perpetually "good enough," use something like Scheme.

There are use cases where longevity and inoffensiveness are important. Embedded scripting, the original motivation for Guile, is one of them. Scheme is my go-to for little personal utility programs. After a long day of dealing with headaches from trendy environment du jour, I want to come home to something that's bulletproof, just works, and I already know. The minimalism and clarity make it a good first learning language. It seems like it'd be good for code "for the ages" like reference implementations and government software, but AFAIK there hasn't been much of that.

Programming language research. Nothing better than scheme for that.

Also quite good for building small programs with no/minimal depencies from scratch. Which I suspect reduces to my first statement...

Here's a comparison of CL and Python: https://lisp-journey.gitlab.io/pythonvslisp/

and CL can be super performant btw.

CL allows for live/REPL programming, unmatched elsewhere, and still has features not found elsewhere too. Happy discovery!

Scheme is just yet another general-purpose programming language, it does not serve any specific use case. (Particular implementations might, though.)