E
Eric Kidd
randomhacks.net · Personal blog · on HN since 2007
Eric Kidd writes about programming languages and techniques, including Ruby, Haskell, probability monads, and Rust kernels.
What HN saysCommenters often cite his essay "Why Ruby is an acceptable Lisp" and his work on probability monads and McCarthy's amb operator.
65HN people shared it
36linked it in comments
35stories submitted
1.2Kstory points
5 months agolast shared
2007people per year2026
Most-shared posts
- 1Why Ruby is an acceptable Lisp (2005)14 people · 148 points · first shared 2014 · 113 comments on HN
- 2Why Ruby is an acceptable Lisp (2005)12 people · 54 points · first shared 2008 · 31 comments on HN
- 3McCarthy's Ambiguous Operator (2005)8 people · 190 points · first shared 2019 · 42 comments on HN
- 4Bayes' rule in Haskell (2007)5 people · 184 points · first shared 2007 · 77 comments on HN
- 5Generalised error handling in Haskell3 people · 4 points · first shared 2009 · 3 comments on HN
- 6Bare Metal Rust: Building Kernels in Rust3 people · 1 points · first shared 2015 · discussion on HN
- 7Substudy3 people · first shared 2019
- 8Build Your Own Probability Monads2 people · 66 points · first shared 2015 · 15 comments on HN
- 9Proving sorted lists correct using the Coq proof assistant (2015)2 people · 4 points · first shared 2018 · discussion on HN
- 10Build your own probability monads [pdf]2 people · 2 points · first shared 2016 · discussion on HN
- 1113 Ways of Looking at a Ruby Symbol2 people · 2 points · first shared 2009 · discussion on HN
- 12Monads in 15 minutes: Backtracking and Maybe (2007)2 people · 1 points · first shared 2020 · discussion on HN
- 13Haskell 8 ways to report errors2 people · first shared 2016
- 14Rust lifetimes: Getting away with things that would be reckless in C++1 people · 231 points · first shared 2014 · 90 comments on HN
- 15Bare Metal Rust 2: Retarget your compiler so interrupts are not evil1 people · 140 points · first shared 2015 · 16 comments on HN
What HN people wrote when they linked it
phoe-krk · 2024-01-31
The idea seems so similar to the classical AMB ambiguous operator introduced by John McCarthy [0]. The implementation seems similar to what I've done a while ago, too, just in Lisp and using Lisp primitives rather than function decorators.
[0] http://www.randomhacks.net/2005/10/11/amb-operator/
[1] https://github.com/phoe/amb/
Syzygies · 2022-08-10
I love Ruby so much as a scripting language, I ask myself why I don't just use it as an "acceptable lisp" [1] for my research, rather than Haskell. Haskell is more easily parallelized than any other language I've experienced. Alas, my experiments with Ruby 3.1 parallel extensions flunked. Who cares about single core speed?
I was always put off by Rust syntax (it's a fly-pollinated flower, to attract C programmers), but I'm starting to get the genius in its machine model. Learning Rust forces one to understand what's happening at the machine level, but offers better control as a reward. Its expressiveness is a lot closer to Ruby than I had imagined, it won't put me back in the C99 stone ages. So my provisional answer is that Rust is a Faster Ruby.
[1] http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
mackwic · 2014-10-12
But Ruby is an acceptable Lisp[0], and has also a lot of libraries. ;)
So, how will Lisp compete ?
Maybe if we look at it pragmatically, the solution is not in the performance nor in the time to develop, but in the ease of maintaining the software in the long term. A field where Lisp is not particularly brilliant.
[0]: http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
ekidd · 2011-07-05
The "Probablistic Functional Programming" paper was really fun, and it builds on some decades-old observations in mathematics.
You can easily extend the PFP framework to handle Bayes rule. I experimented with this a few years back, and was pleasantly surprised how natural it was:
http://www.randomhacks.net/articles/2007/02/22/bayes-rule-and-drug-tes…
(Or, for those who love details, a PDF: http://www.randomhacks.net/darcs/probability-monads/probability-monads… )
pjonesdotca · 2009-08-16
Actually, I think that Eric Kidd would disagree with you. He makes a great point here: http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab… that "In particular, macros which actually compile mini-languages haven’t appeared yet, although they might be possible with enough work."
One can fake a great deal of LISP in Ruby but, I would like to hear more about your thesis of "Ruby's halfway to CL" for no other reason than I've been spending free time "Ruby-fying" Scheme and see more of a gap than you're implying exists.
jerf · 2015-09-01
Even as someone who knows Haskell, it isn't actually possible to read this article and figure out what specifically about Haskell is helping.
My suspicion is that it is Haskell's great support for domain-specific languages. This is both in the sense of languages that are really "just" Haskell APIs but work in such an different manner that they are quite different, and in the sense of writing a full compiler [1] (or any subset of a compiler) for a new language.
For an example of the former, one of my favorite demonstrations is the "probability monad", in which one ends up with a sort of sublanguage inside of Haskell that is probability aware: http://www.randomhacks.net/2007/02/22/bayes-rule-and-drug-tests/ [2] If you want to start to really grasp the power of Haskell, you could do worse than meditate on how you'd implement that in your $FAVORITE_LANGUAGE... and then, most likely, burst into tears when someone shows you just how much of Haskell still works, unchanged, even in that environment (e.g., everything in Control.Monad), rather than having to be implemented in a parallel type hierarchy (or, put another way, producing a new "color" of functions [3]).
While I doubt they use something exactly like that, it's not hard to see how that sort of thing could make it fairly easy to write spam classification code with a lot of the basic plumbing abstracted away entirely.
There's a lot of examples of the latter, but I'm not sure of a really solid open source example to point…
rmunn · 2026-06-12
Just yesterday I stumbled across an article from 2005 titled "Why Ruby is an acceptable LISP": https://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/… I don't agree with all of his points about macros, e.g. I think his line about "The most common use of LISP macros is to avoid typing lambda quite so much" is simply incorrect. But his point about how Ruby allows building DSLs, and so it gives you quite a lot of what you want from Lisp macros, is broadly correct, I think.
And now it's more clear to me why that is.
singularity2001 · 2024-09-06
'Swift is the better rust' inspired by the why-ruby-is-an-acceptable-lisp debate: http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
vinceguidry · 2020-09-07
Not to take away from the sheer amaze-balls power that lisp offers, you can get Ruby superpowers just from one book, Metaprogramming Ruby 2, which is sadly out of print.
Here's a 2005 article comparing Ruby favorably to Lisp: http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
I learned Lisp, went through the whole of HtDP, tried to get into it, but Ruby's friendliness is really special and unique.
ijpsud · 2020-02-22
Too me a bit too - this explains it better I think: http://www.randomhacks.net/2005/10/11/amb-operator/
tpaschalis · 2020-02-22
About last year, this [1] article on the Amb operator was featured in HN, so back then, I grabbed the Rosettacode Go example and wrote a blogpost[2], going through such an example. Feel free to check it out!
[1] http://www.randomhacks.net/2005/10/11/amb-operator/
[2] https://tpaschalis.github.io/golang-amb-operator/
topmonk · 2019-12-22
Sounds interesting. I've been trying to use movies (something called "substudy"* which converts subtitled movies to a csv file which I then import them as cards into anki), but I find it very difficult.
Could you point me in the direction of some of these simple audio books?
* substudy is here: http://www.randomhacks.net/substudy/
fouc · 2018-10-23
In response to your last sentence.
Just wanted to mention that Ruby was highly inspired by Perl, particularly its regular expressions and it has a variety of perlisms. Kind of surprised you went to python and not ruby.
Your lisp mention reminds me of this: http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
laretluval · 2018-10-14
Suppose you have a probability monad, implementing enumeration or random sampling. Like Amb but with probabilities attached.
bayesRule :: (Prob a) -> (a -> Prob b) -> b -> Prob a
bayesRule prior likelihood data = do
h <- prior
d <- likelihood h
guard $ d == data
return h
I don’t actually do Haskell...just thinking out loud.
Looks like it was written similarly here http://www.randomhacks.net/files/build-your-own-probability-monads.pdf
gmfawcett · 2018-02-23
> In Haskell, functions do not fail in traditional sense - they just return indication of failure.
That's too general a statement. Haskell functions certainly can fail in the traditional sense. As a trivial example, "head []" is a well-typed Haskell expression that will raise an exception when evaluated; if the exception is not caught (using a traditional exception handler), then it propagates to an error, and the program exits.
This article [1] about the many ways to handle errors in Haskell is a bit old, but as far as I know, all his points are still relevant. The conclusion (for me) is that if modern Haskell tends to use return-values on failure, it's due to convention (and good taste) among developers, and not due to a design constraint of the language.
[1] http://www.randomhacks.net/2007/03/10/haskell-8-ways-to-report-errors/
bhnmmhmd · 2017-08-20
There was a discussion here about how Ruby is an acceptable Lisp:
http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
Ruby blocks cover a lot of what Lisp macros do. I don't know much Python and JS, but I'm guessing those don't have something similar to blocks/macros.
mrkgnao · 2017-06-02
This post has a good overview of what can be gained by the use of these techniques:
http://www.randomhacks.net/2007/02/10/map-fusion-and-haskell-performan…
> Using just these two rules, I saw a 225% increase in the number of nodes processed per second. Under the right circumstances, GHC can even outperform C code by applying these kinds of inter-procedural optimizations.
Also, we have QuickCheck, which allows us to check properties by randomly generating testcases. The post I linked mentions this.
fnl · 2016-11-04
Standard "canned" reply: Java doesn't force you to annotate exceptions or even to handle them all. Typed returns do. And as to the "where", well, in the originating function.
But that gets us to some real criticism here: You run the danger of getting an Either Monad out of about every function in your code-base... So maybe throwing exceptions isn't the worst thing after all. (/me ducks all the stuff being thrown my way from hardcore [EDIT:] ~Haskell~ functional programming fans :-))
EDIT: s/Haskell/functional programming/
(because its unfair - Haskell can throw stuff: http://www.randomhacks.net/2007/03/10/haskell-8-ways-to-report-errors/…
wichtounet · 2016-08-23
You can write a kernel in pretty much every language. There are some experiments with Rust: http://www.randomhacks.net/bare-metal-rust/
There are several reasons to choose a language rather than another. I personally don't like Rust at all, so I don't see any reason to use it, neither do I see any advantage in using it. But that's only my opinion. A lot of osdev currently is made by hobbyist (not counting the handful of really succesful kernels), so the main argument is simply personal and there is nothing wrong with it. Moreover, keep in mind that Rust is pretty new while C/C++ are decades old, this means more support, more portability, more people that know how to use it, ... This is not negligible at all.
polyfractal · 2015-12-29
If I understand correctly, Phil started writing his series first. That tutorial prompted several people to start working on their own hobby OS, including Steve's and another one here: http://www.randomhacks.net/bare-metal-rust/. I think Redox was already underway when Phil started writing, but I may be mixing up my timelines.
Edit: There is also http://www.alexeyshmalko.com/2015/bkernel-a-rust-operating-system/
Phil has stated his series is basically for fun and learning. I imagine Steve's and Eric's are similar. You don't necessarily want to "combine effort" with someone when you are exploring ideas on your own.
dragonwriter · 2014-10-01
> I don't really encounter many folks making the claim that Ruby is a functional language.
Ruby is a multiparadigm language, and functional is one of the important paradigms it supports. A rather popular essay on Ruby from nearly a decade ago (surprising for me to discover that it was that long ago!) was "Why Ruby is an acceptable LISP" [1]
Its true that recently much of the recent focus on functional languages has been on statically-typed and/or pure functional languages, which neither Ruby nor Lisp is...
[1] http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/
adamors · 2014-05-05
Well, I think it's because Ruby has borrowed a lot of features from Lisp (and Clojure is also a Lisp). Here's an article that argues that it is actually an acceptable Lisp: http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
alxndr · 2013-10-14
> "the claim that Ruby is Lisp -- a claim no one has made"
Posted without comment: this was written just before Matz wrote this email, but here's someone saying that Ruby is an acceptable LISP: http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
raganwald · 2011-12-12
_pius · 2011-08-03
I know and enjoy Lisp, but I don't use it anymore. I do, however, use Ruby, which is an acceptable Lisp.
http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
In general, Lisp doesn't seem special anymore because (1) language implementers have taken Lisp's most important lessons and applied them to their own languages and (2) said languages have become relatively popular.
A lot's happened since "Beating the Averages".
http://www.paulgraham.com/avg.html
benwr · 2011-08-03
I hate to just insert a link into a comment, but this article is a much better response than anything I could come up with:
http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
caioariede · 2011-03-30
cytzol · 2010-10-06
The thing that most amazed me about Common Lisp was not LOOP, but ITERATE. Specifically, "bill a"'s comments in this article (linking to the first one, there are several more down the page):
http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
prog · 2010-07-29
When I started to learn Lisp, the "Which Lisp?" problem was the first thing to hit me. Same with Scheme. I eventually went with CLISP and PLT (Racket).
Issues like hygiene didn't really bother me too much. As long as you are aware of it its not an issue.
While I really like the power of Lisp/Scheme (especially macros), I find that for most programming task Python or Ruby are good enough. There was an interesting post along similar lines 'Why Ruby is an acceptable Lisp'[1].
One thing I am really interested is in seeing how Perl 6 works out. It supports Lisp style macros (by making the parser available to the programmer) while using conventional syntax. While I am a Python fanboy myself I would seriously consider Perl 6 once there is a CPython grade implementation available.
[1] http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
steveklabnik · 2010-02-03
>Neither python nor ruby are lisp.
You may or may not agree, but you'll probably be interested in Why Ruby is an acceptable Lisp:
http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptab…
Covered on HN previously here:
http://news.ycombinator.com/item?id=416589