Comment by incomingpain
2 hours ago
>Why dynamic over static?
I started my coding career in C++. I know static well enough for my lifetime. It makes sense that if you're in the 1980s and choose static as the designer of the language.
But now the choice is available, why would you want to declare the variable. In my code I want to write "bob =" and the language figures that all out. If I feed a string into it or a number, why does it matter?
It saves me oodles of time not having to be concerned at all about that.
It's also very interesting in functions. Yes, I have been using the typing in python. def process_bob(self, bob: int) -> bool:
Technically i can shove whatever i want into that arg of bob. Imagine the function was a network protocol. v 1.1 did X, v1.2 did X and Y. That int becomes perhaps a list and that's totally fine. Very reusable, because iterating, process_bob can just become if bob == int: elif bob == list.
Why would I want my programming language to make things harder on myself for literally no gain?
No comments yet
Contribute on Hacker News ↗