r/ProgrammerHumor • • Sep 25 '26

Meme iHatedItUntilITriedIt

Post image
10k Upvotes

540 comments sorted by

View all comments

1

u/DarthCloakedGuy Sep 25 '26

I tried it... still not sure what the benefit is, and for some things it is very much not wanted

5

u/leavemealone_lol Sep 25 '26

If you build anything that spans over 1000 lines of code, you’d be grateful to instantly recognize the type of a variable.

0

u/EMunney Sep 25 '26

No I think this is more of a beginner take. 1000loc is tiny

3

u/HiCookieJack Sep 25 '26

for me it became worth it when working with multiple people and that my IDE stops guessing what methods exist.

1

u/DarthCloakedGuy Sep 25 '26

Couldn't begin to guess what you mean by "my IDE stops guessing what methods exist" and I'm a solo dev so that makes sense

2

u/HiCookieJack Sep 25 '26

if you write javascript or python code the code completion is statistics, since the IDE does not know what methods exist.

With typing you IDE can determine what functions exist and only suggest actually existing methods.

If you have small projects and work alone you know which methods exist, if you have a big project or multiple people working on it, it's impossible to know what is available and you end up always checking the implementation (If you can find it)

0

u/DarthCloakedGuy Sep 25 '26

Huh. Okay.

But what do you do when you need a variable to be able to hold different classes of object?

3

u/HiCookieJack Sep 25 '26

use a new variable?

Create an abstract class

Create an interface

Create a union type

1

u/Less_Independent5601 Sep 25 '26

It depends on the situation and there are many viable solutions. You could use interfaces as example.

Like, if you have a calendar and multiple different types of events that go on a calendar and need some type of function that based on their own unique definition tells you what time it will be and a description of what the event is.

You can make an interface InteractsWithCalendar, or what have you. The interface demands: if you're implementing me, you must follow my contract. The contract could state that you must define a getCalendarDefinition function.

Then, on the different classes that interact with a calendar, you declare they implement the interface, and you give each class their own respective getCalendarDefinition implementation.

Now, if I want to build my calendar, I could define my variables as an array of type InteractsWithCalendar. Now, I know for sure my objects all implement the getCalendarDefinitio function, and I can call that without worries.

2

u/thisguyfightsyourmom Sep 25 '26

I think a lot of people like it for the code hinting, which …

People who worked without typing often have a sense for it.

But really it’s the catching bugs while you write them rather than in the runtime that sells them.

It’s irritating to write at times though