News for hackers. Stuff that matters.
Re:Diminishing returns of static typing by flavio81 on Monday October 02, 2017 @12:11PM (#15385027)
>Not just, "who the hell uses this", but "where the hell is this defined" as well.

On Common Lisp, a dynamic language, I can also get this answered instantly. I just press a key combination on a method call and i jump to the definition.

So this isn't exclusive to statically typed languages.

Re:Diminishing returns of static typing by KMag on Monday October 02, 2017 @01:08PM (#15385688)
But if the compiler doesn't enforce that types are statically determinable, there will be cases where the tool will have to show you more potential definitions for function definitions than would be shown for a statically typed language.

Maybe good tools are able to perform some static analysis and rule out some of the methods with the same name but impossible types, but the language doesn't rule out situations where the best the tool will be able to do is show you all of the function definitions with the same name as the (dynamically dispatched) function call site you're looking at.

Let's say you have seven different type hierarchies having dynamically dispatched functions named "run", with 5 definitions in each hierarchy, for a total of 35 functions named "run". In a statically typed language, if the code compiles, it's possible to narrow down the type for a given call site to either one of the hierarchies or one definition, meaning you have to look at either 1 or 5 definitions. In a dynamically typed language, there are situations where legal code results in the tool having to throw up its hands and show you all 35 definitions.

The flip side is that if you really have a spot where you'll need to dispatch to any of the different hierarchies, then in a strong statically typed language, you'll need to either create an algebraic sum type covering all 7 hierarchies, or you'll need something like a typecase / typeswitch statement to enumerate out your possibilities.

Re:Diminishing returns of static typing by ubernostrum on Monday October 02, 2017 @01:52PM (#15386098)
there will be cases where the tool will have to show you more potential definitions for function definitions than would be shown for a statically typed language.

And even in a statically-typed language there will be cases where the tooling can only determine fairly generic things statically.

I don't see anyone advocating for abandoning static typing over that occasional limitation. Yet I do see people proposing similarly-infrequent issues as cause to abandon dynamic typing.

Re:Diminishing returns of static typing by jaggederest on Monday October 02, 2017 @02:29PM (#15386454)
When $problem happens to $language_I_prefer, it's an unavoidable difficulty that is easy to work around.

When $problem happens in $language_I_dislike, it's a clear sign that the language itself is inherently broken.

Re:Diminishing returns of static typing by caseymarquis on Monday October 02, 2017 @01:21PM (#15385817)
I had to do a decent amount of setup and wrote a quick script to run the tools which generate ctags to make this happen in CL using slimv. With top tier ides for static languages, this is built in from day 1 with no effort. You can't not have it. That said, a top tier repl for development is missing in languages like C#. I'd love to see that gap bridged.
Re:Diminishing returns of static typing by Eridrus on Tuesday October 03, 2017 @07:36AM (#15391664)
I think it's telling that while there are Lisp aficionados in this thread telling us how great it is, none of these ideas have been implemented in Python or JavaScript or Ruby, the most common dynamically typed languages.

And that's really all I care about, I'm not about to start writing production code in Lisp.

Re:Diminishing returns of static typing by dvlsg on Monday October 02, 2017 @05:20PM (#15388069)
You can even do this with Javascript, too. And without doc types. At least in vscode, anyways.

Well, usually. It gets a little confused when you start using dependency injection containers, or dynamic requires, or anything like that.

Re:Diminishing returns of static typing by Eire_Banshee on Monday October 02, 2017 @12:16PM (#15385080)
Lets be real, when we say dynamic languages, we aren't talking about niche languages like Lisp. We are talking about JS and Python almost exclusively.
Re:Diminishing returns of static typing by flavio81 on Monday October 02, 2017 @01:35PM (#15385946)
>Lets be real, when we say dynamic languages, we aren't talking about niche languages like Lisp.

How can it be a niche language, if it's an ANSI standard, has more than 8 or 10 fully feature, standard-conformant implementations, runs on most CPU types, and has been proven to work in production systems for spaceship guiding, worldwide airfare reservation and credit card transaction verification?

You use Js and Python because you choose to use it, but it's not the only choice. Not only Common Lisp, you could also be working in Clojure with many benefits.

Re:Diminishing returns of static typing by amirouche on Monday October 02, 2017 @12:35PM (#15385291)
Python has jump to definition too.
Re:Diminishing returns of static typing by catnaroek on Monday October 02, 2017 @01:10PM (#15385705)
Does it work in the presence and (ab)use of dynamic features? (e.g., when you have lots of decorated functions) Or is it just a best effort thing? (i.e., only works when your code would actually be expressible in a static way)
Re:Diminishing returns of static typing by fulafel on Monday October 02, 2017 @02:27PM (#15386442)
This is a continuum... in many statically typed languages there are regularly used paths that lead outside the realm of the language-defined type system as well. Consider dynamic class loading in Java, dlopen / reinterpret_cast in C++ etc.
Re:Diminishing returns of static typing by catnaroek on Monday October 02, 2017 @03:16PM (#15386982)
> This is a continuum.

It is not. A language feature is either amenable to static analysis (not necessarily type checking) or it is not.

> Consider dynamic class loading in Java, dlopen / reinterpret_cast in C++ etc.

This actually emphasizes my point. Features that are not amenable to static analysis are problematic for tooling.

Re:Diminishing returns of static typing by adamnemecek on Monday October 02, 2017 @12:39PM (#15385341)
You mean there’s an ide with that feature? It’s never as good as with any statically type language.
Re:Diminishing returns of static typing by markbnj on Monday October 02, 2017 @12:57PM (#15385557)
Sublime Text has this feature on hover, but I am fairly certain it is based on text search of the modules in the python path.
Re:Diminishing returns of static typing by hwayne on Monday October 02, 2017 @12:49PM (#15385455)
Have you tried it? It's usually pretty good for Python.
Re:Diminishing returns of static typing by steelbird on Monday October 02, 2017 @12:53PM (#15385503)
Which IDE?
Re:Diminishing returns of static typing by hwayne on Monday October 02, 2017 @01:13PM (#15385733)
PyCharm and VSCode are both pretty good.
Re:Diminishing returns of static typing by fulafel on Monday October 02, 2017 @01:06PM (#15385656)
There have been references to Clojure, Elixir, Smalltalk, Common Lisp in the comments here, what makes you think just Javascript & Python?
Re:Diminishing returns of static typing by yellowapple on Monday October 02, 2017 @01:54PM (#15386132)
It's worth noting that Elixir (by descent from Erlang) can emulate at least a basic static typing system pretty easily through pattern matching. You miss out on some features common in more traditionally-object-oriented languages (namely: subtypes), but tagged tuples and structs do provide a lot of the same safety benefits in runtime (and tools like Dialyzer can - last I check - use such pattern matching as a basis for static verification).
Re:Diminishing returns of static typing by nv-vn on Monday October 02, 2017 @05:51PM (#15388269)
Elixir and Erlang still lack the ability to typecheck any process behaviors because messages can take any type anywhere.
Re:Diminishing returns of static typing by yellowapple on Monday October 02, 2017 @09:01PM (#15389240)
You can still pattern match when receiving, though (in fact, 'receive' in both Erlang and Elixir does pattern matching already in the same vein as 'case'); just match messages based on a tagged tuple or a record (Erlang) / struct (Elixir) signature or however else you want to define your "types".
Re:Diminishing returns of static typing by hellofunk on Monday October 02, 2017 @01:56PM (#15386159)
Why would you say that? There are far more dynamically typed languages in widespread use than those 2!
Re:Diminishing returns of static typing by pvorb on Monday October 02, 2017 @12:39PM (#15385339)
IntelliJ/WebStorm is also pretty good at this (with JavaScript at least) by indexing a whole project and its dependencies. Refactoring doesn't work that well, though.