IDK buddy, I don’t really care to write the same method for five different types (or read the 30 methods with different type signatures) when I can do it with one. I see the exact opposite of your statement, in my experience.
Extra steps that guarantee you don’t accidentally treat an integer as if it were a string or an array and get a runtime exception.
With generics, the compiler can prove that the thing you’re passing to that function is actually something the function can use.
Really what you’re doing if you’re honest, is doing the compiler’s work: hmm inside this function I access this field on this parameter. Can I pass an argument of such and such type here? Lemme check if it has that field. Forgot to check? Or were mistaken? Runtime error! If you’re lucky, you caught it before production.
Not to mention that types communicate intent. It’s no fun trying to figure out how to use a library that has bad/missing documentation. But it’s a hell of a lot easier if you don’t need to guess what type of arguments its functions can handle.
Type signatures help you to know what a function takes and returns. With dynamic typing, I have to read the entire code of the function just to know this (sometimes even this doesn’t tell me what will actually be returned due to duck typing).
More importantly, type signatures help the compiler verify the types.
Both of these get more and more important as the code size increases. I’d suggest you widen your horizon about static typing.
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
Posts must be relevant to programming, programmers, or computer science.
No NSFW content.
Jokes must be in good taste. No hate speech, bigotry, etc.
Honestly, fuck dynamic typing in general. That shit saves you a few seconds and costs you a few hours.
IDK buddy, I don’t really care to write the same method for five different types (or read the 30 methods with different type signatures) when I can do it with one. I see the exact opposite of your statement, in my experience.
I take it your only experience with statically typed languages is with C. It’s a big world out there!
That’s what generics are for.
So… dynamic typing with extra steps 😂
Extra steps that guarantee you don’t accidentally treat an integer as if it were a string or an array and get a runtime exception.
With generics, the compiler can prove that the thing you’re passing to that function is actually something the function can use.
Really what you’re doing if you’re honest, is doing the compiler’s work: hmm inside this function I access this field on this parameter. Can I pass an argument of such and such type here? Lemme check if it has that field. Forgot to check? Or were mistaken? Runtime error! If you’re lucky, you caught it before production.
Not to mention that types communicate intent. It’s no fun trying to figure out how to use a library that has bad/missing documentation. But it’s a hell of a lot easier if you don’t need to guess what type of arguments its functions can handle.
Type signatures help you to know what a function takes and returns. With dynamic typing, I have to read the entire code of the function just to know this (sometimes even this doesn’t tell me what will actually be returned due to duck typing).
More importantly, type signatures help the compiler verify the types.
Both of these get more and more important as the code size increases. I’d suggest you widen your horizon about static typing.
I started as a python enjoyer. 6 years later I can confidently say fuck dynamic typing, fuck mutable defaults.
Also fuck python and js (used both for work) TS is better but we all know it’s not by much
TS is “better” but often I feel like just configuring typescript takes up a significant amount of the time you save by using it.
Yeah, i feel the same but it is at least configurable and not terrible configurable like python
It gets easier the more you do it but ts needed a default official config to start things up with.
Hahaha exactly! I feel like every time I start a new TS project, I start by copying the tsconfig from an existing one
This. I actually have template which I’m using for all my small projects.
Right tool for the job.
If I just quickly want to whip up a small script, I actually want to save a few seconds.
When I’m doing something larger in scope, static typing all the way.
That’s 100% spot on. Those hours lost never come if the whole project is done in 30 minutes.