Web Development with SmalltalkPhD. Mariano Martinez Peck [email protected] http://marianopeck.wordpress.com
Mariano Martinez PeckAcademics
Software Engineer at UTN-FRBA, Argentina.
PhD in Computer Science at the Université de Lille.
Open-Source
Fuel, Pharo, DBXSuite (OpenDBX and Glorp), etc.
Industry
Previously, many years at different companies developing in different languages.
Currently, Independent Software Consultant
Muchas Gracias!
Context
Objective-C
Why Smalltalk?
Things are changing
Smalltalk is powerfulPure Object Oriented.
Dynamically typed and reflective.
Closures.
Debug and changes “on the fly”.
Everything is an object.
Runs in a VirtualMachine.
1. Domain specific logic. 2. Web logic (UI).
Two common possibilities
Use Smalltalk for domain logic and building UI (using a web framework). The server will answer the generated HTML + Javascript.
Write a separate UI (web logic) in another language (a fully JS client) that connects somehow (rest/json for example) to a Smalltalk server (domain logic).
Web frameworks
Seaside
AidaWeb
Many others…but above are most famous ones.
Quick intro
Open Source (MIT).
In production since 2002.
It is different to most web frameworks.
Fully written in Smalltalk.
In a nutshell
It is component based (pure Smalltalk).
It provides natural flow.
Components are reusable and statefull.
In a nutshell
It is component based (pure Smalltalk).
It provides natural flow.
Components are reusable and statefull.
We don’t think in pages…
We think in Components
There is no JSP, XML, PHP or whatever.
You never see HTTP requests or responses (unless you want to).
Simply Smalltalk.
There are no templates!
Components are c☺☺l
Reuseable
Model, View, Controller
Model
View Controller
You can debug!!!!
We can read Seaside code and learn from it
html div id: ‘title’; with: ‘Title’
<div id=”title”>Title</div>
Canvas and Brush
html div id: ‘list’; with: [ html span class: ‘item’; with: ‘Item 1’. html span class: ‘item’; with: ‘Item 2’ ]
<div id=”list”> <span class=”item”>Item 1</span> <span class=”item”>Item 2</span> </div>
html anchor callback: [ self inform: ‘Hello World’ ]; with: ‘Show Message’
<a href=”/seaside/example1 ?_s=Ru8ZKgqjy0uDX3kf &_k=K5EQyqKE &32”>Show Message</a>
Demo
Pros: • Great learning curve: only one language. • Manage all code the same way. • We use the same IDE tools. • Excellent debugging capabilities. • Reusability.
Cons: • More complicated graphic designer
integration.
Demo
In a nutshell
It is component based (pure Smalltalk).
It provides natural flow.
Components are reusable and statefull.
Natural Flow
value1 := self request: ‘First Number’.
value1 := self request: ‘First Number’.
value2 := self request: ‘Second Number’.
value1 := self request: ‘First Number’.
value2 := self request: ‘Second Number’.
self inform: value1 + value2.
Not concerned about HTTP
No manual request parsing
No XML configuration files
A
call:A Bx :=
AB
call:A Bx :=
AB
answer:B
A
answer:B
A
x :=
This is thanks to Continuations…as we will see later.
Demo
In a nutshell
It is component based (pure Smalltalk).
It provides natural flow.
Components are reusable and statefull.
¿Qué pasaría si todo lo que haces, lo que conoces y lo que te cuentan se te olvidara?
– Memento
¿Qué pasaría si todo lo que haces, lo que conoces y lo que te cuentan se te olvidara?
– HTTP
What happened in the movie?
If it is so bad…why it has certain success?
Well….
Good scalability.
It seems natural (because it is mainstream).
The database performs well so…
But…it’s tedious and manual
You must juggle to keep conversational context…
Abusing of databases is not good either
Seaside is based on reusable statefull components
Continuations
1. Snapshots current estate.
2. “Jumps” to another place (.e.g #call:)
3. Do something.
4. When it comes back (.e.g #answer:), the state is available.
self call: (AnotherComponent new)
Advantages of Continuations
It’s call and return.
Transparent management of the state and the threads.
It helps with double-request and back-button problems.
You can decide what is considered state.
Is not paradise either…
Using continuations I have be heavier!!!
Scalability is a bit different
Other characteristics
Other characteristics
Very nice integration with JQuery, AJAX, Comet, etc.
We can use our preferred Web server when deploying.
It’s not tight to any persistency framework.
Tons of wrapped libs like Twitter Bootstrap, Highcharts, etc…
MIT License
• http://book.seaside.st • http://www.seaside.st
Some conclusionsVery easy to learn, develop and debug.
Good integration with existing libs.
Great with web applications with complex logic and workflows.
It could be heavy (statefull) for certain scenarios.
A bit complicated to build app from graph designer template.
May not be the best choice for plain web pages.
Write a separate UI (web logic) in another language (a fully JS client) that connects somehow (rest/json for example) to a Smalltalk server (domain logic).
Top Related