News for hackers. Stuff that matters.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by massung on Saturday June 15, 2019 @11:03PM (#20193595)
I enjoy hacking in dynamic languages as much as the next programmer. But, the big take-away is that "the initial implementation was done in 1/2 the code" not that the resulting code was more extensible or maintainable (by other programmers!).

> You might say that surely that additional cost would be compensated in reducing the cost of maintenance later. Maybe but I'm not sure.

I am sure. 100%. From many years of experience.

Yes, static types come at an initial cost at initial development time. But they pay that time back in spades. This is exponentially true the larger the code base is (more to keep in one's head), the longer the project lives, and the more people are on it.

Having worked on very large C/C++, Scala and Python projects, when it comes to add a major feature or perform a serious refactor, I always want the static typing and the compiler to inform me when I've missed something. Far too many times has code been checked into a large Python code base that breaks something (completely unbeknownst to the programmer), because there's a code path that's rarely executed or arguments to a function flipped, etc.

That all said. There are major benefits to being able to prototype very quickly in a dynamically typed language, too.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by hermitdev on Sunday June 16, 2019 @02:34AM (#20194146)
Lately I've been doing a lot of greenfield development in Python, developing libs for in house use at my employer. We're using 3.7 currently, and I've fully embraced type hints. With proper type hints and use of pylint, you get the static checking that you'd otherwise miss. Bonus, if you're using an IDE like PyCharm, VS code or visual studio, you usually get the linting for free either as you type or on save.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by lozenge on Sunday June 16, 2019 @06:01AM (#20194764)
Pylint is not designed to be a thorough type checker, you should take a look at mypy or pytype.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by AtHeartEngineer on Sunday June 16, 2019 @02:58AM (#20194213)
I very much agree. Type hinting for everything into and out of a function, and you're in pretty good shape.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by iLemming on Sunday June 16, 2019 @07:12AM (#20194946)
There are not too many dynamically typed languages that truly allow you not to miss static typing. One of them is Clojure. I can't explain exactly how, but somehow I think Clojure is fine without them. I don't think I can say the same thing about JS, Lua, Python or Ruby.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by yakshaving_jgt on Sunday June 16, 2019 @07:32AM (#20194996)
I spent a couple of years working in a Clojure shop with people who actually like Clojure, and the experience for me was not so practically different than if everything had been written in Ruby (and indeed, half the codebase was a legacy RoR system).

You either have a type-checker and compiler, or you don't.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by iLemming on Monday June 17, 2019 @05:55PM (#20207769)
Was it before Spec? In my experience - wise use of Clojure.Spec makes a big difference.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by yakshaving_jgt on Tuesday June 18, 2019 @05:25AM (#20210941)
They used Spec. Indeed wise use of a tool like this does make a difference, but then the onus is on the developer to be disciplined enough to apply it appropriately. Humans do not by default have this discipline.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by danmaz74 on Sunday June 16, 2019 @04:01AM (#20194402)
When thinking about extending and refactoring, you also need to keep in mind that static types add a whole layer which is pretty hard to change. There are advantages and disadvantages, having at static types isn't such a silver bullet.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by wokwokwok on Sunday June 16, 2019 @05:47AM (#20194711)
Hm... well that might be true for extending, I'm not sure you've fully thought through that comment.

Duck types are great for writing new code, but they're very troublesome for refactoring; automated tools have a much harder time automating that process.

Refactoring data structures and implementations in static type systems is bother considerably easier to implement than in dynamic languages, and resultingly, more robust.

Certainly the refactoring tooling these days is pretty sophisticated with type inference, but... well, I've refactoring large python and javascript code bases, and my experience has been that absolutely a static type system makes that process easier, even if you have a comprehensive test suite.

I think it's worth acknowledging that there is a place for static type systems; certainly, it's not a silver bullet, and it results in (usually) a higher lines-of-code count, which is significant; but its naive and wrong to suggest that it has no value at all.

Specifically, for refactoring, it has a lot of value.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by pdimitar on Wednesday June 19, 2019 @01:33PM (#20225302)
To be fair, in languages as terse as OCaml, even the bigger line count isn't a given.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by Lorkki on Sunday June 16, 2019 @04:51AM (#20194574)
So do all the implicit assumptions in duck-typed code, but following them relies fully on the programmer's own caution.

You can of course add explicit checks and tests, eventually paying the same amount (or more) in LOC as the typed implementation's initial cost, but then you're also tasked to keep those up to date, without the compiler's aid.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by jlg23 on Sunday June 16, 2019 @04:40AM (#20194530)
The solutions to these problems in "extending and refactoring" are the same in dynamically and statically typed languages because in both you have to make sure functions/methods get the correctly typed input and return some expected type as output. In both worlds you will either refactor everything, abstract the problem away with interfaces or union types or you'll do type conversions at the boundaries of the code you touch.

That layer is there anyway, except for your interpreter of a dynamic language only knows about problems at run-time, while the compiler that checks a static type system will tell you at compile-time.