Slide 1

Slide 1 text

RubyMotion Mobile & Beyond Presented by Photo by Henk on Unsplash

Slide 2

Slide 2 text

Lori Olson Developer, trainer, mentor and now founder of the WNDX School

Slide 3

Slide 3 text

Why RubyMotion?

Slide 4

Slide 4 text

Well, because RubyMotion IS Ruby.

Slide 5

Slide 5 text

http://www.rubymotion.com/tour/how-it-works/ Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. (http://ruby-lang.org) Since I won’t assume that you are all familiar with ruby, let’s explore ruby just a bit before proceeding

Slide 6

Slide 6 text

Ruby vs Rails Let’s just address this confusion people sometimes have about Ruby vs Rails

Slide 7

Slide 7 text

Ruby is to Rails

Slide 8

Slide 8 text

Python is to Django

Slide 9

Slide 9 text

PHP is to Laravel One is a language the other is a framework

Slide 10

Slide 10 text

about Ruby

Slide 11

Slide 11 text

Ruby Philosophy To make programmers productive and happy Photo by Brooke Cagle on Unsplash

Slide 12

Slide 12 text

Everything is an Object What does that mean?

Slide 13

Slide 13 text

Number 1 2.to_s 3.next 4.days 5.months

Slide 14

Slide 14 text

DSL’s DSL’s or Domain Specific Languages Ruby is ideally suited to the creation of DSL’s and so they abound in the Ruby eco-system. Take for example.

Slide 15

Slide 15 text

Rake Rake is Ruby’s build tool. The equivalent of ‘make’. It is also used as the RubyMotion build tool, so you can customize your project’s build any way you like. The great thing about DSL’s is that you can make it very specific to the task at hand.

Slide 16

Slide 16 text

desc "One line task description" task :name_of_task do # Your code goes here end rake name_of_task This is an example of a trivial Rake task

Slide 17

Slide 17 text

desc "Example of task with parameters and prerequisites" task :my_task, [:first_arg, :second_arg] => ["first_task", "second_task"] do |t, args| args.with_defaults(:first_arg => "Foo", :last_arg => "Bar") puts "First argument was: #{args.first_arg}" puts "Second argument was: #{args.second_arg}" end rake my_task[one,two] This is a more advanced Rake task. But the important thing to note about Rakefiles, is that they are just Ruby. So you can drop extra methods and stuff in where they are needed.

Slide 18

Slide 18 text

Iterators Photo by Dmitri Popov on Unsplash The iterators in Ruby are a thing of beauty

Slide 19

Slide 19 text

response = gets.chomp.downcase validInput = false # Flag to track if input is valid i = 0 #Index for following loop while i < titles.length do validInput = true if response == titles[i] i += 1 end validInput = true if response == "back" I’ll give you an example here. This is a bit of code that my new first-year co-op student wrote, a fragment from his first real Ruby program. And I looked at it, and you can just see his C++ leaking out everywhere…

Slide 20

Slide 20 text

response = gets.chomp.downcase valid_input = titles.include?(response) || response == “back" The Ruby standard library is filled with iterators like include? in which the loop is assumed.

Slide 21

Slide 21 text

Why RubyMotion? Getting back to RubyMotion again…

Slide 22

Slide 22 text

So you might be asking yourself - why use RubyMotion? Why not Objective C or Swift for your iPhone development?

Slide 23

Slide 23 text

Swift • Moving fast • Breaking things Swift is a nicer language, by far, than Objective C. It’s main problem is that it has been evolving very, very fast. When a new major release happens *every year* that means you, as a developer, have to update all your apps *every year* for these breaking changes. That level of change imposes a burden that might not be sustainable for every app or developer.

Slide 24

Slide 24 text

Ruby • More frequent updates • Fewer breaking changes • Over 25 years old, current version 2.5.1 That’s not to say there are never any incremental updates that cause problems. But the Ruby Language group concentrates on evolutionary, not revolutionary change.

Slide 25

Slide 25 text

Yukihiro Matsumoto creator of Ruby By using Ruby, I want to concentrate on the things I do, not the magical rules of the language, like starting with public void something something something to say, "print hello world." I just want to say, "print this!" Speaking of Matz, or Yukihiro Matsumoto, the creator of Ruby *most Ruby developers just call him - MATZ* Matz once said: For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, So Ruby is designed to make programmers happy. And I have to confess, having used Objective C long before iPhones even existed, I can’t say there’s anything resembling “happy” involved in programming with Objective C.

Slide 26

Slide 26 text

Back to RubyMotion Back to RubyMotion. Again. Other ways in which RubyMotion is different include

Slide 27

