Live data from Hacker News

Diminishing returns of static typing

blog.merovius.de

1–10 of 632 posts

Re: Diminishing returns of static typing

#3
The benefit of static typing isn't just reliability. Tooling is another major argument. Won't appeal to certain hardcore programmers who think that even notepad has too many features. But it is great for refactoring, finding all references to a function or a property or navigating through the code at design time. Basically all the features visual studio excels at for .net languages.

And I disagree with the barrier to entry argument. Static typing, by enabling rich tooling, helps a beginner (like it helped me) a lot more by giving live feedback on your code, telling you immediately where you have a problem and why, telling you through a drop down what other options are available from there, etc. Basically makes the language way more self-discoverable than having to RTFM to figure out what you can do on a class.

Re: Diminishing returns of static typing

#4
One of my favorite parts of Powershell is optional typing. Variables are a generic "Object" type by default, which can hold anything from a string to array to "Amazon.AWS.Model.EC2.Tag" or other custom types.

Or, type can be specified when setting the variable:

[String]$myString = "Hello World!"

This would generate a type error:

[Int]$myString = "Hello World!"

Often, typed and untyped variables will sit together:

[Int]$EmployeeID,[String]$FullName,$Address = $Input -split ","

Re: Diminishing returns of static typing

#5
When I went from working at Apple to a language implementation group at another company, my views on Objective-C's duck typing + warnings for classes being useful and good was pretty heretical. It's nice to see other people agree with me.

Especially when it comes to GUI programming, I really don't care if a BlueButton.Click() got called instead of RedButton.Click().

Re: Diminishing returns of static typing

#6
The biggest benefit of static typing is not a reduction of bugs...It's the speed and confidence with which one can accomplish a given task. IDE support, code completion, etc are so much better in a static environment. Take a random file from a pure JS codebase and compare it to something in Typescript. The first would require digging around to even begin to understand what the file is doing. Whereas TS, the code documents itself.

The counterarguemnt - "it's slow to write" - hasn't been true for years with modern type inference and other features.

Re: Diminishing returns of static typing

#7
post #3

The benefit of static typing isn't just reliability. Tooling is another major argument. Won't appeal to certain hardcore programmers who think that even notepad has too many features. But it is great for refactoring, finding all references to a function or a property or navigating through the code at design time. Basically all the features visual studio excels at for .net languages. And I disagree with the barrier to…

Live coding environments are amazing at this, as well. Often without the need for as extensive static typing, since it can just use reflection.

This isn't to say that static typing isn't good at this. Just, even with that, there is a lot of effort that goes into making the rich tooling. A lot of very smart and capable folks work hard to make Visual Studio.

Re: Diminishing returns of static typing

#8
I had the same experience, but I also have to say that the static type systems of some FP-languages feel really light-weight.

So year, static typing doesn't buy you much, but in some languages it's at least cheap.

Re: Diminishing returns of static typing

#9
post #3

The benefit of static typing isn't just reliability. Tooling is another major argument. Won't appeal to certain hardcore programmers who think that even notepad has too many features. But it is great for refactoring, finding all references to a function or a property or navigating through the code at design time. Basically all the features visual studio excels at for .net languages. And I disagree with the barrier to…

Dynamic languages support this kind of tooling too - you can even have seamless data completion (eg. map/dictionary keys). The original Refactoring Browser was written for Smalltalk. Etc.

Of course there are cases where dynamic languages do worse, but it balances out I think.

Re: Diminishing returns of static typing

#10
I think what's often missing from these arguments is that statically checking (or inferring) homogenous lists is probably one of the most superficial uses of the type system in Haskell (and indeed not the interesting feature most power-users of Haskell are interested in as far as I can tell).

What is interesting is using the type system to specify invariants about data structures and functions at the type level before they are implemented. This has two effects:

The developer is encouraged to think of the invariants before trying to prove that their implementation satisfies them. This approach to software development asks the programmer to consider side-effects, error cases, and data transformations before committing to writing an implementation. Writing the implementation proves the invariant if the program type checks.

(Of course Haskell's type system in its lowest-common denominator form is simply typed but with extensions it can be made to be dependently typed).

The second interesting property is that, given a sufficiently expressive type system (which means Haskell with a plethora of extensions... or just Idris/Lean/Agda), it is possible to encode invariants about complex data structures at the type level. I'm not talking about enforcing homogenous lists of record types. I'm talking about ensuring that Red-Black Trees are properly balanced. This gets much more interesting when embedding DSLs into such a programming language that compile down to more "unsafe" languages.

Post reply on HN