this post was submitted on 24 Nov 2025
610 points (89.1% liked)

Programmer Humor

31403 readers
945 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 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] hperrin@lemmy.ca 2 points 5 months ago (14 children)

Considering TypeScript is a superset of JavaScript, you certainly can. But, that generally means you’re using TypeScript poorly.

[–] FishFace@piefed.social 0 points 5 months ago (13 children)

Just look up the video entitled "wat" which is mainly about JavaScript

[–] hperrin@lemmy.ca 2 points 5 months ago (12 children)

Yeah, I’ve seen a lot of those videos where they do things like {} + [], but why would anyone care what JS does in that case? Unless you’re a shit-ass programmer, you’re never going to be running code like that.

The idea behind that kind of type conversion was that JS was originally designed to be extremely lenient. If it ever crashed, the web page would freeze, so it lets you do things other languages just crash from, like divide by zero.

[–] namingthingsiseasy@programming.dev 3 points 5 months ago (1 children)

Yeah, I’ve seen a lot of those videos where they do things like {} + [], but why would anyone care what JS does in that case? Unless you’re a shit-ass programmer, you’re never going to be running code like that.

By this same logic, memory safety issues in C/C++ aren't a problem either, right? Just don't corrupt memory or dereference null pointers. Only "a shit-ass programmer" would write code that does something like that.

Real code has complexity. Variables are written to and read from all sorts of places and if you have to audit several functions deep to make sure that every variable won't be set to some special value like that, then that's a liability of the language that you will always have to work around carefully.

[–] hperrin@lemmy.ca 2 points 5 months ago

No.

By that same logic, memory safety issues in C/C++ don’t make them bad programming languages.

If you’re worried about it, like you’re accepting input from the user, sanitize it.

if (typeof userProvidedData !== "string") {
  throw new Error("Only works on strings.");
}

Better yet, put that in a function called assertString.

load more comments (10 replies)
load more comments (10 replies)
load more comments (10 replies)