This is literally the difference between me and my wife ;)
This is literally the difference between me and my wife ;)
That’s a fair assessment.
The only difference to the standard that I see is that the standard says it should be 1,2,3,4,5, while at least for me it renders as 5,6,7,8,9.
But that’s probably because it doesn’t render as HTML and thus doesn’t rely on HTML to do the numbering.
The Nigerian understanding of religion is fascinating. They just take what they need from any place they want. In the western world most people stick with the faith they were born in, or maybe switch once or twice in their lifetime. In Nigeria it’s common to switch very frequently, always taking the parts they like best and leaving behind the rest.
It’s a very open and interesting way to look at things, not so much tied to their own personal identity (“I am protestant, so I must hate catholics” as it used to be common in the west), but instead they build their own faith from all the best sources they can find.
The media shift is happening right now. It started about 3 weeks ago, and suddenly the media shifts from pro-israel to anti-israel. At least here in central europe this is what’s happening.
Better north of antarctica than north of arctica.
The problem is that people just accept a continuous drop in quality.
I once had a conversation with an old woman who told me that it would be unheard off for someone with some level of status or self respect to wear ill-fitting off-the-shelf clothing back in the 50s, and nowadays even TV news anchors are wearing cheap off-the-shelf suits.
The same thing applies for everything. When I was a kid, the transition from small, independently owned shops with qualified stuff who’d give you proper consultation to chain stores in malls was just under way. Old people would complain all day that the staff in chain stores had no clue about the stuff they were selling. And yet everyone went to the chain stores in the mall because they had a bigger selection and were cheaper.
And now there’s the same thing happening with the chain stores in malls getting replaced by online shopping, and now not only is there no one to consult you on your purchase, you can’t even trust the product listings because they are riddled with errors.
For a while you could trust reviews, but that time is long gone, but still everyone just happily shops and consumes away, because online shopping is cheaper, there’s a bigger selection and it’s more convenient.
The same process is happening all the time everywhere. Stuff just gets gradually shittier, but we just accept it, because we get used to it.
Yeah, especially in peace time. When war heats up and resources get scarce, you use the cheapest thing that does the job. But in peace time you feed your military contractors to keep them happy and to keep them researching and developing so you don’t lose out on modern technology development.
(For clarification, with “war time” I mean “being in a war that actually threatens the country”. The US hasn’t been in a war like that for a very long time. They’ve essentially being in “peace time” while having military training and testing facilities in the middle east.)
You basically defied the whole NaN thing. I may even agree that it should always throw an error instead, but… Found a good explanation by someone:
NaN is the number which results from math operations which make no sense
Well, technically this is the explanation, it really isn’t a good one.
x + 1
with x not being defined also doesn’t result in a NaN
but instead it throws a reference error, even though that undefined variable isn’t a number either. And x = 1;x.toUpperCase();
also doesn’t silently do anything, even though in this case it could totally return "1"
by coercing x to a string first. Instead it throws a TypeError.
It’s really only around number handling where JS gets so weird.
Yeah but actually there can be many interpretations of what someone would mean by that. Increase the bytecode of the last symbol, or search for “1” and wipe it from string. The important thing is that it’s not obvious what a person who wrote that wants really, without additional input.
That’s exactly the thing. It’s not obvious what the person wants and a NaN
is most likely not what the person wants at either. So what’s the point in defaulting to something they certainly didn’t want instead of making it obvious that the input made no sense?
A similarly ambiguous situation would be something like x = 2 y
. For someone with a mathematical background this clearly looks like x = 2 * y
with an implicit multiplication sign. But it’s not in the JS standard to interpret implicit multiplication signs. If you want multiplication, it needs to explicitly use the sign. And thus JS dutifully throws a Syntax Error instead of just guessing what the programmer maybe wanted.
Anyway, your original suggestion was about discrepancy between + and - functionality. I only pointed out that it’s natural when dealing with various data types.
My main point here was that if you have mathematical symbols for string operations, all of the acceptable operations using mathematical symbols need to be string operations. Like e.g. "ab" * 2 => "abab"
, which many languages provide. That’s consistent. I didn’t mean that all of these operators need to be implemented, but if they aren’t they should throw an error (I stated that in my original comment).
What’s an issue here is that “1” + 1 does a string concatenation, while “1” - 1 converts to int and does a math operation. That’s inconsistent. Because even you want to use that feature, you will stumble over +
not performing a math operation like -
.
So it should either be that +/- always to math operations and you have a separate operator (e.g. .
or ..
) for concatenation, or if you overload +
with string operations, all of the operators that don’t throw an exception need to be strictly string-operations-only.
There is operator overloading happening - the + operator has a different meaning depending on the types involved. Your issue however seems to be with the type coercion, not the operator overloading.
For string + string
and number + number
there is operator overloading, that’s correct. For string + number
there is not, there’s only type coercion. It becomes string + string(number)
. All of that is fine. Other languages do that as well.
What’s not fine is that JS also looks the other way on the type coercion tree: There’s no string - string
overloading, so it goes down the type coercion tree, looking for any -
operation that it can cast to and it ends up with number(string) - number(string)
, which makes no sense at all.
If you don’t want it to happen either use a different language, or ensure you don’t run into this case (e.g. by using Typescript). It’s an unfortunate fact that this does happen, and it will never be removed due to backwards compatibility.
It’s not the point of the discussion that there are other languages that are better. This here is about complaining about bad language design, and no matter how you turn this, this is not a matter of taste or anything, this is just bad language design.
You are obviously right that this crap will stay in JS forever. That doesn’t make it good design.
I don’t think so. We’ve all been happily having discussions with bots online for a long time now. People just don’t notice that the person they are writing to isn’t a human.
We went from talking in person to talking via computer and no talking with a computer. It’s not getting better.
This.
The old forums are often still up, and there are still actual humans there, sometimes. But nobody goes there, because nothing’s happening there.
There was this programming forum (blitzforum.de) that I loved when I was a teenager. I spent so much time there and learned so much. I actually attribute a lot of my career to getting an early start there. But the forum is mostly dead nowadays. People still open the page every once in a while, but nobody posts there.
Trolls actually saw themselves as an art from. Everyone else saw them as annoying cretins.
I agree with your comment.
Because there’s in fact no operator overloading happening, true, but that’s mostly an under-the-hood topic.
It should not happen no matter why it does happen under the hood.
Operator overloading for string - string
is wrong and type coercion to implicitly cast this to int(string) - int(string)
is just as wrong.
This here is apparently the original source of the markdown specification, and there it clearly says that this is the correct behaviour: https://daringfireball.net/projects/markdown/syntax#list
Ordered lists use numbers followed by periods:
- Bird
- McHale
- Parish
It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The > HTML Markdown produces from the above list is:
<ol> <li>Bird</li> <li>McHale</li> <li>Parish</li> </ol>
If you instead wrote the list in Markdown like this:
- Bird
- McHale
- Parish
or even:
- Bird
- McHale
- Parish
you’d get the exact same HTML output
Yeah, and almost all languages I know then would throw an exception when you try to use -
with a string, and if they offer multiple operators that take a string and a number, they always only perform string operations with that and never cast to a number type to do math operations with it.
(e.g. some languages have +
for string concatenation and *
to add the same string X time together, so e.g. "ab" * 2 => "abab"
. It’s a terrible idea to have +
perform a string operation and -
performs a math operation.)
The NaN isn’t an thrown. It’s just silently put into the result. And in this case it’s completely unintelligible. Why would an operation between two strings result in a number?
"Hello" - "world"
is an obvious programmer mistake. The interpreter knows that this is not something anyone will ever do on purpose, so it should not silently handle it.
The main problem here is downward coercion. Coercion should only go towards the more permissive type, never towards the more restrictive type.
Coercing a number to a string makes sense, because each number has a representation as a string, so "hello" + 1
makes intuitive sense.
Coercing a string to a number makes no sense, because not every string has a representation as a number (in fact, most strings don’t). "hello" - 1
makes no sense at all. So converting a string to a number should be done by an explicit cast or a conversion function. Using -
with a string should always result in a thrown error/exception.
You aren’t wrong, it wouldn’t be bad for it to just print the help in that case, at least when running interactive.
For automation, printing the full help of a more complex command would completely trash logs.
You can not change history for any published changes - like I said, doing so makes your repository incompatible with any other clone.
That’s the same on Git.
You always have to balance: Do you want the user to have “some” user experience, or none at all.
In the case of image viewers or browsers or stuff, it’s most often better to show the user something, even if it isn’t perfect, than to show nothing at all. Especially if it’s an user who can’t do anything to fix the broken thing at all.
That said, if the user is a developer who is currently developing the solution, then the parser should be as strict as possible, because the developer can fix stuff before it goes into production.