• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scala type system

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
Are Guido and Steve thoughts correct regarding Scala and its typing system?
http://neopythonic.blogspot.com/2008/11/scala.html
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a hard to answer for someone else. I can only say that it hasn't been a problem for me, but I rarely wade into the deep end of the type system pool. It is more complex than Java's type system, and the type guru's can do some weird tricks with it. Sometimes I'll look at a message on the scala-user mailing list and think, "What on earth is that supposed to do?" But those messages usually only come from a few people who really enjoy diving into the hairier parts of the type system. The majority of the time, I just let the type inferencer work its magic.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The trade off is that Scala's type system allows one to do things which are absolutely not expressible in Java. The critics will argue, "We've been expressing our types just fine in Java, if Java's type system doesn't have it that's because it doesn't need it." Which may be true, but some things sure are nice when you learn how to use them.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer the static typing of Scala or Java above the dynamic typing of Python or Ruby, especially for larger, non-trivial software projects.

I've never written a large project with a dynamically typed language, but I can imagine it would become a mess if you'd have to keep in your head all the time what type of data is supposed to be in each variable, and the compiler doesn't do anything to help you. It would be really easy to make mistakes. Proponents of dynamically typed languages say that you just have to write unit tests, but think of all the unit tests you don't have to write if the compiler checks the types for you. I'd rather have the safety of static typing than having to write lots of boring unit tests.

Scala's type system seems more complex than that of Java, but it is also more powerful and better implemented. When I learned about how generics and for example variance annotations work in Scala, I understood better what the issues are with Java's implementation of generics.

And it isn't so that the complexity of Scala's type system is inevitable - the basics are just as easy as Java, and you're not forced to use the more advanced features.
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scala's type system is not trivial (there's a very nice explanation on Programming Scala: The Scala type system ), but is powerful and expressive.
On the other hand, is no surprise that Guido (creator of Python) and Steve (who pushes JavaScript as the "Next Big Language") came against Scala's type system: they're promoters of dynamic typing languages, clearly they would not like a static typing one!
I'm pretty sure that some fans of Haskell would consider Scala's type system "not complex enough"
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic