42
Pharo: un langage moderne, un environnement de live programming, une communauté qui monte Damien Cassou and Stéphane Ducasse http://www.pharo.org

Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Pharo: un langage moderne,un environnement de live programming, une communauté qui monte

Damien Cassou and Stéphane Ducassehttp://www.pharo.org

Page 2: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

What it is

Programming language + IDEObject-Oriented, Dynamic, Reflective

Explore + Change running systems

The Ultimate Live Programming Environment!

Page 3: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Pharo

MIT licenseGreat community of active doersPowerfulElegant and fun to programLiving system under your fingersMac, Linux, Android, iOS, Windows

Page 4: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

3rd most downloaded on Inria gforge600 mailing-list members215 license agreements70 association members28 industrial consortium members

in March 2015

Pharo in numbers

Page 5: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Create an ecosystem where business/innovation

can bloom

Page 6: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

A Little Journey in the Pharo Object Model

Page 7: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

No constructors, no static methods, no operators

No interfaces, no private/protected modifiers

No type declarations, no parametrized types

No primitive types, no boxing/unboxing

Still powerful

Page 8: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

1 class

⇒ SmallInteger

Page 9: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

1 class

⇒ SmallInteger

1 class maxVal

⇒ 1073741823

Page 10: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

1 class

⇒ SmallInteger

1 class maxVal

⇒ 1073741823

1 class maxVal + 1

⇒ 1073741824

Page 11: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

1 class

⇒ SmallInteger

1 class maxVal

⇒ 1073741823

1 class maxVal + 1

⇒ 1073741824

(1 class maxVal + 1) class

⇒ LargePositiveInteger

Page 12: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

(1/3) + (2/3)

⇒ 1

Page 13: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

(1/3) + (2/3)

⇒ 1

2/3 + 1

⇒ 5/3

Page 14: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

(1/3) + (2/3)

⇒ 1

2/3 + 1

⇒ 5/3

1000 factorial

4023872600770937735437024339230039857193748642107146325437999104299385123986290205920442084869694048004799886101971960586316668729948085589013238296699445909974245040870737599188236277271887325197795059509952761208749754624970436014182780946464962910563938874378864873371191810458257836478499770124766328898359557354325131853239584630755574091142624174743493475534286465766116677973966688202912073791438537195882498081268678383745597317461360853795345242215865932019280908782973084313928444032812315586110369768013573042161687476096758713483120254785893207671691324484262361314125087802080002616831510273418279777047846358681701643650241536913982812648102130927612448963599287051149649754199093422215668325720808213331861168115536158365469840467089756029009505376164758477284218896796462449451607653534081989013854424879849599533191017233555566021394503997362807501378376153071277619268490343526252000158885351473316117021039681759215109077880193931781141945452572238655414610628921879602238389714760885062768629671466746975629112340824392081601537808898939645182632436716167621791689097799119037540312746222899880051954444142820121873617459926429565817466283029555702990243241531816172104658320367869061172601587835207515162842255402651704833042261439742869330616908979684825901254583271682264580665267699586526822728070757813918581788896522081643483448259932660433676601769996128318607883861502794659551311565520360939881806121385586003014356945272242063446317974605946825731037900840244324384656572450144028218852524709351906209290231364932734975655139587205596542287497740114133469627154228458623773875382304838656889764619273838149001407673104466402598994902222217659043399018860185665264850617997023561938970178600408118897299183110211712298459016419210688843871218556461249607987229085192968193723886426148396573822911231250241866493531439701374285319266498753372189406942814341185201580141233448280150513996942901534830776445690990731524332782882698646027898643211390835062170950025973898635542771967428222487575867657523442202075736305694988250879689281627538488633969099598262809561214509948717012445164612603790293091208890869420285106401821543994571568059418727489980942547421735824010636774045957417851608292301353580818400969963725242305608559037006242712434169090041536901059339838357779394109700277534720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Page 15: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Language Constructs

^ return“ comments # symbol or array‘ string[] block. separator; cascade| local or block variable:= assignment$ character<...> annotation

Page 16: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Examplescomment: "a comment "character: $cstring: 'a string'symbol: #unix array: { 1 . 123 + 1 }literal array: #(1 2 3 (1 3) $a 4)byte array: #[1 2 3]block: [ :x | x * 2 ]numbers: 1.5 6.03e-34 4 2.4e7keywords: true false nil self super thisContext

Page 17: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Not Syntax

& conjunction (and)| disjunction (or)+ addition< lower thanifTrue: conditiondo: iteration...

all of these are plain methods!

Page 18: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Not Syntax

