frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: Lambduck, a Functional Programming Brainfuck

https://imjakingit.github.io/lambduck/
60•jorkingit•17h ago
What if Brainfuck was less like C and more like Scheme?

The interpreter implemetation is pretty bad. It's not very fast, it's not very good, and it's probably not very correct. But maybe there's some vaguely interesting programs you could write with it!

For example, the Y combinator:

  λf. (λx. f (x x)) (λx. f (x x))
is written as:

  \` \`1 `0 0 \`1 `0 0

Comments

90s_dev•16h ago
This is far too clever for me to even begin to understand.

How do you get the hello world working?

I tried pasting ,--('\< into the code and if it walks like a lamb and quacks like a duck into the stdin field.

jorkingit•14h ago
Hello world should be:

  ``\\1`.'h``\\1`.'e``\\1`.'l``\\1`.'l``\\1`.'o``\\1`.' ``\\1`.'w``\\1`.'o``\\1`.'r``\\1`.'l``\\1`.'d`.'!
Groxx•13h ago
I feel like adding a bit more brainfuckery would help obscure stuff. Make people use Church numerals to form ASCII characters - it'll encourage golfing it down to something equally as obtuse as

    ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
jzemeocala•15h ago
Do Malborge next
mmoskal•15h ago
This seems way too readable! I think you should remove the character literals in the name of purity.

Also, this is likely way more compact than Brainfuck, as the lambda calculus is written essentially as usual.

And seriously, very cool!

jorkingit•14h ago
Thanks! I'm torn on having the character literals actually; they're definitely syntactical sugar, but I was struggling to write programs that printed anything without them getting super unwieldy! If someone smarter than me can write a compact-looking enough Hello World program then consider them gone ;-)
fc417fc802•12h ago
Yeah there's something wrong with the idea of brainfuck having character literals. The de bruijn indexing is definitely on point but the lack of continuations feels wrong to me given the stated goal.

Also shouldn't the indexes be expressed as a repeated character? Like "---" would be index 3. Integer literals are decidedly non-brainfuck as well.

jorkingit•12h ago
getchar does take a continuation of sorts (as in continuation passing) which is passed the input. In one my initial drafts, getchar was a special form that would accept input at the point of evaluation, which was really funny and unpredictable.

putchar I feel kind of weird about, it acting as an identity function with a side effect is kind of weird; I'm not sure changing it to take a second argument as a continuation would make it better or worse.

Regarding the de Bruijn indices, I don't think there's a huge distinction between writing 3 vs writing ---: it would still form a single lexical token, so I feel like --- is just more noise.

Perhaps a de Bruijn index register you could move around and dereference? e.g. from index 1, index 3 is >>*, then index 2 from there is <*. But that feels less functional, because you're now imperatively manipulating some hidden state.

fc417fc802•12h ago
Entirely agreed that it's nothing but more noise, but isn't that exactly how BF is? Why ----- instead of 5-? Well, because BF of course. The point of the exercise (IMO) is having the bare minimum in parsed characters to achieve the turing tarpit.

I quite like the movable register idea but as you say that's no longer a "BF except lambda calculus" it's some other esolang at that point.

I think my objection about the lack of continuations was misplaced given that appears to be a BF take on the lambda calculus rather than a BF take on scheme.

jorkingit•12h ago
You can always write it in continuation-passing style if you really want continuations! It's not pleasant but none of this is supposed to be ;-)

Agreed on having too many characters though, I don't like that having numerical indices makes the syntax whitespace-sensitive, too.

And once I figure out how to write hello world, those character literals are gone!

fc417fc802•11h ago
Maybe my brain just isn't functioning right now but I don't think writing in CPS is the same as having access to first class continuations? But as previously noted I think that was a misplaced request on my part to begin with.
jorkingit•10h ago
It should be! e.g. if every function takes a continuation as its final argument, then:

  call/cc& = \f. \k. f k k
