Want to dive even deeper?

Take the course Beginning Yii by Chris Backhouse and become an expert!
Beginning Yii
by Chris Backhouse

Check it out!
You're watching a preview of this video, click the button on the left to puchase the full version from JavaPolis'06.

Expanding eta-expansion: shapeless polymorphic function values meet macros

Polymorphic function values are one of the key abstractions in shapeless: they are crucial to enabling sequence-like operations such as map, flatMap and filter to be performed on HLists (data structures which combine the heterogeneous typing of tuples with list-like characteristics). Their encoding in Scala has been refined over a number of iterations, but remains a little heavyweight relative to the syntactic ease with which ordinary monomorphic functions or polymorphic methods can be defined. In this talk I will show how we can use macros to automatically promote polymorphic methods to polymorphic function values and how that improves the usability of shapeless.

Published on
  • 664
  • 8
  • 0
  • 3
  • 0
  • Expanding eta-expansion shapeless polymorphic function values meet macros Miles Sabin miles@milessabin.com http://uk.linkedin.com/in/milessabin http://twitter.com/milessabin
  • shapeless resources ● Fork it! http://github.com/milessabin/shapeless /tree/topic/lift-to-poly (see core/src/main/scala/shapeless/poly.scala) ● Mailing list http://groups.google.com/group/shapeless-dev ● Articles/twitter http://chuusai.com/blog @milessabin

Comments

Jo Voordeckers 2 years ago
Excellent quote about readability: #43
Peter Pilgrim 2 years ago
I thought it was one of Johnson better keynotes: a nice return to form when Spring Framework was new 2005
Tom Switzer 2 years ago
I thought the talk was overly negative. He showed no examples of the community actually helping someone or anything. Instead he focused solely on the bad parts and a few choice quotes. It puts the community in a bad light and completely ignores all the awesome people who spend their own free time to help others learn Scala. If you want to make the community better, shine a light on the people who are doing good and teaching others and ignore those who aren't helping. I feel this was a step back for the community, which I personally think has actually been doing really well over the last year (give or take).
tpolecat 2 years ago
Agree with Tom. I found this talk arrogant, insulting, and profoundly ignorant.
Naftoli Gugenheim 2 years ago
Clearly this guy doesn't follow the mailiing lists. The one single individual who made the mailing list unpleasant was banned a long time ago. In order to make his point he has to dig up a 2-year old post?
Nick Clarke 2 years ago
What Tom and tpolecat said. Watching this talk made me quite angry, and if this is really where Scala will end up in 2018 then that's pretty depressing.
2 years ago
His talk was great, blunt, and deep. If we want to make Scala accepted as a first class citizen in the enterprise world besides Java we should follow the pieces of advice he gave us in his talk. He already made it once, so we should be grateful to have him on the Scala side.
Scott Yan 2 years ago
I thought there were good and deep advices in his talk, which we should take in the future. In my opinion, it was a great talk. :)
AndreasS 2 years ago
Often the phrase 'idiomatic' scala code is used in this talk but no definition is given. Scala reinvents java libs because there are problems with the java solution. Finding the problem naming it often helps on improving the situation. Also I dislike the claim that there are more junk libraries in scala than in java. Facts, numbers? Definiton what 'junk' means? Its a bit too foggy to make a real argument but it is used all the time in the talk :/
Josh Cough 2 years ago
I also agree with Tom. There are so many examples in here, but I'll just pick one. He said that we need to have a less arrogant, more accepting community, but also on a huge rant against dispatch - a library built by one of the best community members. This is awesomely hypocritical. His goal is clear, and even stated - he wants Scala to sell out, because he wants to be able to cash in. Scala in 2018 should be about building the best possible Scala, not building the version that makes the most amount of money.
Seth Tisue 2 years ago
I found this talk sadly divisive. Especially when it reopens old wounds in the Scala community from several years ago. Until now, those wounds had been healing just fine.

Also, I think Rod's own position in the enterprise Java world makes him look to that world for Scala's growth. But that world is aging, conservative, and backwards-looking. I think we should focus on making Scala attractive to fresh faces and fresh minds. People at startups, people just now learning to program, and so on. People who pick languages because they're fun to program in, not because legacy lock-in forces their hand. People who if we lose them, are much likelier to choose Ruby, Python, or JavaScript — not Java and the "enterprise" technologies that have accreted around it.
Simon Ochsenreither 2 years ago
What pains me most is not that I've been called arrogant, naive and stupid in that talk, but that the actual "exhibit" does not support but contradict his claims. Instead of wasting his ridicule on me, he could have had a look at what Slick and Scala macros have been up to in the last year. (Hint: The "single line of code" which I wanted to see has already been written.)

