Hacker News new | past | comments | ask | show | jobs | submit login

I've been writing a lot of Groovy recently, and it feels like Scala without type checking. That's not the worst thing in the world, I'd rather just use Scala. With Groovy, I get a lot of the expressiveness of Scala, but the lack of static type checking combined with Groovy doing its best to be magical is a recipe for bugs. For example, in Groovy, you can overload methods accidentally without a warning, which can create a hell of a surprise when somebody passes a null value. Rather than throw an error, Groovy dispatches the call to one of the methods even if neither one is more specific than the other.

There's also this classic bug:

    def printOne(Collection c) {
        if (c.empty) {
            print("Collection is empty")
        } else {
            print(c.iterator().next())
        }
    }
Can you spot the bug? This code works for all Collections... except Maps. If c is a Map, Groovy translates c.empty to c.get("empty"). Constantly having to be on my toes to avoid stuff like that is a pain.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: