What have been the drawbacks of static typing for you?

Over the past couple of years I've been able to do a sort of direct comparison between dynamic and static typing.

We are developing a new platform for writing distributed applications. The first thing we needed was a demo platform we could use to explain the concepts. I did that in JavaScript, because it was really easy to show things graphically in a browser. Even though the code was only for a demo, I did my best to model the actual message passing and the propagation through the various layers, which gave me confidence that the algorithms we developed work.

We won't be shipping JavaScript as the product and decided to write the production code in Rust. I now have a version that does the same things as the JavaScript code and more. I really like having the compiler do a lot of the debugging for me. Every time my program doesn't compile, I repeat the mantra, "That's another bug that won't show up in production." which helps preserve my sanity. Having an IDE that shows me type errors as I modify my code is a huge help.

The one place where I found Rust harder to use is in message dispatch. My code was really ugly until I realized I could use double dispatch. Even so, it's a few lines of code per message type that I'd rather not have.

5 Likes

After the name, you’re prompted to think of all the fields you might need and what types they should have, which might require defining further structs/classes, and so on. Of course, you don’t have to do this – you could just start with no fields and add them as needed – but adding a field requires flipping between at least two points in the code (where the field is defined and where you’re using it; if there’s a constructor or destructuring, there might be more points), so it’s natural to want to save the effort by figuring it out up front. Anyway, you already gave it a name, so maybe you have an idea what fields it needs?

That's not true, it's all up tooling. For example I write some C# code and I have nothing.

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

Then I think "I need a fooer with bar method". Ok, nothing is as simple, just create a Fooer, agree with creating a class, call bar, agree with creating a method, choose its return value, use it... ??? Profit!
Took me same typings as in python except for several alt+Enter combinations to generate appropriate members.

(click image for step by step visualisation)

Being said, it's all up to tooling

3 Likes

A spammer bumped this old thread, and it stays bumped after the spam is deleted. Closing this old thread to prevent further confusion.

1 Like