Live data from Hacker News

The advantages of static typing, simply stated

pchiusano.github.io

61–70 of 127 posts

Re: The advantages of static typing, simply stated

#61

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…

> A language created 33 years ago now with no intention of being used as it is today.

You know that they update the language regularly, and have a games sig? https://groups.google.com/a/isocpp.org/forum/#!forum/sg14

Re: The advantages of static typing, simply stated

#62
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…

I would say 'a statically typed language aided by a type inference engine'. My biggest bugbears with statically typed languages go away when decent type inference comes into play.

Re: The advantages of static typing, simply stated

#63
I think the concept of refactoring in dynamically typed vs statically typed languages is a double-edged sword comparison.

On one hand, refactoring code written in a statically typed languages is less error-prone - But on the other hand, such refactorings tend to affect more code than those of dynamically-typed code.

If your business requirements change often and refactorings are common, it can be a pain to keep having to rethink your code structure.

Dynamically-typed code is often easier to extend and modify. I find that with statically typed code, if you start messing with a small part of your code, sometimes you have to rethink your entire class hierarchy. With dynamic languages, your code can handle quite a few changes before it gets to a point were you need to rethink the overall structure.

Re: The advantages of static typing, simply stated

#64
I think the concept of refactoring in dynamically typed vs statically typed languages is a double-edged sword comparison.

On one hand, refactoring code written a statically typed languages is less error-prone - But on the other hand, such refactorings tend to affect more code than those of dynamically-typed code.

Dynamically-typed code is often easier to extend and modify. I find that with statically typed code, if you start messing with your code, sometimes you have to rethink your entire class hierarchy. With dynamic languages, your code can handle quite a few changes before it gets to a point were you need to rethink the overall structure.

Re: The advantages of static typing, simply stated

#65
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…

> The purpose of a type system is to prove something about the code

The workaday purpose of these type systems is to write more of your intentions into the actual program code and get the compiler to enforce them on your behalf.

That may seem like a mere restatement, but the shift in viewpoint can give tangible benefits to someone who is new to ML-style languages and isn't convinced that making the compiler happy is doing them more good than the pain it's causing them.

Re: The advantages of static typing, simply stated

#67

I started programming with PHP and JavaScript (both dynamically typed) then I started writing games with ActionScript 2 (dynamically typed) then I switched to ActionScript 3 (statically typed), then I got into Java (statically typed) and later C/C++ (statically typed) - So I spent a lot of time with both. For the past few years I've been coding almost exclusively in dynamically typed languages - I did some Python (dy…

> some stuff

Cant't help thinking that that's probably something like 90% of code out there...

Re: The advantages of static typing, simply stated

#68

My disagreement starts with the beginning of this: "A large class of errors are caught, earlier in the development process, closer to the location where they are introduced." I would re-state this as: "A large class of errors are introduced, which otherwise would not exist." Consider dealing with JSON in Java. Every element, however deeply nested, needs to be cast, and miscasting leads to endless errors, elsewhere in…

In Haskell you can generate a parser to a typed structure using library combinators and code generation: data DataMessage = DataMessage { company :: Text } deriving (Show) $(deriveJSON defaultOptions ''DataMessage) data DataList = DataList { _data :: [DataMessage] } deriving (Show) $(deriveJSON defaultOptions { fieldLabelModifier = drop 1 } ''DataList) Which will fail properly when the data is malformed and in the re…

You can also generate the types and parsers from a data sample.

Re: The advantages of static typing, simply stated

#69
post #21

Earlier quoted context omitted.

Java is fine at decoding Json if you know what the fields are going to be. It's not like creating an object with the fields you want is very difficult and then libraries will deserialize it easily. It's also not hard to create a tool that will generate a POJO class from a string of Json. It doesn't really take time so the only problem is that it is yet another class on the classpath

"Java is fine at decoding Json " It does the job but it's not nearly as nice as javascript or python. It's about double the code in Java and it doesn't read nicely. I think it depends on what you're doing.

Java definitely makes it harder to work with json but the only problem I run in to is that I need classes (which I just autogenerate) for every json object. Serializing and deserializing json is a one liner once you have classes set up for them to deserialize into. Again, it is definitely harder than in Python and Javascript but I work with Java and json every day and it's generally only a huge difficulty if you need a strange edge case.

EDIT: also, java is bad at dealing with json if the api could return data in multiple different schemas and you don't know which one it is until you parse it but I've only run into this once and it's just bad API design.

Re: The advantages of static typing, simply stated

#70

I think the concept of refactoring in dynamically typed vs statically typed languages is a double-edged sword comparison. On one hand, refactoring code written in a statically typed languages is less error-prone - But on the other hand, such refactorings tend to affect more code than those of dynamically-typed code. If your business requirements change often and refactorings are common, it can be a pain to keep havin…

However if you're dealing with a language with type inference, you can get a good chunk of the ease benefits of dynamic languages.
Post reply on HN