SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
Pushing the Java Platform
         Further
Me

Charles Oliver Nutter
 ● headius@headius.com
 ● @headius
 ● JRuby co-lead, fulltime since 2006
 ● JVM enthusiast
 ● http://blog.headius.com
JRuby

● Ruby atop the JVM
   ○ "Just another Ruby implementation"
   ○ "Just another JVM language"
● A challenge for the JVM
   ○ Dynamic typing/dispatch
   ○ Own set of core classes
   ○ Heavy use of OS-level features
JRuby

● Ruby atop the JVM
   ○ "Just another Ruby implementation"
   ○ "Just another JVM language"
● A challenge for the JVM
   ○ Dynamic typing/dispatch
   ○ Own set of core classes
   ○ Heavy use of OS-level features
Custom Core Classes

          
What Classes?

● Array: a mutable, growable list of objects
● Hash: an ordered associative collection
● String: a collection of bytes (w/ an encoding in 1.9)
● Symbol: a named identifier
● IO: a stream of bytes (w/ an encoding in 1.9)
● File: a stream of bytes from filesystem
● Range: a range of values
Why Custom?

● Array, Hash
    ○ Behavior must match Ruby exactly
    ○ Many operations must redispatch into Ruby
● String
    ○ Java's String is immutable
    ○ Java's String is UTF-16 char[] based
● Regexp
    ○ byte[] based String necessitates it
    ○ Ruby Regexp is rich in features
● IO, File
    ○ Blocking IO simulated atop non-blocking
    ○ No good abstractions over NIO
String

    
String

 ● Used for both binary and character data
    ○ "It's just bytes"
    ○ IO operations receive, return String
 ● Arbitrary encoding
    ○ Implicit encoding in 1.8 (set globally)
    ○ Explicit encoding in 1.9 (String aggregates Encoding)
 ● Mutable
    ○ More efficient to mutate in-place
    ○ Copy-on-write to reduce object churn
ByteList

http://github.com/jruby/bytelist
ByteList

● A list of bytes
   ○ Abstraction around byte[] + encoding
   ○ Similar operations to StringBuffer
   ○ CoW-capable
ByteList Demo

       
Regexp

    
Regexp

● Operates against byte[] in String
   ○ All other engines operate against char[]
   ○ Transcoding cost == death
● Supports arbitrary encoding
   ○ Not all encodings transcode losslessly
   ○ Mismatched but compatible encodings?
● Bytecode engine
   ○ Avoids StackOverflow bugs in java.util.regex
   ○ Optimization potential
● Advanced regex features
   ○ Encoding-agnostic
   ○ Named groups
Joni

http://github.com/jruby/joni
Joni

 ● Java port of Oniguruma
 ● Ruby-friendly
    ○ byte[] based
    ○ Arbitrary encodings
    ○ Bytecoded engine
 ● Fast
    ○ Avoids transcoding costs
    ○ Sometimes faster than j.u.regex

Thanks to Marcin Mielzynski (github.com/lopex)!
Joni Demo

     
OS-level Features

         
OS-level Features

● Process management
    ○ getpid, waitpid, kill, signal, ...
● Filesystem operations
    ○ symlink, ownership, permissions, ...
● User-friendly IO
    ○ Interruptible, inherit TTY, "select" function, ...
● Binding native libs
    ○ Avoid hand-written native shim (JNI)
    ○ Route around JVM APIs
● UNIX sockets
Java Native Runtime

  http://github.com/jnr
Java Native Runtime

A collection of libraries to make interfacing with OS-level
features easier.

 ● Easy binding of native libs
 ● NIO-like IO atop file descriptors
 ● UNIX sockets
 ● POSIX filesystem operations

Big thanks to Wayne Meissner (@wmeissner)!
JNR-FFI
(foreign function interface)
   http://github.com/jnr/jnr-ffi
JNR-FFI

● Base of the JNR libraries
● Easy binding of native functions
● Struct mapping
● Memory/pointer management
● As fast as JNI?
    ○ Within 10-20% (comparing invocation overhead)
    ○  "a viable alternative, even for reasonably
      performance-sensitive libraries" - @wmeissner
    ○ "A hell of a lot nicer than using JNI!" - @headius
JNR-FFI Demo

       
JNR-POSIX

http://github.com/jnr/jnr-posix
JNR-POSIX

● Commonly used POSIX functions not in JDK
   ○ Symlinks
   ○ Filesystem metadata
   ○ Ownership, permissions
   ○ True "exec"
   ○ Process management
JNR-POSIX Demo

        
JNR-ENXIO
(Extended Native X-platform IO)
    http://github.com/jnr/jnr-enxio
JNR-ENXIO

● Mimics NIO
    ○ Same or similar API
    ○ Channels, Selectors, etc
● Implemented atop JNR-FFI
    ○ 100% Java (other than JNR-FFI)
● Multiple backends
    ○ poll, kqueue currently
    ○ epoll, win32 needed...volunteers?
● Full set of operations for *any* IO type
    ○ NIO can't select on stdio, files
JNR-ENXIO Demo

        
JNR-UNIXSOCKET

http://github.com/jnr/jnr-unixsocket
JNR-UNIXSOCKET

● Built atop jnr-enxio
● UNIX sockets
   ○ Need I say more?
JNR-UNIXSOCKET

        
JNR-X86ASM
(yes, it's what you think)
http://github.com/jnr/jnr-x86asm
JNR-X86ASM

● API for x86/x86_64 ASM generation
● Huh?
   ○ Down to the metal, baybee
   ○ Faster bindings to native functions
   ○ Other weird stuff...
JNR-X86ASM Demo

        
Ruby FFI

http://github.com/ffi/ffi
Ruby FFI

● Ruby DSL for binding native libraries
● Cross-impl
   ○ Supported on JRuby and standard Ruby
● Fun!
Ruby FFI Demo

       
What Have We Learned?

● The JVM can be a great native platform
● No problem is impossible to solve ;-)
● JRuby gives you all this (and more) for free
Links and Q/A

(All on Github)
http://github/
  ● jruby - JRuby organization
      ○ /jruby - JRuby itself
      ○ /bytelist - byte[] container
      ○ /jcodings - byte[] encoding support
      ○ /joni - byte[] regex
  ● /jnr - Java Runtime
      ○ /jnr-ffi - foreign function interface
      ○ /jnr-posix - POSIX features
      ○ /jnr-enxio - native IO
      ○ /jnr-unixsocket - UNIX sockets
      ○ /jnr-x86asm - x86 assembly
  ● /ffi/ffi - Ruby FFI

Contenu connexe

Tendances

Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldSATOSHI TAGOMORI
 
HTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS moduleHTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS moduleKazuho Oku
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with GoSteven Francia
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?Hiroshi SHIBATA
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in GoSteven Francia
 
Kotlin - A very quick introduction
Kotlin - A very quick introductionKotlin - A very quick introduction
Kotlin - A very quick introductionMike Harris
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming LanguageJaeju Kim
 
Mongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam HelmanMongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam HelmanHakka Labs
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Michał Konarski
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Codemotion
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOSconN Masahiro
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel ProgrammingRamazan AYYILDIZ
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mrubyHiroshi SHIBATA
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...Hisham Mardam-Bey
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJSTim Sommer
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02Hiroshi SHIBATA
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokersGaetano Giunta
 

Tendances (20)

Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing World
 
HTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS moduleHTTP::Parser::XS - writing a fast & secure XS module
HTTP::Parser::XS - writing a fast & secure XS module
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
IDLs
IDLsIDLs
IDLs
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in Go
 
Kotlin - A very quick introduction
Kotlin - A very quick introductionKotlin - A very quick introduction
Kotlin - A very quick introduction
 
