3 ms·
As a developer who's written hundreds of thousands of lines of C++, Python, and JS - I don't know! It's not so clear cut. I'm productive in all off them, althou
by QuadrupleA 3y ago
As a developer who's written hundreds of thousands of lines of C++, Python, and JS - I don't know! It's not so clear cut. I'm productive in all off them, although Python mostly wins. I wouldn't write a game engine or a video codec with it though.
JavaScript is inconsistent and weird, but Netscape's legacy long since stuck us all into it.
I can see in a very OOP-heavy style maybe, with huge nested classes, that compile/parse time static typing saves a lot of mistakes - but I've come to see OOP as mostly a disaster, and simple functions and structured data almost always win the simplicity and maintainability battle. And modern language servers / IDEs can catch a lot of typing errors during JS / Python development.
I'm persnickety about a lot of programming stuff, but never had a strong opinion about static vs dynamic typing. Both have millions of successful projects under their belt.
- rdedev 3y agoIn python I mostly code in functional style. Even then types helps me a lot. I make a lot of typos or get the order of arguments wrong. Typing helps me a lot here especially when I'm doing ML. The last thing I want is my training code to crash after it spent 30nmins processing the data. I find pythons gradual typing a really good middle ground for quick prototyping and the type annotate functions once they are mature enough
- boxed 3y ago> or get the order of arguments wrong There's a simple fix for that, just do keyword argument only everywhere you can. For me the hill I'm willing to die on is that labeled/named/keyword arguments are absolutely necessary and most of the usefulness of types is in fact just a shitty version of labeled arguments (god help you if you have a function where two or more arguments have the same type!)
- rdedev 3y agoThe small downside to using kwargs is just the extra letters needed to call the function but I can live with that. As for args with the same type, you can use phantom types I guess but I haven't explored it much in python. I'm pretty interested in the dfdx library in rust which can type enforce matrix or vector operations on it's shape. Stuff like that would really help me
- boxed 3y agoIt's an advantage imo. Makes the code more readable, and much more robust against bad refactors.
- BobbyJo 3y agoTo be fair, C++ is a pretty rough language to be productive in generally, type system aside. GC is the single largest productivity enhancement a language can offer. I'd be way more interested in how Golang, with it's much simpler syntax/types (but they're still static) would compare. Even Java would be better, as, even though it's very verbose, the cognitive load for most tasks is a fraction of C++'s.
- kagakuninja 3y agoMy language evolution went C > C++ > Java > Scala Java was a huge boost, by eliminating the cognitive load of manual memory management. Scala can be used as a "better Java" with less verbosity, but also adds a number of extremely useful features; Java has slowly added some of them into the language over the last 8 years.
- sureglymop 3y agoHave you tried Kotlin? I personally like it a lot as an alternative to Java and Scala. However, I hate any tooling around the JVM based languages. I cannot waste my time messing around with Maven, Gradle, etc.
- kagakuninja 3y agoNo, I am very happy with Scala, and intend to use it for many years to come. JVM tooling IMO is fantastic, it is one of the largest open source communities, and there are many options if you don't like Gradle or Maven. Also, as I understand it, the dependency management systems found in languages like Python and Node are horrible in comparison to the JVM, where it is usually not a problem.
- arp242 3y agoIt's really hard, even with Go there are so many more differences than just types. e.g. in Python/Ruby I had a REPL and used it a lot. Go doesn't really have a good REPL, so I tend to not use it so much. I probably pay some in productivity for that? On the other hand, I type code like: name:=fun("foo","bar");if name=="foo"{fmt.Println(name)} And write and let gofmt sort it out. You can kind of do that in Ruby in theory (not sure if good formatters exist), but Python is more tricky (and I also think the auto-formatters for Python are bad and often make code worse). The flexibility of things like Active{Record,Model} in Rails are great, and hard to emulate with Go. People have tried, and it just doesn't fit with the language very well. Go's simple "just compile to a statically linked binary" distribution model probably saves me time, especially for distributing it to other people. Probably other differences I can't think of right now. So between all of that, how do you split out the productivity of "types" vs. anything else? That's also my problem with the research on this, because you just can't, not really. What you need to do is compare e.g. Python with Mypy vs. without. I don't think anyone has done that(?) And even then you run in to the problems with differences in tasks, differences in programmer experience and ability, etc. which matter because for a lot of these studies n tends to be small.
- AdamN 3y agoYou might like this video from WWDC a few years back on protocol-oriented programming (Swift): https://www.youtube.com/watch?v=p3zo4ptMBiQ https://www.youtube.com/watch?v=p3zo4ptMBiQ