• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Expert JavaScript Programming
 

Expert JavaScript Programming

on

  • 2,554 views

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

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

Statistics

Views

Total Views
2,554
Views on SlideShare
2,552
Embed Views
2

Actions

Likes
0
Downloads
13
Comments
0

2 Embeds 2

http://twitter.com 1
http://us-w1.rockmelt.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Expert JavaScript Programming Expert JavaScript Programming Presentation Transcript

    • •  What  I  want  to  talk  is…   Thank  you  Tarek!
    • •  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!
    • PyConJP  LT (2011/08/27) DeNA  Co.Ltd.,  Smartphone  SG  system  group.   Sphinx-­‐Users.jp  /  eXtreme  Programming  Users  Group  Japan     Shibukawa  Yoshiki
    • 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
    •  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 JavaScript
    • •  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  and  server
    • 29
    • •  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
    • •  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
    • 57
    • •  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;}; })();
    • •  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 }; };
    • 93
    • •  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
    • 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  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.  
    • •  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]; };
    • •  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;})();
    • 179
    • •  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
    • 219
    • 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
    • 247
    • Of  course!!    •  Managing  Life  Cycle  is  important  for  JavaScript   too!   JavaScript
    • 263
    • •  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
    • •  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
    • 295
    • •  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!
    • 321
    • Of  course!!    •  Python’s  strategy  of  op?miza?on  is  as  same  as   JavaScript  too!   Python JS
    • •  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
    • 371
    • •  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.    
    • •  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.
    • •  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.
    • •  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
    • •  What  I  want  to  talk  is…   Thank  you  Tarek!
    • •  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!