Rust Programming Language
Rust Programming LanguageRust Programming Language
Rust Programming Language
 
Mongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam HelmanMongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam Helman
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
 
Rust 101 (2017 edition)
Rust 101 (2017 edition)Rust 101 (2017 edition)
Rust 101 (2017 edition)
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
 
Fluentd at HKOScon
Fluentd at HKOSconFluentd at HKOScon
Fluentd at HKOScon
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel Programming
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
 
T4T Training day - NodeJS
T4T Training day - NodeJST4T Training day - NodeJS
T4T Training day - NodeJS
 
tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02tDiary annual report 2009 - Sapporo Ruby Kaigi02
tDiary annual report 2009 - Sapporo Ruby Kaigi02
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
 

Similaire à JRuby: Pushing the Java Platform Further

PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodbPGConf APAC
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbWei Shan Ang
 
Network Automation: Ansible 101
Network Automation: Ansible 101Network Automation: Ansible 101
Network Automation: Ansible 101APNIC
 
NetflixOSS meetup lightning talks and roadmap
NetflixOSS meetup lightning talks and roadmapNetflixOSS meetup lightning talks and roadmap
NetflixOSS meetup lightning talks and roadmapRuslan Meshenberg
 
Deep Dive into Node.js Event Loop.pdf
Deep Dive into Node.js Event Loop.pdfDeep Dive into Node.js Event Loop.pdf
Deep Dive into Node.js Event Loop.pdfShubhamChaurasia88
 
Python Generators
Python GeneratorsPython Generators
Python GeneratorsAkshar Raaj
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldZvi Avraham
 
WebAssembly: In a Nutshell
WebAssembly: In a NutshellWebAssembly: In a Nutshell
WebAssembly: In a NutshellRangHo Lee
 
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...Linaro
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015Jorg Janke
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with GatlingPetr Vlček
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesDatabricks
 
Bsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdBsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdScott Tsai
 

Similaire à JRuby: Pushing the Java Platform Further (20)

PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodb
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
 
Network Automation: Ansible 101
Network Automation: Ansible 101Network Automation: Ansible 101
Network Automation: Ansible 101
 
Java Memory Descreption
Java Memory DescreptionJava Memory Descreption
Java Memory Descreption
 
NetflixOSS meetup lightning talks and roadmap
NetflixOSS meetup lightning talks and roadmapNetflixOSS meetup lightning talks and roadmap
NetflixOSS meetup lightning talks and roadmap
 
Deep Dive into Node.js Event Loop.pdf
Deep Dive into Node.js Event Loop.pdfDeep Dive into Node.js Event Loop.pdf
Deep Dive into Node.js Event Loop.pdf
 
Python Generators
Python GeneratorsPython Generators
Python Generators
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent World
 
WebAssembly: In a Nutshell
WebAssembly: In a NutshellWebAssembly: In a Nutshell
WebAssembly: In a Nutshell
 
Reverse Engineering 101
Reverse Engineering 101Reverse Engineering 101
Reverse Engineering 101
 
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...
HKG18-411 - Introduction to OpenAMP which is an open source solution for hete...
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
Ruxmon.2015-08.-.proxenet
Ruxmon.2015-08.-.proxenetRuxmon.2015-08.-.proxenet
Ruxmon.2015-08.-.proxenet
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with Gatling
 
Onyx
OnyxOnyx
Onyx
 
Rusty Python
Rusty PythonRusty Python
Rusty Python
 
The Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization OpportunitiesThe Parquet Format and Performance Optimization Opportunities
The Parquet Format and Performance Optimization Opportunities
 
Bsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsdBsdtw17: george neville neil: realities of dtrace on free-bsd
Bsdtw17: george neville neil: realities of dtrace on free-bsd
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 

Plus de Charles Nutter