Slide 27 text

When creating a RubyMotion application, you use simple command-line tools from your terminal. And, you will not be trapped within Apple’s Xcode environment, which is not going to win any prizes as the developers’ favorite IDE. This also makes the RubyMotion environment a friendly accessible environment.

Slide 28

Slide 28 text

RubyMotion comes with a REPL - read - evaluate - print - loop. This REPL allows you to write code in the console, and see changes in real time in your running application, making it simple to experiment and iterate.

Slide 29

Slide 29 text

RubyMotion also provides a “baked in” testing framework (called Bacon actually), allowing you to write functional and integration tests for your applications.

Slide 30

Slide 30 text

Identifying developer pain points, like provisioning for the deployment of applications, RubyMotion has also provided supporting libraries like motion- provisioning and motion-appstore to help you deploy to real devices on one hand, and upload your completed app to the Apple App Store on the other.

Slide 31

Slide 31 text

RubyMotion IS native. This is different. Ruby is a language with many implementations - MRI, JRuby for the JVM, mruby for embedded applications with it’s own compiled bytecode.

Slide 32

Slide 32 text

And… • No, it’s not free* • But you can start for free • Yes you have to wait for updates

Slide 33

Slide 33 text

For example, when Apple unveiled their new MacBook Pro with touch bar on Oct 27th, 2016…

Slide 34

Slide 34 text

You had to wait for the next version of RubyMotion to get touch bar support… until Oct 28… one day.

Slide 35

Slide 35 text

Starter is limited to iOS and Android, and just this latest release, macOS. Splash screen No betas or old versions. Only current version supported.

Slide 36

Slide 36 text

iOS + macOS + (watchOS + tvOS) *watchOS and tvOS only available in the Indie or Professional versions

Slide 37

Slide 37 text

And Android! We won’t really be addressing the Android support here today, but you can do fun things with RubyMotion in Android, too.

Slide 38

Slide 38 text

Ruby Tools! And, you get to use all the familiar Ruby tools!

Slide 39

Slide 39 text

Rake We already discussed

Slide 40

Slide 40 text

RubyGems Libraries that provide functions like web access, integration with social media, Mapping, data access, screen layout, and much much more

Slide 41

Slide 41 text

Bundler Bundler helps pull all those gems together in your project, and keep all the versions compatible

Slide 42

Slide 42 text

No Xcode Required You do not NEED to use Xcode, however, you need it installed. Boo. The command-line tools and simulators are all hiding under the covers of Xcode.

Slide 43

Slide 43 text

Your fav editor You can use whichever editor you like. If you like Vim, use that. Or if you prefer use Emacs, Sublime Text, or even a full featured IDE with RubyMotion support like RubyMine…

Slide 44

Slide 44 text

http://motion-toolbox.com Speaking of gems

Slide 45

Slide 45 text

motion-cocoapods And if you can’t find a gem to do what you want, there’s always CocoaPods, and motion-cocoapods, Your handy-dandy interface to all the Objective-C libraries that others have created for iOS development

Slide 46

Slide 46 text

So many gems http://www.mywebpresenters.com/articles/wp-content/uploads/2012/08/choosing-a-corporate-video-production-company.jpg But there are so many gems? It might be hard to figure out which ones to use…

Slide 47

Slide 47 text

But Rails? IT sure would be nice if there was a framework like Rails, but for iOS development…

Slide 48

Slide 48 text

the RubyMotion community has combined and tested the most active and powerful gems into a single package called RedPotion And so there is. http://docs.redpotion.org/en/latest/ ProMotion, RMQ, CDQ, AFMotion, RedAlert, and MORE!

Slide 49

Slide 49 text

Live demo time

Slide 50

Slide 50 text

As an educator, I like to leave some things as an exercise for those who are interested. You can add those “waiting” indicators, fix the display of the temperatures, or I’m certain you’ll come up with other creative additions to this example. The WNDX School, my school, would like to help YOU get off to a GREAT start with RubyMotion.

Slide 51

Slide 51 text

RubyMotion JumpStart • *class will open on May 25* • Sign up *today* • https://wndx.school • http://bit.ly/ rubymotionwearedevs Our Introductory workshop, featuring RubyMotion & RedPotion will get you going from installation and setup of RubyMotion, generating your first application screens, adding user interactions and navigation, data models, populating your data store from a remote source, and getting that app up and running on your own device. Use the link below to get an *instant* discount on this workshop. I hope to see you there.

Slide 52

Slide 52 text

Thanks, WeAreDevs! Presentation (with links) will be available later this afternoon on SpeakerDeck.com Lori Olson @wndxlori