News for hackers. Stuff that matters.
Re:Ask HN: Who regrets choosing Elixir? by neilwilson on Saturday May 23, 2020 @12:22PM (#23284189)
Type systems are really a set of comprehensive tests you don't have to write yourself that cover a subset of the things you need to test for.

Static languages fell out of favour last time round the dynamic/static merry-go-round because the typing started to get in the way. You ended up writing more type boilerplate than actual code - and not breaking your methods/functions down into smaller functions to avoid having to write out even more type boilerplate.

I often wonder whether type annotations that allow a processor to generate tests that can integrate into your test suite would be a useful thing to have. Sort of like a C preprocessor.

Then you could add ML type headers to Elixir functions and get a set of ExUnit tests back.

Re:Ask HN: Who regrets choosing Elixir? by 59nadir on Saturday May 23, 2020 @12:28PM (#23284243)
> I often wonder whether type annotations that allow a processor to generate tests that can integrate into your test suite would be a useful thing to have. Sort of like a C preprocessor.

We already have this in things like `Arbitrary` type classes, `QuickCheck`, `Hedgehog`, etc.. Hundreds of automatic test cases generated so that you don't focus only on "I thought of these 5 test cases" type of testing.

There is a PureScript compiler called `purerl` for the BEAM which can be used to write BEAM code in a ML derivative. It works and I personally would use it if I had to deliver BEAM code next week. For the most part it's the answer to the "you can only write BEAM code in bad languages" issue.

Re:Ask HN: Who regrets choosing Elixir? by kerkeslager on Saturday May 23, 2020 @01:00PM (#23284523)
> Type systems are really a set of comprehensive tests you don't have to write yourself that cover a subset of the things you need to test for.

Maybe in a very strongly-typed language, but having used a pretty wide variety of statically-typed languages, I can confidently say none of them had strong enough type systems that the assertions made by the type system could be considered "comprehensive". You still need a test suite.