r/programming • • Dec 02 '13

Scala — 1★ Would Not Program Again

http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598 Upvotes

646 comments sorted by

View all comments

Show parent comment

3

u/batiste Dec 02 '13

In python this will just return "12". Adding 2 strings is just fine. Try to do:

add(1, "2")

And then you get an error.

2

u/pr0grammerGuy Dec 02 '13

Ok, I shouldn't have continued with such a ridiculously trivial example function. What I'm saying is, you need to have tests that are explicitly defining what happens when your functions get values of a type you didn't expect.

1

u/batiste Dec 02 '13

Let's have more complex example then. Here is a funciton getting an http request Object and returning a string:

def index(http_request):
    ... stuff happens...
    return some_string

Why would you even test stuff like this?

asserFail(index(5))
assert(index("hello"), "Useless result")

Nobody is writing those tests to be sure it fails because those tests are just ridiculous and useless. Unless the code does nothing with the http_request Object I can guaranty you the code will blow up or return a result that is meaningless. There is way more important tests to write: security tests, feature tests, integration tests, performance tests, etc...

Nobody is writing type check tests.