Your SlideShare is downloading. ×
0
Symmetry, Scala &
Software
Refresh Dublin
15 October 2013

Eric Bowman
@ebowman

ebowman@gilt.com
http://tech.gilt.com
“harmonious and
beautiful proportion
and balance”

http://en.wikipedia.org/wiki/Symmetry
“patterned
self-similarity”

http://en.wikipedia.org/wiki/Symmetry
Symmetry is changing
without changing.
Symmetry
in Scala
Scala
•Object-Oriented/Functional
Hybrid
•Statically Typed
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}

object HelloWo...
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}

object HelloWo...
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

for {
i <- 1 to 10
j <-...
Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());
Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());

val f = for...
String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name....
String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name....
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

Future<Integer> f = cal...
Refactoring
“By continuously improving the design of code,
we make it easier and easier to work with. This
is in sharp contrast to wha...
•Abstraction
•Composition/Decomposition
•Name & Location
1. Finite, unchanging list of possible
refactorings.
2. Every refactoring is reversible.
3. Every refactoring is determini...
Group Theory
“‘Numbers measure size;
groups measure symmetry.”

Groups and Symmetry, Armstrong, Spring-Verlag, 1988, p.1
“The most substantial piece of writing in the whole
literature of mankind”

http://upload.wikimedia.org/wikipedia/commons/...
http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
“the symmetry group of an object is the
group of all isometries under which the
object is invariant with composition as th...
“the symmetry group of a program ... is the
group of all refactorings under which the
program behaves identically after ap...
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

Future<Integer> f = cal...
Breaking
Symmetry
a[i].x += a[i - 1].x;
a[i].y += a[i - 1].y;

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)

http://www.metalev.org/2011/04/source-code-symmetry-and-trans...
http://pages.cs.wisc.edu/~dyer/vsam/images/mona.gif
http://www.leonardodavinci.net/images/gallery/monalisa_detail1.jpg
htt...
http://upload.wikimedia.org/wikipedia/commons/thumb/d/db/MaryRose-carpentry_tools1.jpg/250px-MaryRose-carpentry_tools1.jpg...
http://upload.wikimedia.org/wikipedia/commons/thumb/d/db/MaryRose-carpentry_tools1.jpg/250px-MaryRose-carpentry_tools1.jpg...
http://www.biographyonline.net/artists/images/Much-The_Scream.jpg
http://upload.wikimedia.org/wikipedia/commons/6/63/Miche...
Fin

niF

join us.
http://tech.gilt.com
@gilttech

@ebowman
ebowman@gilt.com
Symmetry, Scala & Software -- Refresh Dublin October 2013
Symmetry, Scala & Software -- Refresh Dublin October 2013
Symmetry, Scala & Software -- Refresh Dublin October 2013
Upcoming SlideShare
Loading in...5
×

Symmetry, Scala & Software -- Refresh Dublin October 2013

951

Published on

