That would be weird if a string containing a space wasn't equal to 0 " " == 0, but that's not the case in JS. If you think that "" and " " being equal to 0 is weird then I agree, but since they are, you should expect "t" and "n" to equal 0 too.
The == operator in JS will try to cast the things being compared and do all kinds of ‘smart’ assumptions about what equality means. This is why everyone uses === instead…
If " " wasn't equal to 0, it wouldn't make sense, but since a string containing a space equals 0, you'd expect the same to apply to a string containing a tab or a newline. (or at least I'd expect that)
I admit I have never dabbled in javascript, despite being a proficient programmer. I now dread to ask... would any string that contains only whitespace == 0? " \t\n \t " for example?
Yes, it would. Just like a string of spaces " " == 0, but it isn't that bad; === is Javascript's version of == in other languages, and, thus, you should be using it if you don't want that wonkiness.
== is just for convenience, like when you want to make sure that the user didn't leave the form empty and the button shouldn't be greyed out, and other UI stuff. Without these kinds of features JS wouldn't be used in so many toolkits.
Ok, I always mistakenly assumed === was the identity operator in JS, too. TIL, thanks! As much as we like to poke fun at JS, every time I’m taught the rationale behind some aspect of it, I find it redeeming and even a little endearing.
The explanation given to you makes it sound like == was deliberately designed to be a more convenient version of ===, but what actually happened was that == used to be the only equality operator in JavaScript, which meant that if you didn’t want it’s auto-coercing behavior then you needed to go out of your way to add additional type checks yourself. Because this was obviously a tremendously inconvenient state of affairs, the === operator was introduced later so that you could test for equality without having to worry about JavaScript doing something clever underneath the hood that you weren’t expecting.
The explanation given to you makes it sound like == was deliberately designed to be a more convenient version of ===
I mean technically == was deliberately designed to be a more convenient version of other languages’ == operator… Just specifically more convenient for light UI stuff since that was all JavaScript was supposed to be used for at the time (or all they thought it would be used for).
But give programmers a way to write and execute a small script and someone will eventually use that to try and write an emulator that emulates the computer it’s running on, so the web evolved into more complicated applications, and then that convenience turned out to be wildly inconvenient, not to mention horribly unexpected for programmers coming from other languages, so then they added the triple equality to match other languages.
Yeah, it’s true. I knew all the other ones, had to put that one in the dev tools console to believe it. I was just happy to know === continues to be sane in that comparison.
You have to remember that the underlying principle of JavaScript seemed to be “never throw an error”, even if what it’s being told to do is weapons grade bollocks.
im convinced most developers spend more time working on making shit work, rather than actually writing code and bugfixing it.
edit: this was mostly a shitpost, and i was expecting some flack, but i got basically none. Can we have a real moment here. Are you guys doing ok? Who made you do this to yourselves?
ok, real talk over, we’re going back to suffering now.
Yup. Thats just enterprise software for you. Something was made requiremnts changed, and then changed again and then ypu have duct tape on top of a duct tape with a duct tape holding those duct tapes and a touch of super glu here and there. Also ducttapes are microscopic in size but the sheer quantity of them is unimaginable.
this part is pretty much expected i think. But i’m starting to see it cropping up into the more meta aspects of programming now. For instance, apps being shipped with existing deprecated packages. Seems like it’s also creeping a little further into the more UI aspects of it as well.
I used to joke with my niece that my programming job was just me staring at screens and meetings all day. She didn’t believe me until she got to shadow me one day and got super bored.
Not op but guessing she had an idea from media like TV shows and movies that make technical jobs seem much more exciting for entertainment over realism. Crises are usually more Jerry accidentally deleted a directory and we need to recover some files and establish safe guard procedures to prevent it from happening again or this thing broke that nobody even knew existed so we gotta figure it out and less type fast enough to save the mainframe from l33t hackers.
Because software devs have the weeks/months to learn vulkan every time they want to use a GUI for their job, or to learn compiler design whenever they wanna use java for their job
As someone who has written a DB handle… that shit is hard, I had to be extremely careful to protect against SQL injection. Everyone rolling their own is how we return to the Era of XSS and SQL Injection on every website. I’d prefer to have young devs use libraries and contribute as they gain knowledge.
They do… but the road to naturally learning that lesson comes with the cost of enabling botnets and destroying businesses. Maybe there should be a qualification exam to be a developer but when there isn’t we need to make sure more junior developers have the best tools they can get to fight against foot guns.
Also, on the topic of security, a lot of good senior level developers don’t have the specialized knowledge to do shit like build a password validation system that isn’t vulnerable to a timing attack or know what a timing attack is…
And timezones, fuck timezones, I’ve written code that correctly handled timezones (and subsequently threw it away when Canada decided to DST on a different weekend). Imagine how shitty it’d be if we constantly had to reinvent the wheel when it came to timezones.
Oh, and forget about databases… do you know how fucking hard it is to write an ACID compliant WAL? The reason postgres is the default open source database (and why so many databases are just layers built on top of postgres’s engine) is because it’s fucking hard. Mongo still (IIRC) has consistency issues, they were a tech darling for half a decade and can’t manage to NoSQL as well as Postgres.
Also, good luck building a GUI with anything more complicated than curses style box art characters.
I started mildly disagreeing with you but I disagree even more that I’ve thought about other tools people would need to roll on their own.
a lot of good senior level developers don’t have the specialized knowledge to do shit like build a password validation system that isn’t vulnerable to a timing attack or know what a timing attack is
Dual monitors are so 2000’s. It’s all about the single large ultra-wide monitor now. You get the benefits of a dual monitor setup without the line in the middle and the RSI neck pain issues.
Yep and in Windows 11 you now have premade window placements so if you hover the maximise button you can select e.g. “right hand, one third width” and another program for “left hand, two thirds width” etc. I use it all the time. I do have a second monitor on top of the ultra wide but mainly because it’s a special colour accurate monitor, for productivity I was doing fine with just the one big UW for years.
I bought an ultra wide at the beginning of COVID and when I started my new job, my employer gave me another one. Now I have two side by side (the newer one is in the middle) and my laptop to the side. Sometimes I struggle to open enough applications to fill all that space.
Does (or does not) he get the credit for committing the fraud that kept Tesla in business long enough to popularize* electric cars that there are other companies at which to build them?
He’s a piece of shit but he restarted the Space Race that was literally dying, push the industry into electric cars when none of them were willing to do it. His actual products may be garbage but it doesn’t stop that it started the movements that needed to happen in the industry.
To say that he contributed nothing at all is unfortunately false as much as I may hate the man
Used dark (not black) themes everywhere for 8 years. My eyesight is still good according to my annual physical, but recently I’ve noticed that I have a hard time reading text written on a dark background. It is slightly blurred, especially when there is no light in the room.
Somewhere I still use dark themes, but I always try to switch to light mode if things look okay with code highlighting or smth.
If so you should really have a check up with an eye doctor, there are lots of eye health tests that you should regularly get beyond checking that you can read a chart at a distance.
They do, I really hear you. I don’t bother going to a doctor for the exhausting fatigue.
But with eyes not seeing well after 8 years of looking at a screen, you’re not an odd case, you’re the same as half of the society. It’s either short sightedness, far sightedness or astigmatism.
programmer_humor
Active
This magazine is from a federated server and may be incomplete. Browse more on the original instance.