Anyway, I found the X vs. Y attitude disappointing, because it devaluates the work of all those people out there who worked incredibly hard to make proponents of _both_ X and Y happy.

Some of the things mentioned are not only reeking of anti-intellectualism, but are just plain dangerous, like the idea of splitting Scala into an "academic" and "pragmatic" profile. That split will not only go through the language, but will divide the community as well. At a time when parts of the community are already on the verge of creating their own language due of the perceived lack of progress in topics they strongly care about, this is certainly not helping.

In the end, the question really is (as Seth) mentions: Are we happy to live solely in a walled, Oracle-owned garden, where we are being shown around as a proof that Java isn't _that_ embarrasingly outdated?
Or do we to target new devices, support more deployment scenarios, encourage people to experiment with it and be more welcoming to people who are not "senior JavaEE experts"?

We all see how rapidly the Java ecosystem is losing mindshare and influence pretty much everywhere (except on the server): Java on the client is pretty much dead, Java applets are more than dead and the mobile story should be known to everyone by now.

The prospect of gaining a bigger share of a stagnating/declining market doesn't sound that great to me when I see how other market segments are experiencing an explosive growth.

In short, do we want to be more like TurboHercules or Xamarin?
Sander Mak 2 years ago
Agreed with Seth, but realistically, that's not where the majority of the easy money is. With Typesafe they chose to make Scala a business. This has consequences. Not saying it's bad, but the enterprise market is one they can't ignore from a business perspective. Personally, I think it's great that Scala doesn't have to be a mono-culture either way.
Seth Tisue 2 years ago
“Scala doesn't have to be a mono-culture either way” — amen.
Sergii Starodubtsev 2 years ago
Like about poetry especially in the beginning.
Justin Forder 2 years ago
I agree with Rod's points, but I don't think it was necessary to use actual quotes from the mailing list to illustrate them.
Darth Hater 2 years ago
The statement about some part of the community is still very valid. The statement of Naftoli Gugenheim above is not true. That "$%"% (Morris is his name) is still on the mailing list.
Darth Hater 2 years ago
The conclusion of this talk that the community is the problem NOT the language should alert us all!
Frederic Masion 2 years ago
Not very smart and a bit provocative but the facts are true :
-The community is the most important thing
-Scala can't become mainstream if it is elitist or for purist
-Scala isn't haskell
-There's no need to reinvent the wheel because it not written in scala

I would prefer do some scala with "java noobs" on my working time rather than doing it with purist only on my free time ;)
It's time to make scala mainstream
Will Barksdale 2 years ago
A couple of these comments represent exactly the attitudes that are so destructive to the language.
Matteo Mortari 2 years ago
I'm new to Scala, and personally I find indeed is missing a clear and neat *instruction* on how to do ORM in Scala (in a simple and neat way). Indeed slide parleys.com/course/learning-gi… resonates with my experience. Besides of this, I like a lot how Scala is helping me in building tools, like data transformations, etc.
Brian Tarbox 2 years ago
All of these things needed to be said. I count myself an advanced beginner in Scala and my heart sinks each time a huge new language feature or feature cluster is added as I'm still absorbing the "old" stuff. Our Boston Area meetings are great and I enjoy them but there is certainly a part of the community that prizes cleverness over readability (though I guess if I was smarter that clever code would be readable). Keep in mind that RJ knows a thing or two about building successful systems.
Viktor Hedefalk 2 years ago
I definitely agree that the description of the community was overly negative. For me, the Scala community has been as important as Scala the language in making me more productive. It's of course easy to dig up a few offensive posts in any large enough mailing list. But I believe that the Scala community is a highly welcoming place for newcomers. I've been hanging out mostly in the Lift list and that has been incredibly valuable for me.

Also, once you start to know the people in the forums you can also kind of filter out and just absorb the good stuff. Actually, Tony has probably written some of the most informative posts out there, and quite soon you'll just accept the wording that sometimes goes with it. The context of the post Rod showed is also not that Tony wrote "f*ck you" to the newcomer OP, but to Kevin, another senior community member and that they clearly have a history. Still, of course you want the forums to be a kind of warm and fuzzy place so I'm definitely not defending it.

parleys.com/course/learning-gi… - "Do we want it to be mainstream?". We'll, the rest of the talk clearly uses that as an axiom. I think Typesafe is great and I have a lot to thank the people there for. It's also great if they can make a few bucks and most of them definitely deserve it. However, Rod's opinions represents the bad part of commercial Scala for me. I for one will scream "fork" if the strive for mainstream makes the language aim for the obvious worse. I hope he doesn't have too much influence over there at Typesafe.