Then in f you can invoke the continuation k as many times as you want, but that does involve a whole program transformation to CPS.
fc417fc802•9h ago
My line of thought had been that doing so doesn't restore execution context. But it dawns on me that without the ability to mutate variables that doesn't have the same relevance.

Still, doesn't it throw the de bruijn indexes off? Or am I wrong about that as well?

Lambda calculus makes my head hurt.

catlifeonmars•5h ago
So here’s my question: is the interpreter more or less compact than a brainfuck interpreter? Which interpreter would have a lower Kolmogorov complexity, or could they be equivalent?
2d8a875f-39a2-4•10h ago
Shouldn't it be called "Fuckbrain" then?
tromp•8h ago
How is a program like

    ``f`,\0`,\0
where f is applied to two arguments, each of which is the next input byte as a Church numeral, evaluated? Does it depend on order of evaluation?

Note that it's also possible to do I/O without additional primitives, as demonstrated in [1].

[1] https://www.ioccc.org/2012/tromp/

jorkingit•7h ago
I saw this the other day! I salute you, it's so much more evil :-)

And yup, the order of evaluation is leftmost innermost.

  ``\\0`,.`,.
with stdin "hi" will print "hi".
naikrovek•5h ago
I’m too stupid to even recognize how esoteric this is.
sph•5h ago
Genius, great work and well done, though I might not be smart enough to do anything with it.

Please share the interpreter’s code, however bad you feel it is.

Also, definition of de Bruijn index for those of us without formal education: https://en.m.wikipedia.org/wiki/De_Bruijn_index

jorkingit•3h ago
https://github.com/imjakingit/lambduck
somat•3h ago
but bf is nothing like c, bf is a stack language, I would say it's closest real language analog is forth.

Anyhow, This is far too clear and straightforward, the bf analog to scheme would probably be unlambda, an implementation of the lambda calculus without lambda forms.

http://www.madore.org/~david/programs/unlambda/

stronglikedan•2h ago
> but bf is nothing like c, bf is a stack language, I would say it's closest real language analog is forth.

I could guess the age of the author based on this. Seems like history gets rolled up to generalizations after a while.

reverendsteveii•3h ago
from the least cute name for a programming language instantly to the most cute name for a programming language. Let's go LambDuck!
reuben364•2h ago
Since the de Bruijn indices are limited (and presumably still Turing complete), I wonder how limited you can make them and still be Turing complete.

How do you wash your clothes in space?

https://www.bbc.co.uk/newsround/57751277
1•thunderbong•44s ago•0 comments

Blood clotting discovery opens "whole new chapter in vascular biology"

https://newatlas.com/disease/new-blood-clotting-mechanism-hemolysis-necroptosis/
3•Brajeshwar•8m ago•0 comments

America tried to ban fake photos in 1912

https://www.freethink.com/the-digital-frontier/fake-photo-ban-1912
2•Brajeshwar•8m ago•0 comments

Some thoughts on human-AI relationships

https://reservoirsamples.substack.com/p/some-thoughts-on-human-ai-relationships
1•tosh•9m ago•0 comments

The Chicxulub Asteroid Impact and Mass Extinction

https://www.science.org/doi/10.1126/science.1177265
3•simonebrunozzi•14m ago•0 comments

Wise goes to the US. Will its founder's supercharged voting rights follow?

https://www.theguardian.com/business/nils-pratley-on-finance/2025/jun/05/wise-goes-to-the-us-will-its-founders-supercharged-voting-rights-follow
1•colinprince•16m ago•0 comments

First Map Made of a Solid's Quantum Geometry

https://www.quantamagazine.org/first-map-made-of-a-solids-secret-quantum-geometry-20250606/
1•rbanffy•17m ago•0 comments

Show HN: Poseidon, an Oncall AI agent (open source alt to resolve.ai)

https://github.com/harshadmanglani/poseidon
1•harshadmanglani•18m ago•0 comments

Big Mouth Billy Bass now talks back with AI

