Hacker News new | ask | show | jobs
by FLUX-YOU 3530 days ago
>My last job was in C#, and it seemed like so many things were stringly typed, entirely nullable, or used something else to weaken the type system.

I see this happen when a bad database design was born before the C# code, e.g. varchar NULL types everywhere.

1 comments

That does happen, but I think the issue is more with education around using types. A lot of people nowadays spend a few years in python/js/java/etc before they have the chance to spend time in a community that really embraces types as the fundamental design tool. Also, it is hard to see the benefits of good typing if my first statically typed language is Java and I'm constantly told to cast into and out of Object. So, I put a lot of blame on the way people are taught to program. People tend to have a pretty hard time uprooting years of experience.
Could you offer a learning path for one with experience in js/python?
I don't know if i could offer a "path", but here are a few ideas to try out:

1. Start using hypothesis or jsverify. 2. Play around with Elm. 3. Participate in a community that highly values types.

## Properties vs Types

Just to explain a bit, types and properties are about program correctness. So they serve the same purpose for us. Types are essentially properties that your type checker can prove for you. Sometimes it is hard or impossible to prove something, so you might reach for property based tests to "approximate" the proof.

So when I'm thinking about my code correctness: 1. write a type where I can 2. write a property where I want to write a type 3. write examples to keep me grounded

Property based testing frameworks will help you move up that ladder.

## Elm

Of course, it will also be helpful to start actually leveraging a type system. I think Elm is a good option for people who are new to using types this way. It has a powerful, but relatively simple, type system that can help you learn good type design without having to deal with all of the features that Haskell/Scala/Rust/Ocaml/etc would have. Also, it has pretty great compiler error messages. So it should be less intimidating than a lot of nearby options.

## Community

Community might be the most important element. Participating in a community that values types (again, I suggest Elm) will be a great investment. Downloading Elm and a property based testing library could be a recipe to feel overwhelmed. Be sure to have a slack channel/mailing list/irc channel ready to help you when you start to feel overwhelmed.