54
SEVEN LANGUAGES IN SEVEN WEEKS Renan Ranelli

sete linguagens em sete semanas

Embed Size (px)

Citation preview

Page 1: sete linguagens em sete semanas

SEVEN LANGUAGES IN SEVEN WEEKS

Renan Ranelli

Page 2: sete linguagens em sete semanas

Renan Ranelli (Milhouse)

Page 3: sete linguagens em sete semanas

Software Engineer @

Renan Ranelli (Milhouse)

Page 4: sete linguagens em sete semanas
Page 5: sete linguagens em sete semanas
Page 6: sete linguagens em sete semanas

AGENDA

• Why should I care about learning new languages?• A little bit about the languages in the book and how

they compare with Ruby• What I learned during the last few years

Page 7: sete linguagens em sete semanas

WHO IS THIS TALK FOR

• You, who is an Object oriented programmer and has heard about functional programming

• You, who have no clear understanding on why learning many languages will help you be better at your language of choice

Page 8: sete linguagens em sete semanas

1 - WHY SHOULD I CARE?

Page 9: sete linguagens em sete semanas

WHY SHOULD I CARE ?

• First of all...

• I Think you should learn programming languages

• But my opinion probably will not matter to you.So, listen to these guys:

Page 10: sete linguagens em sete semanas

http://blog.golang.org/concurrency-is-not-parallelism

Page 11: sete linguagens em sete semanas

http://blog.golang.org/concurrency-is-not-parallelism

Page 12: sete linguagens em sete semanas

http://blog.golang.org/concurrency-is-not-parallelism

Page 13: sete linguagens em sete semanas
Page 14: sete linguagens em sete semanas

DISCLAIMER: ALL THE LANGUAGES HERE ARE TURING COMPLETE

Page 15: sete linguagens em sete semanas

WE WILL A LITTLE ABOUT

• Ruby• Io• Prolog• Scala• Erlang• Clojure• Haskell

Page 16: sete linguagens em sete semanas

WHAT I AIM TO ACHIEVE

• I will try to explain what is important when learning a new programming language

• I expect to show you that characterizations such as “it is a functional language” or “it is object oriented” is insufficient and most of the times innapropriate

• I *Do Not* intend to teach you any of the languages

Page 17: sete linguagens em sete semanas

WE WILL A LITTLE ABOUT

• Ruby• Io• Scala• Erlang• Clojure• Haskell

Support for OOP

Support for FP

Page 18: sete linguagens em sete semanas

2 – SELECTED POINTS ABOUT EACH LANGUAGE

Page 19: sete linguagens em sete semanas

RUBY

• Object oriented, class based, dynamic and strongly typed

• *Extremely* meta-programmable• OPEN CLASSES !!!!!!• Complex syntax, complex evaluation rules• Reads like a novel

• We all know and love it

Page 20: sete linguagens em sete semanas

IO

• Object oriented, prototype based, strongly typed• Extremely simple and consistent syntax• Heavy emphasis on message passing, not method call.

(method is a message that returns an object that can receive the message call)

• Easy to create DSLs• Excellent concurrency primitives (futures, corroutines,

actors)• CRAZY amount of reflective power

Page 21: sete linguagens em sete semanas

IO

Page 22: sete linguagens em sete semanas

IO

Message

Page 23: sete linguagens em sete semanas

IO

Message

Page 24: sete linguagens em sete semanas

IO

Message

Page 25: sete linguagens em sete semanas

IO

Message

Page 26: sete linguagens em sete semanas

IO

Page 27: sete linguagens em sete semanas

IO

Page 28: sete linguagens em sete semanas

SCALA

