3 ms·
It's honestly the opposite for me. I need the mental crutches provided by strong static typing. TL;DR: I work with a lot of very smart, very talented softwar
by CoastalCoder 4y ago
It's honestly the opposite for me. I need the mental crutches provided by strong static typing.
TL;DR:
I work with a lot of very smart, very talented software developers who thrive with Python's dynamic qualities. They have little problem reasoning about our software's runtime behavior.
Unfortunately, I'm a bit less intelligent than them. I have a much harder time understanding the code's design and behavior due to that dynamism. I would really benefit from the crutch of strong static typing, and the more obvious relationship between static source code and runtime behavior.
- ReflectedImage 4y agoWhy "strong static typing" in particular? Surely there are many other things that could help.
- CoastalCoder 4y agoI find that in software with a strong static typing, I can generally understand each function or class on its own, without much consideration of the context(s) in which it's used. If that same software were written in e.g. idiomatic Python without the use of typing hints, I often need to read a lot more comments, and look at the particular contexts in which that function or class is used, in order to understand its intended purpose and supported use-cases. Things like monkey-patching make it even harder for me. So for someone accustomed to understanding a piece of software by reading the source code (i.e., human, static analysis), a big software system written in highly dynamic Python has a really long learning curve.
- ReflectedImage 4y agoBut generally speaking the code is only 1/3rd of the size. So you have a lot less to read. The only place monkey patching is typically used is in places it has no effect on code meaning such as GEvent.
- kaashif 4y ago> But generally speaking the code is only 1/3rd of the size. So you have a lot less to read. Are you implying type hints triple the size of code? This is very far away from my experience, no idea what kind of monster types you're writing. The only places you need hints are really function parameters and return types - your IDE can infer the rest.
- ReflectedImage 4y agoI've written countless programs with both static typing and dynamic typing, side by side. The statically typed programs are three times as long. It's not the type hints that are responsible. It's the supporting code for allowing the usage of static type checking. Abstract base classes, interface, generics, that stuff which just doesn't exist in the dynamically typed world.
- twblalock 4y agoEven Java is pretty terse these days, but even if it wasn’t, you spend far more time maintaining and editing old code than you spend writing brand new code. All the stuff that looks like verbosity is information that helps you. I’ve also seen monkey patching done in crazy ways even on small projects. Languages like Ruby pretty much encourage it. I can’t imagine what it would look like to edit a Python or Ruby codebase that was a decade old and had 1000 people working on it. But I’ve done that in Java fairly easily because the types help. A little bit of “public static final” here and there is a small price to pay for more maintainable code in the long run.
- kaba0 4y agoDo you have any empirical evidence for that 1/3 claim?
- ReflectedImage 4y agoNope but this site does! https://news.ycombinator.com/item?id=10933524 https://news.ycombinator.com/item?id=10933524
- kaashif 4y agoSame, but the best software engineers write code that's maintainable and understandable by anyone, including themselves on 5 years. If you ever find yourself asking what's actually in this variable, and the code is too dynamic for the IDE to tell, it's going to be too hard for a lot of developers to tell, and maybe even the author themselves in a few years. If the type hints are too complex and involve multi line annotations with 500 unioned types, then we should remember: the programmer does still have to remember what type that parameter can be, even if it's not annotated. Leaving out the annotation doesn't simplify the program, it just moves some information from from explicit to implicit. Calling static typing a crutch is like calling a passenger airliner's takeoff checklist a crutch. I mean maybe it is from one perspective...
- zelphirkalt 4y agoAdding optional type hints in Python is no problem and does not hurt performance at all. You could add them without changing anything else in your project, except imports for type names.