•  What	  I	  want	  to	  talk	  is…	  	            Thank	  you	  Tarek!
•  Expert	  Python	  Programming	  is	  a	     super	  cool	  book!	    – It	  provides	  very	  pragma?c	  knowledge	    ...
PyConJP	  LT	 (2011/08/27)	              DeNA	  Co.Ltd.,	  Smartphone	  SG	  system	  group.	                Sphinx-­‐User...
Twicer:	  @shibukawa	•  Job	       –  Honda	  R&D	  →	  DeNA	       –  I’m	  playing	  Smartphone	  everyday!	  •  Communi...
 I’m	  crea?ng	  games	  on	  ngCore.	  Please	  download	  it!
•  All	  acendees	  must	  have	  it,	  aren’t	  they?
•  So,	  you	  are	  already	  Python	  expert!	                              Python
•  I	  don’t	  have	  to	  describe	  Python	  at	  all.	           Python                                                ...
•  I	  will	  describe	  JavaScript	  along	  with	  Expert	  Python	     Programming.	              Py               Java...
•  I	  will	  describe	  JavaScript	  along	  with	  Expert	     Python.	              Py                JavaScript       ...
•  Wri?ng	  code	  more	  than	  1000	  lines.	  •  Program	  runs	  on	  not	  only	  browser	  but	  also	     desktop	 ...
29
•  node.js	  (hcp://nodejs.org)	     –  Good	  interac?ve	  shell	  for	  JavaScript	         •  Windows	              –  ...
•  I’m	  using	  Emacs.	  Sorry	  Tarek.	      –  js2-­‐mode	  is	  good!	          •  hcp://code.google.com/p/js2-­‐mode	...
57
•  Global	  namespace	  is	  important	  than	  Python	      –  JavaScript	  has	  only	  one	  global	  area.	  •  1.	  S...
•  This	  is	  good	  technique	  for:	      –  Inser?on	  ini?alize	  code.	      –  Bridging	  incompa?bility	  between	...
93
•  JavaScript	  has	  descriptor	  like	  Python	  •  Call	  func?on	  during	  access	  object’s	  property	             ...
123
Of	  course!!	  	  •  Good	  names	  are	  important	  for	  JavaScript	  too!	                   JavaScript              ...
153
•  Original	  JavaScript	  doesn’t	  have	  “import”	     mechanism.	     –  It	  is	  important	  for	  crea?ng	  large	 ...
•  It	  supports	  require	  and	  exports.	  •  ngCore	  build	  tool	  treats	  source	  code	  like	  this:	 var Button...
•  It	  supports	  require	  and	  exports.	  •  ngCore	  build	  tool	  treats	  source	  code	  like	  this:	 MODULES[“m...
179
•  I	  don’t	  know	  what	  you	  want	  to	  create.	  •  There	  are	  many	  different	  environment	  today.	     –  M...
219
Of	  course!!	  	  •  SCM	  is	  important	  for	  JavaScript	  too!	  •  I	  love	  mercurial.	  During	  using	  git,	  ...
247
Of	  course!!	  	  •  Managing	  Life	  Cycle	  is	  important	  for	  JavaScript	     too!	                      JavaScri...
263
•  Famous	  tool	  in	  JS	  community	  is	  JSDoc	  series.	      –  JSDoc-­‐toolkit	  2.4	  is	  the	  latest	  stable	...
•  Sphinx	  is	  good	  tool	  for	  almost	  all	  programmers!	      –  You	  can	  create	  becer	  document!	      –  ...
295
•  I’m	  using	  Jasmine.	  •  If	  your	  code	  run	  in	  browser	  or	  mobile	  device,	  you	     can	  run	  logic	...
321
Of	  course!!	  	  •  Python’s	  strategy	  of	  op?miza?on	  is	  as	  same	  as	     JavaScript	  too!	                 ...
•  Each	  JavaScript	  engines	  have	  different	  character:	      –  V8	      –  V8	  for	  Android	      –  Safari	    ...
371
•  Asynchronous	  is	  the	  most	  important	  part	  of	  JS	      –  It	  is	  a	  pit	  fall	  Java	  programmer	  fal...
•  jsDeffered	     –  hcp://cho45.stuawsc.com/jsdeferred/	   next(function() { /* task 1 */ }). next(function() { /* task 2...
•  Try	  to	  write	  following	  “Counter”	  class.	   var counter = new Counter(); fs.writeFile(“METADATA”, data1, count...
•  All	  func?ons	  which	  uses	  Async	  call	  must	  receive	     callback	  func?on.	      –  If	  not,	  caller	  ca...
•  What	  I	  want	  to	  talk	  is…	  	            Thank	  you	  Tarek!
•  Expert	  Python	  Programming	  is	     super	  cool	  book!	    – It	  provides	  very	  pragma?c	  knowledge	     for...
Expert JavaScript Programming
Upcoming SlideShare
Loading in …5
×

Expert JavaScript Programming

2,740 views

Published on

Expert JavaScript Programming for Expert Python Programming Readers. This is the lightning talks slide at PyConJP.

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

No Downloads
Views
Total views
2,740
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Expert JavaScript Programming

  1. 1. •  What  I  want  to  talk  is…   Thank  you  Tarek!
  2. 2. •  Expert  Python  Programming  is  a   super  cool  book!   – It  provides  very  pragma?c  knowledge   for  Python  programmers.   – It  provides  very  acute  insight  for   Other  language  programmer!
  3. 3. PyConJP  LT (2011/08/27) DeNA  Co.Ltd.,  Smartphone  SG  system  group.   Sphinx-­‐Users.jp  /  eXtreme  Programming  Users  Group  Japan     Shibukawa  Yoshiki
  4. 4. Twicer:  @shibukawa •  Job   –  Honda  R&D  →  DeNA   –  I’m  playing  Smartphone  everyday!  •  Community   –  Sphinx-­‐Users.jp  Organizer   –  XPJUG   –  PySpa  •  Books   –  Simple  and  Steady  Way  of  Learning  for   So`ware  Engineers(Gihyo)   –  Expert  Python  Programming   (ASCII-­‐MW)   –  Pomodoro  Technique  illustrated   (ASCII-­‐MW)   –  The  Art  of  Community   (O’reilly  Japan)   :   web
  5. 5.  I’m  crea?ng  games  on  ngCore.  Please  download  it!
  6. 6. •  All  acendees  must  have  it,  aren’t  they?
  7. 7. •  So,  you  are  already  Python  expert! Python
  8. 8. •  I  don’t  have  to  describe  Python  at  all. Python
  9. 9. •  I  will  describe  JavaScript  along  with  Expert  Python   Programming. Py JavaScript
  10. 10. •  I  will  describe  JavaScript  along  with  Expert   Python. Py JavaScript
  11. 11. •  Wri?ng  code  more  than  1000  lines.  •  Program  runs  on  not  only  browser  but  also   desktop  and  server
  12. 12. 29
  13. 13. •  node.js  (hcp://nodejs.org)   –  Good  interac?ve  shell  for  JavaScript   •  Windows   –  Use  binary  package   •  Linux   –  Use  apt-­‐get  or  emerge  or  anything   •  MacOSX   –  Use  MacPorts  or  Homebrew  •  npm  (hcp://npmjs.org)   –  easy_install  for  nodejs   node.js
  14. 14. •  I’m  using  Emacs.  Sorry  Tarek.   –  js2-­‐mode  is  good!   •  hcp://code.google.com/p/js2-­‐mode   •  Download  source  and  M-­‐x  byte-­‐compile-­‐file   •  Add  following  line  following  lines:   (autoload js2-mode "js2" nil t)   (add-to-list auto-mode-alist (".js$" . js2-mode)) •  Other  DeNA  guys  are  using  Emacs,  Vim,  Eclipse,   WebStorm.   Emacs js2-­‐mode
  15. 15. 57
  16. 16. •  Global  namespace  is  important  than  Python   –  JavaScript  has  only  one  global  area.  •  1.  Self-­‐invoke  func?on   (function() { // This area is private! })();  •  2.  Export  only  accessor  methods   var getter; (function() { var privateVar = 100; getter = function() {return privateVar;}; })();
  17. 17. •  This  is  good  technique  for:   –  Inser?on  ini?alize  code.   –  Bridging  incompa?bility  between  browsers.   –  Crea?ng  unit  test  for  browser  on  node.js.     function a() { // initialize code or check compatibility a = function() { // function logic it is used always }; };
  18. 18. 93
  19. 19. •  JavaScript  has  descriptor  like  Python  •  Call  func?on  during  access  object’s  property   var obj = {}; var temp = null; Object.defineProperty(obj, "test", { get: function() { return temp; }, set: function(val) { temp = val; } }); JS
  20. 20. 123
  21. 21. Of  course!!    •  Good  names  are  important  for  JavaScript  too! JavaScript
  22. 22. 153
  23. 23. •  Original  JavaScript  doesn’t  have  “import”   mechanism.   –  It  is  important  for  crea?ng  large  so`ware.   –  CommonJS  proposes  good  design.   •  It  is  used  by  node.js  and  ngcore.  •  jQuery  builder,  closure  compiler…  many  libraries   are  created  with  many  source  files.   –  Combine  all  needed  sources.  
  24. 24. •  It  supports  require  and  exports.  •  ngCore  build  tool  treats  source  code  like  this: var Button = require(‘./UI/Button’).Button; exports.MyWindow = function() { this.title = “hello world”; this.size = [100, 100, 400, 200]; };
  25. 25. •  It  supports  require  and  exports.  •  ngCore  build  tool  treats  source  code  like  this: MODULES[“modulename”] = (function() { var exports = {}; var require = function(file){ return MODULES[file]; }; var Button = require(‘./UI/Button’).Button; exports.MyWindow = function() { this.title = “hello world”; this.size = [100, 100, 400, 200]; }; return exports;})();
  26. 26. 179
  27. 27. •  I  don’t  know  what  you  want  to  create.  •  There  are  many  different  environment  today.   –  My  recommend  environment  is  ngCore.  You  can   create  Android  and  iOS  games  from  same  source.   Future,  ngCore  will  support  HTML5.   ngCore
  28. 28. 219
  29. 29. Of  course!!    •  SCM  is  important  for  JavaScript  too!  •  I  love  mercurial.  During  using  git,  I  some?mes  got   error  because  I  type  hg  instead  of  git. JavaScript
  30. 30. 247
  31. 31. Of  course!!    •  Managing  Life  Cycle  is  important  for  JavaScript   too!   JavaScript
  32. 32. 263
  33. 33. •  Famous  tool  in  JS  community  is  JSDoc  series.   –  JSDoc-­‐toolkit  2.4  is  the  latest  stable  version.   –  JSDoc  3  is  now  crea?ng.   –  node-­‐jsdoc-­‐toolkit  is  easy  to  use  and  fast!   •  hcps://github.com/p120ph37/node-­‐jsdoc-­‐toolkit  •  Do  you  like  auto  generated  document?  I  don’t   like.  It  is  hard  to  write  good  document.   node-­‐jsdoc-­‐toolkit
  34. 34. •  Sphinx  is  good  tool  for  almost  all  programmers!   –  You  can  create  becer  document!   –  Easy  to  learn,  easy  to  write.  hard  to  write  Plugin…  •  I’m  crea?ng  CommonJS-­‐domain  and  CommonJS-­‐ autodoc  plugin  now.  Please  wait!   Sphinx CommonJS
  35. 35. 295
  36. 36. •  I’m  using  Jasmine.  •  If  your  code  run  in  browser  or  mobile  device,  you   can  run  logic  test  on  node.js.   –  Fast  feedback!  Fast  development  cycle.   –  You  can  install  node-jasmine  via  npm.   –  “Func?ons  that  rewrites  thyself”  technique  is  useful!
  37. 37. 321
  38. 38. Of  course!!    •  Python’s  strategy  of  op?miza?on  is  as  same  as   JavaScript  too!   Python JS
  39. 39. •  Each  JavaScript  engines  have  different  character:   –  V8   –  V8  for  Android   –  Safari   –  Safari  for  iOS   –  WebView  for  iOS   –  Firefox   –  Internet  Explorer…  •  You  have  to  profile  on  the  environments  you  use.     JS
  40. 40. 371
  41. 41. •  Asynchronous  is  the  most  important  part  of  JS   –  It  is  a  pit  fall  Java  programmer  fall   –  Callback  hell!   –  Sequen?al  source  code  is  more  readable  and  easy  to   understand.    
  42. 42. •  jsDeffered   –  hcp://cho45.stuawsc.com/jsdeferred/   next(function() { /* task 1 */ }). next(function() { /* task 2 */ }); chain( function() { /* task 1 */ }, function() { /* task 2 */ } ); –  Sorry  I  have  never  used  it…   –  Maybe  twisted  programmers  familiar  with  this.
  43. 43. •  Try  to  write  following  “Counter”  class.   var counter = new Counter(); fs.writeFile(“METADATA”, data1, counter.newTask()); fs.writeFile(“REQUEST”, data2, counter.newTask()); counter.wait(function() { // All task is finished.   });•  It  works  similar  to  sleep  sort.  Run  all  tasks  at  the   same  ?me  and  check  only  the  task  end.
  44. 44. •  All  func?ons  which  uses  Async  call  must  receive   callback  func?on.   –  If  not,  caller  can’t  know  whether  all  tasks  are  finished   or  not   Func?on  caller Callback  func?on Pass Async
  45. 45. •  What  I  want  to  talk  is…   Thank  you  Tarek!
  46. 46. •  Expert  Python  Programming  is   super  cool  book!   – It  provides  very  pragma?c  knowledge   for  Python  programmers.   – It  provides  very  acute  insight  for   Other  language  programmer!

×