bringing the ruby language into the mobile world
DESCRIPTION
Presentation given at RubyWorld 2014 (Matsue, Japan), a business conference about the Ruby programming language. Slides in Japanese / English. Sample code: https://github.com/lrz/rubymotion-hybrid-sampleTRANSCRIPT
Bringing the Ruby language into the mobile world
RUBYMOTION
Laurent Sansonetti
Founder of HipByte (RubyMotion)
2001年から
Ruby信者ですI love Ruby since 2001
ここにいる皆さんもRuby信者ですよね
We are all here because we love Ruby
Rubyで優れている点は何でしょうか?
What is the best thing about Ruby?
文法が、The syntax
パワフルで簡潔なことConcise, yet powerful
初心者が学ぶのが 簡単なこと
Easy enough to learn for beginners
柔軟性があることFlexible enough for advanced use
Some may say Ruby is a bad rip-off of Lisp or Smalltalk, and I admit that. But it is nicer to
ordinary people. !
— matz
Ruby文法を最も活用しているものは何でしょう?
What is the best use of the Ruby syntax?
DSLs
Domain Specific Languages
特定機能を高いレベルで抽象化します
Wrap a particular functionality into a higher-level abstraction
抽象化された機能は 自然なインタフェースで
記述できますThe abstraction becomes a natural
language interface
より簡単に機能を利用できるようなります
The functionality can then be accessed more easily
Complex → Simple
Programmers → Happy
RubyはWeb開発で
とてもポピューラですRuby is very popular for
Web development
多くのWebアプリがRubyで書かれています
There are lots of Web apps written in Ruby
Twitter, Github, Basecamp, etc.
なぜでしょう?Why so?
Ruby on Rails
RailsはWeb開発用の
Ruby製フレームワークRails is a Ruby framework for
Web development
RailsはWeb開発を容易にしました
Rails makes Web development easier
RailsはWebテクノロジーに特化したDSLです
Rails is a DSL for Web technologies
Complex → Simple
Programmers → Happy
Change
現在、モバイルデバイスはPCシェアを奪っています
Mobile devices are now replacing personal computers
Source: http://ben-evans.com/benedictevans/2014/10/28/presentation-mobile-is-eating-the-world
PC → Phone / Tablet
Source: http://ben-evans.com/benedictevans/2014/10/28/presentation-mobile-is-eating-the-world
多くの人々は、ネットの閲覧などにモバイルデバイスを利
用していますMost people use mobile devices
to be connected
モバイルの世界では、2つの巨人がいます
Two major players in the mobile industry
Apple and Google
iOS and Android
0%
20%
40%
60%
80%
2012 2013
78.6%69%
15.2%18.7%
iOS Android
Smartphone Market Share
Source: © IDC (Jan 2014)
0%
18%
35%
53%
70%
2012 2013
61.9%
45.8%
36%
52.8%
iOS Android
Tablet Market Share
Source: © Gartner (March 2014)
モバイルマーケットのほぼすべてがiOSとAndroidです
Almost all of the mobile market is iOS and Android
デバイスは20億以上+2 billion devices combined
モバイルデバイスはアプリを実行できます
Mobile devices run apps
Webアプリの技術を利用し、アプリを開発できます
It is possible to write mobile apps using Web technologies
しかし、エンドユーザは ネイティブなモバイルアプリ
を好みますBut end users prefer using
native mobile apps
ネイティブアプリは、iOSやAndroidのSDK APIを使用し開発
されますNative apps are written using the
platform SDK APIs
ネイティブアプリはより良いUXを提供します
Native apps provide a better user experience
ネイティブアプリは軽快に動作します
Native apps are faster
Facebook released major upgrades to its iPhone and iPad apps. Those who have suffered from the sluggishness of the current apps can breathe a collective sigh of relief: these new versions are much faster. !The apps look nearly identical to their predecessors. The main difference is that most of their old Web-based code has been replaced with the native programming code used for iOS, Apple’s mobile operating system. !New York Times, August 23, 2012Source: http://bits.blogs.nytimes.com/2012/08/23/facebook-iphone-ipad/
We have definitely shifted from HTML5 to native. The primary reason for that is, we’re seeing that more and more people are spending more time in the app, and the app is running out of memory. […] !The second reason we’ve gone native is trying to get some of the animations — the spinners and the way they work — getting that smoothness, we felt like we needed native to really do that well. !Venture Beat, April 17, 2013Source: http://venturebeat.com/2013/04/17/linkedin-mobile-web-breakup
現在、ネイティブなモバイルアプリ開発は分断化されてい
ますThe current state of native mobile
development is fragmented
Language IDE APIs
iOS Objective-C Swift Xcode iOS SDK
Android Java Android Studio Android SDK
異なる二つの開発言語Two different languages
コードの共有は 困難
Difficult to share code
異なる二つのIDETwo different IDEs
開発の効率が悪いDifficult to be efficient
どうにか簡単にすることができないでしょうか?
Can we make this simpler?
Language IDE APIs
iOS Objective-C / Swift Xcode iOS SDK
Android Java Android Studio Android SDK
Language IDE APIs
iOS
Ruby
Xcode iOS SDK
Android Android Studio Android SDK
共通言語としてのRubyRuby as a common platform language
Language IDE APIs
iOS
Ruby
Xcode iOS SDK
Android Android Studio Android SDK
Language IDE APIs
iOS
Ruby Your favorite editor
iOS SDK
Android Android SDK
開発者はテキストエディタにこだわりがあります
Developers have strong opinions regarding text editors
開発者には好きなエディタを使用していただきましょう
Let’s make them use the editor they like
RUBYMOTION
Rubyで、iOSとAndroidのネイティブアプリを開発できます
Write iOS and Android native apps in Ruby
iOS向けのRubyの実装Implementation of Ruby for iOS
RubyMotion Objective-C
Objective-C Runtime
iOS / OS X
iOS APIをネイティブに呼び出します
Call into the native iOS APIs natively
ブリッジでは ありません
Not a bridge
iOS Hello Worldclass AppDelegate def application(application, didFinishLaunchingWithOptions:options) label = UILabel.new label.text = "Hello World!" label.sizeToFit! viewController = UIViewController.new viewController.view.backgroundColor = UIColor.whiteColor label.center = viewController.view.center viewController.view.addSubview(label)! frame = UIScreen.mainScreen.applicationFrame @window = UIWindow.alloc.initWithFrame(frame) @window.rootViewController = viewController @window.makeKeyAndVisible! true endend
iOS Hello Worldclass AppDelegate def application(application, didFinishLaunchingWithOptions:options) label = UILabel.new label.text = "Hello World!" label.sizeToFit! viewController = UIViewController.new viewController.view.backgroundColor = UIColor.whiteColor label.center = viewController.view.center viewController.view.addSubview(label)! frame = UIScreen.mainScreen.applicationFrame @window = UIWindow.alloc.initWithFrame(frame) @window.rootViewController = viewController @window.makeKeyAndVisible! true endend
Android向けの
Rubyの実装Implementation of Ruby for Android
RubyMotion
Java
Dalvik / ART
Android
Java Native Interface
Android APIをネイティブに呼び出します
Call into the native Android APIs natively
ブリッジでは ありません
Not a bridge
Android Hello Worldclass MainActivity < Android::App::Activity def onCreate(savedInstanceState) super! text = Android::Widget::TextView.new(self) text.text = 'Hello RubyMotion!' self.contentView = text endend
Android Hello Worldclass MainActivity < Android::App::Activity def onCreate(savedInstanceState) super! text = Android::Widget::TextView.new(self) text.text = 'Hello RubyMotion!' self.contentView = text endend
RubyMotionは、アプリを静的コンパイルします
RubyMotion apps are statically compiled
Com
pila
tion
Machine Code
Assembly
LLVM IR
AST
Ruby File
アプリは機械語に変換されたバイナリになります
RubyMotion apps are machine-code binaries
インタプリタでは ありません
No interpreter
RubyMotionは成功したエコシステムです
RubyMotion is a successful ecosystem
チームで開発していますDeveloped by a team of thought
leaders
Team
Team
2012年に着手しましたLaunched in 2012
数千の顧客Thousands of customers
多くのRubyMotion 製のアプリがリリースされています
Lots of RubyMotion apps in production
Bandcamp
RubyMotion lets us write the Bandcamp app without that
dirty feeling you get from fooling around with Xcode.
!Like the best tools, it makes the
hard things easy. !
Daniel Dickison
Frontback
With RubyMotion, it’s easier to get on board. Every line you write is needed application logic, nothing more.The fact you don’t have to use XCode is a big win. !Melvyn Hills
A Dark Room
Idiomatic Ruby wrappers on top of iOS, frictionless workflows, and
the “it just works” culture that Ruby fosters, trumps any
hesitation I once had with RubyMotion.
!Amir Rajan
今後のRubyMotionアプリ開発について少し紹介します
Let’s have a glimpse of the future of RubyMotion app development
ハイブリッドな プロジェクトになります
The future is hybrid projects
アプリのプロジェクトはiOSとAndroid両方を対象
Projects that work on both iOS and Android
ひとつのコードベースOne codebase
プラットフォームに依存したコードをなくします
Isolate platform-specific code
ポータブルに抽象化したDSLを使用します
Use portable high-level abstractions (DSLs)
Language IDE APIs
iOS
Ruby Your favorite editor
iOS SDK
Android Android SDK
Language IDE APIs
iOS
Ruby Your favorite editor
Community DSLs
Android
Demo
まとめConclusion
ネイティブなモバイルアプリ開発は分断化されていますMobile development is fragmented
RubyMotionは独自の技術を提供し、開発をより簡単にします
RubyMotion makes it easier by providing a unique experience
開発言語はひとつですOne language
開発環境はひとつですOne development environment
ポータブルに抽象化したDSL
Portable high-level abstractions (DSLs)
Complex → Simple
Programmers → Happy