SlideShare a Scribd company logo
1 of 23
Download to read offline
Except where otherwise noted, this work is licensed under: http:
//creativecommons.org/licenses/by-nc-sa/3.0/
The polyglot programmer
Leganés, feb 11, 12
David Muñoz
@voiser
objective:
qualitative description of languages
let’s focus on some simple concepts
style (structured / OO / prototype / functional / ...)
typing (static / dynamic / strong / weak)
execution model (high / low level, native, vm, thread safety, ...)
difference between syntax, semantics, idioms, libraries and tools
C (1972) - structured
#include <stdio.h>
void update(int i) {
i = i + 1;
}
int main() {
int i = 0;
println(“i = %dn”, i); // i = 0
update(i);
println(“i = %dn”, i); // i = ?
char * str = (char*)i; // ?
return 0;
}
hero
C (1972) - structured
#include <stdio.h>
void update(int i) {
i = i + 1;
}
int main() {
int i = 0;
println(“i = %dn”, i); // i = 0
update(i);
println(“i = %dn”, i); // i = ?
char * str = (char*)i; // ?
return 0;
}
master
static typing
pass by value
it’s a high level assembly!
weak type system
C (1972) - structured
0000000000400506 <update>:
400506: 55 push %rbp
400507: 48 89 e5 mov %rsp,%rbp
40050a: 89 7d fc mov %edi,-0x4(%rbp)
40050d: 83 45 fc 01 addl $0x1,-0x4(%rbp)
400511: 5d pop %rbp
400512: c3 retq
0000000000400513 <main>:
400513: 55 push %rbp
400514: 48 89 e5 mov %rsp,%rbp
400517: 48 83 ec 10 sub $0x10,%rsp
40051b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
400522: 8b 45 fc mov -0x4(%rbp),%eax
400525: 89 c6 mov %eax,%esi
400527: bf e4 05 40 00 mov $0x4005e4,%edi
40052c: b8 00 00 00 00 mov $0x0,%eax
400531: e8 aa fe ff ff callq 4003e0 <printf@plt>
400536: 8b 45 fc mov -0x4(%rbp),%eax
400539: 89 c7 mov %eax,%edi
40053b: e8 c6 ff ff ff callq 400506 <update>
400540: 8b 45 fc mov -0x4(%rbp),%eax
400543: 89 c6 mov %eax,%esi
400545: bf e4 05 40 00 mov $0x4005e4,%edi
40054a: b8 00 00 00 00 mov $0x0,%eax
40054f: e8 8c fe ff ff callq 4003e0 <printf@plt>
400554: b8 00 00 00 00 mov $0x0,%eax
400559: c9 leaveq
40055a: c3 retq
40055b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
god of metal
C++ (1983) - Object oriented
#include <iostream>
using namespace std;
class Point
{
public:
float _x, _y;
Point(float x, float y)
: _x(x), _y(y) {}
};
ostream &operator<<
(ostream &os, Point const &p)
{
return os <<
"Point(" << p._x << "," << p._y << ")";
}
void update(Point p) {
p._x += 1;
p._y += 1;
}
int main() {
Point a(1, 2);
cout << a << endl; // Point(1, 2)
update(a);
cout << a << endl; // Point(?, ?)
char * str = (char*)a; // ?
char * str = (char*)&a; // ?
return 0;
}
C++ (1983) - Object oriented
#include <iostream>
using namespace std;
class Point
{
public:
float _x, _y;
Point(float x, float y)
: _x(x), _y(y) {}
};
ostream &operator<<
(ostream &os, Point const &p)
{
return os <<
"Point(" << p._x << "," << p._y << ")";
}
void update(Point p) {
p._x += 1;
p._y += 1;
}
int main() {
Point a(1, 2);
cout << a << endl;
update(a);
cout << a << endl;
char * str = (char*)a;
char * st2 = (char*)&a;
return 0;
}
static typing
pass by value (also by ref,
not shown in this
example)
a little bit higher level than assembly
weak type system
namespaces
(operator) overloading
module Example where
data Point a = Point a a deriving (Show)
update (Point x y) = Point (x+1) (y+1)
applyTwice f x = f (f x)
main =
let
a = Point 1 1
b = applyTwice update a
b = update b -- ?
in
print b
Haskell (1990) - functional
module Example where
data Point a = Point a a deriving (Show)
update (Point x y) = Point (x+1) (y+1)
applyTwice f x = f (f x)
main =
let
a = Point 1 1
b = applyTwice update a
b = update b -- ?
in
print b
Haskell (1990) - functional
data type and constructor
strong, static typing, type inference
looks and feels different. Don’t take a look at the native code generated.
immutability
Let’s give it a try
Python (1991)
describe me!
Python (1991) code example
class AgentManager:
def add(self, name, source, sender=None, locale="en"):
""" Add an agent to the list. """
self.set_locale(locale)
if not self.has_permissions(sender):
print(MSG_NO_PERM)
return self.feedback(MSG_NO_PERM, sender)
alist = self.read_list()
$ python3
...
>>> 1 + "2"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> a = 1
>>> a = "this is a string"
https://github.com/voiser/zoe-startup-kit/blob/master/agents/zam/zam.py
Python (1991)
high level
object oriented
dynamic, strong typing
vm, gc
pretty*syntax, significant whitespace
huge community
(probably there’s a python library for that!)
CPython / Jython / PyPy / IronPython
what if I describe you a language without
letting you see actual code?
high level
object oriented
vm jit, gc
static, explicit, strong* typing
(messy) generic types
simple*, verbose, bureaucratic
enormous community
Java - let me break your strong type system
import java.util.List;
public class T3chFest {
private Object[] stuff;
private List<Object> rooms;
public T3chFest(String[] talks, List<String> rooms) {
this.stuff = talks;
stuff[0] = Thread.currentThread(); // ?
this.rooms = rooms; // ?
List rooms2 = rooms; // ?
this.rooms = rooms2; // ?
}
}
~ java + ML
functional + object oriented
jvm
static, strong rock-solid adamantium-like
heavier-than-the-gods-of-metal typing
nice* syntax with (partial) type inference
A language build on its type system
into JVM? learn. it. now.
Scala (2003)
scala> val a = Array("a", "b", "c")
a: Array[String] = Array(a, b, c)
scala> val b: Array[Object] = a
<console>:11: error: type mismatch;
found : Array[String]
required: Array[Object]
Note: String <: Object, but class Array is invariant in type T.
Scala (2003) - fun with invariance
scala> class Animal;
scala> class Mammal extends Animal;
scala> class Human extends Mammal;
scala> class Group[ +A]
scala> def sizeof(g: Group[ Animal]) = ...
scala> sizeof(new Group[ Animal]())
scala> sizeof(new Group[ Mammal]())
scala> class Veterinary[ -A]
scala> def treat(g: Group[Mammal], v: Veterinary[ Mammal]) = ...
scala> treat(..., new Veterinary[ Mammal]())
scala> treat(..., new Veterinary[ Animal]())
scala> class Treatment[ T <: Mammal]
scala> def cure[B](x: Group[ B]) : Treatment[ B] = …
error: type arguments [B] do not conform to class Treatment's type parameter bounds [T
<: Mammal]
scala> def cure[ B <: Mammal](x: Group[B]) : Treatment[ B] = ...
Scala - basic types
typeclasses
structural types (a.k.a. duck typing)
refined types
self-recursive types
path-dependent types
...
tip of the iceberg
The recruiter’s infinite knowledge
Why are you interested in Scala, when
Java 8 already has lambdas?
Except where otherwise noted, this work is licensed under: http:
//creativecommons.org/licenses/by-nc-sa/3.0/
Leganés, feb 11, 12
Thanks!

