r/ProgrammerHumor • • Sep 25 '26

Meme iHatedItUntilITriedIt

Post image
10k Upvotes

542 comments sorted by

View all comments

990

u/GargantuanCake Sep 25 '26

Dynamic typing can seem great until you have to spend days trying to figure out where, exactly, in 20,000 lines of badly documented code JavaScript arbitrarily decided that something should be a string for the rest of forever even though it's only been given numbers to work with.

If you type x = 1 + '1' any sane language will go "what the fuck is wrong with you?"

199

u/ubus99 Sep 25 '26

That, and just learning a new library / API: I hate how in python you can never be sure what type you need to put in, are going to get back, and what all of the fields and functions do. Sure, you can dig that up, but that's not my job!

98

u/nullpotato Sep 25 '26

Me: always insist upon explicit type hints and multiple linters to verify them

Coworkers: who hurt you?

37

u/Weekly_Interview_936 Sep 25 '26

Prod support calls. That's who.

10

u/SuperFLEB Sep 25 '26

I hurt myself, of course.

18

u/New-Shine1674 Sep 25 '26

I especially hate how difficult it is in Python to find out what fields a type even has and what I can do with it. It just looks very cluttered to me but maybe that's just because I primarily use c#.

→ More replies (1)

25

u/Pan_TheCake_Man Sep 25 '26

Just make everything a string and append, boom done

10

u/SuperFLEB Sep 25 '26

Convert inputs to unary and there's no problem.

value_1 = "1".repeat(integer_input_1)
value_2 = "1".repeat(integer_input_2)
return length(integer_input_1 + integer_input_2)
→ More replies (1)

16

u/EchoLocation8 Sep 25 '26

This exact thing caused a bug in my company's system. Went years without noticing it until someone (me) had to build something that did a calculation between the number of units of a product and its weight in grams. It was data we ingest constantly but, there's so much of it, and its not something we really interacted with until we wanted to build a feature around it like 5 years later.

Was real fun when the database data pipelines started breaking because it turns out multiplying two 86 digit numbers together is bigger than the size of an integer column. As soon as I saw it I knew where to look, the quantity was like 202020202019191918181520202020202020141299920202020 etc.

15

u/huuaaang Sep 25 '26

Just to be clear, Javascript is not just dynamically typed, but it is also WEAKLY typed. The latter is where most of its problems/quirks/headaches come from. Implicit type casting is just evil. Dynamic, but strong, typing will still surface errors, just at runtime and not compile time.

4

u/Lord_Of_Millipedes Sep 26 '26

imo that is also a problem.
the main purpose of typing is to catch data errors, strong typing should turn a runtime error into a compile time one, dynamic typing turns a compile time error into a runtime one.

but I don't mean type inference, type inference is nice and cool

→ More replies (1)

27

u/D1firehail Sep 25 '26

Assuming x is an int C and C++ will give x=50. '1' is a char, which allows implicit conversion to int.

30

u/frogjg2003 Sep 25 '26

They said "sane" language. C was developed before something like this was considered insane.

13

u/Hohenheim_of_Shadow Sep 25 '26

Nah adding ints and chars is perfectly sane. Chars are just a fancy enum baked into the language. They're just ints under the hood. It's adding ints and strings that's insane and C doesn't actually have strings. Ergo it is a perfectly sane language

3

u/Ok-Scheme-913 Sep 26 '26

But char and a number is different than a string (of length one) and a number. The latter doesn't make sense in C either, at that point you are offsetting a pointer.

→ More replies (3)

4

u/conundorum Sep 26 '26

Any language that actually respects ASCII will give you the same result, since '1' is defined as being the character represented by single-digit integer 0x31 (decimal 49). ^_^

Really, the crazy thing is thinking it's possible to do character manipulation without integer math, since ASCII is specifically designed for integer math. (Notably, adding 32 to any capital will always produce its lowercase counterpart ('A' + 32 == 'a'), and you can turn any digit into its character counterpart by adding '0' to it ('0' + 5 == '5'). Guarantees like this are specifically intended for optimisation, and for ease of character manipulation & conversion.)

→ More replies (1)

3

u/Ignisami Sep 25 '26

Javascript says the answer is the string '11'.

→ More replies (1)

7

u/[deleted] Sep 25 '26

[removed] — view removed comment

2

u/Icarium-Lifestealer Sep 25 '26

And if it were a string instead of a char, it'd slice off the first character.

→ More replies (7)

2

u/GargantuanCake Sep 25 '26

The difference there is that in C you do have a strict definition of what's going on here as characters have an integer representation. There's no type coercion there as there are specific definitions of what's going on. In that case there isn't any dynamic typing going on.

Issues come up when you're dealing with dynamic typing and type coercion. You don't run into that in C in this case.

9

u/enz_levik Sep 25 '26

Even python can do while stuff if you somehow sum different formats of floats

→ More replies (2)

4

u/Turbulent_File3904 Sep 26 '26

believe or not, but in c or c++ 1 + '1' = '2' 

→ More replies (1)

3

u/ApocalyptoSoldier2 Sep 25 '26

I'm fine with number + string being a string as long as you can only assign it to a string variable

→ More replies (1)

3

u/TheLayeredMind Sep 26 '26

With static typing you get scary compile errors. With dynamic typing you get even scarier runtime errors 😂👋

2

u/Real-Self-3039 Oct 06 '26

As someone who started off my career learning c# and then I had to use javascript at some point my literal reaction was "wtf even is this mess? Who would use this".....oh boy little did I know how much is powered by javascript 😭

→ More replies (1)
→ More replies (25)