Talk given as part of the Refreshing Series, about how symmetry manifests itself in software, using Scala as an example where internal symmetry leads to much greater expressiveness.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
951
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Symmetry, Scala & Software -- Refresh Dublin October 2013"

  1. 1. Symmetry, Scala & Software Refresh Dublin 15 October 2013 Eric Bowman @ebowman ebowman@gilt.com http://tech.gilt.com
  2. 2. “harmonious and beautiful proportion and balance” http://en.wikipedia.org/wiki/Symmetry
  3. 3. “patterned self-similarity” http://en.wikipedia.org/wiki/Symmetry
  4. 4. Symmetry is changing without changing.
  5. 5. Symmetry in Scala
  6. 6. Scala •Object-Oriented/Functional Hybrid •Statically Typed
  7. 7. public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } }
  8. 8. public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } } object HelloWorld extends App { println("hello, world") } !
  9. 9. public class HelloWorld { public static void main(String[] args) { System.out.println("hello, world"); } } object HelloWorld extends App { println("hello, world") } ! println("hello, world")
  10. 10. for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { System.out.println(i*j); } } ! !
  11. 11. for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { System.out.println(i*j); } } ! ! for { i <- 1 to 10 j <- 1 to 10 } println(i * j) !
  12. 12. Future<Integer> f = callService1(); Future<Integer> f2 = callService2(f.get()); System.out.println(f2.get());
  13. 13. Future<Integer> f = callService1(); Future<Integer> f2 = callService2(f.get()); System.out.println(f2.get()); val f = for { x <- callService1() y <- callService2(x) } yield y println(Await.result(f, Duration.Inf)) !
  14. 14. String capitalize(String name) { if (name == null) return null; else return Character.toUpperCase( name.charAt(0)) + name.substring(1); }
  15. 15. String capitalize(String name) { if (name == null) return null; else return Character.toUpperCase( name.charAt(0)) + name.substring(1); } def capitalize(n: Option[String]): Option[String] = { for (name <- n) yield { name(0).toUpper + name.substring(1) } } ! !
  16. 16. for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { System.out.println(i*j); } } ! ! Future<Integer> f = callService1(); Future<Integer> f2 = callService2(f.get()); System.out.println(f2.get()); Ja va String capitalize(String name) { if (name == null) return null; else return Character.toUpperCase( name.charAt(0)) + name.substring(1); } for { i <- 1 to 10 j <- 1 to 10 } println(i * j) ! val f = for { x <- callService1() y <- callService2(x) } yield y println(Await.result(f, Duration.Inf)) ! ! def capitalize(name: Option[String]): Option[String] = for (n <- name) yield { n(0).toUpper + n.substring(1) } ! ! Sc al a
  17. 17. Refactoring
  18. 18. “By continuously improving the design of code, we make it easier and easier to work with. This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently adding new features. If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code.” http://en.wikipedia.org/wiki/Code_refactoring
  19. 19. •Abstraction •Composition/Decomposition •Name & Location
  20. 20. 1. Finite, unchanging list of possible refactorings. 2. Every refactoring is reversible. 3. Every refactoring is deterministic. 4. Refactorings can be combined in any order.
  21. 21. Group Theory
  22. 22. “‘Numbers measure size; groups measure symmetry.” Groups and Symmetry, Armstrong, Spring-Verlag, 1988, p.1
  23. 23. “The most substantial piece of writing in the whole literature of mankind” http://upload.wikimedia.org/wikipedia/commons/5/53/Evariste_galois.jpg
  24. 24. http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
  25. 25. http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
  26. 26. “the symmetry group of an object is the group of all isometries under which the object is invariant with composition as the operation” http://en.wikipedia.org/wiki/Symmetry_group
  27. 27. “the symmetry group of a program ... is the group of all refactorings under which the program behaves identically after applying refactorings in any order”
  28. 28. for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 10; j++) { System.out.println(i*j); } } ! ! Future<Integer> f = callService1(); Future<Integer> f2 = callService2(f.get()); System.out.println(f2.get()); Ja va String capitalize(String name) { if (name == null) return null; else return Character.toUpperCase( name.charAt(0)) + name.substring(1); } for { i <- 1 to 10 j <- 1 to 10 } println(i * j) ! val f = for { x <- callService1() y <- callService2(x) } yield y println(Await.result(f, Duration.Inf)) ! ! def capitalize(name: Option[String]): Option[String] = for (n <- name) yield { n(0).toUpper + n.substring(1) } ! ! Sc al a
  29. 29. Breaking Symmetry
  30. 30. a[i].x += a[i - 1].x; a[i].y += a[i - 1].y; http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
  31. 31. a[i].x += a[i - 1].x; a[i].y += a[i - 1].y; a(i) += a(i-1) http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
  32. 32. 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
  33. 33. 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
  34. 34. 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
  35. 35. http://www.biographyonline.net/artists/images/Much-The_Scream.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.pics24h.com/img/artwork/5-most-famous-paintings/5-most-famous-paintings03.jpg
  36. 36. Fin niF join us. http://tech.gilt.com @gilttech @ebowman ebowman@gilt.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×