狠狠撸

狠狠撸Share a Scribd company logo
Power Assert
YAPC::ASIA 2013, 9/20, Kanagawa
Fuji Goro (gfx) <gfuji@cpan.org>
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
myself
Working at COOKPAD, Inc.
Rubyist / Androider / JSXer
CPAN:
Xslate
Mouse
Plack::Middleware::DevFavicon
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Power Assert
http://dontmindthelanguage.wordpress.com/
2009/12/11/groovy-1-7-power-assert/
Invented in Groovy
Ported to JavaScript by @t_wata, 2013
Ported to Perl by @tokurhiom, 2013
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Test::Power
expect { $x->is_foo }
expect { $x->foo eq ‘bar’ }
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
FAILURE MESSAGES
not ok 1 - L7 : expect { $h->foo->bar == 42 };
# $h->foo
# => undef
# $h
# => bless( {}, 'main' )
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
END
Part 1. End.
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Part 2.
perl.js - Perl 5.18.1 running on browsers
build with emscripten
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Demo
http://gfx.github.io/perl.js/
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Emscripten
LLVM to JavaScript compiler
Compile LLVM bitcode into JavaScript
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Emscripten
Use JavaScript as a machine code
Like a kernel & CPU, not an emulator nor
translator
All the syscalls are implemented in the
emscripten runtime libraries
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
For example: fork(2)
// src/library.js
fork: function() {
// pid_t fork(void);
// We don't support multiple
processes.
___setErrNo(ERRNO_CODES.EAGAIN);
return -1;
},
Most POSIX syscalls are just dummies :(
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
utime(2)
// src/library_fs.js
utime: function(path, atime, mtime) {
var lookup = FS.lookupPath(path,
{ follow: true });
var node = lookup.node;
node.node_ops.setattr(node, {
timestamp: Math.max(atime, mtime)
});
},
Emscripten has a virtual file system
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
BuilD PERL
Write own Make?le based on Make?le.micro
cf. pl! - Perl 5.16.3 based emscripten-ed perl
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Problems
Does not support call main() more than twice
exit() closes stdin, stdout, stderr but there’s
no way to open them again
Fatal errors which cause abort() breaks the
internal state, which then needs to reload the
page (the JavaScript interpreter)
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
Conclusion
Use emscripten for C/C++ applications
Write once, run everywhere
13年9月20日金曜日
perl.js Fuji Goro (gfx) YAPC::Asia 2013
END
http://github.com/gfx/perl.js
13年9月20日金曜日

More Related Content

Power Assert and perl.js

  • 1. Power Assert YAPC::ASIA 2013, 9/20, Kanagawa Fuji Goro (gfx) <gfuji@cpan.org> 13年9月20日金曜日
  • 2. perl.js Fuji Goro (gfx) YAPC::Asia 2013 myself Working at COOKPAD, Inc. Rubyist / Androider / JSXer CPAN: Xslate Mouse Plack::Middleware::DevFavicon 13年9月20日金曜日
  • 3. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Power Assert http://dontmindthelanguage.wordpress.com/ 2009/12/11/groovy-1-7-power-assert/ Invented in Groovy Ported to JavaScript by @t_wata, 2013 Ported to Perl by @tokurhiom, 2013 13年9月20日金曜日
  • 4. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Test::Power expect { $x->is_foo } expect { $x->foo eq ‘bar’ } 13年9月20日金曜日
  • 5. perl.js Fuji Goro (gfx) YAPC::Asia 2013 FAILURE MESSAGES not ok 1 - L7 : expect { $h->foo->bar == 42 }; # $h->foo # => undef # $h # => bless( {}, 'main' ) 13年9月20日金曜日
  • 6. perl.js Fuji Goro (gfx) YAPC::Asia 2013 END Part 1. End. 13年9月20日金曜日
  • 7. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Part 2. perl.js - Perl 5.18.1 running on browsers build with emscripten 13年9月20日金曜日
  • 8. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Demo http://gfx.github.io/perl.js/ 13年9月20日金曜日
  • 9. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Emscripten LLVM to JavaScript compiler Compile LLVM bitcode into JavaScript 13年9月20日金曜日
  • 10. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Emscripten Use JavaScript as a machine code Like a kernel & CPU, not an emulator nor translator All the syscalls are implemented in the emscripten runtime libraries 13年9月20日金曜日
  • 11. perl.js Fuji Goro (gfx) YAPC::Asia 2013 For example: fork(2) // src/library.js fork: function() { // pid_t fork(void); // We don't support multiple processes. ___setErrNo(ERRNO_CODES.EAGAIN); return -1; }, Most POSIX syscalls are just dummies :( 13年9月20日金曜日
  • 12. perl.js Fuji Goro (gfx) YAPC::Asia 2013 utime(2) // src/library_fs.js utime: function(path, atime, mtime) { var lookup = FS.lookupPath(path, { follow: true }); var node = lookup.node; node.node_ops.setattr(node, { timestamp: Math.max(atime, mtime) }); }, Emscripten has a virtual file system 13年9月20日金曜日
  • 13. perl.js Fuji Goro (gfx) YAPC::Asia 2013 BuilD PERL Write own Make?le based on Make?le.micro cf. pl! - Perl 5.16.3 based emscripten-ed perl 13年9月20日金曜日
  • 14. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Problems Does not support call main() more than twice exit() closes stdin, stdout, stderr but there’s no way to open them again Fatal errors which cause abort() breaks the internal state, which then needs to reload the page (the JavaScript interpreter) 13年9月20日金曜日
  • 15. perl.js Fuji Goro (gfx) YAPC::Asia 2013 Conclusion Use emscripten for C/C++ applications Write once, run everywhere 13年9月20日金曜日
  • 16. perl.js Fuji Goro (gfx) YAPC::Asia 2013 END http://github.com/gfx/perl.js 13年9月20日金曜日