- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Yammer moving away from Scala
I'm surprised I haven't seen this mentioned by now:
Email critique of Scala: https://gist.github.com/1406238
A sample new story on it: http://www.infoq.com/news/2011/11/yammer-scala
It's a very detailed email from an employee at Yammer on why they are
migrating from Scala back to Java. I know it was intended to be private,
but it's gone public now, and there's nothing personal in the email anyways.










Re: Yammer moving away from Scala
Here is a follow-up that puts it in perspective: http://eng.yammer.com/blog/2011/11/30/scala-at-yammer.html
I hope that some good will come out of this. For example, it's no good if a company has a coding rule that says "use var i = 0; while (i < n) { ... i += 1 } instead of for (i <- 0 until n)" That should be a standard optimization, not one that requires a special flag. I don't think it's rocket science to address this. Ditto with the performance of the hash map. It should not be necessary to use java.util.HashMap.
The angst about TraversableLike and builder typeclasses is understandable. I had to work through that when writing the collections chapter for Scala for the Impatient. I ended up advising readers to use Iterable or Seq, and to ignore all the other interfaces. I realize this will outrage someone somewhere. And yes, the operators have gotten a bit out of hand in the collections library. I put them all into a table, and the result wasn't pretty. (The problem isn't the operators, but their inconsistency.) There is a lot to like about the collections library, but it's not perfect. Perhaps it needs to get redone one more time, or perhaps Scaladoc needs to be smarter about giving a more user-centric view.
Some of the other issues raised surely resonate with most of us: IDEs, sbt/Maven, version incompatibilies. That will take blood, sweat, toil, and tears to work through. Eventually it will all work, but you can't blame a user to be frustrated about it.
Cheers,
Cay
Re: Yammer moving away from Scala
Cay, thanks for the thoughtful suggestions!
On Fri, Dec 2, 2011 at 7:55 PM, Cay Horstmann <cay [dot] horstmann [at] gmail [dot] com> wrote:
Absolutely right. That's two things we will address in 2.10. Do you have suggestions regarding inconsistency of operators? Given a long enough deprecation cycle we could do changes if they are necessary. One other thing I thought of was merging the Traversable and Iterable layers if collections, because this would get rid of about 20% of the supertraits of standard collection classes. I think two of the things we need to do on the docs side is hide implementation details better in the ScalaDoc and put a link to the collections API overview
http://www.scala-lang.org/docu/files/collections-api/collections.html
into the scaladoc of each collection class. Yes, that's largely what we are working on right now.
Cheers
-- Martin
Re: Yammer moving away from Scala
I'm sick and tired that the conclusion of “language experts” that Scala sucks is based to 90% on those three method names.
Re: Yammer moving away from Scala
(I would dump /:\, though, as it serves little purpose. "fold" is clearer and faster to type (for most people), and /:\ suffers from which-goes-on-what-side ambiguity. (Especially given that people typically start with left folds to avoid stack overflow.))
--Rex
On Fri, Dec 2, 2011 at 4:55 PM, Simon Ochsenreither <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
Re: Yammer moving away from Scala
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You're assuming intellectual honesty on behalf of the claimant. Given
that the position held by the potential student is already bogus, all I
can do is wish you the best in the battle ahead of you.
On 12/04/2011 01:36 AM, Rex Kerr wrote:
> Why don't we try explaining things in a helpful and friendly way, instead
> of deleting useful things that might require explanation?
>
> (I would dump /:\, though, as it serves little purpose. "fold" is clearer
> and faster to type (for most people), and /:\ suffers from
> which-goes-on-what-side ambiguity. (Especially given that people typically
> start with left folds to avoid stack overflow.))
>
> --Rex
>
> On Fri, Dec 2, 2011 at 4:55 PM, Simon Ochsenreither <
> simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
>
>> I know, it sounds lame ... but can we get rid of /:, :\ and /:\?
>>
>> I'm sick and tired that the conclusion of “language experts” that Scala
>> sucks is based to 90% on those three method names.
>>
>
Re: Yammer moving away from Scala
I have no doubt that people who are interested in it will easily understand it.
But I'm really sick and tired of refuting the quick impressions from the same, sad piece of code written in 2008 for the next decade. It will never stop. Malicious people will always use this method against the language.
I would like to spend my time doing something useful for people interested and not waste my time by dubious "Java experts" writing pages of "gut feelings" of code they don't like in a language they never used.
Bye,
Simon
Re: Yammer moving away from Scala
Are you going to let wrong people affect the API of scala? It can only get better from here!
On Dec 3, 2011 7:55 AM, "Simon Ochsenreither" <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:Re: Yammer moving away from Scala
if i listened to conclusions like this, i would now be very, very confused because there are so many religions, and i am supposed to join any of them because they are all correct.
RE: Yammer moving away from Scala
When I present Scala to my students I show them the operator-like methods but also the named methods. Then I say, “Personally I prefer the named methods because I find them easier to read in the code later. I’ll let you play around with both and decide for yourself.”
I find about 50% of the students will use the operator-like methods and 50% will use the named methods. That’s fine with me.
Peter
From: scala-debate [at] googlegroups [dot] com [mailto:scala-debate [at] googlegroups [dot] com] On Behalf Of HamsterofDeath
Sent: Saturday, December 03, 2011 04:08
To: scala-debate [at] googlegroups [dot] com
Subject: Re: [scala-debate] Yammer moving away from Scala
Am 02.12.2011 23:23, schrieb Tony Morris:
Are you going to let wrong people affect the API of scala? It can only get better from here!
On Dec 3, 2011 7:55 AM, "Simon Ochsenreither" <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
I know, it sounds lame ... but can we get rid of /:, :\ and /:\?
I'm sick and tired that the conclusion of “language experts” that Scala sucks is based to 90% on those three method names.
tell them to use fold, foldLeft and foldRight if they don't want to use non letter methods.
if i listened to conclusions like this, i would now be very, very confused because there are so many religions, and i am supposed to join any of them because they are all correct.
Re: Yammer moving away from Scala
"If I used folds a lot, and perhaps I will someday, I would quite happily use the /: operator ... if I considered folding to be just as primitive as +, I'd much rather write /: than foldLeft, just as I'd rather write + than plus."
http://rickyclarkson.blogspot.com/2008/01/in-defence-of-0l-in-scala.html
On 3 December 2011 13:15, Peter C. Chapin <PChapin [at] vtc [dot] vsc [dot] edu> wrote:
Re: Yammer moving away from Scala
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12/03/2011 07:07 PM, HamsterofDeath wrote:
> Am 02.12.2011 23:23, schrieb Tony Morris:
>>
>> Are you going to let wrong people affect the API of scala? It can only
>> get better from here!
>>
>> On Dec 3, 2011 7:55 AM, "Simon Ochsenreither"
>> > > wrote:
>>
>> I know, it sounds lame ... but can we get rid of /:, :\ and /:\?
>>
>> I'm sick and tired that the conclusion of “language experts” that
>> Scala sucks is based to 90% on those three method names.
>>
> tell them to use fold, foldLeft and foldRight if they don't want to use
> non letter methods.
>
> if i listened to conclusions like this, i would now be very, very
> confused because there are so many religions, and i am supposed to join
> any of them because they are all correct.
>
You could just get on with it, like us irreligious people do. Try it!
Re: Yammer moving away from Scala
> Absolutely right. That's two things we will address in 2.10.
Yay.
> One other thing I thought of was merging the Traversable and Iterable
> layers if collections, because this would get rid of about 20% of the
> supertraits of standard collection classes.
Yes please.
Re: Yammer moving away from Scala
On Fri, Dec 2, 2011 at 11:08 AM, martin odersky wrote:
> I think two of the things we need to do on the docs side is hide
> implementation details better in the ScalaDoc and put a link to the
> collections API overview
>
> http://www.scala-lang.org/docu/files/collections-api/collections.html
>
> into the scaladoc of each collection class.
I'm a little worried about further hiding implementation details in
the docs. Part of Coda's point was that all the hiding and such
promote cargo cult engineering. I'm not sure how much there is to be
done about it, but it definitely seems like trying to hide things like
type class implicits in the docs is only going to lead to arguments of
the form "Scala is so complex that they have to hide it from you!"
Maybe that's not what you meant, but it definitely seems worrisome. I
don't have any constructive ideas, unfortunately.
RE: Yammer moving away from Scala
> -----Original Message-----
> From: scala-debate [at] googlegroups [dot] com [mailto:scala-
> debate [at] googlegroups [dot] com] On Behalf Of David Hall
>
> I'm a little worried about further hiding implementation details in
> the docs. Part of Coda's point was that all the hiding and such
> promote cargo cult engineering. I'm not sure how much there is to be
> done about it, but it definitely seems like trying to hide things like
> type class implicits in the docs is only going to lead to arguments of
> the form "Scala is so complex that they have to hide it from you!"
I agree that hiding things in the documentation, especially documentation
that is intended to be referential in nature, is not a good idea. On the
other hand making it clear where the extension points are would be good. I
can also understand hiding private API information for some suitable
definition of "private." On the other hand seeing all that weird looking
stuff in the scaladocs can also be motivational. It goes like this:
1. What the $%&%$ is that?
2. Hmm.
3. Google/Books/Papers/Tutorials
4. Interesting.
5. Cool!
Peter
Re: Yammer moving away from Scala
On 03.12.2011 14:24, Peter C. Chapin wrote:
> definition of "private." On the other hand seeing all that weird looking
> stuff in the scaladocs can also be motivational. It goes like this:
>
> 1. What the $%&%$ is that?
> 2. Hmm.
> 3. Google/Books/Papers/Tutorials
> 4. Interesting.
> 5. Cool!
Actually that was sort of how it was for me when I first discovered
Scala, and was part of what attracted me to it. All that new weird,
"complex" stuff seemed like a magical forest waiting to be explored. It
brought the fun back in programming, and I hadn't quite felt that way
since I learned assembly in my late teens.
Wow. That sounded fantastically nerdy. :)
Knut Arne Vedaa
Re: Yammer moving away from Scala
On Fri, Dec 2, 2011 at 8:31 PM, David Hall <dlwh [at] cs [dot] berkeley [dot] edu> wrote:
The point is that Scala's collections are fully extensible, whereas in many other languages they are not (that means the collections you can write there do not have the same status as the built in collections). To make extensions smooth we have to expose factory classes, builders, builder factories, and the like. I believe it is not at all cargo cult engineering if you program with collections without knowing the details. Engineers need to keep abstractions separate. Bridge builders need not know quantum mechanics for their work, even though it might be interesting for them to educate themselves in it. Collection users need not know the bits collections are composed from; the public user API is all they need. The main problem is that, besides in documentation, we cannot really distinguish user and creator APIs.
Cheers
-- Martin
Re: Yammer moving away from Scala
I think it's worthwhile to mention this follow up: http://eng.yammer.com/blog/2011/11/30/scala-at-yammer.html
Re: Yammer moving away from Scala
On 30 Nov 2011, at 18:24, Jeff Nowakowski wrote:
> I'm surprised I haven't seen this mentioned by now:
>
> Email critique of Scala: https://gist.github.com/1406238
>
> A sample new story on it: http://www.infoq.com/news/2011/11/yammer-scala
>
> It's a very detailed email from an employee at Yammer on why they are migrating from Scala back to Java. I know it was intended to be private, but it's gone public now, and there's nothing personal in the email anyways.
The point that he makes that (to me, at least) resonates most strongly relates to the Scala community. I don't know how to fix it, but we really do need to fix it.
It must be possible to create a supportive and welcoming environment for people coming to the language. Right now, the Scala community is nothing like that.
We've been using Scala heavily over the last 18 months and are in the process of selecting which language we'll use for a major new development. There are two things that count strongly against Scala - the binary compatibility issue and the poisonous nature of community that surrounds the language.
Personally, I'm strongly in favour of Scala. I'd rather stick pins in my eyes than use Java and I don't see any credible choice other than Scala. But my case is severely weakened by by the squabbles, flame wars and just plain rudeness that constantly breaks out here.
How do we (can we) address this?
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: paul [at] paulbutcher [dot] com
AIM: paulrabutcher
Skype: paulrabutcher
Re: Yammer moving away from Scala
So I'm going to call what you've pointed out the "FP" response, though it's not limited to FP, and certainly many hardcore FP-ers don't share this mindset. Because Scala is good at supporting different programming paradigms (FP, Actors, whatever), it can attract people who are locked into those mindsets; and if some of those people decide to move their attitude to the mailing lists, the result is pretty nasty.
I can think of only two responses. I'm reluctant to even suggest the second, but think it must be said:
1) Have Martin periodically post a message reminding everyone that Scala is a multiparadigm language, and asking for tolerance for other points of view.
2) If necessary, banning people from a list. I don't like it, but if the atmosphere on the lists might cause Scala to fail, I think it's worth considering.
Ken
Re: Yammer moving away from Scala
If you argue for being tolerant against people with a different view point I guess it would be incredibly arrogant to ban people with the "wrong" view point, wouldn't it?
BR,
Den 3 dec 2011 20:23 skrev "Kenneth McDonald" <ykkenmcd [at] gmail [dot] com>:John
Re: Yammer moving away from Scala
Regards,
Roland
Am Samstag, 3. Dezember 2011 23:50:00 UTC+1 schrieb John Nilsson:
Re: Yammer moving away from Scala
There are far less condescending ways to make a point. Messages like this exchange will be moderated for 'tone'. You'll be given an opportunity to rephrase a post to get your point across. Different opinions are welcome on the list. Veiled insults are not. No matter who they are aimed at.
On Dec 3, 2011 6:05 PM, "rkuhn" <google [at] rkuhn [dot] info> wrote:Re: Yammer moving away from Scala
I'm not sure I get it either. Was this aimed at all participants in this exange, the last poster in it, past posters of exchanges it hinted at or potential futures excahnges of which it discussed?
In case I came of as condencending I'm sorry. My intent was more of a humorous kind.
BR,
Den 4 dec 2011 00:23 skrev "Josh Suereth" <joshua [dot] suereth [at] gmail [dot] com>:John
Re: Yammer moving away from Scala
Humor is OK. Self-deprecating always better than -insulting others, unless it's Daniel Spiewak, cuz you know...
Again, this was targetted at other statements on this list which lead to the non-exhange of ideas nor were they generally humurous. This behavior, while overlooked in the past, is no longer acceptable even on scala-debate.
let's discuss ideas not question each others motives or intelligence. If you did not intend offense and your post is moderated, we'll help rewrite the thought to come across with the least emotional baggage.
This is in response to Ken's suggestion of blocking users, which will not happen but for extreme cases of repeated social misjudgment and general "trolling". I'd rather see all view points discussed, but if you cannot behave in a civil fashion, you will be removed from the list.
On Dec 3, 2011 7:10 PM, "John Nilsson" <john [at] milsson [dot] nu> wrote:Re: Yammer moving away from Scala
This was aimed at specific posters in the exchange who shall remain nameless. We're going to moderate posts in an attempt to further the exchange of ideas rather than insults.
If you feel the need to issue a belittling statement, Simply refrain and the internet will be a slightly better place. If you don't realize that a statement is in the category of "belittling" we'll try to help rephrase the thought.
This was not aimed at John or Roland but at earlier emails in the exchange.
On Dec 3, 2011 7:10 PM, "John Nilsson" <john [at] milsson [dot] nu> wrote:Re: Yammer moving away from Scala
So, in all form I do apologize, I did not mean to be condescending, I was just pointing out a possible misunderstanding between John and Ken.
Am Sonntag, 4. Dezember 2011 00:22:23 UTC+1 schrieb Josh Suereth:
Re: Yammer moving away from Scala
Am Mittwoch, 30. November 2011, 23:08:57 schrieb Paul Butcher:
> On 30 Nov 2011, at 18:24, Jeff Nowakowski wrote:
> > I'm surprised I haven't seen this mentioned by now:
> >
> > Email critique of Scala: https://gist.github.com/1406238
> >
> > A sample new story on it: http://www.infoq.com/news/2011/11/yammer-scala
> >
> > It's a very detailed email from an employee at Yammer on why they are
> > migrating from Scala back to Java. I know it was intended to be private,
> > but it's gone public now, and there's nothing personal in the email
> > anyways.
First: I think it's to be expected that not every adoption will succeed. One
size doesn't fit all. Scala has it's issues (as a language, as an ecosystem,
as a community) but so does .
Furthermore it's a little unfortunate that a personal communication leaked
into the public. But now it's on the table for all to behold. And some of the
criticism is not really new (at least to me). Many issues are already being
adressed by typesafe so there is a chance for improvement.
My take home message: many (maybe even small) burdens and inconveniences have
summed up to a point where scala was not perceived as being worth the cost.
Fair enough.
> The point that he makes that (to me, at least) resonates most strongly
> relates to the Scala community. I don't know how to fix it, but we really
> do need to fix it.
I don't think we can fix it on this medium. It's the internet, it's all about
personality. It's uncontrolled.
And yes - some of the flames are used as evidence by people who don't like
scala to show that the community is hostile. Nothing can change that (unless
there are no longer such posts - but this won't happen. It's the internet).
So what can be done?
Officially: Documentation, education, official statements from the scala
maintainer about all major topics. Provide official references and resources.
But all this has already been done or is on its way.
So I think it's ok - scala is on its way.
Community:
val wishListForCommunity = List("pragmatism", "pragmatism", "pragmatism",
"patience", "peace")
Sometimes people don't want to be educated - not even remotely. They just want
a quick copy & modify & paste solution for an obstacle to get pressing
business done. Not providing a solution but trying to convince them that their
solution outline is crap firsthand or trying to baffle them with links to
fundamental articles of some sort won't scala do a favour. If I don't find a
switch to turn an engine on I don't want to read about electricity...
Providing a solution together with a hint that there is room for improvement
will often be received better.
Greetings
Bernd
Re: Yammer moving away from Scala
I find the part about the "poisonous nature of community" hard to believe. First, I didn't realize that it is any more "poisonous" than any other online community. And even if it were, I can't imagine that would be much of a factor in selecting a language for a business. Then again, I'm lucky enough to have the freedom to select Scala without any approval from anyone else, and I'm the only one in my immediate organization who currently uses it, so maybe I just can't see the problem you are referring to.
In defense of Victor, he did preface his question with "Just to be very clear, ...". I think the hostile reply was an overreaction, but that sort of thing is common in online discussions.
--Russ P.
--
http://RussP.us
Re: Yammer moving away from Scala
On 30 Nov 2011, at 22:41, Russ Paielli wrote:
> I find the part about the "poisonous nature of community" hard to believe. First, I didn't realize that it is any more "poisonous" than any other online community.
Sadly, it really is. You're absolutely correct that misunderstandings and flame wars are endemic on the internet, but for some reason the Scala community is much more prone to them than any other I've ever participated in. Worse, we have a habit of unloading on newbies so that their first experience of trying to participate is a negative one. You don't have to look far to find many examples of exactly this.
I spent quite a lot of time using Ruby (from around 2006 to 2010). One of the things that really helped Ruby adoption was the fact that the community was welcoming and supportive. Scala would benefit hugely if we could achieve the same.
(and yes, I know that if you go search the archives, you will find examples of flame wars in the Ruby community - the infamous Zed Shaw falling out of love with Ruby being a classic example. But that doesn't change the fact that the overall impression of the community was positive, in stark contrast with Scala at the moment).
> And even if it were, I can't imagine that would be much of a factor in selecting a language for a business.
You have at least two examples of people telling you that it's a problem. Me, and the Yammer post that sparked this discussion off. And there are plenty of others.
Community is an *incredibly* important part of what makes a language successful.
> In defense of Victor, he did preface his question with "Just to be very clear, ...". I think the hostile reply was an overreaction, but that sort of thing is common in online discussions.
My post was not intended to be aimed at Victor at all (in fact, I hit "send" before his message arrived in my inbox). One of the unfortunate side-effects of the bad atmosphere that surrounds this list is that people get "jumpy" and start taking offence unnecessarily. It becomes a self-perpetuating negative cycle. We all need to participate in breaking that cycle.
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: paul [at] paulbutcher [dot] com
AIM: paulrabutcher
Skype: paulrabutcher
Re: Yammer moving away from Scala
>> Personally, I'm strongly in favour of Scala. I'd rather stick pins in my
>> eyes than use Java and I don't see any credible choice other than Scala. But
>> my case is severely weakened by by the squabbles, flame wars and just plain
>> rudeness that constantly breaks out here.
i wonder to what degree Scala is powerful enough to let various
disparate communities think they can use it, and then they come to
loggerheads on the lists? Like, there's the "i wish i were doing
haskell" crowd that will poo poo you if you don't already know the
typeclassopedia by heart; there's the performance nuts; there's the
people who really just kinda want a slightly less painful java but not
much more than that; there's yadda yadda yadda.
with java nobody is under any mistaken impression that it is or can be
anything other than plain old java. if you add on something like guava
or apache functional stuff you know you are out in la la land and your
noize only shows up on those mailing lists for only like-minded
suckers to read.
fun.
Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 11:45 PM, Raoul Duke <raould [at] gmail [dot] com> wrote:
That I not true, I got flamed on SO for using obscure language features like instance initializers and qualified "this" when some guy wanted the golfiest snippet to traverse a list + this in pure Java:
So apparently you can be one of the weird guys in the Java world as well.
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang
Re: Yammer moving away from Scala
2011/11/30 √iktor Ҡlang <viktor [dot] klang [at] gmail [dot] com>
Re: Yammer moving away from Scala
I can't comment usefully on all of the points, but as someone who attempts to do a lot of high-performance work in Scala, they've captured the issues with high-performance Scala reasonably well. In detail:
Indeed. For loops are slow. After "create the pipe operator for yourself", this is probably the second-most-common question/answer pair on StackOverflow. JVMs cannot reliably optimize even specialized range code in for loops, especially if they're nested.
This is also true in some cases. The Scala HashMap does an embarrassing amount of boxing of key-value pairs. For example, the += method takes a tuple (often created by the user to begin with), then accesses the two elements, packaging them into an Entry object, which it finally passes off to HashTable. For simple mappings this can give a ~10x slowdown. I wouldn't say to _never_ use scala.collection.mutable (e.g. ArrayBuffer is pretty close to java.util.ArrayList in performance), but there are some gotchas lurking in there, with HashMap being one of the worst offenders.
Here, I disagree. What is your use case, and how sure are you that you are _actually_ not modifying that java.util.concurrent.ConcurrentHashMap anywhere? You can often write less-formally-safe code that performs better, but that doesn't make it a good idea unless you identify this as a key bottleneck, at which point you fix the key bottleneck and take away the lesson that _you fix key bottlenecks_, not that you _always use less-formally-safe code_.
That's not nearly as big of an issue as always using final val in classes if it can in fact be final (even in places where it seems redundant, such as inside a class itself marked final). Anyway, using private[this] is a good practice for other reasons: it prevents classes from messing with each others' internals, which makes it harder to reason about the code.
This one I also disagree with. Understand the relative cost of closures compared to the code that they enclose. Use appropriately. Also, in deeply nested loops, create the functions by hand at the outer level; the compiler doesn't notice that it can move closure creation into the outside loop. For example, if you have an array of options of strings, using arr.foreach(_.foreach(x => ...)) takes about twice as long as arr.foreach(_.foreach(f)) where f is defined outside.
Anyway, these criticisms seem, for the most part, reasonably well-founded, except that the bottom line is that you miss out on many of Scala's best features in your critical inner loops. Unless your entire code base is critical inner loops, using Java is unlikely to make your life easier. (There is a lot more to remember when writing high-performance Scala than when writing high-performance Java, however.)
--Rex
Re: Yammer moving away from Scala
Also, in my opinion, the critisims layed against SBT is entirely justified. I think the idea of having a Scala based build tool is great, and the incremental compilation is great, and the console is great. However the custom DSL is extremely hard to use, and the implementation source code is impossible to read. Additionally many features just do not work as expected, either by design or due to bugs.
Re: Yammer moving away from Scala
Aleksey Nikiforov skrev 2011-11-30 21:27:
> When I first dicovered that for loops were not optimized I was surpised.
> When I discovered a resistance to optimizing them I was shocked. The
> decision to do nothing about for loops baffles me to this day.
For comprehensions are just syntactic sugar. Optimizing just them is not
very useful, instead effort should be put into generic optimization of
HOF's (and other inlining).
/Jesper Nordenberg
Re: Yammer moving away from Scala
This is exactly the thinking that baffles me. There are for-loops in Java. Not comprehensions, LOOPs. Anyone coming from Java will expect for LOOPs or simlar functionality.
It does not matter to me if it is a syntactic sugar or if they are comprehensions. What matters to me is to be able to write the code:
var sum = 0; for (i <- 0 until array.length) sum += array(i)
And have it work as fast as possible. Scala fails that expectation. It fails it so much that this is one of the most frequent questions on stack overflow. Also, it appears to be the number 1 on the list of problems with Scala as viewed by the employee at Yammer who wrote the email:
So, they were looking for loops as well, not comprehensions. Why not send them an email and ask them if perhaps they were "talking about for comprehensions or just foreach"?! If you think I was overreacting, I would LOVE to see their response.
It is nice to have for-comprehensions optimized. But I really do not care about for-comprehensions. I want something that looks like for loops and works like for loops. 99% of my code uses emulated for-loops via while-loops. It's painful and error prone, so I take this issue very personally.
Not providing proper for-LOOPs is akin to saying: Scala is not meant for the applications that require for-loops. Which sends the message that Scala is not meant for performance-sensitive applications. So guess what, the folks at Yammer got the message and went back to Java.
You can tell me that they are comprehensions, or a more general case should be optimized. But I do not care about those uses at all. Ranges and closures can never be optimized to the level of while loops. And I need the LOOPs. And so do many other people not interested in functional aspects of Scala.
Re: Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 20:11, Aleksey Nikiforov wrote:
> On Wed, Nov 30, 2011 at 3:43 PM, Jesper Nordenberg
> wrote:
>>
>> Aleksey Nikiforov skrev 2011-11-30 21:27:
>>
>>> When I first dicovered that for loops were not optimized I was surpised.
>>> When I discovered a resistance to optimizing them I was shocked. The
>>> decision to do nothing about for loops baffles me to this day.
>>
>>
>> For comprehensions are just syntactic sugar. Optimizing just them is not
>> very useful, instead effort should be put into generic optimization of HOF's
>> (and other inlining).
>>
>> /Jesper Nordenberg
>
>
>
> This is exactly the thinking that baffles me. There are for-loops in Java.
> Not comprehensions, LOOPs. Anyone coming from Java will expect for LOOPs or
> simlar functionality.
>
> It does not matter to me if it is a syntactic sugar or if they are
> comprehensions. What matters to me is to be able to write the code:
>
> var sum = 0; for (i <- 0 until array.length) sum += array(i)
The body of the loop compiles (with -optimize) to:
59: iload 8
61: iload_3
62: if_icmpne 93
(last iteration code elided)
93: iload 8
95: istore 6
97: aload 5
99: aload 5
101: getfield #50; //Field scala/runtime/IntRef.elem:I
104: aload_0
105: getfield #11; //Field XXS$$array:[I
108: iload 6
110: iaload
111: iadd
112: putfield #50; //Field scala/runtime/IntRef.elem:I
115: iload 8
117: aload 7
119: invokevirtual #53; //Method scala/collection/immutable/Range.step:()I
122: iadd
123: istore 8
125: goto 59
Java's
4: iload_2
5: aload_0
6: getfield #2; //Field array:[I
9: arraylength
10: if_icmpge 28
13: iload_1
14: aload_0
15: getfield #2; //Field array:[I
18: iload_2
19: iaload
20: iadd
21: istore_1
22: iinc 2, 1
25: goto 4
I had noticed before this strange characteristic of Scala bytecode of
breaking loop bodies in two parts, and jumping between them. I suppose
that's probably related to the inlining of closures, but, still, this
unnecessary jumping can't possible be good.
Anyway, notice how lines 104-111 in Scala are the same as lines 14-20
of Java. Where it differs is that Scala is using IntRef all over the
place. That's sum stored as IntRef on slot 5, on the heap. And look at
lines 93, 95 and 108: slot 8 is "i", but it reads it on 93, stores on
slot 6 on 95, then do the arithmetic, and next restores it from slot 6
on 108! Slot 6 need not exist at all, and it could have just read from
slot 8 at that point!
And on the elided part, it does this as it returns:
84: putfield #50; //Field scala/runtime/IntRef.elem:I
87: aload 5
89: getfield #50; //Field scala/runtime/IntRef.elem:I
92: ireturn
I even understand why it isn't optimizing this, but these lines would
be completely unnecessary if "sum" was on the stack in first place!
I'm impressed by the job done to inline the closure, but then it seems
to punt out on a minor optimization such as getting rid of IntRef. So
close, yet still so far...
Here are the test classes if anyone wants to look into it:
class XXS {
private val array = Array.range(0, 100)
def tst = { var sum = 0; for (i <- 0 until array.length) sum +=
array(i); sum }
}
class XXJ {
private int[] array;
XXJ() {
for (int i = 0; i < 100; i++)
array[i] = i;
}
int tst() {
int sum = 0;
for (int i =0; i < array.length; i++)
sum += array[i];
return sum;
}
}
>
> And have it work as fast as possible. Scala fails that expectation. It fails
> it so much that this is one of the most frequent questions on stack
> overflow. Also, it appears to be the number 1 on the list of problems with
> Scala as viewed by the employee at Yammer who wrote the email:
>
> 1. Don't ever use a for-loop.
>
> So, they were looking for loops as well, not comprehensions. Why not send
> them an email and ask them if perhaps they were "talking about for
> comprehensions or just foreach"?! If you think I was overreacting, I would
> LOVE to see their response.
>
>
> It is nice to have for-comprehensions optimized. But I really do not care
> about for-comprehensions. I want something that looks like for loops and
> works like for loops. 99% of my code uses emulated for-loops via
> while-loops. It's painful and error prone, so I take this issue very
> personally.
>
> Not providing proper for-LOOPs is akin to saying: Scala is not meant for the
> applications that require for-loops. Which sends the message that Scala is
> not meant for performance-sensitive applications. So guess what, the folks
> at Yammer got the message and went back to Java.
>
> You can tell me that they are comprehensions, or a more general case should
> be optimized. But I do not care about those uses at all. Ranges and closures
> can never be optimized to the level of while loops. And I need the LOOPs.
> And so do many other people not interested in functional aspects of Scala.
>
Re: Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 11:11 PM, Aleksey Nikiforov <lexn82 [at] gmail [dot] com> wrote:
Alright, so you're not talking about for comprehensions, you're talking about the foreach-method. Because optimizing desugaring of for comprehensions is a much deeper topic.
So you allow yourself to overreact because someone else might overreact even more?
I'm trying to understand the topic at hand so there can be a meaningful discussion, this is scala-debate after all.
Something like that should be a prime use case for a macro, to expand it into a while construct, I mean.
So your only problem with foreach is that it does not have the raw performance that you need? Otherwise the for-comprehension sugar is just fine? So "proper" in this sentence means "high performance".
The question is how deep the rabbit hole goes, what if you add a guard to a for comprehension, should the optmizations be applied anyway, because then we're just not simply talking about "for loops" anymore, and people might wonder why the "for loop" users have so much better performance than the "for loop with guard" users.
This is why I suspected that the discussion was about foreach, but it would really be about optimizing the desugaring of for comprehensions, which is why I needed to ask what we actually were talking about.
When writing high performance code you _always_ have to use the right tool for the job, if that means dropping into a little bit of Java, or into sun.misc.Unsafe, into cache-line padding classes, write your own custom data structures or doing object pooling. But that Scala would be unsuited for high performance code just not true, I think 45 million asynchronous messages processed per second on a 6 core box is pretty decent performance.
So essentially you'd just want Javas good old for(... ; ....; ...) ?
As I said earlier, if nothing else, it could most probably be implemented using macro expansion in the future. So it is just a special sugar for a while construct.
Cheers,
√
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang
Re: Re: Yammer moving away from Scala
On Nov 30, 2011, at 11:48 PM, √iktor Ҡlang wrote:
> e, I think 45 million asynchronous messages processed per second on a 6 core box is pretty decent performance.
Off-topic, but I'd love to know more about that benchmark. Can you share some details? 45M messages with complex synchronization are pretty impressive whereas 45M no-ops are not.
Cheers,
- Tiark
Re: Re: Yammer moving away from Scala
2011/12/1 Tiark Rompf <tiark [dot] rompf [at] epfl [dot] ch>
Complex synchronization? The only monitor lock ever taken in the bench is in the BlockingQueue of the ThreadPoolExecutor, all else is just volatiles/CAS
Of course the benchmark isn't doing any work besides sending and receiving messages, otherwise it would benchmark something else than sending and receiving messages.
https://github.com/jboner/akka/tree/master/akka-actor-tests/src/test/scala/akka/performance/microbench
Cheers,
√
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang
Re: Re: Yammer moving away from Scala
Let's not attack strawmen ...
Thanks for the pointer. Of course there are multiple ways to interpret the results, but (playing the devil's advocate here) one perspective is that message exchange has an upper bound of 45 MHz on a multi-core, multi-GHz machine.
Cheers,- Tiark
Re: Re: Yammer moving away from Scala
2011/12/1 Tiark Rompf <tiark [dot] rompf [at] epfl [dot] ch>
So what did you mean by complex synchronization?
That was not the upper bound, that was after a bit of tuning, not full tuning, on a 6-core box.
This was just on a 6-core box, we're running tests on our 48-core box right now for additional optimization opportunities.
Right now we've found a bottleneck in java.util.concurrent.{ThreadPoolExecutor, LinkedBlockingQueue, ArrayBlockingQueue},
so we're working to build our own stuff for that.
Cheers,
√
--
Viktor Klang
Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts
Twitter: @viktorklang
Re: Re: Yammer moving away from Scala
What would be nice regarding performance is to have a page on the
scala site where:
- It is explained what you can expect from -optimize, on a server JVM.
- Advices are given to improve performance in bottlenecks.
That would help in situation like those described in the mail that
started this discussion.
Best regards,
Nicolas.
Re: Re: Yammer moving away from Scala
> So essentially you'd just want Javas good old for(... ; ....; ...) ?
> As I said earlier, if nothing else, it could most probably be implemented
> using macro expansion in the future. So it is just a special sugar for a
> while construct.
feature request:
#PRAGMA JAVA
...
#PRAGMA ENDJAVA
:-)
Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 9:27 PM, Aleksey Nikiforov <lexn82 [at] gmail [dot] com> wrote:
That's simply not true. The position is that we should not do isolated ad-hoc fixes but go to the root of things. Scala's overall optimizations need to be good enough that they can optimize standard for-loops. And they are already very close of doing this. I wonder whether Yammer ever tried compiling with -optimize.
Cheers
-- Martin
Re: Yammer moving away from Scala
Hi,
I don't know if that's what's planned but I guess that once the effect
system is there and once "until" is annotated as pure, some
deforestation or one of its variants could be applied there.
Paul
On Wed, Nov 30, 2011 at 22:35, martin odersky wrote:
>
>
> On Wed, Nov 30, 2011 at 9:27 PM, Aleksey Nikiforov wrote:
>>
>> When I first dicovered that for loops were not optimized I was surpised.
>> When I discovered a resistance to optimizing them I was shocked. The
>> decision to do nothing about for loops baffles me to this day.
>>
> That's simply not true. The position is that we should not do isolated
> ad-hoc fixes but go to the root of things. Scala's overall optimizations
> need to be good enough that they can optimize standard for-loops. And they
> are already very close of doing this. I wonder whether Yammer ever tried
> compiling with -optimize.
>
> Cheers
>
> -- Martin
>
Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 4:35 PM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
By "very close" I assume you mean "works in many cases as long as the number of items is large"? I've never gotten good performance out of a for-comprehension on, for instance, short arrays or ranges. (Well, except for the ScalaCL plugin.) I think it's lingering object creation overhead...haven't chased it down.
Also, one can forgive people for not compiling with -optimize, since (1) it is slower, and (2) for years it did nothing beneficial for performance.
Anyway, let's get macro capability (or compile {} blocks) implemented and then everyone who wants to can add a jfor that works just like the Java for (or the collections library can be compilable).
--Rex
Re: Yammer moving away from Scala
On Wed, Nov 30, 2011 at 3:35 PM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
Re: Yammer moving away from Scala
On 30 November 2011 21:48, Aleksey Nikiforov <lexn82 [at] gmail [dot] com> wrote:
Same here. If an optimization is stable, trustworthy, doesn't double compilation time, doesn't bloat the resulting code and speeds things up, it should be there by default. If it doesn't do all of these things then I probably don't have time to compile exactly those scala classes that will benefit from it under -optimize and the rest of my codebase without it.
I understand that it is a Hard Problem to have the compiler optimize away arbitrary for comprehensions over arbitrary structures fully. In the special case of desugaring Range to a for(init;test;incr), or List to a for(list;!=Nil;l=tail), for example, I think this is critical to a whole range of applications. When writing some matrix code, I had to manually desugar all my for comprehensions to get a 100x speedup, as all the time was taken in boxing and instantiating HOF instances.
How is the effects system coming along?
Matthew
--
Dr Matthew PocockIntegrative Bioinformatics Group, School of Computing Science, Newcastle Universitymailto: turingatemyhamster [at] gmail [dot] com gchat: turingatemyhamster [at] gmail [dot] commsn: matthew_pocock [at] yahoo [dot] co [dot] uk irc.freenode.net: drdozerskype: matthew.pococktel: (0191) 2566550mob: +447535664143
Re: Yammer moving away from Scala
I assume that compiling with -optimize takes longer, and that is why it is not the default. If it takes no longer to compile (and it works reliably), then yes it might as well be the default.
--Russ P.
--
http://RussP.us