Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今時なウェブ開発をSmalltalkでやってみる?

 今時なウェブ開発をSmalltalkでやってみる?

「Smalltalkってまだ生きているの?」とそんな悲しいことを質問されたりするので、Pharo Smalltalkで今時なウェブ開発をする方法について話します。
ESUG 2015で入賞したPharoJSやEnterprise Pharo本に掲載されているライブラリなどPharo Smalltalkでウェブ開発をする方法を話したいと思います。

newapplesho

March 31, 2017
Tweet

More Decks by newapplesho

Other Decks in Technology

Transcript

  1. S H O Y O S H I D A

    S O R A B I T O I N C ࠓ࣌ͳ΢Σϒ։ൃΛSmalltalkͰ΍ͬͯΈΔ? 3 1 M A R C H 2 0 1 7
  2. ։ ൃ ऀ ʹ Ѫ ͞ Εͯ ͍ Δ ݴ

    ޠ ̎ Ґ ࠷ ৽ χϡ ʔε https://fossbytes.com/most-loved-and-most-hated-programming-languages/ Which Are The Most Loved and Most Hated Programming Languages | 2017
  3. Ͱɺ ࠓ ೔ ͷ ࠂ ஌ ͸ ɾ ɾ ɾ

    ͢Έ·ͤΜɻ໺৺త͗͢·ͨ͠
  4. Π ϯε τ ʔϧ Gofer it smalltalkhubUser: 'noury' project: 'PharoJS';

    configurationOf: #PharoJS ; loadBleedingEdge.
  5. C O D E + T E S T M

    O D E L PharoͰίʔσΟϯάͯ͠ɺςετΛPharoͰߦ͏ counter := MyCounter new. counter count. counter increment. counter count. ͓ͳ͡ΈͷΧ΢ϯλʔΞϓϦΛߟ͑Δ
  6. C O D E + T E S T I

    N T E G R AT I O N
  7. C O D E + T E S T I

    N T E G R AT I O N MyCounterController Λ࡞ΓMyCounterBrowserAppʹ ModelͱControllerΛࢦఆ͢Δ
  8. C O D E + T E S T I

    N T E G R AT I O N MyCounterControllerΛ࡞ΓMyCounterBrowserAppʹ ModelͱControllerΛࢦఆ͢Δ
  9. MyCounterController MyCounterController>>increment self counter increment. self updateDisplay MyCounterController>>reset self counter

    reset. self updateDisplay MyCounterController>>updateDisplay self countDisplay innerHTML: self counter count
  10. MyCounterBrowserApp MyCounterBrowserApp>>initialize super initialize. counter := MyCounter new. controller :=

    MyCounterController new. controller counter: counter. controller countDisplay: self countDisplay. self resetButton addEventListener: #click block: [ controller reset ]. self incrementButton addEventListener: #click block: [ controller increment ]
  11. C O D E + T E S T I

    N T E G R AT I O N MyCounterController Λ࡞ΓMyCounterBrowserAppʹ ModelͱControllerΛࢦఆ͢Δ MyCounterBrowserApp setUpAppFolder. MyCounterBrowserApp appFolder. ϏϡʔͰ͋ΔHTMLϑΝΠϧΛ༻ҙ͠σΟϨΫτϦΛࢦఆ͢Δ
  12. C O D E + T E S T I

    N T E G R AT I O N <!DOCTYPE html> <meta charset="utf-8" /> <head> <title>MyCounter</title> </head> <body> <div class="container"> <div id="countDisplay" class="countText">0</div> <button id="resetButton" class="resetButton">Reset</button> <button id="incrementButton" class="incrementButton">Increment</button> </div> <script language="javascript" type="text/javascript" src="js/index.js"></script> </body> </html> ϏϡʔͰ͋ΔHTMLϑΝΠϧΛ༻ҙ͠σΟϨΫτϦΛࢦఆ͢Δ
  13. PjTranspiler PjTranspiler convertToJs:[ 1+1 ] . jsString := PjTranspiler convertToJs:[

    [ 1+ 1 ] ]. jsString := PjTranspiler convertToJs:[:x | x + 1 ]. jsString := PjTranspiler convertToJs:[ [:x | x + 1] value:2 ]. PjTranspiler convertToJs: MyCounter. SmalltalkͷίʔυΛJavaScriptʹม׵
  14. MyCounterBrowserAppTest MyCounterBrowserAppTest>>setUp super setUp. application := self currentApp. countDisplay :=

    application countDisplay. resetButton := application resetButton. incrementButton := application incrementButton. MyCounterBrowserAppTest>>currentApp self subclassResponsibility
  15. MyCounterBrowserAppTest MyCounterBrowserAppTest>>testClickOnIncrementButtonIncreasesCountAn dUpdatesDisplay 1 to: 10 do: [ : expectedCount

    | incrementButton click. self assert: countDisplay innerHTML equals: expectedCount asString ]
  16. PjBridge bridge := PjBridge startOn: 9001 title:'test'. bridge clientTitle. bridge

    evalBlock: [1+2]. bridge evalBlock: [|x| x := 6 * 7]. bridge loadClass: MyCounter. bridge evalBlock: [ |counter| counter := MyCounter new. counter increment. counter count.]. bridge stop. JavaScript Interpreterͱର࿩తʹίʔυΛ࣮ߦ͢Δ ίϯιʔϧʹ݁Ռ͕දࣔ͞ΕΔ