More Related Content

What's hot

Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...John De Goes
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemJohn De Goes
 
Halogen: Past, Present, and Future
Halogen: Past, Present, and FutureHalogen: Past, Present, and Future
Halogen: Past, Present, and FutureJohn De Goes
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meetMario Fusco
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Leonardo Borges
 
Demystifying functional programming with Scala
Demystifying functional programming with ScalaDemystifying functional programming with Scala
Demystifying functional programming with ScalaDenis
 
The Death of Final Tagless
The Death of Final TaglessThe Death of Final Tagless
The Death of Final TaglessJohn De Goes
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Jonas Bonér
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation JavascriptRamesh Nair
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free MonadsJohn De Goes
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
Future vs. Monix Task
Future vs. Monix TaskFuture vs. Monix Task
Future vs. Monix TaskHermann Hueck
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Susan Potter
 

What's hot (20)

Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
The Easy-Peasy-Lemon-Squeezy, Statically-Typed, Purely Functional Programming...
 
The Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect SystemThe Design of the Scalaz 8 Effect System
The Design of the Scalaz 8 Effect System
 
Halogen: Past, Present, and Future
Halogen: Past, Present, and FutureHalogen: Past, Present, and Future
Halogen: Past, Present, and Future
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
Demystifying functional programming with Scala
Demystifying functional programming with ScalaDemystifying functional programming with Scala
Demystifying functional programming with Scala
 