https://boingboing.net/2025/06/06/big-mouth-billy-bass-now-talks-back-with-ai.html
2•cmsefton•20m ago•0 comments

Ask HN: Will something replace transformers and GPUs in the next 10 years?

1•melenaboija•21m ago•1 comments

Breakthrough in search for HIV cure leaves researchers 'overwhelmed'

https://www.theguardian.com/global-development/2025/jun/05/breakthrough-in-search-for-hiv-cure-leaves-researchers-overwhelmed
3•colinprince•22m ago•0 comments

Indirect strengthening through reactivation of contextually bound memories

https://www.nature.com/articles/s44271-025-00250-5
1•PaulHoule•22m ago•0 comments

Defence Tech: Collective Property, Private Control

https://www.lrb.co.uk/the-paper/v47/n10/laleh-khalili/collective-property-private-control
1•mitchbob•23m ago•1 comments

Odd Couple: Gas Giants and Red Dwarfs

https://www.centauri-dreams.org/2025/06/06/odd-couple-gas-giants-and-red-dwarfs/
2•JPLeRouzic•24m ago•0 comments

Fresh strain of pro-Russian wiper flushes Ukrainian critical infrastructure

https://www.theregister.com/2025/06/06/pro_russia_wiper_ukraine/
2•rntn•25m ago•0 comments

Show HN: A minimal analytics tool, using Redis and Node.js

https://github.com/orangecoloured/analog
1•rckt•27m ago•0 comments

JPMorgan has had enough of grads accepting future-dated roles elsewhere

https://fortune.com/2025/06/06/jamie-dimon-jpmorgan-fire-talent-who-accept-roles-within-18-months/
2•thehoff•27m ago•1 comments

Show HN: Lovable/Bolt Security Scanner

https://vibe-eval.com/
1•alex_mia•28m ago•0 comments

An AI Tools Website for All Those Tools You Dreamt of as a Child

https://klutz.netlify.app
1•Jeff9James•28m ago•1 comments

Shared Memory Across GenAI Tools

https://base0.ai/
1•surya_m95•28m ago•1 comments

Show HN: Tape/Z – a toolkit for analysing z/OS assembler (HLASM) code

https://github.com/avishek-sen-gupta/tape-z
2•armorer•32m ago•0 comments

IRS open-sources Direct File tax software amid political and industry pushback

https://www.zdnet.com/article/irs-open-sources-direct-file-tax-software-amid-political-and-industry-pushback-heres-why/
2•CrankyBear•34m ago•1 comments

Controversial genetics testing startup Nucleus Genomics raises $14M Series A

https://techcrunch.com/2025/01/30/controversial-genetics-testing-startup-nucleus-genomics-raises-14m-series-a/
1•ZeljkoS•34m ago•0 comments

See how a dollar would have grown over the past 94 years [pdf]

https://www.newyorklifeinvestments.com/assets/documents/education/investing-essentials-growthofadollar.pdf
10•mooreds•35m ago•11 comments

Ask HN: How are you using Markdown files these days?

1•fred_terzi•36m ago•2 comments

The Extremely Human Last Mile

https://aboard.com/the-extremely-human-last-mile/
2•gbseventeen3331•38m ago•2 comments

The Flow of the River (1953) by Loren C. Eiseley [video]

https://www.youtube.com/watch?v=QxNhHKISP-A
1•ShrugLife•38m ago•0 comments

Verifying a 5μS TAS of Super Mario Bros 3 on real hardware

https://www.youtube.com/watch?v=BGvvY5FOTL8
2•indrora•38m ago•0 comments

We're close to translating animal languages – what happens then?

https://www.theguardian.com/world/2025/jun/01/were-close-to-translating-animal-languages-what-happens-then
4•bookofjoe•38m ago•0 comments

Trump's 'Golden Dome' plan has a major obstacle: Physics

https://www.sciencenews.org/article/golden-dome-missile-defense-physics
6•gbseventeen3331•38m ago•0 comments