/import language._
twc…@gma….com 2 years ago
I am from the Groovy community and have to say Rod's comments about the Scala community are spot on. The Scala community is full of 'self-righteous language bigots'. There might be some nice people in the community but as a failed Scala programmer, I have to say one thing that turned me away from Scala and back to Groovy was the negative community. No need for anyone to consider themselves better for knowing something that another person does not yet understand. Good luck attracting new developers.

I must admit I did not like Rod's assessment of Groovy as a 'poor language' but he is someone I greatly respect technically and is entitled to his opinion. Nevermind, my community is full of very nice, helpful people. We can usually have what I consider 'big boy' conversations where you can disagree and not be verbally abused.
con…@gma….com 2 years ago
I think this talk will become a important MILESTONE for scala.

As a advanced-/beginner+ scala programmer working on my first project, I remembered my early days of frustration:
horrible language API docs(think about CanBuildFrom's),
incompatibility issues between scala versions,
a community that dislikes(or even hates) any questions related to Java or Java libraries,
a community that advocates(or even enforces) immutability but never tells you how it would complicates your problem(think about lenses),
libraries that are impossible to use util you read and understand its source code... ...
The list can go on and on.

So what Rod did here is no trivial IMHO, he studies and understands what it means for a beginner to start learning scala, what they like, what frustrate them, what the community should do to help them.

He's blunt, he even use words like "sellout" while he could use "compromise". But what kind of "sellout" is it?
Is it sellout if you take two minutes to write an alias of a method called ':<<|' with a name 'filterAndAppendTo'?
Is it sellout if you tell a beginner to (try and) "pimp" a Java library and give him some good example on how to "pimp" it, instead of writing a new one? (the word pimp also shows how self-righteous we are.)
My answers will be no, and i truly believe that i'd learnt much faster and achieved more if our community is a bit more friendly.

So my two cents: as a community we need to reflect on a lot of things we did, and Rod's talk is a very good point to start.
And people, don't be fixated on those so-called "sellouts" because they are not. They are compromises we make to become a better community and eventually making scala a better language for everyone.
Mathew de Detrich 2 years ago
Simon, your comment actually is proving Rod's point, not disproving it.

If you want a completely intellectual language whos target domain is an audience who have a masters in computer science and spent the last 2 years studying category theory, then go learn Haskell, or heck, go even deeper and learn stuff like Agda

On the other hand, if you want a pragmatic language that is trying to blend OOP and Functional programing, then use Scala

One of the biggest issues personally is the amount of clever hackery and boilerplate abuse in Scala libraries is painful. Reading someone elses Scala code, almost all of the time, ends up resulting in a metaphorical lobotomy. Scala as a langauge is nice, but so many core parts of its system are a mess. Its build tool, SBT, is horrifically overcomplicated (and believe it or not, a build tool, moreso than any part of the language, needs to be easily understandable by anyone, because anyone is going to be using that tool), and Scala still severly lacks any decent ORM/Database layer. Slick is a nice concept, but is anything but DRY considering how expressive scala is (just look at how you define models), and the other ORM (such as squeryl) suffer the same problems.

The other comment I would like to make, is that pure functional programming is not the solution to everything. ORM's are needed in Scala, just as they are needed in Java, because they solve certain types of real world problems much better than how functional alternatives do. People in scala need to stop reinventing everything in a purely functional way just for the hell of it or because they like it.
Jelle Victoor 2 years ago
Rod is making these blunt statements to strengthen his point, don't be personally offended by it, that is not the goal of this talk. I thought he had some interesting insights.
Worst talk ever in my life! what a negative talk with pointless enumeration of mythical problems. If there are problems, suggest solutions. This is especially needed when the problems mentioned are "personal", "moody" nonsense ones. I was actually surprised that the word "F**K" and an explicit naming of the subject was in a talk! was he drinking when he prepared the talk slides? pathetic, such a waste of my time for this one.
Nicolas Martignole 2 years ago
I agreed to most of its points, being a "pragmatic developer". This was really an interesting keynote. Scala is moving fast, most of the Scala developers are also Java developers. I really think also the point about OO is important. Scala was not designed to be "just a functional language". I encourage Scala-fist to read the intro by Martin Odersky in "Programming in Scala : a comprehensive step by step guide".
Alan Johnson 2 years ago
Great talk. I'm very new to Scala and so I don't know much about the community, but I think his points apply not just to Scala, but to any community.
Anton Kuzmin 2 years ago
Good talk. All those who felt offended, are just pumped up with their pride and they couldn't stand the constructive criticism.

Login to add comments!