Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Mate, you should learn Scala before writing about it...

scala> def hasUppercase(s: String) = s.exists(_.isUpper)

hasUppercase: (s: String)Boolean

scala> hasUppercase("Charlie Brown")

res2: Boolean = true

scala> hasUppercase("schmuck")

res3: Boolean = false



From TFA:

Please note that, below, when I refer to a multi-paradigm language, such as Scala, as an OOP language, I am specifically referring to the OOP qualities in that language. And I would like you to ask yourself, if you use a multi-paradigm language to write in the “functional” paradigm, are you actually gaining anything from the OOP qualities of that language? Could you perhaps achieve the same thing, more easily, using a language that is fundamentally “functional”, rather than object oriented?


Yes, isUpper is a method on Char, _.isUpper is a lambda that is given to exists, which is a method on the trait TraversableOnce, which String happens to implement, along with many other things, such as Option and Future. Where's the OO and where's the functional? In the Clojure example in the OP does the author realise that all of those things are in effect Java objects? Does any of this make the code better or worse?

But that's not the point, the Scala code provided there is beyond ignorant, whoever wrote that has no right to be judgemental of the language or its founding paradigms.


> are you actually gaining anything from the OOP qualities of that language

Yes.

> Could you perhaps achieve the same thing, more easily, using a language that is fundamentally “functional”, rather than object oriented?

No.

(That was easy. :-D)


This blew my mind. The "scala" example he used was literally a java code snippet pulled from here http://batsov.com/articles/2011/05/12/jvm-langs-clojure/

IT'S LITERALLY JAVA SYNTAX, COMPLETELY INVALID SCALA.




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

Search: