Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    T

    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.

    Visit blogHN submissions
    Languages & CompilersMathProgramming
    What HN says

    HN 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.

    Stats for nerds
    18HN people shared it
    8linked in comments
    87story points
    Jun 2025last shared
    2009people per year2025

    Top posts on HN

    1. 1
      How to generate a double-precision floating-point number in [0, 1] uniformly
      5 people · 70 points · first shared 2015 · 36 comments on HN
    2. 2
      Proposal for Ephemerons in Scheme
      1 person · 9 points · first shared 2010 · 4 comments on HN
    3. 3
      Lisp Style Guide
      4 people · 6 points · first shared 2007 · Discussion on HN
    4. 4
      ISP of the Future
      1 person · 2 points · first shared 2013 · Discussion on HN
    5. 5
      Paredit.el
      3 people · first shared 2009
    6. 6
      Random real.c
      2 people · first shared 2023
    7. 7
      T
      1 person · first shared 2017
    8. 8
      Paredit.credits
      1 person · first shared 2012
    9. 9
      Random real.c
      1 person · first shared 2019
    10. 10
      Paredit
      1 person · first shared 2012

    What HN people wrote when they linked it

    • FabHKMay 2025

      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/generation.jl

      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-in-the-interval-01/

      [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

    • calibraxisFeb 2012

      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/EoSmODsX7WgJ)

      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.

    • glkindlmannJun 2025

      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/a673553dd7925b0f103c81f19a7ff6f2e509eada/cauldron/random.h#L1391C8-L1391C33

    • KirinDaveMar 2009

      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.

    • c00p3rSep 2010

      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.

    • redcalxFeb 2019

      See NextDoubleHighRes() here:

      https://github.com/colgreen/Redzen/blob/master/Redzen/Random/RandomSourceBase.cs

      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.

    Related

    Danny Yoohashcollision.org24 people

    F*dging up a Racket

    Danny Yoo
    Personal · last shared 2026
    Luke Palmerlukepalmer.wordpress.com35 people

    IDE WTF

    Luke Palmer
    Personal · last shared 2020
    Random ASCIIrandomascii.wordpress.com274 people

    There are only four billion floats, so test them all (2014)

    Random ASCII
    Personal · last shared 2026
    Nick Drozdnickdrozd.github.io25 people

    Signed Char Lotte

    Nick Drozd
    Personal · last shared 2026
    Alan Wolfeblog.demofox.org54 people

    Derivatives, Gradients, Jacobians and Hessians

    Alan Wolfe
    Personal · last shared 2026
    Amit Patelamitp.blogspot.com18 people

    Non-Consensual Personalization

    Amit Patel
    Personal · last shared 2026
    Vidar Holenvidarholen.net68 people

    Useless Use of "dd" (2015)

    Vidar Holen
    Personal · last shared 2025
    Simon Byrnesimonbyrne.github.io15 people

    Beware of Fast-Math

    Simon Byrne
    Personal · last shared 2025