Reg Braithwaite
raganwald.com · Personal blog · on HN since 2008
Reg Braithwaite (raganwald) writes about JavaScript, functional programming, combinators, and programming theory with practical examples.
What HN saysCommenters praise how it mixes theory with application, and one calls him the only writer covering idiomatic, dynamic JavaScript patterns.
94HN people shared it
35linked it in comments
116stories submitted
4.8Kstory points
5 months agolast shared
2008people per year2026
Most-shared posts
- 1Homepage8 people · first shared 2008
- 2Trampolines in JavaScript7 people · 170 points · first shared 2013 · 72 comments on HN
- 3Remembering John Conway's FRACTRAN6 people · 110 points · first shared 2020 · 14 comments on HN
- 4When FP? And When OOP? (2013)4 people · 152 points · first shared 2016 · 151 comments on HN
- 5Carnac the Magnificent4 people · 48 points · first shared 2015 · 16 comments on HN
- 6Yes, JavaScript is a Lisp4 people · 12 points · first shared 2013 · 1 comments on HN
- 7How I Learned to Stop Worrying and Love the State Machine3 people · 700 points · first shared 2018 · 208 comments on HN
- 8To Grok a Mockingbird3 people · 79 points · first shared 2018 · 10 comments on HN
- 9What's a Transducer?3 people · 11 points · first shared 2017 · discussion on HN
- 10Deriving the Y Combinator and Sage Bird from the Mockingbird3 people · 8 points · first shared 2018 · discussion on HN
- 11Closing Iterables Is a Leaky Abstraction3 people · 5 points · first shared 2017 · discussion on HN
- 12Exploring Regular Expressions and Finite-State Recognizers, Part I3 people · 5 points · first shared 2019 · discussion on HN
- 13Time, Space, and Life as We Know It (2017)3 people · 3 points · first shared 2017 · discussion on HN
- 14Greenspunning Predicate and Multiple Dispatch in JavaScript3 people · 3 points · first shared 2014 · discussion on HN
- 15Why recursive data structures?2 people · 404 points · first shared 2017 · 121 comments on HN
What HN people wrote when they linked it
vanderZwan · 2018-09-04
I love blogs like this. Some people are really good at hitting that sweet spot of explaining things in a way that mixes theory with application in such a way that the insight becomes easier to grok.
Reg "raganwald" Braithwaite's blog is another one:
http://raganwald.com/
a4isms · 2023-03-17
Way back when Joel Spolsky was a high-profile blogger in the "starting your own software business" genre, I asked him for advice about my blogging, and he replied "Stop what you're doing and get your blog onto your own domain."
I had procrastinated because other platforms made everything so damn easy, and hosting my own blog meant being a part-time web admin. But I took his advice, and set up http://raganwald.com.
Some years after that, Posterous launched on HN, and I gave it a try. It was great, so very convenient! But I carefully kept copies of everything I posed there, and sure enough... One day it closed its doors, and I republished evrything on raganwald.com (some of my urls are raganwald.com/posterous/xxxxx.html, this is why).
But what about all the links to the old posterous articles? All dead, so some threads right here on HN point to dead URLs. This is bad for me and for HN. For this reason, I personally reject the strategy of posting on my own domain and republishing it simultaneously on some other platform. Everything I write is on a domain I control, and if I get less traffic, so be it. Running my own blog on my own low-traffic domain is like running a store in a building I own. The mall is very attractive, but I'm done with landlords.
p.s. There are hosted solutions that respect you your own domain. Some are free, like... Github Pages. And that's what I use. It is not essential that I own the server, just the…
hajile · 2024-04-10
The book is primarily good at introducing the basic concepts of functional programming. It’s also one of the best for that in my opinion.
You wouldn’t use the quicksort from your textbook in production because it’s an example designed to teach specific principles. A complete tour of the literature on just that one story and all its variants and implications be a decent sized book all by itself.
Likewise, the examples inJS Allonge are vehicles to explore functional concepts.
I’d also note that there’s a PDF available for free.
http://raganwald.com/assets/javascriptallongesix.pdf
imbnwa · 2023-07-08
Only writer I know who discusses pure JS patterns that embrace those its dynamism is Raganwald Braithwaite[0]. For example, most people I know would call this hacky code[1], when this is just design patterns in idiomatic, non-Java/C#-constrained JavaScript. The truth, most devs desire intellisense and/or theorycrafting that comes with static types and compilers.
[0]https://raganwald.com/
[1]https://raganwald.com/2014/04/10/mixins-forwarding-delegatio...
prezjordan · 2021-01-20
One of my favorite facts about FRACTRAN that's often missing from articles around it [0]
> And it follows that FRACTRAN games are undecidable. This doesn’t speak directly to the Collatz conjecture, because (1/2)n | 3n + 1 is not a FRACTRAN game. But it does follow that arbitrary Collatz games are undecidable, since the set of all Collatz games includes the set of all FRACTRAN games.
[0] https://raganwald.com/2020/05/03/fractran.html#why-fractran-really-mat…
jessaustin · 2019-12-18
Someone who has written so much [0] about functional programming, I would suspect has written an interpreter before.
[0] http://raganwald.com/
braythwayt · 2019-02-23
It’s my favourite (“favourite” is not synonymous with “best” by any metric other than amusement) solution as well:
http://raganwald.com/2018/11/14/dyck-joke.html
matt4077 · 2017-04-01
For those unfamiliar with the author: he is one of about a dozen people I can can remember, where I immediately knew "wow, this guy is smarter than you, and almost as funny. Let's enjoy this"[1].
He's also a good example for the yiddish concept of "Mensch".
continue here: http://raganwald.com
[1]: Bragging not intended–it just seems to me like the difference must be fairly large in any direction before I consciously notice it.
bootload · 2017-01-10
"Does anybody know a widely used and open source project using literate programming? (Edit: please include only programs expressed "as a web of ideas" that Knuth mentions - apparently otherwise it's not literate programming, just loads of inline documentation?)"
Funny you ask this, I ran across a @raganwald post mentioning a great example of ^literate programming^ (mixing code and documentation), "Literate CoffeeScript" [0]. You can read about how CoffeeScript does this at http://coffeescript.org
[0] blog post: http://raganwald.com/2013/03/27/literate-coffeescript.coffee.html
[1] raw text: https://raw.githubusercontent.com/raganwald/raganwald.github.com/maste…
kafkaesq · 2016-02-19
Overly complex algorithm questions (that the interviewer expects an immediate, near-optimal solution to -- even though they were open in the literature for several years before these solutions were found); or reasonably enough questions that just aren't articulated properly (this happens amazingly often); gratuitous brain teasers, or "Carnac the Magnificent"[1] question so any sort; or just the sheer duration of some of these one-way, "prove to me you aren't a liar or an idiot, while I play with my cellphone" sessions (6-8 hours over multiple visits); and then, quite often, dealing with the candidate in a desultory fashion afterwards -- all qualify as borderline hazing, in my book.
[1] https://raganwald.com/2015/05/08/carnac-the-magnificent.html
raganwald · 2013-09-06
Did you see the follow-up post "High-Level Trampolining?"
http://raganwald.com/2013/03/29/high-level-trampolining.html
stouset · 2013-02-22
> I drop a CNAME file into the repo. For http://raganwald.com, the file contains the text raganwald.com. Once you push that, Github starts resolving hits to raganwald.com to whatever you are publishing
What prevents me from putting a CNAME file with that in my own repo, out of curiosity?
bayindirh · 2020-06-04
> Programs are not designed to be readable, they are designed to solve a problem.
No. Code should be readable. When a code is fresh only you and God knows what it does and how it does. 6 month later, only God knows how your code works. You need to re-read and understand it to grasp it again.
Unless you marked all magic with big comments blocks or you wrote your code explicitly, it'll take some headache-inducing hours to re-understand it.
> The first goal is to get the correct program, and only after, it is important to make the code readable. A readable code that doesn't work is not worth much.
Again no. You can leave a non-working but readable code overnight and understand the problem tomorrow morning. You can't remember random noise after a good night's sleep (unrelated: This is why regex is hard for our brains).
Related read: http://raganwald.com/2013/04/02/explicit-versus-clever.html
michaelsbradley · 2013-11-13
Jim Duey's blog post on the State Monad was helpful to me[1].
I agree that one shouldn't reach for monads just because one finds them interesting or neat, or challenging for that matter.
An analogy: consider that in many cases, `while` and `for` loops are great when looping is what's called for. But there are many times when recursion is more attractive still. But what to do if your language doesn't have TCO, and blowing the callstack is a real concern? Well, then you can use trampolines![2]
Now, trampolines are great, but you don't need to always reach for them. An analysis should be done of the problem at hand, and "the right tool chosen for the task", which may be a simple `while` loop. The same goes for monads. Are there cases where the State Monad makes the most sense among other programming patterns? Yes, I think so. Particularly, when you are trying to model a multi-step and nested-steps computation where the steps are intertwined in such a way that one can easily identify "global state" at work. In that case, the State Monad is a tool that will let you thread the global state through the steps and levels of computation without having to twist yourself into knots doing it some other way AND without relying on unfettered mutability.
[1] http://www.clojure.net/2012/02/10/State/
[2] http://raganwald.com/2013/03/28/trampolines-in-javascript.html
[&] http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/tr…
fanf2 · 2024-09-16
I like Raganwald’s ode to Fractran which relates it to Minsky’s register machines and (surprisingly) the Collatz conjecture. https://raganwald.com/2020/05/03/fractran.html
rstuart4133 · 2024-07-22
Why over complicate it? FRACTRAN is a Turning complete language based on only one operation: multiplication. It's Wikipedia entry gives a short FRACTRAN program that finds all primes. https://en.wikipedia.org/wiki/FRACTRAN
In the words of it's inventor, John Conway:
Makes workday really easy! FRACTRAN needs no complicate programming manual. It's entire syntax can be learned in 10 seconds, and programs for quite complex and interesting functions can be written almost at once. The entire configuration of a FRACTRAN computer at any instant is a single integer - no messy "tapes" or other foreign concepts to be understood by the fledging programmer. What's not to like? This is a good introduction for someone seriously considering doing their next project in FRACTRAN: https://raganwald.com/2020/05/03/fractran.html
tpmx · 2023-05-03
https://raganwald.com/assets/snobol-green-book.pdf
"4.6.4 Example - Tower of Hanoi" on pages 109-111 (the scanned page numbers)
ughitsaaron · 2022-11-01
This is the first time I've heard of "trampolines". How interesting.
Do you use this strategy for implementing recursion? Are there consequences or trade offs?
For others who are curious, see
1) https://stackoverflow.com/questions/25228871/how-to-understand-trampol… and
2) https://raganwald.com/2013/03/28/trampolines-in-javascript.html
skue · 2020-12-05
> "Any sufficiently complicated model class contains an ad hoc, informally specified, bug-ridden, slow implementation of half of a state machine." (not sure where I read this quote).
Can’t tell you where you read it, of course, but believe it originates from Braithwaite/raganwald:
http://raganwald.com/2018/02/23/forde.html
Slackwise · 2020-08-24
Pretty sure it will not. Nothing is lazy in JS by default:
> One caveat of spreading iterables: JavaScript creates an array out of the elements of the iterable. That might be very wasteful for extremely large collections. For example, if we spread a large collection just to find an element in the collection, it might have been wiser to iterate over the element using its iterator directly.
> And if we have an infinite collection, spreading is going to fail outright.
http://raganwald.com/2015/02/17/lazy-iteratables-in-javascript.html
infraruby · 2015-12-18
> I want the candidate to plan
Then ask for that, and assess the plan, otherwise you're expecting Carnac the Magnificent: http://raganwald.com/2015/05/08/carnac-the-magnificent.html
Double_Cast · 2015-11-24
I was poking around his blog. Fwiw, it appears he's well aware of this. He calls interviewers who ask vague questions and expect particular answers "Carnac the Magnificent" [0].
[0] http://raganwald.com/2015/05/08/carnac-the-magnificent.html
eskimobloood · 2015-07-08
You can at least try decorators with babel using[1]
$ babel --optional es7.decorators
or
babel.transform("code", { optional: ["es7.decorators"] });
Here[2] is an article that describes how to use it for mixins
[1] https://babeljs.io/docs/usage/experimental
[2] http://raganwald.com/2015/06/26/decorators-in-es7.html
agumonkey · 2015-03-24
Reminds me of javascript trampoline http://raganwald.com/2013/03/28/trampolines-in-javascript.html . Was it an inspiration or did you recreate it from scratch ?
picks_at_nits · 2015-02-02
From the footnote:
"Well, actually, this does not work for arrays that contain undefined as a value, but we are not going to see that in our examples. A more robust implementation would be (array) => array.length === 0, but we are doing backflips to keep this within a very small and contrived playground.”
http://raganwald.com/2015/02/02/destructuring.html#fn:wellactually
vorbote · 2014-12-20
Better formatted version of the blog post:
http://raganwald.com/2014/12/20/why-why-functional-programming-matters…
The original paper by John Huges mentioned in the posting:
Internet Archive: https://web.archive.org/web/20070323095313/http://www.math.chalmers.se…
PostScript, PDF and the BibTeX reference.
hyperpape · 2014-09-11
Whenever you get to extreme cases, there's always going to be something subtle. I'm sure he didn't google " how to copy files", but looked for people who'd worked with many terabytes of data. Reminds me of a nice story by Reginakd Braithwaite: http://raganwald.com/2013/03/26/the-interview.html
mck- · 2014-05-24
Trampolining is a technique to achieve Tail-call Elimination in ES5 [1]
However, I found this to only work in a linearly recursive algorithm (eg factorial) and not in a bi-directional recursive algorithm (eg tree construction)
I'm thinking TCO in ES6 might solve this problem? Anyone tried?
[1] http://raganwald.com/2013/03/28/trampolines-in-javascript.html
acjohnson55 · 2014-04-22
On the other hand, so many people have abandoned the most common forms of OOP. See for example the story from yesterday [1]. Many writers have written about how brittle object hierarchies are in anything nontrivial, [2] for example.
I will say though that newer models of OOP, focusing on interfaces and composability of behavior, seem to have quite a bit of steam left in them.
[1] https://news.ycombinator.com/item?id=7618933
[2] http://raganwald.com/2014/03/31/class-hierarchies-dont-do-that.html
officialjunk · 2013-09-14
tail call elimination can be implemented in javascript:
http://raganwald.com/2013/03/28/trampolines-in-javascript.html