Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Apart from the differences in syntax, can Scala be considered a superset of Java that adds the functional paradigm to the object-oriented paradigm?

Or are there any major features in Java for which there is no direct Scala equivalent? With major features I mean program constructs that would force me to heavily rewrite / restructure my code, e.g., if I had to port a Java program to Scala. Or can I expect that, given a Java program, I can port it to Scala almost line-by-line?

share|improve this question
8  
Look at this article: What features of Java have been dropped in Scala? –  Robert Harvey Nov 1 '12 at 18:55
    
@RobertHarvey That should be posted as an answer :) Though the author was a self-admitted newbie when he wrote it, so there might be some omissions and mistakes (I'm a Scala newbie myself, so I can't tell). –  Andres F. Nov 1 '12 at 20:54
    
@Robert Harvey: Thanks for the link. With the term 'major features' I mean features that can radically influence the way in which you design a program. For example, I consider multiple inheritance a major feature, and the ++ (increment operator) a minor feature. My feeling is that, apart from some minor aspects, Scala is a super-set of Java, i.e. I can take a Java program and port to to Scala by rewriting it almost line-by-line (if I want to do so, even though Scala might offer better constructs). This is however a newbie feeling: I am a beginner with Scala. –  Giorgio Nov 2 '12 at 10:22
1  
I have no problem to delete this question if someone finds it does not belong in this site or if it is not formulated properly but I would appreciate whoever down-voted it to write a short comment explaining what is wrong with it. Thanks. –  Giorgio Nov 2 '12 at 14:58
    
@Robert Harvey: The link provides really good information. I have a feeling that I can use this document as a starting point for porting Java code to Scala. If you post it as an answer I will up-vote it. –  Giorgio Nov 2 '12 at 15:13
add comment

1 Answer

up vote 1 down vote accepted

I think it's not too much of an over-simplification to say, "Yes." Look at lambdas in Java 8 - they work almost exactly like they work in Scala now, but retrofitted to be backward-compatible with the way Java works now.

All the collections and most of the APIs in Scala are immutable by default which is a nice plus. I wish they would port that back to Java. The Java APIs are very inconsistent in regard to immutability. Make sure to check out Robert Harvey's link in the comments under the original question - it offers a much more detailed and nuanced answer to this question.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.