& conjunction (and)| disjunction (or)+ addition< lower thanifTrue: conditiondo: iteration...

Boolean>>

Boolean>>

Number>>

Magnitude>>

Boolean>>

Collection>>

their classes

3 = 2 ifTrue: [ Error signal: 'Help' ]

Page 19: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

3 kinds of messagesUnary messages

Binary messages

Keyword messages

5 factorialTranscript cr

3 + 4

2 between: 0 and: 5

Transcript show: 'hello world'

Page 20: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman.send( mail, recipient);

Keyword messages

Page 21: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman.send( mail, recipient);

Keyword messages

Page 22: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman send mail recipient

Keyword messages

Page 23: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman send mail to recipient

Keyword messages

Page 24: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman send: mail to: recipient

Keyword messages

Page 25: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

postman send: mail to: recipient

Keyword messages

send:to: method in the Postman class

receiver argument 1 argument 2

message send

Page 26: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Black magic

Page 27: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Execution Stack as an Object

To define exceptions from within the language

Debugger support!

Advanced debugging

Continuation

Page 28: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

thisContext

returns an object that represents the method invocationcan walk (even modify!) the stack

Page 29: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Serializing Continuations[ "some code causing an error" ] on: Error do: [ :error | FLSerializer serialize: error toFileNamed: 'error.fuel' ]

On a different computer open a debugger on the serialized error:

FLMaterializer materializeFromFileNamed: 'error.fuel'; debug.

Page 30: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Powerful Breakpoints?

Would be so good if we could say:“Stop method bar only if it is called from method named foo” i.e.,bar ... Halt whenCalledFrom: #foo. ...

Page 31: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Halt>> whenCalledFrom: aSelector | ctxt | ctxt := thisContext. [ ctxt sender isNil ] whileFalse: [ ctxt := ctxt sender. ctxt selector = aSelector ifTrue: [ self signal ] ]

Page 32: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Pointer Swapping

anObject become: anotherObject

Page 33: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

| pt1 pt2 ref |

pt1 := 0@0.

pt2 := 100@100.

ref := pt1.

pt1 become: pt2.

self assert: ref = (100@100).

self assert: pt2 = (0@0).

self assert: pt1 = (100@100).

Pointer Swapping

Page 34: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Demo:

Pharo, a live programming environment

Color swapping

Page 35: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

We are a cool community

Page 36: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

www.10pines.comwww.2denker.dewww.agilitic.com

www.airflowing.comwww.anymorphic.comwww.ardishealth.com

www.beta9.bewww.bombardier.com

www.cmsbox.comwww.finworks.biz

seaside.gemstone.comwww.ibizlog.comwww.inceptive.bewww.jooshr.comwww.majcon.de

www.mindclue.chwww.miriamtech.com

www.myneat.orgwww.netstyle.ch

www.objectfusion.frwww.panasoft.comwww.pinesoft.co.uk

www.promedmedical.netwww.sharedlogic.ca

www.smallworks.com.arwww.trantaria.com www.square-i.net

yesplan.be

Companies

Page 38: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Lafhis (University of Bueno Aires )Software Composition Group (scg.unibe.ch)CAR (Ecole des mines www.ensm-douai.fr)RMoD (Inria)Ummisco (IRD)Reveal (University of Lugano) Lysic (University of Bretagne Occidentale)Pleiad (University of Santiago)CEA-List

Research Groups

Page 39: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

Pharo books

Pharo by example translated to french, merci!translated to spanish, gracias!translated to japanese, ありがとう!

Deep into Pharo

http://pharobyexample.org

http://deepintopharo.com

Page 40: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

New books are coming

Enterprise Pharo

A glimpse at VM

Page 41: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

[...]June 2010 BruxellesJuly 2010 LondonSeptember 2010 BarcelonaSeptember 2010 LilleJanuary 2011 LilleJuly 2011 LilleOctober 2011 BruxellesFebruary 2012 BernOctober 2012 BernApril 2012 LilleAugust 2012 GhentOctober 2012 Perto MadrynJanuary 2013 SantiagoFebruary 2013 LilleApril 2013 LilleJune 2013 LilleFebruary 2014 LilleApril 2014 LilleSeptember 2014 LilleJanuary 2015 LilleApril 2015 Lille

Open Pharo Sprints

Page 42: Pharo - Inriased.bordeaux.inria.fr/seminars/pharo_20150324.pdf · 2020-02-18 · Pharo MIT license Great community of active doers Powerful Elegant and fun to program Living system

To Take AwayBecause it is simple and extensible, Pharo is a nice platform to experiment on

Use it for your own research and developments

http://www.pharo.org