6 ms·
This is one of the big reasons I prefer static typing. When looking at some unfamiliar code in an unfamiliar codebase, I can reason about the code much faster
by magicalhippo 6y ago
This is one of the big reasons I prefer static typing.
When looking at some unfamiliar code in an unfamiliar codebase, I can reason about the code much faster when I can see what functions return, and quickly go check their types out if the type is unknown. This makes me much more productive.
I helped maintain a 250kLOC Python program. I came in when it already at over 200kLOC. I spent so much time, every time, just trying to figure out what's going on because I never knew what something returned.
- baby 6y agoThat’s really painful indeed when you review python/erlang/etc. code or Golang with interface{}
- gameswithgo 6y agoWhat little quality research there is on programming productivity, does support the idea that dynamic typing is a productivity hindrance as code bases get larger, for exactly this reason. Some studies actually have video data of the programmers at work and they can seem them having to hop around to function definitions more to figure out what they are supposed to pass in, etc
- rajacombinator 6y ago250kLOC Python sounds scary. But that would easily be 1mLOC+ lines in Java ...
- magicalhippo 6y agoI'd much rather have a million lines of Java. And I'm not a huge fan of Java. It can be a bit tedious going down the AbstractWidgetInterfaceFactoryFactory rabbit holes, but at least I have a fighting chance.
- joelbluminator 6y agoTo each his own...
- rajacombinator 6y agoHonestly they both sound horrific. Any code base that large ...
- joelbluminator 6y agoYep, indeed. Most of my head scratch moments with big code bases aren't about anything as technical as types. It's not as if knowing the types would have made me realize what the code actually does, which is the main hurdle.
- magicalhippo 6y agoIn my experience, static types allows me to ignore a lot of code, which helps dealing with large codebases. Sure it won't do magic with 1MLOC of spaghetti code, but in a reasonably sane codebase it makes it much easier to know which parts to care about and which you can ignore for the time being. Again, that's my experience at least.
- gher-shyu3i 6y agoNot necessarily. It's possible to write quite terse code in Java, especially Java 10+ (var, streams, etc.). And now with records and pattern matching, even more so.
- paddim8 6y agoI don't understand why people say this about Java and C# vs. Python. You can easily write concise code. There will be more lines because of things like brackets and some other simple things, but c'mon, it's not 2005.
- emergie 6y agolombok is the holy grail of java boilerplate removal. With proper usage of spring-data, spring-cloud-stream, spring-* lomboked java code can be very terse. If you follow conventions repositories, rest clients, mappers etc. are often defined only by interfaces and annotations - actual implementations are generated. The downside is that the entrance to the full blown spring-* world has a step learning curve - there is a lot to read at spring.io.
- mike22 6y agoStatic typing is great until people ignore it. They pass around Map<String, String>, use magic strings for the keys, and stuff in Integers, Enum::toString, and UUIDs as values. And also building XML blobs by hand instead of serializing an object of a concrete class, and also deser’ing it manually on the other end (which receives it over SOAP no less).