r/programming • • Feb 22 '15

Java Makes Programmers Want To Do Absolutely Anything Else With Their Time

http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35 Upvotes

636 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Feb 22 '15

Variable name, Colon, Variable Type is stupid and forces me to type an extra colon all over the place, which is contrary to their usual design pattern of "remove unnecessary bloat" like semi-colons

Like "val x = List(1, 2)"? Or "val rand = new Random()" What semicolons? :D

...using the .AsInstanceOf[Type] method...

implicit class As(a: Any) { def as[T] = a.asInstanceOf[T] } // Problem solved

5

u/azth Feb 22 '15

Like "val x = List(1, 2)"? Or "val rand = new Random()" What semicolons? :D

I presume he's referring to

def foo(x: Int, y: String): Bar

though I personally prefer having the colon there as it is a visually distinctive marker.

0

u/btchombre Feb 22 '15

I find the colon does nothing for me. You could use the same logic to say that Scala should mandate semi-colons at the end of statements as a "visual marker". I love that they made the semicolon optional, but then they just replace it with an equally redundant colon. It's not needed at all and makes the code visually more complex than it could to be.