Live data from Hacker News

Is Typed Clojure worth the trouble?

blog.juxt.pro

31–40 of 62 posts

Re: Is Typed Clojure worth the trouble?

#31
post #14

Earlier quoted context omitted.

The problem is the overhead in adding typing. The time taken to learn the type system is a one-off but static typing has running costs in slowing down development, discouraging exploratory programming, extra cognitive load in reasoning about the type system, and "false positives" in disallowing otherwise correct programs. It does nearly eliminate a class of bugs - this is wonderful, but the bugs it does eliminate ten…

Do you have any evidence to prove this? I've read a few papers that disagree with your opinions...

That's the thing though, there are lots of papers that support both sides of the argument out there. For example, take this http://macbeth.cs.ucdavis.edu/lang_study.pdf large scale study of GitHub projects. In the study, Clojure is right up there for correctness with hardcore statically typed languages like Haskell.

There's plenty of software written in both typing disciplines in the wild. Yet, nobody managed to conclusively demonstrate that software written in statically typed languages is produced faster and with less overall defects or that it has lower maintenance cost. The very fact that we're still having these debates says volumes in my opinion.

Majority of arguments regarding benefits of static typing appear to be rooted squarely in anecdotal evidence.

Re: Is Typed Clojure worth the trouble?

#32
post #22

Earlier quoted context omitted.

I believe ClojureScript only supports boolean type hints/performance optimization. Other type hints are "supported" but don't do anything.

Yeah. They are not really necessary in a Javascript VM that is optimized for these sort of languages anyway.

This is not entirely accurate, the ClojureScript compiler actually internally propagates type information for further optimization. And nothing precludes a Typed ClojureScript which feeds even more information to the compiler.

Re: Is Typed Clojure worth the trouble?

#33
post #20
post #14

Earlier quoted context omitted.

Do you have any evidence to prove this? I've read a few papers that disagree with your opinions...

Probably based on personal experience. For me, whenever I start a project from scratch I usually start with the most dynamic environment I can find, then hack away until I have something that resembles the functionality I need, before locking it down. In the beginning of a project I don't care if something is 100% correct, I just want to see what my idea looks like, and what I actually need. I don't want to deal with…

Don't know why people are downvoting you, your approach is perfectly valid.

Re: Is Typed Clojure worth the trouble?

#34
post #27
post #25

Earlier quoted context omitted.

By that logic, most object oriented languages like Java, C# and C++ are fundamentally flawed as calling a method only works most of the time. Besides, code in general only work most of the time. Static typing does not protect you from bugs.

I didn't call anything flawed, fundamentally or otherwise; but I take your point. I think that there is an important distinction between 'almost-there' solutions. Suppose that you have a piece of code that is specified to work in a certain way. Because code, and the hardware on which it runs, is made (at least indirectly) by humans, it will fail under some conditions; it only satisfies its specification. I think that…

Oops, I an important word out:

> Because code, and the hardware on which it runs, is made (at least indirectly) by humans, it will fail under some conditions; it only satisfies its specification.