The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018Charles Nutter
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandCharles Nutter
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMCharles Nutter
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015Charles Nutter
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Open Source Software Needs You!
Open Source Software Needs You!Open Source Software Needs You!
Open Source Software Needs You!Charles Nutter
 
InvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesInvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesCharles Nutter
 
Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Charles Nutter
 
Doing Open Source the Right Way
Doing Open Source the Right WayDoing Open Source the Right Way
Doing Open Source the Right WayCharles Nutter
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Charles Nutter
 
Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Charles Nutter
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Charles Nutter
 
The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013Charles Nutter
 
High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013Charles Nutter
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 MinutesCharles Nutter
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesCharles Nutter
 

Plus de Charles Nutter (20)

The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018The Year of JRuby - RubyC 2018
The Year of JRuby - RubyC 2018
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM Wonderland
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Open Source Software Needs You!
Open Source Software Needs You!Open Source Software Needs You!
Open Source Software Needs You!
 
InvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method HandlesInvokeBinder: Fluent Programming for Method Handles
InvokeBinder: Fluent Programming for Method Handles
 
Over 9000: JRuby in 2015
Over 9000: JRuby in 2015Over 9000: JRuby in 2015
Over 9000: JRuby in 2015
 
Doing Open Source the Right Way
Doing Open Source the Right WayDoing Open Source the Right Way
Doing Open Source the Right Way
 
JRuby: The Hard Parts
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard Parts
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013Beyond JVM - YOW! Brisbane 2013
Beyond JVM - YOW! Brisbane 2013
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
 
The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013The Future of JRuby - Baruco 2013
The Future of JRuby - Baruco 2013
 
High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013
 
Invokedynamic in 45 Minutes
Invokedynamic in 45 MinutesInvokedynamic in 45 Minutes
Invokedynamic in 45 Minutes
 
Invokedynamic: Tales from the Trenches
Invokedynamic: Tales from the TrenchesInvokedynamic: Tales from the Trenches
Invokedynamic: Tales from the Trenches
 

Dernier

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

