Type of "not a number" is number
Programmer Humor
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
People that try to do mathematical operations with strings blaming the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense because they realized it would be used by people that have no idea what they are doing. Clearly they were right.
the programming language that had a stated design goal to do its best and try to keep running scripts that make no sense...
...itself makes no sense. It is wrong and bad that Javascript was ever designed that way in the first place.
It was never intended to run full applications but only the small business scripts and hobbyist homepage stuff that were the thing in the 90s, across inconsistent browsers that were a jungle of hit and miss behaviour where it was preferred that menus keep working even if the mouse effect was not. Anything of scale was expected to be done in Java. Dynamic web pages did not exist and as anything not static was generated server side into a static html file to be rendered on the client.
Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today. It's not a bad thing that IDE and even compilers and preprocessors try to help you write better code today, but then it simply didn't exist.
JavaScript is from a different time and because it has the hard requirement or backwards compatibility there is no changing it and has not been for thirty years except to add stuff to it.
I think it's just silly to ask the past to keep up with the present. Bad code is not the fault of the language regardless, even though junior devs and even seasoned ones like to think so to protect their ego. I think it is better to accept it, learn from it and roll with it because every single platform and language has their weird quirks anyway.
Signed, old dude that learned programming in 8 bit BASIC and 6502 machine code without an assembler, where code bad enough would freeze your machine that required a cold boot and starting over from your last save that you didn't do.
Anyway, back then it wasn't considered the job of the programming language to hold the hand of the aspiring developer as it is common today.
But that’s exactly what it’s doing by trying to figure out what the developer meant. ‘“11” + 1’, should cause the compiler to tell the developer to to fuck themselves.
Executing after undefined behavior is arguably worse than terminating with an exception. A terminated script can't leak data or wreak havoc in other ways.
it would be used by people that have no idea what they are doing. Clearly
And so let's enable these people?
Let's add AI to the mix while we're at it.
Heck, I need to learn some new languages apparently. Here I was expecting an angry "CS0029 cannot implicitly convert type 'string' to 'int'!
If you mix types like that, it's your own fault
Lol. In a dynamically typed language? I will do this always, that's why I am using it
It's my favorite language too, but I also find this hilarious.
Lets fix it. I think that since we are removing the ones, then "11" - 1 should be equal to "".
This is my favorite language: GHC Haskell
GHC Haskell:
GHCi> length (2, "foo")
1
Feels like it could be one of those facebook posts to test "smart" people. Only the top 1% of people can answer this simple math question: "11" + 2 * 2 - 3