Scala & symmetry

Eric Bowman
Eric BowmanVP Engineering at Zalando - Hiring in Berlin, Dortmund, Dublin, Helsinki, Erfurt & Mönchengladbach
Scala Days 2013
Gilt Groupe
ebowman@gilt.com
http://www.flickr.com/photos/justusthane/1252907196/
Gilt provides insider access to today’s top designer labels, at up to 60% off retail.
Through our daily flash sales, which begin at noon EST, we offer everything from
high-end designer clothing and home furnishings to fine dining experiences. Our
products are grouped into five stores: Women, Men, Baby & Kids, Home and City.
Working from New York City, Dublin, or home/remotely, Gilt Tech’s 120 engineers
develop all of our technology in-house. Since Gilt’s founding days, we have
pursued a structure that enables us to address unique needs other e-commerce
platforms simply cannot support. These needs include the ability to handle
intense traffic spikes, offer prompt customer service, manage operations
(inventory, payments and shipping), and execute many other tasks.
As a rapidly growing company with an international customer base, Gilt’s priorities
focus on scalability and personalization. Gilt.com was originally built on Ruby on
Rails, but our rapid growth quickly led to scalability issues — prompting us to
migrate many parts of our website to the Java Virtual Machine. In 2011 we began
migrating our operations to Scala, which is currently our core stack.
http://search.savills.com/property-detail/gbedrseds090073
http://en.wikipedia.org/wiki/File:John_Paul_Jones_by_Charles_Wilson_Peale,_c1781.jpg
http://books.google.ie/books?id=diROAAAAYAAJ&pg=PA400&img=1&zoom=3&hl=en&sig=ACfU3U35lRj3v5Hwfzqe6ANIFr5f4L5RdA&ci=365%2C82%2C311%2C259&edge=0
“Symmetry,aswideorasnarrow
asyoumaydefineitsmeaning,is
oneideabywhichmanthrough
theageshastriedtocomprehend
andcreateorder,beauty,and
perfection.”--HermannWeyl
Symmetry:NotHowItLooks
Symmetryischanging
withoutchanging.
HowisScala
Symmetric?
EverythingisanObject
Java Scala
void dump(int x) {
System.out.println(
Integer.toString(x));
}
def dump(x: Int): Unit = {
println(x.toString)
}
void dump(Complex x) {
System.out.println(
x.toString());
}
def dump(x: Complex): Unit = {
println(x.toString)
}
:(
def dump[T](x: T): Unit = {
println(x.toString)
}
UniformAccessPrinciple
Java Scala
public class Datum {
public final int x;
public Datum(int x) {
this.x = x;
}
}
class Datum(val x: Int)
public class Datum {
private final int y;
public int x() {
return f(g(y));
}
public Datum(int y) {
this.y = y;
}
}
class Datum(y: Int) {
def x = f(g(y))
}
“All services offered by a module should be available through a
uniform notation, which does not betray whether they are implemented
through storage or through computation” - Bertrand Meyer
http://en.wikipedia.org/wiki/Uniform_access_principle
Immutable|Mutable
List<String> foo() {
ArrayList<String> items = computeItems();
return items;
}
Immutable|Mutable
List<String> foo() {
ArrayList<String> items = computeItems();
if (unlikelyThing()) {
return items.subList(
0, items.size() / 2);
} else {
return items;
}
}
List<String> foo() {
ArrayList<String> items = computeItems();
return items;
}
PatternMatching
x match {
case even if (x % 2) == 0 => even/2
case odd => odd + 1
}
PatternMatching
x match {
case even if (x % 2) == 0 => even/2
case odd => odd + 1
}
catch {
case io: IOException => ...
case e: Exception => ...
}
PatternMatching
x match {
case even if (x % 2) == 0 => even/2
case odd => odd + 1
}
catch {
case io: IOException => ...
case e: Exception => ...
}
val split: String => String = {
case null => None
case str => Some(str)
}
Monads
for {
x <- monad1
y <- monad2
} yield x op y
Monads
for {
x <- monad1
y <- monad2
} yield x op y
Traversable
Option
Future
IO
Reader
Writer
Error
Continuation
Asymmetry
PointlessSymmetry
try {
Class c = Class.forName("MyClass");
Object instance = c.newInstance();
c.getMethod("myMethod").invoke(instance);
} catch (NullPointerException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
} catch (ClassNotFoundException e) {
} catch (NoSuchMethodException e) {
} catch (InstantiationException e) {
}
http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
a[i].x += a[i - 1].x;
a[i].y += a[i - 1].y;
Ill-ConceivedSymmetry
http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
a[i].x += a[i - 1].x;
a[i].y += a[i - 1].y;
a(i) += a(i - 1)
Ill-ConceivedSymmetry
private def immediateAstNodes(n: Any): List[AstNode] = n match {
case a: AstNode List(a)
case t: Token Nil
case Some(x) immediateAstNodes(x)
case xs @ (_ :: _) xs flatMap { immediateAstNodes(_) }
case Left(x) immediateAstNodes(x)
case Right(x) immediateAstNodes(x)
case (l, r) immediateAstNodes(l) ++ immediateAstNodes(r)
case (x, y, z) immediateAstNodes(x) ++ immediateAstNodes(y) ++ immediateAstNodes(z)
case true | false | Nil | None Nil
}
http://stackoverflow.com/questions/8618082/visitor-pattern-in-scala
BeautifulAsymmetry
Symmetry&Aesthetics
Symmetry&Aesthetics
http://pages.cs.wisc.edu/~dyer/vsam/images/mona.gif
Symmetry&Aesthetics
http://pages.cs.wisc.edu/~dyer/vsam/images/mona.gif
http://www.leonardodavinci.net/images/gallery/monalisa_detail1.jpg
Symmetry&Aesthetics
http://pages.cs.wisc.edu/~dyer/vsam/images/mona.gif
http://www.leonardodavinci.net/images/gallery/monalisa_detail1.jpg
http://www.saylor.org/site/wp-content/uploads/2012/04/6-mona-lisa.gif
Balance
Rest
Binding
Order
Law
Rigidity
Constraint
Motion
Loosening
Arbitrariness
Accident
Life & Play
Freedom
http://www.acadeuro.org/fileadmin/user_upload/publications/ER_Symmetry_supplement/Lorenz.pdf
Balance
Rest
Binding
Order
Law
Rigidity
Constraint
Motion
Loosening
Arbitrariness
Accident
Life & Play
Freedom
http://www.acadeuro.org/fileadmin/user_upload/publications/ER_Symmetry_supplement/Lorenz.pdf
Platform Product
Symmetry Asymmetry
http://upload.wikimedia.org/wikipedia/commons/thumb/d/db/MaryRose-carpentry_tools1.jpg/250px-MaryRose-carpentry_tools1.jpg
http://test.classconnection.s3.amazonaws.com/324/flashcards/95324/png/altarpiece.png
http://upload.wikimedia.org/wikipedia/commons/6/63/Michelangelos_David.jpg
http://amolife.com/image/images/stories/Art&Abstract/most_popular_sculptures%20(7).jpg
http://www.biographyonline.net/artists/images/Much-The_Scream.jpg
http://www.pics24h.com/img/artwork/5-most-famous-paintings/5-most-famous-paintings03.jpg
http://upload.wikimedia.org/wikipedia/commons/6/63/Michelangelos_David.jpg
http://amolife.com/image/images/stories/Art&Abstract/most_popular_sculptures%20(7).jpg
http://www.biographyonline.net/artists/images/Much-The_Scream.jpg
http://www.pics24h.com/img/artwork/5-most-famous-paintings/5-most-famous-paintings03.jpg
http://www.iie.org/~/media/Images/Corporate/Static-Header/D-F/SH-EmmyNoether.ashx?mh=235&mw=300
http://memegenerator.net/instance/38640565
FinFin
http://tech.gilt.com
@gilttech
@ebowman
ebowman@gilt.com
1 of 33

Recommended

Symmetry, Scala & Software -- Refresh Dublin October 2013 by
Symmetry, Scala & Software -- Refresh Dublin October 2013Symmetry, Scala & Software -- Refresh Dublin October 2013
Symmetry, Scala & Software -- Refresh Dublin October 2013Eric Bowman
1.7K views39 slides
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS... by
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...Lara Schenck
8.5K views104 slides
Agile Data Science 2.0 - Big Data Science Meetup by
Agile Data Science 2.0 - Big Data Science MeetupAgile Data Science 2.0 - Big Data Science Meetup
Agile Data Science 2.0 - Big Data Science MeetupRussell Jurney
1.8K views80 slides
Improving application design with a rich domain model (springone 2007) by
Improving application design with a rich domain model (springone 2007)Improving application design with a rich domain model (springone 2007)
Improving application design with a rich domain model (springone 2007)Chris Richardson
8K views48 slides
Agile Data Science 2.0 by
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0Russell Jurney
503 views86 slides
Agile Data Science 2.0 by
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0Russell Jurney
760 views98 slides

More Related Content

Similar to Scala & symmetry

Priming Java for Speed at Market Open by
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market OpenAzul Systems Inc.
1.3K views41 slides
Agile Data Science 2.0 by
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0Russell Jurney
2.4K views119 slides
From clever code to better code by
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
198 views38 slides
Art of Javascript by
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
1.4K views98 slides
Scaling business app development with Play and Scala by
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and ScalaPeter Hilton
1.8K views68 slides
Ten useful JavaScript tips & best practices by
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
3.5K views52 slides

Similar to Scala & symmetry(11)

Priming Java for Speed at Market Open by Azul Systems Inc.
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
Azul Systems Inc.1.3K views
From clever code to better code by Dror Helper
From clever code to better codeFrom clever code to better code
From clever code to better code
Dror Helper198 views
Art of Javascript by Tarek Yehia
Art of JavascriptArt of Javascript
Art of Javascript
Tarek Yehia1.4K views
Scaling business app development with Play and Scala by Peter Hilton
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and Scala
Peter Hilton1.8K views
Ten useful JavaScript tips & best practices by Ankit Rastogi
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi3.5K views
vertopal.com_DataEncodingForDataClustering-5 (1).pdf by zraibianour
vertopal.com_DataEncodingForDataClustering-5 (1).pdfvertopal.com_DataEncodingForDataClustering-5 (1).pdf
vertopal.com_DataEncodingForDataClustering-5 (1).pdf
zraibianour3 views
Deep Anomaly Detection from Research to Production Leveraging Spark and Tens... by Databricks
 Deep Anomaly Detection from Research to Production Leveraging Spark and Tens... Deep Anomaly Detection from Research to Production Leveraging Spark and Tens...
Deep Anomaly Detection from Research to Production Leveraging Spark and Tens...
Databricks727 views
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club by Data Con LA
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubJoining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Data Con LA3.4K views
Idioms in swift 2016 05c by Kaz Yoshikawa
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
Kaz Yoshikawa440 views

Recently uploaded

Unit 1_Lecture 2_Physical Design of IoT.pdf by
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdfStephenTec
12 views36 slides
Future of Indian ConsumerTech by
Future of Indian ConsumerTechFuture of Indian ConsumerTech
Future of Indian ConsumerTechKapil Khandelwal (KK)
21 views68 slides
virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
11 views15 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
14 views1 slide
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
263 views86 slides
Voice Logger - Telephony Integration Solution at Aegis by
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
39 views1 slide

Recently uploaded(20)

Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Future of AR - Facebook Presentation by ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56114 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
6g - REPORT.pdf by Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex10 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Powerful Google developer tools for immediate impact! (2023-24) by wesley chun
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)
wesley chun10 views

Scala & symmetry