This sentence was supposed to end "it only satisfies its specification some of the time." I was not going for Knuth-ian irony about proving vs testing (https://en.wikiquote.org/wiki/Donald_Knuth#Sourced).

Re: Is Typed Clojure worth the trouble?

#35
post #29
post #26

Earlier quoted context omitted.

> Static typing does not protect you from bugs. But it does. It doesn't protect you from all bugs, but nobody claimed it did.

True, should have specified what I meant. The thing is, static typing doesn't necessarily protect you from more bugs than a dynamic language. For instance, Clojure is less prone to NPEs because you don't call methods on objects, and because a lot of your program manipulates datastructures, and nil is treated as an empty datastructure. Of course, a language like Rust, which doesn't have null, does protect against NPEs…

Reading this again make me realize that I'm wrong. Static typing will safeguard you against certain types of bugs that a dynamic language don't. The point I was trying to make was that a static language doesn't necessarily protect you against a certain type of bug, which you may rarely experience in a dynamic language.

Re: Is Typed Clojure worth the trouble?

#36
post #23
post #13

I am impressed by the fact that Typed Closure is a lot of things in addition to language design -- library development, editor/tool development, even community engagement and evangelism. > Clojure codebases typically rely on tests to verify the correctness of the code. OT, but this is a pet peeve of mine. Tests aren't verification, and they cannot demonstrate correctness (without being exhaustive). Clojure codebases…

> Tests aren't verification, and they cannot demonstrate correctness (without being exhaustive). Agreed, but it's important to note that there's very little that can demonstrate correctness. Most type systems by themselves don't; as Pierce describes it in TAPL, "[a] type system is a syntactic method for automatically checking the absence of certain erroneous behaviors" (emphasis mine). It's possible that, in a depend…

It's difficult to demonstrate full functional correctness. However, it is pretty easy to demonstrate partial correctness. Most tests -- even if they were completely exhaustive -- correspond to partial correctness rather than functional correctness.

Re: Is Typed Clojure worth the trouble?

#37
Doesn't Clojure already have optional static type annotations like Common Lisp? I thought it did when I looked through the tutorials.

In Common Lisp you can define pretty much any type (with deftype), you can define algebraic types and even value dependent types. Once you add full type declarations to your code, you will get warnings for inconsistent and violated type declarations.

Re: Is Typed Clojure worth the trouble?

#38
post #3

Earlier quoted context omitted.

That's nonsense frankly. I've worked with an excellent team of Haskellers before I don't think we'd have been anywhere near as good without the type system. I'd agree that having an awesome team gives you a lot of other advantages, and actually FP is a huge opportunity to build that team for start ups. FP tends to attract the kind of people who make up a great team. It's for this reason that I think the conclusions o…

I'd agree that having an awesome team gives you a lot of other advantages, and actually FP is a huge opportunity to build that team for start ups. FP tends to attract the kind of people who make up a great team. Yes, absolutely. It's amazing how overlooked this fact seems to be, by many. Languages aren't that hard to learn, so excluding the really awful ones (e.g. Java for anything other than code that has to be on t…

Why is Java one the of really awful ones? I know Java is not the best language, it's not my favorite language, but I wouldn't say its really awful.

Re: Is Typed Clojure worth the trouble?

#39
post #4

Type checkers are an automated solution for the problem of not having good teammates. If you don't have that problem you won't benefit that much from type checking and might have many other huge advantages.

that is static typing FUD. if it takes you a few days or weeks to learn to use the type checker and it saves you from expensive runtime errors later, then whats the problem?

More like its FKF (Fear of the Known and Familiar). Most (if not all) programmers have experience with static typing and most of those experiences were not pleasant hence why a lot of people don't like static typing. People start to hate it even more when it gets shoved down their throats i.e. "You must absolutely must use static typing otherwise your software is unreliable and buggy".

Static typing requires discipline, it is no magic cure for bugs which will automatically make your programs correct, same way forcing everything to be in class in Java does not automatically make readable, modular and reusable code, its just restrictive and annoying.

The disciplines required for static typing to be effective can be employed in dynamic typing however merely having a static type system does not mean the discipline will be developed. In order for a static type system to not be restrictive (like Java's or C++'s) it has to be flexible i.e. it has allow types of varying degrees of vagueness. If I am an inexperienced programmer with no discipline nothing stops me from picking the vaguest type possible and making a complete mess. Type errors do not prevent all bugs, in-fact they prevent only a minimal subset of bugs, most bugs are related to logic errors involving an ill-thought out algorithm or data errors related to invalid data provided by the user which often can only be caught by dynamic type systems.

Re: Is Typed Clojure worth the trouble?

#40
post #38

Earlier quoted context omitted.

I'd agree that having an awesome team gives you a lot of other advantages, and actually FP is a huge opportunity to build that team for start ups. FP tends to attract the kind of people who make up a great team. Yes, absolutely. It's amazing how overlooked this fact seems to be, by many. Languages aren't that hard to learn, so excluding the really awful ones (e.g. Java for anything other than code that has to be on t…

Why is Java one the of really awful ones? I know Java is not the best language, it's not my favorite language, but I wouldn't say its really awful.

Two words: no functions.
Post reply on HN