3 ms·
Ask HN: Is there any programming language that doesn't have WTFs?
After reading this page:
https://github.com/satwikkansal/wtfpython?tab=readme-ov-file#-needles-in-a-haystack-
I wonder if there's any language that thought about all edge cases and avoided exceptions and such gotchas at the design level.
JS is notorious for such WTFs but even Python—which I've used for over a decade now—has surprised me countless times.
Is Haskell also like that? How about Lisps (CL, Racket, Clojure, Scheme, etc.)?
- PaulHoule 2y agoOnly highly abstract languages like Brainfuck https://esolangs.org/wiki/Brainfuck https://esolangs.org/wiki/Brainfuck which are too simple to have WTFs, although you might say the whole thing is a WTF. I think AVR-8 assembler is WTF free, but I'd like a more powerful macro assembler which would probably introduce a WTF. Common Lisp is full of WTFs, I went through many stages of grief reading Graham's On Lisp but most notable was "if he was using Clojure he wouldn't be fighting with nconc". People have problems with Clojure too https://www.more-magic.net/posts/thoughts-on-clojure.html https://www.more-magic.net/posts/thoughts-on-clojure.html
- Gibbon1 2y agoFor #3 on that list C has that too. And I often use it. printf( "thing1=%u\n" "thing2=%u\n" "thing3=%u\n" "thing4=%u\n" "thing5=%u\n", thing1, thing2, thing3, thing4, thing5);
- tromp 2y agoHaskell is relatively WTF free as a language, behaving pretty much like the lambda calculus, but the standard libraries have their share of WTFs, such as the Enum instance for Double: ghci> [0, 0.3 .. 2.0] [0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1] I'd rather not see 2.1 in a range up to 2.0
- jose_zap 2y agoThat’s floating point, though. Not Double. Floating point has the same gotchas in all languages because it is a defined standard.
- tromp 2y agoThat list is of type (Fractional a, Enum a) => [a], but ghci defaults to Doubles, as you can see from ghci> [0, 0.3 .. 2.0] :: [Float] [0.0,0.3,0.6,0.90000004,1.2,1.5,1.8000001,2.1000001] ghci> [0, 0.3 .. 2.0] :: [Double] [0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1] Exceeding the upper bound by 0.1 is not due to a general floating gotcha, but a specific choice in the definition of typeclass method enumFromThenTo for both Floats and Doubles.
- Qem 2y agoRelated: https://en.wikipedia.org/wiki/Principle_of_least_astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...