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

What's the difference between JavaScript and Java?

What's the difference between JavaScript and Java?

Masayuki Izumi

February 19, 2016
Tweet

More Decks by Masayuki Izumi

Other Decks in Programming

Transcript

  1. > Masayuki IZUMI a.k.a. @izumin5210 > Rekimoto Lab. at the

    Univ. of Tokyo > Strobo, Inc. / Wantedly, Inc. > Rubyist / Androider / {Java,Type}Scripter
  2. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  .78 .PEFM7JFX8IBUFWFS $PNQPOFOU "SDIJUFDUVSF -JCSBSZ

    #BDLCPOFKT    &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  3FBDU  "OHVMBS  'MVY  3FEVY 
  3. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  .78 .PEFM7JFX8IBUFWFS #BDLCPOFKT  

     &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  $PNQPOFOU "SDIJUFDUVSF -JCSBSZ 3FBDU  "OHVMBS  'MVY  3FEVY  %BUB#JOEJOH
  4. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  $PNQPOFOU .78 .PEFM7JFX8IBUFWFS #BDLCPOFKT 

      &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  3FBDU    7JSUVBM%0. "OHVMBS  5ZQF4DSJQU3Y+4 "SDIJUFDUVSF -JCSBSZ 'MVY  3FEVY 
  5. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  "SDIJUFDUVSF -JCSBSZ .78 .PEFM7JFX8IBUFWFS #BDLCPOFKT

       &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  $PNQPOFOU 3FBDU  "OHVMBS  'MVY  3FEVY  6OJEJSFDUJPOBMEBUBqPX
  6.  .78 .PEFM7JFX8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UQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY
  11.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU BOOPUBUJPOQSPDFTTJOH Ͱ ର߅͢Δ BOOPUBUJPOQSPDFTTJOH

    TUSPOHUZQJOH +BWB @Reducer(Counter.class) public class CounterReducer { @Dispatchable(IncrementCountAction.class) public Counter increment(Counter state) { return new Counter(state.getCount() + 1); } @Dispatchable(DecrementCountAction.class) public Counter decrement(Counter state) { return new Counter(state.getCount() - 1); } @Dispatchable(ClearCountAction.class) public Counter clear() { return new Counter(0); } } export default function counter(state = 0, action) { switch (action.type) { case 'INCREMENT' : return state + 1 case 'DECREMENT' : return state - 1 default: return state } }
  12.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU 3Y+BWB

    ͷ SY0CTFSWBCMF5 Λ 1SPNJTFMJLF ͳڞ௨ *' ͱ͢Δ function fetchPosts(reddit) { return dispatch => { dispatch(requestPosts(reddit)) return fetch(`https://www.reddit.com/r/${reddit}.json`) .then(response => response.json()) .then(json => dispatch(receivePosts(reddit, json))) } } (MPCBM'FUDI ͕ 1SPNJTF Λฦ͢
  13.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU 3Y+BWB

    ͷ SY0CTFSWBCMF5 Λ 1SPNJTFMJLF ͳڞ௨ *' ͱ͢Δ public Observable<ReceiveTodoListAction> call(Dispatcher dispatcher) { return dispatcher.dispatch(new DoingFetchAction()) .flatMap(_action -> client.fetch()) .map(todoList -> { this.todoList = todoList; return new ReceiveTodoListAction(todoList); }); } 0CTFSWBCMF"DUJPO Λฦ͢
  14.  8JUIWJFX FWFOU QSPQBHBUJPO .FTTBHF EJTQBUDI XJUI"DUJPO VQEBUF JGOFFEFE IUUQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY

    "OESPJE "DUJWJUZ 'SBHNFOU FUD %BUB#JOEJOH <layout> <data> <variable name="store" type="com.example.android.RootStore"/> </data> <LinearLayout> <TextView android:text="@{store.getUser().getName()}"> </LinearLayout> </layout>
  15.  FH.71 %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ1SPQFSUZ$IBOHFE VTFSFWFOU BDUJPO

    EJTQBUDI 1SFTFOUFS EFMFHBUF PQFSBUF MPHJD JP FUD DBMM"TZOD"DUJPO PQFSBUF
  16.  FH$MFBO"SDIJUFDUVSF %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ VTFSFWFOU BDUJPO

    EJTQBUDI )BOEMFST EFMFHBUF MPHJD JP FUD DBMM"TZOD"DUJPO 1SFTFOUFS OPUJGZ PQFSBUF PQFSBUF
  17.  FH$MFBO"SDIJUFDUVSF %BHHFS %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ VTFSFWFOU

    BDUJPO EJTQBUDI )BOEMFST EFMFHBUF MPHJD JP FUD DBMM"TZOD"DUJPO 1SFTFOUFS OPUJGZ PQFSBUF PQFSBUF
  18.  FH$MFBO"SDIJUFDUVSF %BHHFS %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ VTFSFWFOU

    BDUJPO EJTQBUDI )BOEMFST EFMFHBUF MPHJD JP FUD DBMM"TZOD"DUJPO 1SFTFOUFS OPUJGZ PQFSBUF PQFSBUF @Scope @Retention(RetentionPolicy.RUNTIME) @interface TimelineScope {} interface TimelineView { /* snip */ }
  19.  FH$MFBO"SDIJUFDUVSF %BHHFS %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ VTFSFWFOU

    BDUJPO EJTQBUDI )BOEMFST EFMFHBUF MPHJD JP FUD DBMM"TZOD"DUJPO 1SFTFOUFS OPUJGZ PQFSBUF PQFSBUF @TimelineScope class TimelineHandlers { private final TimelineView view; private final RootStore store; @Inject TimelineHandlers(TimelineView view, RootStore store) { this.view = view; this.store = store; } /* snip. */ } ˞1SFTFOUFS ΋ಉ༷ͳͷͰলུ
  20.  FH$MFBO"SDIJUFDUVSF %BHHFS %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ VTFSFWFOU

    BDUJPO EJTQBUDI )BOEMFST EFMFHBUF MPHJD JP FUD DBMM"TZOD"DUJPO 1SFTFOUFS OPUJGZ PQFSBUF PQFSBUF @Module class TimelineModule { private final TimelineView view; TimelineModule(TimelineView view) { this.view = view; } @Provides @TimelineScope TimelineView provideTimelineView() { return view; } }
  21.  $MFBO"SDIJUFDUVSF %SPJEVY ͷ QSPTDPOT QSPT  4UPSF Ͱ͢΂ͯͷঢ়ଶΛ؅ཧͰ͖Ε͹ɼ 

    1SFTFOUFS ͸ 4UPSF Λ؂ࢹ͢Δ͚ͩʹͳΔ  )BOEMFST ΋ 4UPSF ʹ EJTQBUDI ͢Δ͚ͩ  ϩδοΫ͸ "DUJPO ͷ޲͜͏ଆʢ3FQPTJUPSZ ͳͲʣʹ  -PDBMVOJUUFTU ͰΧόʔͰ͖Δൣғ͕ѹ౗తʹ޿͍  ѹ౗తʹෳࡶʜοʂʂʢ͜͜·Ͱ΍Δඞཁ͋Δʁʣ DPOT
  22.  $PODMVTJPO "QQMJDBUPJOBSDIJUFDUVSFPO'SPOUFOE+4  .78 .PEFM7JFX8IBUFWFS  $PNQPOFOUCBTF VOJEJSFDUJPOBMEBUBqPX QPSUJOHSBDLUSFEVYJ[VNJO%SPJEVY

      "OOPUBUJPOQSPDFTTJOH Ͱॊೈ͞Λิ͏   3Y+BWB Ͱ 1SPNJTF ͷ୅ΘΓͱͳΔڞ௨ *'   Ծ૝ %0. ͸ͳ͍͚Ͳ %BUB#JOEJOH ͸ศར $MFBO"SDIJUFDUVSF ͸͍͍ͧ