• OOP, FP, statically typed, strongly typed• Has a powerful type system (not as much as Haskell's)• Offers advanced FP concepts such as monads and type

classes• Easy(-ish) to create DSLs• You can emulate non-strict evaluation with “call by

name” vs “call by value” parameter passing strategies• Suffers from the Java legacy to a certain extent (nulls)

Page 29: sete linguagens em sete semanas

SCALA

Page 30: sete linguagens em sete semanas

SCALA

Page 31: sete linguagens em sete semanas

SCALA

Page 32: sete linguagens em sete semanas

SCALA

Page 33: sete linguagens em sete semanas

SCALA

Page 34: sete linguagens em sete semanas

ERLANG

• Designed by Ericsson to build telecom software• Alien syntax, derived from Prolog• Functional, enforces extreme isolation of processes.

Truly share-nothing.• Amazing support for faul-tolerant, near-real-time

distributed application development• Quite opinionated ..• ALIEN SYNTAX

Page 35: sete linguagens em sete semanas

CLOJURE

• Is a LISP (!!1!!11)• FP, supports OOP, strongly typed and dynamically• Strong focus on good concurrency primitives and

immutable & persistent data structures• Being a LISP, has macros• Being a LISP, code is data and data is code• Not so Lispy. No custom reader macros and no

automatic tail call optimizations (schemers be mad)

Page 36: sete linguagens em sete semanas

CLOJURE

• Although Clojure is a strict language, you can simulate non-strictness using macros

• Its possible to define the language on-the-fly, i.e., the language is internally reprogramable (heavy influce in both Ruby and Smalltalk)

• Offers the CLOS-like long forgotten multiple-dispatch !

Page 37: sete linguagens em sete semanas

HASKELL

• Non-strict (lazy) pure functional language• No exceptions and no mutable state (!)• Unparalleled type system (at least in production-ready

languages) with parametric types, type classes, algebraic data types and type inference

• Offers the full pack of FP crazyness: Monads, Monoids, Functors, applicatives, Foldables and Semigroups are common ground among Haskell programmers

• Much more close to Math, simplyfing the way we represent abstract, symbolic and self-recursive constructs

Page 38: sete linguagens em sete semanas

HASKELL

• Makes it impossible to mutate state• But allow you to simulate its effects with Monads

Page 39: sete linguagens em sete semanas

HASKELL

Page 40: sete linguagens em sete semanas

HASKELL

Page 41: sete linguagens em sete semanas

HASKELL

Page 42: sete linguagens em sete semanas

3 – WHAT I LEARNED AFTER READING THIS BOOK

Page 43: sete linguagens em sete semanas

WHAT DOES IT TAKE TO LEARN A NEW LANGUAGE ?

• Syntax• The programming languages primitives• The type system (strong or weak? Static or dynamic?)• Evaluation rules (precedence, strictness, etc)• Idioms• Libraries• Tools, IDEs, yadda yadda

Page 44: sete linguagens em sete semanas

WHAT DOES IT TAKE TO USE A LANGUAGE IN PRODUCTION

• Meta-programming and extensibility models• Concurrency model• Library distribution• Debugging, IDEs, Tools, Refactoring tools ...• *Community*• Concurrency model (again!)

Page 45: sete linguagens em sete semanas

YOU CAN'T SEPARATE THE LANGUAGE AND ITS ECOSYSTEM

Page 46: sete linguagens em sete semanas

IS IT THAT RUBY IS PRODUCTIVE IN ITSELF, OR ARE RUBY LIBRARIES, LIKE RAILS, PRODUCTIVE??

Page 47: sete linguagens em sete semanas

LEARN FROM OTHERS

Page 48: sete linguagens em sete semanas

UNDERSTAND HOW THEY SOLVE PROBLEMS YOU HAVE, OR PROBLEMS YOU DON'T EVEN KNOW YOU HAVE

Page 49: sete linguagens em sete semanas

GET TO KNOW WHAT YOU CAN IMITATE !

SEE CONCURRENT-RUBY AND CELLULOID !

Page 50: sete linguagens em sete semanas

THERE IS *A LOT* OF COOL STUFF OUT THERE. LOOK OUTSIDE YOUR COMMUNITY

Page 51: sete linguagens em sete semanas

HAVE FUN

Page 52: sete linguagens em sete semanas

HAVE FUN

Page 53: sete linguagens em sete semanas

OBRIGADO !

Page 54: sete linguagens em sete semanas

@renanranelli

/rranelli

Renan Ranelli (Milhouse)

milhouseonsofware.com