JRuby: Pushing the Java Platform Further

  • 1. Pushing the Java Platform Further
  • 2. Me Charles Oliver Nutter ● headius@headius.com ● @headius ● JRuby co-lead, fulltime since 2006 ● JVM enthusiast ● http://blog.headius.com
  • 3. JRuby ● Ruby atop the JVM ○ "Just another Ruby implementation" ○ "Just another JVM language" ● A challenge for the JVM ○ Dynamic typing/dispatch ○ Own set of core classes ○ Heavy use of OS-level features
  • 4. JRuby ● Ruby atop the JVM ○ "Just another Ruby implementation" ○ "Just another JVM language" ● A challenge for the JVM ○ Dynamic typing/dispatch ○ Own set of core classes ○ Heavy use of OS-level features
  • 6. What Classes? ● Array: a mutable, growable list of objects ● Hash: an ordered associative collection ● String: a collection of bytes (w/ an encoding in 1.9) ● Symbol: a named identifier ● IO: a stream of bytes (w/ an encoding in 1.9) ● File: a stream of bytes from filesystem ● Range: a range of values
  • 7. Why Custom? ● Array, Hash ○ Behavior must match Ruby exactly ○ Many operations must redispatch into Ruby ● String ○ Java's String is immutable ○ Java's String is UTF-16 char[] based ● Regexp ○ byte[] based String necessitates it ○ Ruby Regexp is rich in features ● IO, File ○ Blocking IO simulated atop non-blocking ○ No good abstractions over NIO
  • 8. String  
  • 9. String ● Used for both binary and character data ○ "It's just bytes" ○ IO operations receive, return String ● Arbitrary encoding ○ Implicit encoding in 1.8 (set globally) ○ Explicit encoding in 1.9 (String aggregates Encoding) ● Mutable ○ More efficient to mutate in-place ○ Copy-on-write to reduce object churn
  • 11. ByteList ● A list of bytes ○ Abstraction around byte[] + encoding ○ Similar operations to StringBuffer ○ CoW-capable
  • 13. Regexp  
  • 14. Regexp ● Operates against byte[] in String ○ All other engines operate against char[] ○ Transcoding cost == death ● Supports arbitrary encoding ○ Not all encodings transcode losslessly ○ Mismatched but compatible encodings? ● Bytecode engine ○ Avoids StackOverflow bugs in java.util.regex ○ Optimization potential ● Advanced regex features ○ Encoding-agnostic ○ Named groups
  • 16. Joni ● Java port of Oniguruma ● Ruby-friendly ○ byte[] based ○ Arbitrary encodings ○ Bytecoded engine ● Fast ○ Avoids transcoding costs ○ Sometimes faster than j.u.regex Thanks to Marcin Mielzynski (github.com/lopex)!
  • 17. Joni Demo  
  • 19. OS-level Features ● Process management ○ getpid, waitpid, kill, signal, ... ● Filesystem operations ○ symlink, ownership, permissions, ... ● User-friendly IO ○ Interruptible, inherit TTY, "select" function, ... ● Binding native libs ○ Avoid hand-written native shim (JNI) ○ Route around JVM APIs ● UNIX sockets
  • 20. Java Native Runtime http://github.com/jnr
  • 21. Java Native Runtime A collection of libraries to make interfacing with OS-level features easier. ● Easy binding of native libs ● NIO-like IO atop file descriptors ● UNIX sockets ● POSIX filesystem operations Big thanks to Wayne Meissner (@wmeissner)!
  • 22. JNR-FFI (foreign function interface) http://github.com/jnr/jnr-ffi
  • 23. JNR-FFI ● Base of the JNR libraries ● Easy binding of native functions ● Struct mapping ● Memory/pointer management ● As fast as JNI? ○ Within 10-20% (comparing invocation overhead) ○  "a viable alternative, even for reasonably performance-sensitive libraries" - @wmeissner ○ "A hell of a lot nicer than using JNI!" - @headius
  • 26. JNR-POSIX ● Commonly used POSIX functions not in JDK ○ Symlinks ○ Filesystem metadata ○ Ownership, permissions ○ True "exec" ○ Process management
  • 28. JNR-ENXIO (Extended Native X-platform IO) http://github.com/jnr/jnr-enxio
  • 29. JNR-ENXIO ● Mimics NIO ○ Same or similar API ○ Channels, Selectors, etc ● Implemented atop JNR-FFI ○ 100% Java (other than JNR-FFI) ● Multiple backends ○ poll, kqueue currently ○ epoll, win32 needed...volunteers? ● Full set of operations for *any* IO type ○ NIO can't select on stdio, files
  • 32. JNR-UNIXSOCKET ● Built atop jnr-enxio ● UNIX sockets ○ Need I say more?
  • 34. JNR-X86ASM (yes, it's what you think) http://github.com/jnr/jnr-x86asm
  • 35. JNR-X86ASM ● API for x86/x86_64 ASM generation ● Huh? ○ Down to the metal, baybee ○ Faster bindings to native functions ○ Other weird stuff...
  • 38. Ruby FFI ● Ruby DSL for binding native libraries ● Cross-impl ○ Supported on JRuby and standard Ruby ● Fun!
  • 40. What Have We Learned? ● The JVM can be a great native platform ● No problem is impossible to solve ;-) ● JRuby gives you all this (and more) for free
  • 41. Links and Q/A (All on Github) http://github/ ● jruby - JRuby organization ○ /jruby - JRuby itself ○ /bytelist - byte[] container ○ /jcodings - byte[] encoding support ○ /joni - byte[] regex ● /jnr - Java Runtime ○ /jnr-ffi - foreign function interface ○ /jnr-posix - POSIX features ○ /jnr-enxio - native IO ○ /jnr-unixsocket - UNIX sockets ○ /jnr-x86asm - x86 assembly ● /ffi/ffi - Ruby FFI