Winning the Application
Server Arms Race
Using Smalltalk to Redefine Web Development
Avi Bryant
Web apps: why bother?
“I’m more of the mind that HTML based
apps suck.”
— James Robertson
Web apps: why bother?
“One of the reasons to use Lisp in writing
Web-based applications is that you ca!
use Lisp. When you...
What is a web app?
“A collection of functions that take
HTTP requests as input and produce
HTTP responses as output.”
What is a web app?
User with Web Browser
GET /foo?x=3
...
Content-Type:
text/html
...
/foo
What is a web app?
User with Web Browser
GET /foo?x=3
...
Content-Type:
text/html
<a href=“/bar”
...
/foo /bar /baz
Client/server app
VisualWorks Client
GemStone Server
Get
Shipping
Address
Get
Billing
Address
Get
Payment
Info
Show
Confirmation
Get
Shipping
Address
Get
Billing
Address
Get
Payment
Info
Show
Confirmation
Cart info Cart info
Shipping info
Cart info
Shi...
/shipping
User with Web Browser
cart
/billing
cart
shipping
cart
shipping
/payment
cart
shipping
billing
cart
shipping
bil...
User with Web Browser
cart cart
shipping
cart
shipping
cart
shipping
billing
cart
shipping
billing
cart
shipping
billing
p...
an App
a32cf6d
a Sessiona Sessiona Session
76ebc65
...
User
GET /foo?sid=a32cf6d
... <a href=“/bar?sid=a32cf6d”>...
/foo
an App
a32cf6d
a Sessiona Sessiona Session
76ebc65
...
User
GET /bar?sid=a32cf6d
... <a href=“/baz?sid=a32cf6d”>...
/bar
/shipping
User with Web Browser
/billing
sid
shipping
/payment
sid
billing
sid
payment
a Session
shipping billing
sid sid ...
Book
flight
Browse
flights
Choose
flight
Choose
seat
Why global session state is evil
Book
flight
Browse
flights
Choose
flight
Choose
seat
Choose
flight
Choose
seat
Why global session state is evil
Book
flight
Browse
flights
Choose
flight
Choose
seat
Choose
flight
Choose
seat
?
Why global session state is evil
an App
a32cf6d
a Sessiona Sessiona Session
76ebc65
...
a Component
f5c
a Component a Component
a21
...
... <input name=“page”
value=“f5b”>...
a Session
a21
a BrowseFlights
POST ... page=a21&flight=747
... <input name=“page”
v...
a Session
a21
a BrowseFlights
POST ... page=a21&flight=525
User
... <input name=“page”
value=“cc4”>...
a ChooseFlight
cc4
...
WOComponent
subclass: #BillingAddress
instanceVariableNames: ‘ship bill’
response
^ ‘<form ...’
processRequest: aRequest
b...
“Seaside is to most other Smalltalk web
toolkits as Smalltalk is to most other OO
languages, it’s as simple as that.”
— Ce...
WebObjects
• http://www.apple.com/webobjects/
• http://jakarta.apache.org/tapestry/
WOComponent
subclass: #BillingAddress
instanceVariableNames: ‘ship bill’
processRequest: aRequest
bill := self addressFrom...
WOComponent
subclass: #BillingAddress
instanceVariableNames: ‘ship bill’
processRequest: aRequest
bill := self addressFrom...
WOComponent
subclass: #BillingAddress
instanceVariableNames: ‘ship bill’
processRequest: aRequest
bill := self addressFrom...
checkoutProcess
^ (ShippingAddress new next:
(BillingAddress new next:
(PaymentInfo new next:
(ConfirmationPage new))))
WOComponent
subclass: #BillingAddress
instanceVariableNames: ‘ship bill’
processRequest: aRequest
bill := self addressFrom...
checkoutProcess
^ ShippingAddress new next:
[:ship |
BillingAddress new next:
[:bill |
PaymentInfo new next:
[:pay |
Confi...
checkoutProcess
^ PaymentInfo new next:
[:pay |
ShippingAdress new next:
[:ship |
BillingAddress new next:
[:bill |
Confir...
“...programming language features do well
(all other things being equal) when they
eliminate either distant or dynamic sta...
checkoutProcess
|pay ship bill|
pay := self call: PaymentInfo new.
ship := self call: ShippingAddress new.
bill := self ca...
“We could write the code to say, if the
user clicks on this link, go to the color
selection page, and then come back
here....
<form>
Name: <input name="name"><br>
Street: <input name="street"><br>
City: <input name="city"><br>
Country:
<select name...
renderOn: html
html form: [
html label: ‘Name’.
html textInputNamed: ‘name’; break.
html label: ‘Street’.
html textInputNa...
renderOn: html
html form: [
html label: ‘Name’.
html textInputWithCallback: [:v | name := v]; break.
html label: ‘Street’....
<form>
Name: <input name="1"><br>
Street: <input name="2"><br>
City: <input name="3"><br>
Country:
<select name="4">
<opti...
Upcoming SlideShare
Loading in …5
×

Winning the Application Server Arms Race

1,337 views

Published on

Winning the Application Server Arms Race. Using Smalltalk to Redefine Web Development, Avi Bryant. (ESUG 2004, Koethen)

Published in: Technology, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,337
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Winning the Application Server Arms Race

  1. 1. Winning the Application Server Arms Race Using Smalltalk to Redefine Web Development Avi Bryant
  2. 2. Web apps: why bother? “I’m more of the mind that HTML based apps suck.” — James Robertson
  3. 3. Web apps: why bother? “One of the reasons to use Lisp in writing Web-based applications is that you ca! use Lisp. When you’re writing software that is only going to run on your own servers, you can use whatever language you want.” — Paul Graham
  4. 4. What is a web app? “A collection of functions that take HTTP requests as input and produce HTTP responses as output.”
  5. 5. What is a web app? User with Web Browser GET /foo?x=3 ... Content-Type: text/html ... /foo
  6. 6. What is a web app? User with Web Browser GET /foo?x=3 ... Content-Type: text/html <a href=“/bar” ... /foo /bar /baz
  7. 7. Client/server app VisualWorks Client GemStone Server
  8. 8. Get Shipping Address Get Billing Address Get Payment Info Show Confirmation
  9. 9. Get Shipping Address Get Billing Address Get Payment Info Show Confirmation Cart info Cart info Shipping info Cart info Shipping info Billing info Cart info Shipping info Billing info Payment info
  10. 10. /shipping User with Web Browser cart /billing cart shipping cart shipping /payment cart shipping billing cart shipping billing cart shipping billing payment
  11. 11. User with Web Browser cart cart shipping cart shipping cart shipping billing cart shipping billing cart shipping billing payment formatting processing formatting do stuff processing formatting do stuffdo stuff processing
  12. 12. an App a32cf6d a Sessiona Sessiona Session 76ebc65 ... User GET /foo?sid=a32cf6d ... <a href=“/bar?sid=a32cf6d”>... /foo
  13. 13. an App a32cf6d a Sessiona Sessiona Session 76ebc65 ... User GET /bar?sid=a32cf6d ... <a href=“/baz?sid=a32cf6d”>... /bar
  14. 14. /shipping User with Web Browser /billing sid shipping /payment sid billing sid payment a Session shipping billing sid sid sid sessions
  15. 15. Book flight Browse flights Choose flight Choose seat Why global session state is evil
  16. 16. Book flight Browse flights Choose flight Choose seat Choose flight Choose seat Why global session state is evil
  17. 17. Book flight Browse flights Choose flight Choose seat Choose flight Choose seat ? Why global session state is evil
  18. 18. an App a32cf6d a Sessiona Sessiona Session 76ebc65 ... a Component f5c a Component a Component a21 ...
  19. 19. ... <input name=“page” value=“f5b”>... a Session a21 a BrowseFlights POST ... page=a21&flight=747 ... <input name=“page” value=“a21”>... User a ChooseFlight f5b
  20. 20. a Session a21 a BrowseFlights POST ... page=a21&flight=525 User ... <input name=“page” value=“cc4”>... a ChooseFlight cc4 f5b a ChooseFlight
  21. 21. WOComponent subclass: #BillingAddress instanceVariableNames: ‘ship bill’ response ^ ‘<form ...’ processRequest: aRequest bill := self addressFrom: aRequest. ^ PaymentInfo new shippingAddress: ship; billingAddress: bill; yourself
  22. 22. “Seaside is to most other Smalltalk web toolkits as Smalltalk is to most other OO languages, it’s as simple as that.” — Cees de Groot
  23. 23. WebObjects • http://www.apple.com/webobjects/ • http://jakarta.apache.org/tapestry/
  24. 24. WOComponent subclass: #BillingAddress instanceVariableNames: ‘ship bill’ processRequest: aRequest bill := self addressFrom: aRequest. ^ PaymentInfo new shippingAddress: ship; billingAddress: bill; yourself
  25. 25. WOComponent subclass: #BillingAddress instanceVariableNames: ‘ship bill’ processRequest: aRequest bill := self addressFrom: aRequest. ^ PaymentInfo new shippingAddress: ship; billingAddress: bill; next: (ConfirmationPage new) yourself
  26. 26. WOComponent subclass: #BillingAddress instanceVariableNames: ‘ship bill’ processRequest: aRequest bill := self addressFrom: aRequest. ^ next shippingAddress: ship; billingAddress: bill; yourself
  27. 27. checkoutProcess ^ (ShippingAddress new next: (BillingAddress new next: (PaymentInfo new next: (ConfirmationPage new))))
  28. 28. WOComponent subclass: #BillingAddress instanceVariableNames: ‘ship bill’ processRequest: aRequest bill := self addressFrom: aRequest. ^ next value: bill “BillingAddress new next: [:bill | PaymentInfo new billingAddress: bill; ....]”
  29. 29. checkoutProcess ^ ShippingAddress new next: [:ship | BillingAddress new next: [:bill | PaymentInfo new next: [:pay | ConfirmationPage new shippingAddress: ship; billingAddress: bill; paymentInfo: pay; yourself]
  30. 30. checkoutProcess ^ PaymentInfo new next: [:pay | ShippingAdress new next: [:ship | BillingAddress new next: [:bill | ConfirmationPage new shippingAddress: ship; billingAddress: bill; paymentInfo: pay; yourself]
  31. 31. “...programming language features do well (all other things being equal) when they eliminate either distant or dynamic state and replace it with either close or lexical state. The underlying point being that we may favour language features that facilitate copying and modifying small bits of code -- fragments which work in their new context -- as a fundamental programming activity.” — Graydon Hoare
  32. 32. checkoutProcess |pay ship bill| pay := self call: PaymentInfo new. ship := self call: ShippingAddress new. bill := self call: BillingAddress new. self call: (ConfirmationPage new shippingAddress: ship; billingAddress: bill; paymentInfo: pay)
  33. 33. “We could write the code to say, if the user clicks on this link, go to the color selection page, and then come back here.... It made our software visibly more sophisticated than that of our competitors.” — Paul Graham
  34. 34. <form> Name: <input name="name"><br> Street: <input name="street"><br> City: <input name="city"><br> Country: <select name="country"> <option value="CA">Canada</option> <option value="US">US</option> </select> <br> <input type="submit"> </form> aRequest( ‘name’->‘Avi’, ‘street’-> ‘123 W. 15th’ ‘city’->‘Vancouver’, ‘country’-> ‘CA’)
  35. 35. renderOn: html html form: [ html label: ‘Name’. html textInputNamed: ‘name’; break. html label: ‘Street’. html textInputNamed: ‘street’; break. html label: ‘City’. html textInputNamed: ‘city’; break. html label: ‘Country’. html selectNamed: ‘country’ do: [ html optionNamed: ‘CA’ label: ‘Canada’. html optionNamed: ‘US’ label: ‘US’. ]; break. html submitButton. ] processRequest: aRequest name := aRequest at: ‘name’. street := aRequest at: ‘street’. ...
  36. 36. renderOn: html html form: [ html label: ‘Name’. html textInputWithCallback: [:v | name := v]; break. html label: ‘Street’. html textInputWithCallback: [:v | street := v]; break. html label: ‘City’. html textInputWithCallback: [:v | city := v]; ‘city’; break. html label: ‘Country’. html selectFromList: self countries; break. html submitButtonWithAction: [self saveAddress]. ]
  37. 37. <form> Name: <input name="1"><br> Street: <input name="2"><br> City: <input name="3"><br> Country: <select name="4"> <option value="5">Canada</option> <option value="6">US</option> </select> <br> <input type="submit" name="7" value="Submit"> </form> aRequest( ‘1’->‘Avi’, ‘2’->..., ‘7’-> ‘Submit’) aCallbackStore( ‘1’->[:v | name := v], ‘2’->..., ‘7’->[self saveAddress])

×