News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by jandrewrogers on Thursday October 30, 2025 @11:15PM (#45767975)
Pure functional works great until it doesn't. For a lot of systems-y and performance-oriented code you need the escape hatches or you'll be in for a lot of pain and annoyance.

As a practical observation, I think it was easier to close this gap by adding substantial functional capabilities to imperative languages than the other way around. Historically, functional language communities were much more precious about the purity of their functional-ness than imperative languages were about their imperative-ness.

Re:John Carmack on Mutable Variables by jancsika on Friday October 31, 2025 @12:41AM (#45768501)
Hehe, purity is one helluva drug!

For some reason, this makes me think of SVG's foreignObject tag that gives a well-defined way to add elements into an SVG document from an arbitrary XML namespace. Display a customer invoice in there, or maybe a Wayland protocol. The sky's the limit!

On the other hand, HTML had so many loose SVG tags scattered around the web that browsers made a special case in the parser to cover them without needing a namespace.

And we all know how that played out.

Posted from an xhtml foreignObject on my SVGphone

Re:John Carmack on Mutable Variables by Fire-Dragon-DoL on Friday October 31, 2025 @03:13AM (#45769165)
Unfortunately unless there's an explicit way to state what has side effects like a mut keyword, a lot of fp programming advantages lose value because most devs default to mutable stuff, so the fp benefits don't compound
Re:John Carmack on Mutable Variables by black_knight on Friday October 31, 2025 @03:53AM (#45769353)
I think this works quite well with IO in Haskell. Most of my code is pure, but the parts which are really not, say OpenGL code, is all marked as such with IO in their type signatures.

Also, the STM monad is the most carefree way of dealing with concurrency I have found.

Re:John Carmack on Mutable Variables by christophilus on Friday October 31, 2025 @03:54AM (#45769360)
F# isn’t purely functional, though, and strikes a nice balance. I just don’t really like the .NET ecosystem, being 100% Linux these days, as it always seems slightly off to me somehow.
Re:John Carmack on Mutable Variables by pvdebbe on Friday October 31, 2025 @07:49AM (#45770985)
Same. I strikes me a great shame that there aren't great F#-like languages that targeted the JVM.
Re:John Carmack on Mutable Variables by bmitc on Friday October 31, 2025 @09:48AM (#45771956)
Really? What's wrong with .NET? It's one of the nicest cross-platform platforms out there. What Microsoft has done with it is amazing.
Re:John Carmack on Mutable Variables by internet_points on Friday October 31, 2025 @07:00AM (#45770644)
> you need the escape hatches

Isn't this a strawman? Even Haskell has unsafePerformIO and Debug.Trace etc. It just also provides enough ergonomics that you don't need them so often, and they "light up" when you see them, which is what we want: to know when we're mutating.

Re:John Carmack on Mutable Variables by fsloth on Friday October 31, 2025 @08:02AM (#45771080)
"Pure functional works great until it doesn't. "

That's why F# is so great.

Functional is default, but mutable is quite easy to do with a few mutable typedefs.

The containers are immutable, but nobody stops you from using the vanilla mutable containers from .net

It's such a beautiful, pragmatic language.

Re:John Carmack on Mutable Variables by bmitc on Friday October 31, 2025 @09:47AM (#45771947)
F# is not a pure functional language. It is a functional-first language that does imperative and OOP better than imperative and OOP languages.

You can program F# just like you would Python, and it will be more readable, concise, performant, and correct.