this post was submitted on 25 Jan 2024
663 points (97.7% liked)

Programmer Humor

19154 readers
2012 users here now

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

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 17 points 7 months ago (6 children)

How does people manage to work with that language?

[–] [email protected] 15 points 7 months ago

by not ever using == and !=, but only === and !==

[–] [email protected] 10 points 7 months ago (2 children)

Because in reality you're not doing stupid stuff like that in the image. And using Typescript definitely helps.

However I'm always annoyed that the month parameter when constructing a date object is 0 based. So 1st of Jan is

new Date(2024, 0, 1)
[–] [email protected] 8 points 7 months ago* (last edited 7 months ago)

However I'm always annoyed that the month parameter when constructing a date object is 0 based. So 1st of Jan is

new Date(2024, 0, 1)

That's nothing. The 'tm' type in the C standard library also starts months at 0. But the year 0 is the actually the year 1900.

So 1. january 2024 would be

tm date{ .tm_mday=1, .tm_mon=0, .tm_year=124 };.

[–] [email protected] 1 points 7 months ago

Looks confusing at first, but I found it nice for accessing a month array.

const months = ["Jan", "Feb", ...];

months[0] === "Jan";

const label = months[date.getMonth()];
[–] [email protected] 10 points 7 months ago (1 children)
[–] [email protected] 3 points 7 months ago (1 children)

Yep. It's the only reason I'm still somewhat sane.

[–] [email protected] 2 points 7 months ago

I got by without it for years, but not that I have it I have no idea how I did it back then.

[–] [email protected] 7 points 7 months ago (1 children)

By banishing the bad part of the language with linter.

For instance, standard eslint preset has rules that enforce usage of ===, https://eslint.org/docs/latest/rules/eqeqeq

These rules often come with project starter template

[–] [email protected] 4 points 7 months ago

And typescript is basically just a linter on steroids

[–] [email protected] 6 points 7 months ago (1 children)

almost forced to for web front end. why you would use it anywhere else, however, i will never know

[–] [email protected] 4 points 7 months ago

The same reason people drive their car to buy groceries.

You bought it for something where it was the only option, driving 30km to work everyday. But ever since you got it, the trip to the super market is kinda too hot in the summer and too cold in the winter and what if you spontaneously need to buy more than expected?

People learn it for front end dev, and then they use what they know for back end too.

[–] [email protected] 2 points 7 months ago* (last edited 7 months ago)

Ikr? English is hard /s