The Death of Final Tagless
The Death of Final TaglessThe Death of Final Tagless
The Death of Final Tagless
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Post-Free: Life After Free Monads
Post-Free: Life After Free MonadsPost-Free: Life After Free Monads
Post-Free: Life After Free Monads
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
Future vs. Monix Task
Future vs. Monix TaskFuture vs. Monix Task
Future vs. Monix Task
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Stack queue
Stack queueStack queue
Stack queue
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
Joy of scala
Joy of scalaJoy of scala
Joy of scala
 

Similar to T3chFest 2016 - The polyglot programmer

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossumoscon2007
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.pptssuserd64918
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploitshughpearse
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type ClassesTapio Rautonen
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsMichael Pirnat
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Guy Lebanon
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScriptChengHui Weng
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answersdebarghyamukherjee60
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriyacodebits
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
Behavior driven oop
Behavior driven oopBehavior driven oop
Behavior driven oopPiyush Verma
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 

Similar to T3chFest 2016 - The polyglot programmer (20)

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossum
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.ppt
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Generic Functional Programming with Type Classes
Generic Functional Programming with Type ClassesGeneric Functional Programming with Type Classes
Generic Functional Programming with Type Classes
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Behavior driven oop
Behavior driven oopBehavior driven oop
Behavior driven oop
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 

Recently uploaded

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 

Recently uploaded (20)

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 

