News for hackers. Stuff that matters.
Re:Clojure vs. The Static Typing World by taeric on Friday October 27, 2017 @12:35PM (#15569953)
The thing that baffles me on this is the idea that static typing is limited to something only the compiler can do.

If instead it was merely a form of static analysis, then it could easily be seen as something that can be added. Which, in many languages, it can be. The forms of analysis the advanced tools can give for C codebases is quite impressive. All without having to rewrite the system with more precise types.

Similarly with LISP. It is widely lauded as a very popular dynamic language. However, there is nothing stopping you from statically analyzing it. Obviously some practices make this more difficult, but sometimes just having an escape hatch for the developer is enough. Just as obviously, these practices that truly make it hard to analyze statically aren't used that often. That is, a decent sized program will almost certainly use the features in a few spots. But only a few and the majority of the code can still be analyzed easily statically.

Re:Clojure vs. The Static Typing World by moomin on Friday October 27, 2017 @01:13PM (#15570303)
This ignores the benefits that a type system can give you on top of correctness: autocomplete works better with types, so does automated refactoring. Compile-time polymorphism is lovely. Return type polymorphism is awesome.
Re:Clojure vs. The Static Typing World by guntars on Friday October 27, 2017 @01:59PM (#15570730)
I think the point is that programs written in a dynamically typed language aren't that dynamic most of the time. With static analysis, you're able to get at least some benefit from autocomplete and automatic refactoring. The parts of the code where it doesn't work - well, the developer has made the tradeoff that it's worth it there.

Sometimes I wonder why there aren't more 'empirically' typed languages, i.e., you write a function and some unit tests that exercise it and from that the compiler can determine what are the actual types and values the function sees for every variable.

Re:Clojure vs. The Static Typing World by taeric on Friday October 27, 2017 @05:43PM (#15572459)
That is mostly the point, yes. And I'll note that autocomplete is already challenged in a functional style, since you aren't always dispatching to methods of an object.

As an easy example, if you are looking for functions that can return a Foo, autocomplete does little to help you know that you have to call .convertToFoo() on any of the baz instances in scope. There is already more than just basic type mapping going on. (To that end, a graph traversal assuming shortest path from symbols in scope to the desired shape works. So it is doable, of course.)

To your question of "empirically typed", that is close to some of the stuff that more advanced tools can do. I liked showing folks that Coverity wouldn't just tell you that you forgot to check for null, but would show you how the null would get there from the call patterns. Quite impressive.

Re:Clojure vs. The Static Typing World by always_good on Friday October 27, 2017 @12:52PM (#15570110)
> there is nothing stopping you from statically analyzing it

Well, sure there is. Someone has to decide it's worthwhile to build it, then they have to build it, and polish it to a point where it's usable which generally means a community has to form around that tool.

Years of work.

Doesn't surprise me that people think it's more worthwhile to just use a statically-typed language.

Re:Clojure vs. The Static Typing World by taeric on Friday October 27, 2017 @05:45PM (#15572470)
That isn't stopping you from doing it. That is just making it more difficult.

But, and this is my point, this was effort that had to happen in creating the static languages, too. Just now we locked out the benefits to existing problems to problems that are rewritten in the new languages. Contrast this with hardening existing codebases by running enhanced tooling against them.

Re:Clojure vs. The Static Typing World by jahewson on Friday October 27, 2017 @01:04PM (#15570220)
The analysis tools for C codebases are quite impressive mostly because it’s a statically typed language which is amenable to such analysis.
Re:Clojure vs. The Static Typing World by taeric on Friday October 27, 2017 @05:48PM (#15572489)
I challenge that assertion. Some of the most impressive analysis of C is specifically on some stuff that is dynamic in nature. (In particular, showing just that you didn't check for null is easy. Showing how the null could get there takes effort.)

This also ignores some of the analysis for lisp languages. I know typed racket comes up every week for this topic. It didn't invent type checking for lisp, either.