News for hackers. Stuff that matters.
Re:Static typing will not save us from broken software by DRMacIver on Sunday October 23, 2016 @02:12PM (#12774637)
> Being able to hit . and get a reliable list of things I can do is worth many millions of dollars to me.

...and mostly is possible because of the many millions of dollars that were thrown into developing it rather than the type system. Quality of tooling has much more to do with the amount of money invested in it than whether the language is statically typed.

But this isn't a post about static vs dynamic typing as I said right at the top. It's a post about the effect of static typing on software quality.

Re:Static typing will not save us from broken software by heinrich5991 on Sunday October 23, 2016 @02:24PM (#12774691)
Code completion is a fundamentally harder (if not impossible) problem with dynamically typed languages, as you might need whole-program and control flow analysis to even get the types of local variables. This fact has nothing to do with the money involved, it's probably rather another formulation of the halting problem.
Re:Static typing will not save us from broken software by DRMacIver on Sunday October 23, 2016 @02:28PM (#12774716)
> Code completion is a fundamentally harder (if not impossible) problem with dynamically typed languages

Code completion tools originally came out of Smalltalk. It's relatively doable if you can attach to a running process that has dynamic access to your code.

So that's "not necessary". It's also not sufficient: Most statically typed languages simply don't have this sort of tooling because it's very hard to write, and advanced type systems make it even harder.

Re:Static typing will not save us from broken software by overgard on Sunday October 23, 2016 @02:40PM (#12774773)
Most Smalltalks didn't really have great code completion (or code completion at all), and when they did, a lot of it had to do with the verbosity of method signatures removing a lot of ambiguity. Don't get me wrong, Smalltalk has some really cool features, but they did it by having a workflow completely different from static languages, and trying to imitate Smalltalk's environment in a language not designed from the ground up for it (ie, python or perl or whatnot) would be a lot harder. The fact that it's hard to write language tools in general doesn't change the fact that it's way harder to write an IDE for a dynamic language than it is for a static one.
Re:Static typing will not save us from broken software by DRMacIver on Sunday October 23, 2016 @03:04PM (#12774883)
> Most Smalltalks didn't really have great code completion (or code completion at all),

Ditto most statically typed languages.

> The fact that it's hard to write language tools in general doesn't change the fact that it's way harder to write an IDE for a dynamic language than it is for a static one.

It doesn't, but the fact that there's nearly as much variation within statically typed languages in terms of how difficult this is to do as there is between statically and dynamically typed languages does. And this only gets worse as we move to the sort of languages that the static-types-for-correctness people advocate for.

Re:Static typing will not save us from broken software by overgard on Sunday October 23, 2016 @03:20PM (#12774973)
> It doesn't, but the fact that there's nearly as much variation within statically typed languages in terms of how difficult this is to do as there is between statically and dynamically typed languages does.

I really don't buy this. Yes different languages present different degrees of difficulty, but the ceiling is much lower for dynamic languages compared to static ones. In dynamic languages, there are absolutely (very common) situations where types cannot be accurately inferred (or inferred at all). If I write

   def f(x, a): return x[a]

That's practically impossible for an IDE to do anything with.

The reason why not every static language has great tool support is more to do with A) if the compiler was designed with hooks/apis for tools to use (like clang and rust do), and B) if the language has enough popularity for anyone to bother. I'm pretty sure if you take two languages of relatively equal popularity, and compare the dynamic one to the static one, the static one almost always has better IDE/tool support. For instance, lets take Swift vs Ruby (they're next to each other on the Tiobe index). I've yet to see a Ruby IDE that is much of an improvement on a text editor, whereas Swift is pretty young and already has tooling comparable to much more mature languages.

Re:Static typing will not save us from broken software by pmontra on Sunday October 23, 2016 @04:32PM (#12775289)
You're right. I autocomplete Ruby with pabbrev in emacs. Basically it remembers what I wrote and suggests me the strings that match the prefix I'm typing. It's great and more that enough. It can't know the number of arguments I have to pass but it rarely matters. All I usually code in Ruby are Rails apps and they are pretty simple, even the ones with dozens of routes and models. Furthermore the location of classes and files is very predictable. There is no need of an IDE to navigate through the code. I came to think that if a language or a framework needs an IDE there is something wrong with it that the IDE must fix.
Re:Static typing will not save us from broken software by Oreb on Monday October 24, 2016 @06:46AM (#12777796)
> I've yet to see a Ruby IDE that is much of an improvement on a text editor, whereas Swift is pretty young and already has tooling comparable to much more mature languages.

I've never worked with Ruby, but I do work with (and mostly enjoy) Swift. The one thing I really don't like about Swift is that the currently available tooling (both AppCode and Xcode) is extremely primitive compared to what I am used to from Common Lisp and Clojure.

Re:Static typing will not save us from broken software by overgard on Monday October 24, 2016 @11:15AM (#12779533)
Anecdotal data point of one guy's opinion, with no elaboration on reasons? Convincing. I'm talking about WHY analyzing dynamic languages is fundamentally undecidable in many cases without run time knowledge. Trying to do anything other than heuristics on some of these things is about as decidable as the halting problem. The only argument I've heard against this is you can have a hybrid environment with a REPL so your dead code is live. Ok, but you can do the same thing with static typing too.
Re:Static typing will not save us from broken software by steveklabnik on Sunday October 23, 2016 @04:18PM (#12775224)
That function looks like this in Rust: https://doc.rust-lang.org/std/ops/trait.Index.html (it's heavily generic, it could be slightly less verbose if it didn't have to handle Sized)

The compiler will errr if x isn't indexable, or if it is but not by the type of a, in terms of your function's names.

Re:Static typing will not save us from broken software by mpweiher on Monday October 24, 2016 @04:43AM (#12777403)
The reason Swift has tooling is that it has a $600 billion company paying for that tooling. Said tooling plugs into Xcode/clang, which is an IDE for, primarily, Objective-C, which happens to be a dynamically typed programming language (with optional static typing).

For my own Objective-Smalltalk, I added code-completion to both the REPL and a few IDEs fairly trivially.

Re:Static typing will not save us from broken software by overgard on Monday October 24, 2016 @11:09AM (#12779463)
Jetbrains has a Swift IDE, and they're not a $600 billion company.
Re:Static typing will not save us from broken software by crdoconnor on Sunday October 23, 2016 @03:20PM (#12774972)
>Code completion is a fundamentally harder (if not impossible) problem with dynamically typed languages, as you might need whole-program and control flow analysis to even get the types of local variables.

This pre-supposes that you don't have a test to run the program, because if you do you can just embed an interpreter in it and you have access to everything - tab completion included.

IMO This approach is partly what made IPython notebooks so spectacularly successful, and the future of dynamic language programming will look something like that.