T3chFest 2016 - The polyglot programmer

  • 1. Except where otherwise noted, this work is licensed under: http: //creativecommons.org/licenses/by-nc-sa/3.0/ The polyglot programmer Leganés, feb 11, 12 David Muñoz @voiser
  • 3. let’s focus on some simple concepts style (structured / OO / prototype / functional / ...) typing (static / dynamic / strong / weak) execution model (high / low level, native, vm, thread safety, ...) difference between syntax, semantics, idioms, libraries and tools
  • 4. C (1972) - structured #include <stdio.h> void update(int i) { i = i + 1; } int main() { int i = 0; println(“i = %dn”, i); // i = 0 update(i); println(“i = %dn”, i); // i = ? char * str = (char*)i; // ? return 0; } hero
  • 5. C (1972) - structured #include <stdio.h> void update(int i) { i = i + 1; } int main() { int i = 0; println(“i = %dn”, i); // i = 0 update(i); println(“i = %dn”, i); // i = ? char * str = (char*)i; // ? return 0; } master static typing pass by value it’s a high level assembly! weak type system
  • 6. C (1972) - structured 0000000000400506 <update>: 400506: 55 push %rbp 400507: 48 89 e5 mov %rsp,%rbp 40050a: 89 7d fc mov %edi,-0x4(%rbp) 40050d: 83 45 fc 01 addl $0x1,-0x4(%rbp) 400511: 5d pop %rbp 400512: c3 retq 0000000000400513 <main>: 400513: 55 push %rbp 400514: 48 89 e5 mov %rsp,%rbp 400517: 48 83 ec 10 sub $0x10,%rsp 40051b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp) 400522: 8b 45 fc mov -0x4(%rbp),%eax 400525: 89 c6 mov %eax,%esi 400527: bf e4 05 40 00 mov $0x4005e4,%edi 40052c: b8 00 00 00 00 mov $0x0,%eax 400531: e8 aa fe ff ff callq 4003e0 <printf@plt> 400536: 8b 45 fc mov -0x4(%rbp),%eax 400539: 89 c7 mov %eax,%edi 40053b: e8 c6 ff ff ff callq 400506 <update> 400540: 8b 45 fc mov -0x4(%rbp),%eax 400543: 89 c6 mov %eax,%esi 400545: bf e4 05 40 00 mov $0x4005e4,%edi 40054a: b8 00 00 00 00 mov $0x0,%eax 40054f: e8 8c fe ff ff callq 4003e0 <printf@plt> 400554: b8 00 00 00 00 mov $0x0,%eax 400559: c9 leaveq 40055a: c3 retq 40055b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) god of metal
  • 7. C++ (1983) - Object oriented #include <iostream> using namespace std; class Point { public: float _x, _y; Point(float x, float y) : _x(x), _y(y) {} }; ostream &operator<< (ostream &os, Point const &p) { return os << "Point(" << p._x << "," << p._y << ")"; } void update(Point p) { p._x += 1; p._y += 1; } int main() { Point a(1, 2); cout << a << endl; // Point(1, 2) update(a); cout << a << endl; // Point(?, ?) char * str = (char*)a; // ? char * str = (char*)&a; // ? return 0; }
  • 8. C++ (1983) - Object oriented #include <iostream> using namespace std; class Point { public: float _x, _y; Point(float x, float y) : _x(x), _y(y) {} }; ostream &operator<< (ostream &os, Point const &p) { return os << "Point(" << p._x << "," << p._y << ")"; } void update(Point p) { p._x += 1; p._y += 1; } int main() { Point a(1, 2); cout << a << endl; update(a); cout << a << endl; char * str = (char*)a; char * st2 = (char*)&a; return 0; } static typing pass by value (also by ref, not shown in this example) a little bit higher level than assembly weak type system namespaces (operator) overloading
  • 9. module Example where data Point a = Point a a deriving (Show) update (Point x y) = Point (x+1) (y+1) applyTwice f x = f (f x) main = let a = Point 1 1 b = applyTwice update a b = update b -- ? in print b Haskell (1990) - functional
  • 10. module Example where data Point a = Point a a deriving (Show) update (Point x y) = Point (x+1) (y+1) applyTwice f x = f (f x) main = let a = Point 1 1 b = applyTwice update a b = update b -- ? in print b Haskell (1990) - functional data type and constructor strong, static typing, type inference looks and feels different. Don’t take a look at the native code generated. immutability
  • 13. Python (1991) code example class AgentManager: def add(self, name, source, sender=None, locale="en"): """ Add an agent to the list. """ self.set_locale(locale) if not self.has_permissions(sender): print(MSG_NO_PERM) return self.feedback(MSG_NO_PERM, sender) alist = self.read_list() $ python3 ... >>> 1 + "2" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> a = 1 >>> a = "this is a string" https://github.com/voiser/zoe-startup-kit/blob/master/agents/zam/zam.py
  • 14. Python (1991) high level object oriented dynamic, strong typing vm, gc pretty*syntax, significant whitespace huge community (probably there’s a python library for that!) CPython / Jython / PyPy / IronPython
  • 15. what if I describe you a language without letting you see actual code?
  • 16. high level object oriented vm jit, gc static, explicit, strong* typing (messy) generic types simple*, verbose, bureaucratic enormous community
  • 17. Java - let me break your strong type system import java.util.List; public class T3chFest { private Object[] stuff; private List<Object> rooms; public T3chFest(String[] talks, List<String> rooms) { this.stuff = talks; stuff[0] = Thread.currentThread(); // ? this.rooms = rooms; // ? List rooms2 = rooms; // ? this.rooms = rooms2; // ? } }
  • 18. ~ java + ML functional + object oriented jvm static, strong rock-solid adamantium-like heavier-than-the-gods-of-metal typing nice* syntax with (partial) type inference A language build on its type system into JVM? learn. it. now. Scala (2003)
  • 19. scala> val a = Array("a", "b", "c") a: Array[String] = Array(a, b, c) scala> val b: Array[Object] = a <console>:11: error: type mismatch; found : Array[String] required: Array[Object] Note: String <: Object, but class Array is invariant in type T. Scala (2003) - fun with invariance
  • 20. scala> class Animal; scala> class Mammal extends Animal; scala> class Human extends Mammal; scala> class Group[ +A] scala> def sizeof(g: Group[ Animal]) = ... scala> sizeof(new Group[ Animal]()) scala> sizeof(new Group[ Mammal]()) scala> class Veterinary[ -A] scala> def treat(g: Group[Mammal], v: Veterinary[ Mammal]) = ... scala> treat(..., new Veterinary[ Mammal]()) scala> treat(..., new Veterinary[ Animal]()) scala> class Treatment[ T <: Mammal] scala> def cure[B](x: Group[ B]) : Treatment[ B] = … error: type arguments [B] do not conform to class Treatment's type parameter bounds [T <: Mammal] scala> def cure[ B <: Mammal](x: Group[B]) : Treatment[ B] = ... Scala - basic types
  • 21. typeclasses structural types (a.k.a. duck typing) refined types self-recursive types path-dependent types ... tip of the iceberg
  • 22. The recruiter’s infinite knowledge Why are you interested in Scala, when Java 8 already has lambdas?
  • 23. Except where otherwise noted, this work is licensed under: http: //creativecommons.org/licenses/by-nc-sa/3.0/ Leganés, feb 11, 12 Thanks!