Live data from Hacker News

All Programming Languages are Wrong (2018)

users.rcn.com

41–50 of 79 posts

Re: All Programming Languages are Wrong (2018)

#41

He claims all programming languages are wrong and then he bashes C++ virtual functions vs regular functions, C++ templates, single dispatch and fixed precision arithmetic. Looks like "all languages" means C++ to him. There exist languages with arbitrary precision arithmetic, e.g. Python or languages with much sophisticated polymorphism e.g. Haskell, Scala or Rust.

Or Common Lisp, where you not only have arbitrary precision by default. You also have rationals.

Re: All Programming Languages are Wrong (2018)

#43
post #39

Earlier quoted context omitted.

stream.map(f).collect(…) is where checked exceptions failed. #map is a generic method that should obviously throw each of the checked exceptions f can throw, but without some kind of generic sum type Java can't express that. Everyone is forced to choose between "can throw any exception" (e.g., Callable ) and "can only throw unchecked exceptions" (e.g., Function ), each of which spreads virally and punishes anyone usi…

There is no need to get rid of checked exceptions to fix that. You need generics for exceptions. If the inner function can throw some exception, then it should be possible to declare the stream method that it will throw the same exception. I believe that the JVM doesn't actually support this, so the reasons were got the horrible situation we're in is because they didn't want to sacrifice backward compatibility.

I think we're saying the same thing. If f(T) can return U or throw A or B or C, there needs to be a way to declare that Stream#map takes a Function and returns a Stream or throws A or B or C. But that sum type A|B|C doesn't exist in Java if there's no common base class.

Re: All Programming Languages are Wrong (2018)

#44
post #20

Earlier quoted context omitted.

I used to think so, but * Java also has unchecked exceptions, and, incredibly, there's still no consensus as to which exceptions should be used for what and when, though these days the most common approach is to simply stick only to RuntimeExceptions, which is terrible. * Functional error handling using Option, Either, Try etc are arguably much simpler, safer and more powerful than exceptions. Simpler because they do…

Slightly off topic, but what should a map or flatMap implementation on boolean do? Presumably run on true and skip on false? That’s not really what I expect from map (that it’s filtered the input). I could imagine book.filter.map as a way to conditionally execute

Haha you're putting me on the spot here, I guess I haven't really thought too deeply about the specifics!

Maybe flatMap would return true only if all chained booleans are true?

Bimap would allow you to provide functions for what to do in true and false case?

Fold would allow you to turn true or false into a single type?

I'm sure someone more experienced in FP can weigh in with something more correct! :p

Re: All Programming Languages are Wrong (2018)

#45

He claims all programming languages are wrong and then he bashes C++ virtual functions vs regular functions, C++ templates, single dispatch and fixed precision arithmetic. Looks like "all languages" means C++ to him. There exist languages with arbitrary precision arithmetic, e.g. Python or languages with much sophisticated polymorphism e.g. Haskell, Scala or Rust.

> There exist languages with arbitrary precision arithmetic, e.g. Python

  Floating point numbers are implemented using double in C.
  All bets on their precision are off unless you happen to 
  know the machine you are working with.
https://docs.python.org/2.4/lib/typesnumeric.html

Re: All Programming Languages are Wrong (2018)

#46
This is part of the introduction to a language he's been designing since forever. I attended the International Lisp Conference in Boston around 2005 and he did a presentation there of what seems like a precursor to this.

Some of his views might be controversial, but he has plenty of Lisp implementation experience and clearly knows his stuff.

And from what I've read so far, he writes excellent documentation. I'd recommend anyone to at least skim the whole thing [0].

[0] http://users.rcn.com/david-moon/Lunar/index.html

Re: All Programming Languages are Wrong (2018)

#48
post #10

IMO the biggest problems with almost all popular programming languages are 1) null 2) exception based error handling such that, when you call foo() where foo is String foo(){ blabla } you can get a String, null OR an exception (!!!) and most compilers happily let you treat it as if it only ever returns a String. I hope some day null is no longer a thing, and that Functional Programming types like Option, Either, Try…

I am probably in the minority here but I think Java was on the right track with checked exceptions.

Coming from C# to Java, checked exceptions are the worst. There are so many layers that can fail even in a simple API call - network, database, permissions, memory, etc.. We're not going to handle each of those cases differently, if we were going to we could always catch the specific exception type explicitly. But usually it's fail the API call, catch the base exception, and report the relevant failure message. Fail fast, report, move on. Maybe there are other programming situations where you want to catch every possible type of exception and run some custom logic for each one? I'd be interested to hear about it.

Re: All Programming Languages are Wrong (2018)

#49
post #26
post #16

Does anyone else consider these type of articles the clickbait of the programming world? They tend to all follow the formula of 1. Make over the top statement in title. 2. Vaguely address the over the top statement in content. For example the author hasn't shown us why "All" programming languages are "wrong". They haven't shown how they would fix them to make them "right". Their premises (e.g. "computation is almost…

"computation is almost free" actually triggered me. that's the java argument from 20 years ago, now we have go and rust. it implies electron is actually a sane approach to ui development. the author is very vague about why exactly numbers don't fit in the type system, and in which languages. first class types for numbers exist in some languages. is he advocating for default overflow checks, which bloat code size?

> the author is very vague about why exactly numbers don't fit in the type system

Numbers are hard!

Consider something simple:

    9999999999999999.0 - 9999999999999998.0
In discussing what is Right™ we are making a choice between all the possible Good™ ways we can deal with that expression. Here are some of the most obvious:

1. atof() could fail since the string representation doesn’t match the resulting float, but then what should happen for 0.3? I've seen this only occasionally.

2. We could use a hypothetical atonumber() which uses decimal or big float or some other representation, but what does this do to performance? This gets tried a lot.

3. We can ignore the issue and blame the programmer for not constraining the input domain to that of our function. This is what most people do.

I don't personally like any of these; I've seen and experienced some of the problems with each of the approaches, so I wonder if there's a Good™ fourth option (or a fifth). Maybe it's only because I have my own ideas of what a fourth option might look like that I'm not very quick to consider this a "solved" problem to the point that someone (anyone) knows the Right™ answer, but maybe it's worth you (and others!) thinking about this too.

I'm extremely interested in suggestions here.

Re: All Programming Languages are Wrong (2018)

#50
post #10

IMO the biggest problems with almost all popular programming languages are 1) null 2) exception based error handling such that, when you call foo() where foo is String foo(){ blabla } you can get a String, null OR an exception (!!!) and most compilers happily let you treat it as if it only ever returns a String. I hope some day null is no longer a thing, and that Functional Programming types like Option, Either, Try…

I am probably in the minority here but I think Java was on the right track with checked exceptions.

Always hated checked exceptions because there seems the basic assumption underlying them, that exceptions can usually be handled as near to the code throwing it as possible, while in every real world project I ever was involved in, 90% of the possible exceptions usually had to be handled "far away".

So this means, you will have a whole bunch of re-throws, or exceptions wrapped in "higher design level" exceptions which you then throw to finally communicate the error condition to the proper component, polluting all signatures on the way with "throws".

Or you catch it as early as possible, wrap it in a RuntimeException, re-throw it unchecked and let the high level component properly handle it, effectively bypassing the "checked exceptions" system :D

Just my two cents, I know this might be a controversial position.

Post reply on HN