Introduction of Pharo 5.0
-
Upload
masashi-umezawa -
Category
Software
-
view
1.022 -
download
0
Transcript of Introduction of Pharo 5.0
![Page 1: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/1.jpg)
2016 SoftUmeYa, LLC.
Masashi Umezawa
The 88th Tokyo Smalltalk meetup
![Page 2: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/2.jpg)
What is Pharo?
A most modern and powerful Smalltalk-
language environment
OSS
MIT License
You can read all sources including VM
Aggressive
Not so caring about backward-compatibility
Actively adding new features - Trait, Slot, etc.
Multi-platform
Win, Mac, Linux, iOS, Android
![Page 3: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/3.jpg)
Installation
Just download and extract files http://pharo.org/download
Or, you can just use Zeroconf script
Run the vm with the image file
$ curl get.pharo.org | bash
$ pharo.exe pharo5.0.image
![Page 4: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/4.jpg)
How to use Japanese fonts Open the settings tool by selecting
"System" -> "Settings" and enter the search word
'font'
Toggle the "Use Free Type" check-box to
read local fonts
You can now select
native fonts like
"Meiryo"
![Page 5: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/5.jpg)
New features of Pharo 5.0
Spur VM
Breakpoint, Watchpoint
Unified FFI
Quality Assistant
![Page 6: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/6.jpg)
Spur VM State-of-the-art, newly designed fast VM
About 35% faster than the older Cog VM
Fast #become:
Fast weak reference
Fast, efficient GC
Segmented heap allocation
Pinned objects
64 bit object format
![Page 7: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/7.jpg)
If you concatenate Japanese strings…
Concatenating single- and multi-byte strings
was very slow
because of costly #become:
[10000 timesRepeat: ['abcdefg', 'あいうえおかきくけこ']]
timeToRun
Pharo 4.0
0:00:00:17.573
Pharo 5.0
0:00:00:00.117
![Page 8: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/8.jpg)
Breakpoint, Watchpoint No more "self halt", nor "self inspect"
You can stop message sends at any point
You can check variable changes historically
![Page 9: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/9.jpg)
UFFI "Unified" FFI
Best breeds of FFI, Alien FFI and NativeBoost FFI
self ffiCall: <external function signature>
Callback (call-in) implementation is easier
Library name abstraction layer for multi-platform
support
Good example: PunQLite
UnQLiteFFI>>open: dbHandle named: dbName mode: mode
^ self ffiCall: #( int unqlite_open( db_ptr* dbHandle, String
dbName, uint mode) )
![Page 10: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/10.jpg)
Quality Assistant
Pharo lively analyze your code!
If it is baddy smelled, you can see suggestions
変数への代入は分岐から外出しした方が良くない?
![Page 11: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/11.jpg)
Other features
Debugger UI Renewal
GTDebugger
Simplified UI
Customizable debugger
Rubric
Newly designed text edit component
Develop a richer text-edit in a few lines of code
Slot
Variables are now objects
You can add various hooks to variable accesses
![Page 12: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/12.jpg)
Installing packages Open "Tools" -> "Catalog Browser"
You can easily install packages via catalog
browser
Filter the packages by clicking 'Pharo 5.0' tag
Mustache
A popular template engine
Teapot
Sinatra-like lightweight web-app framework
PunQLite
UnQLite (KVS) binding
=> Now ready for Web App development!
![Page 13: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/13.jpg)
Example: a blog web app (1)
An append-only blog http://localhost:8080/blogs?id=id&text=text
just write a blog via above url
![Page 14: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/14.jpg)
Example: a blog web app (2)
Class definition
Object subclass: #MyTeapotApp
instanceVariableNames: 'teapot db'
classVariableNames: ''
package: 'TeapotApp-Lesson'
![Page 15: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/15.jpg)
Example: a blog web app (3)
Initialization
MyTeapotApp >> initialize
teapot := Teapot configure: #port -> 8080.
db := PqDatabase open:
(FileSystem workingDirectory / 'blogs.db') pathString.
self setupRoutes.
Teapotの設定
PqDatabaseのオープン
![Page 16: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/16.jpg)
Example: a blog web app (4)
Setting up routers
MyTeapotApp >> setupRoutes
teapot
GET: '/blogs' -> [:req | | id value |
id := req at: #id.
value := req at: #text ifAbsent: [''].
db transact: [db appendAt: id value: value].
'blogId'->id. 'text'-> (db at: id)];
output:
(TeaOutput mustacheHtml:
'<h1>Blog:blogId</h1><p>text</p>').
URLパラメータの取り出し
内容をDBに格納
テンプレートの適用
![Page 17: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/17.jpg)
Example: a blog web app (5)
Start/stop
MyTeapotApp >> start
teapot start
MyTeapotApp >> stop
db close.
Teapot stopAll.
![Page 18: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/18.jpg)
Example: a blog web app (6)
"Do it" in Playground
app := MyTeapotApp new start.
app explore
Open web browser
http://localhost:8080/blogs?id=id&text=text
Input some values in the parameters
![Page 19: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/19.jpg)
Other useful links for developers
Github
https://github.com/pharo-project
Pharo continuous build server
https://ci.inria.fr/pharo
Pharo bug tracking system
https://pharo.fogbugz.com
![Page 20: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/20.jpg)
Documents
Tutorials in Pharo
Help -> Pharo Tutorials
Pharo MOOC
Online-streaming seminars
http://files.pharo.org/mooc/
Pharo Books
http://files.pharo.org/books/
Pharo by Example
Deep into Pharo
Enterprise Pharoなど
![Page 21: Introduction of Pharo 5.0](https://reader031.fdocuments.net/reader031/viewer/2022022201/5899b7571a28aba11e8b61a9/html5/thumbnails/21.jpg)
Summing up
Pharo is a modern, aggressively
progressing Smalltalk
Version 5.0 is the fastest and refined. It
is recommended to migrate to 5.0 if you
are using older Pharo.