Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Dialyzer is fully integrated into Elixir, yes. But again, it’s optional typing.


Dialyzer also takes a while to get used to and for several teams I've been in the initial cost of learning turned out to not outweigh the theoretical savings won by it.

There are other more modern libraries that defer the errors to runtime but also make them much more clear (like `norm`). Libraries like `boundaries` can also help you enforce, a-hem, boundaries in your code and making sure that you write less spaghetti code.

I personally stick to Dialyzer in personal projects but it's an uphill battle to constantly keep it happy while OCaml / Rust / Haskell will just immediately yell at you with a well-described error (well, Rust anyway, the other two can be vague sometimes).


I know how to use Dialyzer and am quite proficient with it. I cannot say, however, that it helps me in any way. I think strong typing is a crutch for bad programmers and I've yet to encounter anything in my 30+ years of programming to change my mind.


There are type systems out there that allow you to model more than "is a string, is a float, is an int".

There are CVEs for use-after-free bugs in Firefox, IE, the Linux kernel and more. Rust's type system helps prevent those. There are CVEs for double-free bugs in OpenSSH, OpenSSL, and Kerberos. Again, Rust's type system helps prevent those. There are CVEs for null dereferencing in the Linux kernel, CUPS, and OpenSSL. Many languages have type systems that help preventing those.

There's many more classes of bugs that can be prevented by judicious use of robust type systems. Dismissing strong, static typing as "a crutch for bad programmers" is just plain wrong.

All of this, of course, assumes the only use for static types is preventing issues. Algebraic data types actually allow you to write simpler, more concise code in languages that support them. Typeclasses make for a whole model of polymorphism that's just incredibly painful to implement in languages that don't support them.


> Dismissing strong, static typing as "a crutch for bad programmers" is just plain wrong.

No, it's correct. The problem is that innocentoldguy doesn't realize that he is a bad programmer. (That's not an attack on him - we all are bad programmers.)

So here we are, bad programmers. Here's this crutch - or, less negatively put, here's a tool that can help. Maybe we can be somewhat better bad programmers if we use it.


I get your point, but if we're all bad then "bad" loses its meaning. I'm definitely a better programmer than many of my peers, and worse than a whole bunch of others.


We're bad, not in comparison with each other, but in comparison to the external standard of "good enough that we don't need a crutch".

In fact, if you want to be a better (less bad) programmer, learn to use the available crutches more effectively.


Well, it's a bit like saying that computers of the electronic kind are a crutch for bad computers of the human kind.

Or that planes are a crutch for bad travelers who can't fly under their own power.


There's two sides to it:

First, there's only so much I can hold in my brain at once. If the computer can do some of the tedious busy work, let it.

Second, the first perspective talks about catching errors and oversights. A sufficiently non-bad programmer could make do without. But static typing also allows for some programming techniques that wouldn't work without.

As a silly example, Haskell makes heavy use of overloading-by-return-type. You just don't the information about what return-type is expected available dynamically, it needs to be static.

There's also lots of optimizations that are safe only when the compiler knows more about your code. (Of course, a sufficiently non-bad programmer could write directly in the machine language of every processor she's writing code for..)

In practice, typing helps me a lot with eg exhaustiveness checking for my pattern matches.

The type system that dialyzer exposes is pretty weak. So not a good standard to measure all of typing against.


Strong typing can be a crutch for bad programmers in the same way that a prosthetic leg can be a crutch for an amputee.

The world record 100m men's sprint for double-leg-below-the-knee amputees is now frozen at 10.57s (record set in 2013); omitting Usain Bolt who is clearly freakishly good even among world-class sprinters, the 100m world record is 9.74s.

I am very happy to use strong static type systems.


That depends on what kind of software you have worked on. I also got quite far with dynamic languages in the last 10 years but at one point the static strong typing helps you a lot in making invalid state impossible at compile time.

Growing complexity kind of mandates a static strong typing at one point. Sure, complexity can be managed and reduced -- and distributed among smaller projects (i.e. splitting big projects) -- but even that has a limit.


Dialyzer solves certain problems for me that still exist in many "typed" languages. A great example is pos_integer(). In something like Typescript I can use "number", but that doesn't assert I can't receive a negative number, or a zero.


In general, you'd need something like dependent types for solving this properly. Like eg Agda has.


Ada has this without general dependent types AFAIK


Yes and no. The definitions are in the type system, but the checks are done at runtime, just like you would do manually. You don't really get the benefit of typing.

The reason I can say that: you don't have to provide proofs that a value has to be positive to get things to compile.


Checks at runtime are also a good idea, but yes, very different from static dependent types.

There's some interesting work on making such contracts work well in a lazy language with higher-order functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: