Taylor Campbell

mumble.net/~campbell · Personal blog · on HN since 2007

Taylor Campbell writes about Lisp and Scheme, the paredit Emacs mode, and generating random floating-point numbers.

What HN saysHN links it for its treatment of uniform random floats, with working C code, though one commenter is skeptical of the claim that it is the first efficient algorithm.
18HN people shared it
12linked it in comments
8stories submitted
87story points
1 year agolast shared
2007people per year2026

Most-shared posts

  1. 1
  2. 2
    Lisp Style Guide
    4 people · 6 points · first shared 2007 · discussion on HN
  3. 3
    Paredit.el
    3 people · first shared 2009
  4. 4
    Random real.c
    2 people · first shared 2023
  5. 5
    Proposal for Ephemerons in Scheme
    1 people · 9 points · first shared 2010 · 4 comments on HN
  6. 6
    ISP of the Future
    1 people · 2 points · first shared 2013 · discussion on HN
  7. 7
    Paredit
    1 people · first shared 2012
  8. 8
    Paredit.credits
    1 people · first shared 2012
  9. 9
    Random real.c
    1 people · first shared 2019
  10. 10
    T
    1 people · first shared 2017

What HN people wrote when they linked it

danieldk · 2015-04-10
I get the impression that it's indeed not a solved problem, and even implementations that do not have to follow standards like C++ get it wrong. I recently submitted this to Hackernews, which is a nice treatment of the problems: http://mumble.net/~campbell/2014/04/28/uniform-random-float?
calibraxis · 2012-02-29
Sounds unlikely. May I ask what experience you had with 1980's structure editors (presumably Interlisp)? My reading of history is that it wasn't rejected by users, but rather killed off by MacLisp implementors teaming up to create Common Lisp, thereby getting the ARPA funding (when ARPA wanted to consolidate Lisp). (https://groups.google.com/forum/#!msg/comp.lang.lisp/Llmnxk2SYUk/EoSmO… Paredit, a favorite among modern Lisp users, was directly inspired by Interlisp's structure editing. Paredit's own author calls it a "cheesy imitation" of Interlisp. (http://mumble.net/~campbell/emacs/paredit.credits) Personally, I think Lisp is ripe for many different visual/kinesthetic interpretations, and this one certainly is pretty.
glkindlmann · 2025-06-02
That page ends with "This is the first efficient algorithm for generating random uniform floating-point numbers that can access the entire range of floating point outputs with correct probabilities". I am very skeptical. The same basic idea is described here [1] (though without any pretty pictures, but with a link to working code), and I know others have implemented the same insight [2]. This seems like the kind of thing that is reinvented every time some who cares about random numbers learns how IEEE 754 works. [1] http://mumble.net/~campbell/2014/04/28/uniform-random-float [2] https://github.com/camel-cdr/cauldron/blob/a673553dd7925b0f103c81f19a7…
an1sotropy · 2023-04-15
Others have previously pondered this, and the related issue of how to randomly select floats in [0,1). I found this to be a helpful account: https://mumble.net/~campbell/2014/04/28/uniform-random-float and there's working C code too: http://mumble.net/~campbell/2014/04/28/random_real.c
neilv · 2022-07-30
The Emacs paredit.el that they cite is by Taylor Campbell. https://www.emacswiki.org/emacs/ParEdit http://mumble.net/~campbell/emacs/paredit.el
redcalx · 2019-02-09
See NextDoubleHighRes() here: https://github.com/colgreen/Redzen/blob/master/Redzen/Random/RandomSou… There's an explanation in the comments, and a link to the original fuller explanation and source, here: https://mumble.net/~campbell/tmp/random_real.c I.e. I'm pretty sure your approach gives a non uniform distribution, but happy to discuss in more detail if you want.
sctb · 2017-08-19
There are some more bits of T-ness here: http://mumble.net/~campbell/t/ related to the T Revival Project, which itself is in need of reviving.
jamii · 2014-08-21
The same thing is true for lisp. Writing a tree-based interaction mode like paredit that doesn't die horribly on malformed text is a non-trivial problem (http://mumble.net/~campbell/emacs/paredit.el - 2625 lines of emacs lisp just to edit a tree).
drothlis · 2012-05-23
No idea sorry... the user who uploaded it to emacswiki didn't leave any contact details. And it's not part of the paredit source repo: http://mumble.net/~campbell/emacs/paredit/ :-(
c00p3r · 2010-09-01
http://mumble.net/~campbell/scheme/style.txt The reader of the code should not be forced to stumble over a semantic identity because it is expressed by a syntactic distinction. The reader's focus should not be directed toward the lexical tokens; it should be directed toward the structure, but using square brackets draws the reader's attention unnecessarily to the lexical tokens. But it is not only about a style. When [x y] means a different thing than (x y) it is a different language construction, with different behavior.
KirinDave · 2009-03-03
So things like paredit mode (http://mumble.net/~campbell/emacs/paredit.el) for Emacs don't count because... why exactly? Honestly I find most people who "hate parenthesis" don't actually hate parenthesis. They hate the idea of having to delimit the start of a statement as well as the finish. And unless your editor is helping out it can sometimes be a pain (let's admit it, it can be). But like every computer language, Lisp makes a tradeoff here and says that the features they can enable with such an incredibly regular syntax outweigh the pain of needing an editor mode.
FabHK · 2025-05-07
There's another approach for doing this: generate a random number between 1 and 2 (they all have the same exponent) and then subtract 1 (that's the default implementation in Julia [0]). But I think it also just gives you 2^53 different numbers. So, between .5 and 1 you miss out on every second representable number, between 0.25 and .5 you miss out on 3/4 of them, and so on. I guess for many cases that's good enough, but the article seems like a nice improvement. ETA: Lemire has some thoughts on this [1] and links to what might be a prior solution [2]. Vigna (of xoroshiro fame) writes about it at the bottom of [3] and also links to [2]. So, presumably the implementation described in the article is faster? ("There have been some past attempts to fix these flaws, but none that avoid a huge performance penalty while doing so." EDIT2: BTW, one of the things I love about HN (well, the world, really) is that there are people that care deeply that we can uniformly sample floats between 0 and 1 correctly, and all of them, and do it faster. [0] see https://github.com/JuliaLang/julia/blob/master/stdlib/Random/src/gener… rand(r::AbstractRNG, ::SamplerTrivial{CloseOpen01_64}) = rand(r, CloseOpen12()) - 1.0 [1] https://lemire.me/blog/2017/02/28/how-many-floating-point-numbers-are-… [2] https://mumble.net/~campbell/2014/04/28/uniform-random-float https://mumble.net/~campbell/2014/04/28/random_real.c [3] https://prng.di.unimi.it

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close