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?

9eed44f137609e6ce3b6f1e14f80b9e1?s=128

Masayuki Izumi

February 19, 2016
Tweet

Transcript

  1. 8IBUTUIFEJ⒎FSFODFCFUXFFO +BWB4DSJQUBOE+BWB .BTBZVLJ*;6.*!J[VNJO %SPJE,BJHJ%": 'FC

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

    Univ. of Tokyo > Strobo, Inc. / Wantedly, Inc. > Rubyist / Androider / {Java,Type}Scripter
  3. 8IBUTUIFEJ⒎FSFODFCFUXFFO +BWB4DSJQUBOE+BWB

  4. 8IBUTUIFEJ⒎FSFODFCFUXFFO +BWB4DSJQUBOE+BWB NPEFSOGSPOUFOE+4 BOESPJEBQQMJDBUJPO BSDIJUFDUVSFEFTJHO

  5. ?8IBUEPZPVUIJOLBCPVU ʠ'SPOUFOE+BWB4DSJQUʡ 

  6. *OUIFNFBOUJNF UIFMBUFTUBOEHSFBUFTU+BWB4DSJQUGSBNFXPSL DPNFTBSPVOEFWFSZTJYUFFONJOVUFT IUUQTXXXBMMFOQJLFDPNKBWBTDSJQUGSBNFXPSLGBUJHVF "+4GSBNFXPSLPOFWFSZUBCMF"MMFO1JLF

  7. 5IFSF ZPVDBOTFFIPX +BWB4DSJQUBQQGSBNFXPSLTʟ UPEPFYBNQMFT DPNQBSFUPKVTUK2VFSZPSWBOJMMB+BWB4DSJQU "+4GSBNFXPSLPOFWFSZUBCMF"MMFO1JLF

  8. 0CKFDUJWFJOUIJTQSFTFOUBUJPO 5SZJOUSPEVDJOH ʠ&YQMPTJWF(SPXUIPG+BWBTDSJQUʡ   JOUP"OESPJE+BWB IUUQTEFWFMPQFSTBMFTGPSDFDPNCMPHTEFWFMPQFSSFMBUJPOTFYQMPTJWFHSPXUIKBWBTDSJQUOQNFOUFSQSJTFIUNM

  9. $IBOHFTJO'SPOUFOE+BWB4DSJQU -JCSBSJFT'SBNFXPSLT"SDIJUFDUVSFT 3FWJFX

  10. $IBOHFTJO+4%BXOPGEZOBNJDXFC * QSPUPUZQFKT * K2VFSZ  5PBCTUSBDUBXBZCSPXTFSJODPOTJTUFODJFT (We really wanted

    document.querySelector() !!!!!) 
  11. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  .78 .PEFM7JFX8IBUFWFS $PNQPOFOU "SDIJUFDUVSF -JCSBSZ

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

     &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  $PNQPOFOU "SDIJUFDUVSF -JCSBSZ 3FBDU  "OHVMBS  'MVY  3FEVY  %BUB#JOEJOH
  13. $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 
  14. $IBOHFTJO+43*" 3JDI*OUFSOFU"QQMJDBUJPO 41" 4JOHMF1BHF"QQMJDBUJPO  "SDIJUFDUVSF -JCSBSZ .78 .PEFM7JFX8IBUFWFS #BDLCPOFKT

       &NCFSKT  ,OPDLPVUKT    "OHVMBS+4  $PNQPOFOU 3FBDU  "OHVMBS  'MVY  3FEVY  6OJEJSFDUJPOBMEBUBqPX
  15.  'SPOUFOE+4 5IFSFBSFNBOZJNQMFNFOUBUJPOT "OESPJE+BWB 5IFSFBSFGFXJNQMFNFOUBUJPOT "QQMJDBUJPO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FT *OUSPEVDUJPOUP3FEVY4QFBLFS%FDL IUUQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY
  31. 0CKFDUJWFJOUIJTQSFTFOUBUJPO 5SZJOUSPEVDJOH ʠ&YQMPTJWF(SPXUIPG+BWBTDSJQUʡ JOUP"OESPJE+BWB

  32. 5SZQPSUJOH ʠ3FEVYʡJOUP"OESPJEBQQMJDBUJPO

  33. J[VNJO%SPJEVY

  34.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU

  35.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU BOOPUBUJPOQSPDFTTJOH

    Ͱ ର߅͢Δ
  36.  %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 } }
  37.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU ڧྗͳܕ੍໿ʹΑΓ

    +4 ʹൺ΂ ݎ࿚ͳઃܭΛ૊Έ΍͍͢
  38.  %J⒎FSFODFCX+BWB4DSJQUBOE"OESPJE+BWB BOOPUBUJPOQSPDFTTJOH TUSPOHUZQJOH +BWB EVDLUZQJOH pSTUDMBTTGVODUJPO QSPNJTF +BWB4DSJQU 3Y+BWB

    ͷ SY0CTFSWBCMF5 Λ 1SPNJTFMJLF ͳڞ௨ *' ͱ͢Δ
  39.  %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 Λฦ͢
  40.  %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 Λฦ͢
  41.  8JUIWJFX FWFOU QSPQBHBUJPO .FTTBHF EJTQBUDI XJUI"DUJPO VQEBUF JGOFFEFE IUUQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY

    'SPOUFOE+4 3FBDU "OHVMBS FUD
  42.  8JUIWJFX FWFOU QSPQBHBUJPO .FTTBHF EJTQBUDI XJUI"DUJPO VQEBUF JGOFFEFE IUUQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY

    "OESPJE "DUJWJUZ 'SBHNFOU FUD
  43.  8JUIWJFX FWFOU QSPQBHBUJPO .FTTBHF EJTQBUDI XJUI"DUJPO VQEBUF JGOFFEFE IUUQTTQFBLFSEFDLDPNBYSPTTJOUSPEVDUJPOUPSFEVY

    "OESPJE "DUJWJUZ 'SBHNFOU FUD %BUB#JOEJOH
  44.  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>
  45.  FH%SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ1SPQFSUZ$IBOHFE VTFSFWFOU BDUJPO EJTQBUDI

  46.  FH.71 %SPJEVY %BUB#JOEJOH 7JFX 4UPSF MBZPVU OPUJGZ1SPQFSUZ$IBOHFE VTFSFWFOU BDUJPO

    EJTQBUDI 1SFTFOUFS EFMFHBUF PQFSBUF MPHJD JP FUD DBMM"TZOD"DUJPO PQFSBUF
  47.  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
  48. ༨ஊ

  49. $MFBO"SDIJUFDUVSF

  50.  IUUQTCMPHUIMJHIUDPNVODMFCPCUIFDMFBOBSDIJUFDUVSFIUNM

  51.  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
  52.  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 */ }
  53.  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 ΋ಉ༷ͳͷͰলུ
  54.  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; } }
  55.  $MFBO"SDIJUFDUVSF %SPJEVY ͷ QSPTDPOT QSPT  4UPSF Ͱ͢΂ͯͷঢ়ଶΛ؅ཧͰ͖Ε͹ɼ 

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

  57.  $PODMVTJPO "QQMJDBUPJOBSDIJUFDUVSFPO'SPOUFOE+4  .78 .PEFM7JFX8IBUFWFS  $PNQPOFOUCBTF VOJEJSFDUJPOBMEBUBqPX QPSUJOHSBDLUSFEVYJ[VNJO%SPJEVY

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