Seaside Portability

1,792 views

Published on

Seaside is a rare example of software that runs on all the major current Smalltalk platforms: Pharo, Gemstone, GNU Smalltalk, Squeak, VA Smalltalk, and VisualWorks. This presentation to the NYC Smalltalk users group looks at some of the tools and techniques the Seaside team uses to make life as easy as possible for the frameworks porters.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,792
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
17
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Seaside Portability

  1. 1. Portability in Seaside NYC Smalltalk December 10, 2009
  2. 2. Julian Fitzell Co-creator of Seaside Independent consultant
  3. 3. 694 classes
  4. 4. 6844 methods
  5. 5. Platforms
  6. 6. External Interface Support XML Support enables XML–Smalltalk object mapping, includes a server interface via XML request handlers and reading of remote resources B disk via TCP sockets using HTTP requests OLE Support enables an application to use OLE clients and custom control services. Domino Connection allows an application to retrieve and work with Domino documents as well as access Notes mail system. Download a risk-free trial copy: www.instantiations.com/VAST/download m/VAST Build Quality Software l other trademarks mentioned are the property of their respective owners.
  7. 7. Portability Photo: Alexia´s, flickr.com
  8. 8. Goals Create consistent experience Minimize platform changes Isolate platform changes Ease code updates (in both directions!)
  9. 9. Namespacing: WAObject #seasideUrl
  10. 10. Syntax Photo: pipp, sxc.hu
  11. 11. n o Underscore Assignments a_1 b←2
  12. 12. n o Brace Arrays { 1. 2. 1 + 2 }
  13. 13. n o Array Constructors #[ ‘string’, 123, Object new ]
  14. 14. n o Byte Arrays #[ 1 2 3 ]
  15. 15. n o Variable Bindings {Smalltalk.Object}
  16. 16. n o Selection Blocks {:i | i.is.permanent}
  17. 17. o k Pragma <javascript: 1.5>
  18. 18. ANSI Photo: njd89, sxc.hu
  19. 19. ANSI Protocols Object, Character, Boolean, nil, etc. Block Exception Numeric Collection Date and Time Stream
  20. 20. Exceptions Photo: ingythewingy, flickr.com
  21. 21. Exception Protocols #signal, #signal:, ... #on:do:, #ensure:, #ifCurtailed: #defaultAction, #isResumable #pass, #outer, #retry, #resume Warning, Error, Notification, ZeroDivide, ...
  22. 22. n o [ ... ] on: Error do: [ ... ]
  23. 23. y e s [ ... ] on: Error do: [ |err| ... ]
  24. 24. n o #defaultAction + non-resumable exceptions
  25. 25. “The exact behavior and result of this method is implementation defined.”
  26. 26. Unless the exception is resumable, “the action taken upon completion of the #defaultAction method is implementation defined”
  27. 27. n o MyException signal
  28. 28. Collections Photo: ijsendoorn,sxc.hu
  29. 29. Collection Protocols Array, Set, OrderedCollection, Interval, ... #do:, #collect:, #select:, #reject:, #detect:, ... #includes:, #isEmpty, anySatisfy:, ... #asSet, #asOrderedCollection, ... #at:put:, #at:ifAbsent:, #removeKey:, ...
  30. 30. n o Collection>>#=
  31. 31. n o #withIndexDo:
  32. 32. y e s #keysAndValuesDo:
  33. 33. n o #pairsDo:
  34. 34. y e s 1 to: aCollection size by: 2 do: [ :i | ... ]
  35. 35. Strings Photo: Lynne Lancaster, sxc.hu
  36. 36. n o Symbol is a String
  37. 37. n o #match:
  38. 38. n o Object>>#asString
  39. 39. n o #displayString
  40. 40. n o Non-ASCII Strings
  41. 41. Streams Photo: Lynne Lancaster, sxc.hu
  42. 42. Stream Protocols ReadStream, WriteStream, ReadWriteStream #close, #isEmpty, #position, #reset, ... #do:, #next, #peek, #upTo:, ... #cr, #nextPut:, #nextPutAll:, ...
  43. 43. n o #next, at the end of a stream
  44. 44. y e s Check #atEnd first
  45. 45. n o #position #position:
  46. 46. Times and Dates Photo: inya, sxc.hu
  47. 47. y e s DateAndTime + Duration
  48. 48. n o TimeStamp
  49. 49. k in d a Time
  50. 50. s o r ta Date
  51. 51. Cross-Platform Behaviour Consistent Conflicting Missing
  52. 52. Unit Slime Grease Tests Consistent Conflicting Missing Use it! Avoid it! Add it! (Test it!)
  53. 53. Unit Tests Photo: shadowkill, sxc.hu
  54. 54. Done?
  55. 55. Unit Tests 150 131 44 44 20 0 Seaside 2.5 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 3.0
  56. 56. Unit Tests 1,200 1,115 1,050
  57. 57. Slime Lint Tests for Seaside Photo: A Syed, sxc.hu
  58. 58. Rules to detect Portability Issues
  59. 59. a _ 1. b := { a + 2. 3 }. c pairsDo: [ :a :b | a raisedTo: b ]
  60. 60. a _ 1. b := { a + 2. 3 }. c pairsDo: [ :a :b | a raisedTo: b ]
  61. 61. a _ 1. b := { a + 2. 3 }. c pairsDo: [ :a :b | a raisedTo: b ]
  62. 62. a _ 1. b := { a + 2. 3 }. c pairsDo: [ :a :b | a raisedTo: b ]
  63. 63. Rules to detect Seaside Bugs
  64. 64. html div with: ‘Hello World’; id: ‘message’. html updater id: ‘message’; callback: [ :r | html text: ‘Bye’ ]
  65. 65. html div with: ‘Hello World’; id: ‘message’. html updater id: ‘message’; callback: [ :r | html text: ‘Bye’ ]
  66. 66. html div with: ‘Hello World’; id: ‘message’. html updater id: ‘message’; callback: [ :r | html text: ‘Bye’ ]
  67. 67. Grease Platform Compatibility Layer Photo: DarkSide, sxc.hu
  68. 68. Pragmatic
  69. 69. Minimal
  70. 70. Unit Tested
  71. 71. ANSI++
  72. 72. Grease Features Consistent object initialization Consistent exception signalling Common convenience methods Platform-dependent behaviour Unit tests
  73. 73. y e s GRObject class>>#new ^ self basicNew initialize
  74. 74. y e s GRError class>>#signal “VW implementation” ^ self raiseSignal
  75. 75. y e s Object>>#greaseString “Squeak implementation” ^ self asString
  76. 76. y e s#trimLeft #upToLast: #ifNil: #isCollection
  77. 77. y e s GRPlatform current base64Decode: 'aGk='. GRPlatform current addToStartupList: SomeClass. GRPlatform current openDebuggerOn: anException.
  78. 78. Packaging ↑ SUnit Photo: Tory Byrne, www.sxc.hu
  79. 79. 73 Packages
  80. 80. Common Seaside-Core
  81. 81. Platform-Specific Seaside-Pharo-Core
  82. 82. Test Seaside-Tests-Core Seaside-Tests-Pharo-Core
  83. 83. BON US! Find incorrect layer dependencies
  84. 84. Monticello
  85. 85. Monticello Declarative modeling Distributed repositories Optimistic code merging Vendor round-tripping
  86. 86. Monticello ☹ Slow with large repositories ☹ Inconvenient with many packages ☹ Awkward when renaming and moving between packages
  87. 87. Future?
  88. 88. Metacello Declare and load package configurations Express dependencies on other projects Easily upgrade to newest versions
  89. 89. Mason Automate build process Run tests for each package + dependencies
  90. 90. Monticello2 Faster Per-method version history Better interface for projects with many packages Easier to port? (uses Grease)
  91. 91. book.seaside.st
  92. 92. Summary Write tests! Avoid extended syntax Use ANSI where possible Package out platform-specific code Slime/Lint for what you can’t use, Grease for what you can
  93. 93. www.seaside.st blog.fitzell.ca jfitzell@gmail.com

×