C# really is a very nice language. If it played more nicely with platforms other than Windows, I think it would have been an ideal choice for medium-sized projects and larger. It's a bit of a statically typed Python with a little more cluttered syntax.
As to why someone would want to add type declarations to a dynamically typed language. In my opinion static (i.e written in the code) types are convenient where the types are known while writing the code. Sometimes, however, this is not the case. Types can be created at runtime, by querying the database or reading from a .json. A Qt designer file gives you a QWidget subclass. SQLite and key-value stores hold untyped objects. Any metaclass action results in a class that's generated in runtime.
In these cases, having a static type system would make you work with it somehow. It can be generating class declarations from configuration files as part of the build process (which .NET does). It can be creating an "interface" ISomethingThatGoesInTheDatabase with subclasses DBInt, DBString, DBUserProfile, etc, thereby duplicating a class hierarchy (and yes, I've seen that happen in a Java project).
Many of these issues can be overcome by using Object in statically typed code. However, that's very frowned upon by static typing people. I think Python type annotations might hit the sweet spot - you can use them wherever they're useful, but you don't have to use them where they don't make sense.
The last time I used the .NET ORM stuff it used code generation. It doesn't surprise me to know that it's better these days, because the language designers generally make good decisions.
If you're working with two untyped systems - by which I mean systems that would work with all types - then you don't need to know what you're working with. For example, an event/notification system. The code that handles the method arguments doesn't need to know what type they are. The best you can do is treating them as Object[]; creating INotificationMethodCallArguments is much worse than just not knowing what type it is. Once someone decided to create a superclass or an interface (it's an is-a relationship, right?), you have to create classes that wrap existing classes and it becomes a huge and useless waste of time.
Likewise a storage system. It takes stuff and stores it, then retrieves it for you. You know what you're going to get, but the storage system doesn't know what it's going to give you. It should handle Objects, not IRetrievedItem. When I worked in Java, there were so many useless types.
Hence. If you know the type, by all means write it down. If you don't, don't. Don't create a new type so that you have something to write down. And while in most cases you know the type, the overhead of these useless types was a huge weight on the back of that Java team I was part of, because these types then invade normal code, conversions start happening back and forth... It's not pretty.
Do you feel comfortable deploying that code to production without code review, unit tests, integration tests, and passing all of the system tests?
It doesn't matter what language I use, I am going to engage a sane testing policy to ensure the highest quality product possible.
I have found that the ratio of testing to lines of code remains about the same regardless of what language I use. So I try to reduce the lines of code and redundant information in the code.
I could probably reduce your code above to a few lines of Python, and still keep it under 80 chars per column. Add a few unit tests, and it will be ready for system integration before lunch.
Personally I feel like not having to debug missing semi colons is my favourite python feature. Less bracket matching debugging is good too, especially as you can optionally wrap anything you want in brackets and do whitespace-independent formatting.
But up near the top of my favourite features is a "we're all adults here" approach to things like private members and mixing types. It gives you a multitude of heuristics as you're reading code to tell if the code you're reading is quality code or not, which extends to being able to tell if it was written by a Java programmer.
I didn't insult Java programmers. I prefer python, but that's because I've written a lot more code in python. Whenever I have to write JavaScript I always frustrate myself by dropping semi colons, as I can't seem to train myself not to.
In python you can pass anything you want to a function, and if you start seeing any code at the start of a function which is doing type handling of arguments you don't really have to review that closely to know what discussions to have with the person who wrote it.
My comment about Java programmers is one about expression. I don't know Java, and yet when a Java-only programmer writes python I can sometimes tell purely because of the way they express their ideas.
As to you being rude, yes you were very. I just told you my feelings about my personal favourite features of python and you told me I was bike-shedding. Actually there are lots of good reasons to choose one language or another, in the few circumstances where you have a choice, but the best reason is whichever language suits your team best. Anything else, such as type safety, is bike shedding the project imo.
0
u/[deleted] Jan 05 '18
[deleted]