Live data from Hacker News

The advantages of static typing, simply stated

pchiusano.github.io

41–50 of 127 posts

Re: The advantages of static typing, simply stated

#41
post #29

It's frustrating that this static vs dynamic 'battle' still goes on. The longer everyone thinks this is actually a problem, the longer we have to wait for innovations to happen. Look at the web in 2016, the technology is a complete disarray. Look at the game industry in 2016, where C++ is thrown around as the the cause and solution to all life's problems. A language created 33 years ago now with no intention of being…

With static typing the computer doesn't "understand" your code. It just automatically checks the correctness proof you've presented to it. And the correctness is limited only to certain properties of the program, that a given type system supports.

We can argue about the definition of 'understand' all day, but it's a simple fact that the computer has more of an understanding of the structure of your program with a type system, and thus can help out more.

Re: The advantages of static typing, simply stated

#42
post #25

Newbie starts with C++, moves on to Haskell after a very brief dabbling in some dynamic languages, and comes out thinking expressive static type systems are great. No great surprise, no real insight. The purpose of programming languages is to bridge the gap between ideas and execution. The purpose of a type system is to prove something about the code; astute readers will notice that this is an orthogonal concern. Sta…

[deleted]

Re: The advantages of static typing, simply stated

#43
I've recently joined a team writing primarily in Clojure, whose proponents often tout repl-driven programming as a unique benefit to the language.

In a statically typed language (the stronger the better), aided by a good IDE, I don't need to be constantly executing my code against data during development; My editor is constantly validating my code, and when it stops complaining, my code will work. And months later when I or someone else uses that code in another part of the system, they won't need to execute that code to see how it behaves, as the types themselves provide documentation and as-you-code feedback.

Re: The advantages of static typing, simply stated

#44

Interestingly, most of these advantages are not specific to static typing, but derive from having a language that talks about types – even a dynamic one. For example, most of these advantages apply to Julia as well, a dynamic language that has type declarations, which: - Lets you create typed collections so that if you insert the wrong kind of value, you get an error immediately, albeit only when code runs, not befor…

How can you define throwing an error at runtime instead of compile time an advantage?

Re: The advantages of static typing, simply stated

#45
> Is it safe to call f(x)?

The author asserts that static typing allows the compiler to answer this question, but this only allows the compiler to spot type errors in advance. There are many other kinds of errors that are completely invisible to the compiler.

In a dynamically typed language, if I don't spot the error from reading the code, I must wait until runtime/testing to discover the error. This is also true for a statically typed language for every kind of error except type errors. Personally, type errors haven't been the kind of errors that haunt my dreams. I guess that's why I'm not enthusiastic about static typing.

Re: The advantages of static typing, simply stated

#46
post #3

Earlier quoted context omitted.

Have you considered the possibility instead that JSON is not an appropriate serialization protocol or storage mechanism for the problem to be solved? Or that it isn't being used effectively/correctly (that is, it isn't being parsed correctly, e.g. with a library or some other mechanism that makes checking underlying types less cumbersome)? I noted in a comment downstream from here that plenty of C and C++ JSON librar…

We have no control over the API that we draw from. We are drawing from the API of a different company. I wish they didn't use JSON. If they have to use JSON, I wish they at least enforced a consistent schema. But they don't. And that is why static type checking fails: because the real world is chaotic, and when you have to interact with that real world, you are often forced to do so dynamically, because of the mistak…

The real world being dynamic has almost literally nothing to do with this issue. The concepts are completely unrelated.

Although I'd agree that I find development with dynamically typed languages a bit more chaotic than static or strongly typed ones. And not necessarily in a fun, good way, either.

Re: The advantages of static typing, simply stated

#47
post #43

I've recently joined a team writing primarily in Clojure, whose proponents often tout repl-driven programming as a unique benefit to the language. In a statically typed language (the stronger the better), aided by a good IDE, I don't need to be constantly executing my code against data during development; My editor is constantly validating my code, and when it stops complaining, my code will work. And months later wh…

with F# you have a REPL, it is not only prerogative of dynamic typed languages.

Re: The advantages of static typing, simply stated

#49
post #43

I've recently joined a team writing primarily in Clojure, whose proponents often tout repl-driven programming as a unique benefit to the language. In a statically typed language (the stronger the better), aided by a good IDE, I don't need to be constantly executing my code against data during development; My editor is constantly validating my code, and when it stops complaining, my code will work. And months later wh…

> my code will work

You mean your code will compile and run. Whether it behaves as desired is completely unknown without testing.

Re: The advantages of static typing, simply stated

#50

It's frustrating that this static vs dynamic 'battle' still goes on. The longer everyone thinks this is actually a problem, the longer we have to wait for innovations to happen. Look at the web in 2016, the technology is a complete disarray. Look at the game industry in 2016, where C++ is thrown around as the the cause and solution to all life's problems. A language created 33 years ago now with no intention of being…

>The advantage of static typing is obvious to me; the more my computer understands of my code, the less work I have to do.

There's nothing about dynamic typing which precludes this.

There are also things which it is not necessary for your computer to understand but the rigidities of an excessively strict type system will demand it be told those things anyway.

Post reply on HN