开发者

What are the best features of Scala? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I can say that I really love Scala but now I would li开发者_开发问答ke to know the features you cannot live without when working with Scala? What about Scala 2.8?


If I had to go back to Java here's what I'd miss the most: closures, higher order functions, pattern matching, case classes, and the emphasis on immutability.

I've been on 2.8 for a while. If I had to go back to 2.7, the main thing I'd miss is the consistency, cleanness, and richness of the 2.8 collections API. It's waaaaaay better the 2.7 stuff. But I'd also really miss named and default arguments.


Type inference saves so much pointless typing. map and foreach and the like on collections are great, especially in combination with default-lazy iterators and really easy function syntax.

But, as someone who does a lot of scientific computing, what I'd actually miss the most is being able to write high-performance code, wrap it in efficient classes, and then use maps and mathematical operators (+, *, whatever) to manipulate those high-level constructs the way that I actually think about them.

As for 2.8 vs. 2.7--the improvement is pretty incremental from my perspective. It's a little better in many areas; there's little to point to and say, "Oh wow, that!". I expect the new specialized annotation will help me a lot, but I haven't seen it fully in action in the library yet, so I'm withholding judgment.


I enjoy writing in Scala. That's the #1 feature in my book :)

I can just get on with what I want instead of dancing through Java's hoops:

  • val/var means I don't have to write the type twice
  • Closures mean I don't have to write lots of anonymous interfaces and can re-use lots more code
  • Named parameters mean I don't have to remember the position of each argument - great for both reading and writing
  • Case classes mean I get toString and equals for free... makes debugging far easier!
  • A decent API for collections (e.g. map, fold) mean that I can say what I want to do instead of dancing the iteration dance

As for 2.8 vs 2.7... I've only ever really spent quality time with 2.8 ;-)


I think it is not a feature but the conciseness which Scala achieves is what I like the most.

This is of course only possible because of type inference, closures, a great type system etc. I just do not think you can break it down to one or two features. They work together and the result, concise code, is what I would call the killer feature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