News for hackers. Stuff that matters.
Re:Why Kotlin is my next programming language (2015) by dmichulke on Sunday June 19, 2016 @08:09AM (#11932703)
The underlying idea is that it shouldn't handle the wrong type at all, it should fail.

If some function A calls function B with a wrong type, the problem is with function A. So basically, there should be only type tests after IO functions (probably after parsing), the rest can be assertions.

Re:Why Kotlin is my next programming language (2015) by mac01021 on Sunday June 19, 2016 @08:37AM (#11932768)
And you don't need tests to make sure the assertions are there?
Re:Why Kotlin is my next programming language (2015) by dmichulke on Sunday June 19, 2016 @10:09AM (#11933012)
Interesting point :)

At some point you have to assume something is there and correct (e.g., you don't write tests to check whether the tests are there, also you assume the testing tools work, ...).

In static languages you also assume the programmer set the right type for the function argument, so you might as well assume to have an assertion in the critical code of the functional languages.

Re:Why Kotlin is my next programming language (2015) by bbcbasic on Tuesday June 21, 2016 @03:03AM (#11943969)
> At some point you have to assume something is there and correct

If you excel at compositional design then this may work OK but a lot of code bases I have worked on just need a good ol' refactor to sort the mess out. And then the "there and correct" part could fail due to human error, or the new person not knowing the old assumptions etc. The asserts are a step in the right direction in documenting the assumptions though. Types go one level better by both documenting the interface, and enforcing that contract at compile time.

Re:Why Kotlin is my next programming language (2015) by winstonewert on Monday June 20, 2016 @12:53AM (#11936120)
Do you need a test to verify that your compiler correctly checks the type signature? (Actually, that could be occasionally useful in the face of implicit conversions)
Re:Why Kotlin is my next programming language (2015) by bbcbasic on Tuesday June 21, 2016 @06:37PM (#11950016)
You can't get true 100% coverage* on digital hardware. (on quantum maybe!) so what to test or not is always a judgement call. Most of the time I'd assume the software stack is trustworthy but if you are doing something extreme you may want to test the compiler or even formally prove the compiler works as expected.

* true as in all possible inputs and outputs rather than merely all code paths

Re:Why Kotlin is my next programming language (2015) by winstonewert on Tuesday June 21, 2016 @07:38PM (#11950366)
Perhaps a better way to ask my question: do you write a test to make sure your type signature was correct?
Re:Why Kotlin is my next programming language (2015) by eropple on Monday June 20, 2016 @01:21PM (#11939477)
My compilers have test suites.
Re:Why Kotlin is my next programming language (2015) by winstonewert on Monday June 20, 2016 @04:32PM (#11941304)
And the compiler that generates the assert also has a test suite for that.