SlideShare a Scribd company logo
Spoiling The Youth With Ruby
EURUKO 2010
Karel Minařík
Karel Minařík
→ Independent web designer and developer („Have Ruby — Will Travel“)

→ Ruby, Rails, Git and CouchDB propagandista in .cz

→ Previously: Flash Developer; Art Director; Information Architect;… (see LinkedIn)

→ @karmiq at Twitter




→   karmi.cz



                                                                                Spoiling the Youth With Ruby
I have spent couple of last years introducing spoiling
humanities students to with the basics of PR0GR4MM1NG.
(As a PhD student)

I’d like to share why and how I did it.

And what I myself have learned in the process.




                                                 Spoiling the Youth With Ruby
I don’t know if I’m right.




                       Spoiling the Youth With Ruby
But a bunch of n00bz was able to:

‣ Do simple quantitative text analysis (count number of pages, etc)
‣ Follow the development of a simple Wiki web application and
  write code on their own
‣ Understand what $ curl ‐i ‐v http://example.com does
‣ And were quite enthusiastic about it


5 in 10 have „some experience“ with HTML
1 in 10 have „at last minimal experience“ with programming (PHP, C, …)




                                                                         Spoiling the Youth With Ruby
ΓΝΩΘΙ ΣΕΑΥΤΟN




Socrates
Socrates is guilty of spoling the youth (ἀδικεῖν τούϛ τε νέουϛ
διαφθείροντα) and not acknowledging the gods that the city

does, but some other new divinities (ἓτερα δὲ δαιμόνια καινά).


— Plato, Apology, 24b9




                                                  Spoiling the Youth With Ruby
Some of our city DAIMONIA:

Students should learn C or Java or Lisp…
Web is for hobbyists…
You should write your own implementation of quick sort…
Project management is for „managers“…
UML is mightier than Zeus…
Design patterns are mightier than UML…
Test-driven development is some other new divinity…
Ruby on Rails is some other new divinity…
NoSQL databases are some other new divinities…
(etc ad nauseam)



                                                      Spoiling the Youth With Ruby
Programming is
a specific way of thinking.




                          Spoiling the Youth With Ruby
1   Why Teach Programming (to non-programmers)?




                                    Spoiling the Youth With Ruby
„To use a tool on a computer, you need do little more than
point and click; to create a tool, you must understand the
arcane art of computer programming“


— John Maeda, Creative Code




                                                   Spoiling the Youth With Ruby
Literacy
(reading and writing)




                        Spoiling the Youth With Ruby
Spoiling the Youth With Ruby
Spoiling the Youth With Ruby
Complexity
„Hack“
Literacy




To most of my students, this:


    File.read('pride_and_prejudice.txt').
         split(' ').
         sort.
         uniq




is an ultimate, OMG this is soooooo cool hack

Although it really does not „work“ that well. That’s part of the explanation.


                                                                    Spoiling the Youth With Ruby
2   Ruby as an „Ideal” Programming Language?




                                   Spoiling the Youth With Ruby
There are only two hard things in Computer Science:
cache invalidation and naming things.
— Phil Karlton




                                           Spoiling the Youth With Ruby
The limits of my language mean the limits of my world
(Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt)

— Ludwig Wittgenstein, Tractatus Logico-Philosophicus 5.6




                                                                Spoiling the Youth With Ruby
Ruby as an „Ideal” Programming Language?




We use Ruby because it’s…
Expressive
Flexible and dynamic
Not tied to a specific paradigm
Well designed (cf. Enumerable)
Powerful
(etc ad nauseam)




                                           Spoiling the Youth With Ruby
All those reasons are valid
for didactic purposes as well.




                                 Spoiling the Youth With Ruby
Ruby as an „Ideal” Programming Language?




Of course… not only Ruby…




                                           Spoiling the Youth With Ruby
Ruby as an „Ideal” Programming Language?




              www.headfirstlabs.com/books/hfprog/

                                              Spoiling the Youth With Ruby
www.ericschmiedl.com/hacks/large-256.html

http://mit.edu/6.01
http://news.ycombinator.com/item?id=530605
Ruby as an „Ideal” Programming Language?




             5.times do
               print "Hello. "
             end


                                           Spoiling the Youth With Ruby
Ruby as an „Ideal” Programming Language?




Let’s start with the basics...



                                           Spoiling the Youth With Ruby
An algorithm is a sequence of well defined and
finite instructions. It starts from an initial state
and terminates in an end state.
— Wikipedia




                                            Spoiling the Youth With Ruby
Algorithms and kitchen recipes


                    1. Pour oil in the pan
                    2. Light the gas
                    3. Take some eggs
                    4. ...




                                        Spoiling the Youth With Ruby
SIMPLE ALGORITHM EXAMPLE


Finding the largest number from unordered list

1. Let’s assume, that the first number in the list is the largest.

2. Let’s look on every other number in the list, in succession. If it’s larger
then previous number, let’s write it down.

3. When we have stepped through all the numbers, the last number
written down is the largest one.




http://en.wikipedia.org/wiki/Algorithm#Example                       Spoiling the Youth With Ruby
Finding the largest number from unordered list


FORMAL DESCRIPTION IN ENGLISH



Input: A non‐empty list of numbers L
Output: The largest number in the list L

largest ← L0
for each item in the list L≥1, do
  if the item > largest, then
    largest ← the item
return largest




                                             Spoiling the Youth With Ruby
Finding the largest number from unordered list


DESCRIPTION IN PROGRAMMING LANGUAGE   C
1 #include <stdio.h>
2 #define SIZE 11
3 int main()
4 {
5   int input[SIZE] = {1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19};
6   int largest = input[0];
7   int i;
8   for (i = 1; i < SIZE; i++) {
9     if (input[i] > largest)
10       largest = input[i];
11   }
12   printf("Largest number is: %dn", largest);
13   return 0;
14 }


                                                         Spoiling the Youth With Ruby
Finding the largest number from unordered list


DESCRIPTION IN PROGRAMMING LANGUAGE   Java
1 class MaxApp {
2   public static void main (String args[]) {
3     int[] input = {1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19};
4     int largest = input[0];
5     for (int i = 0; i < input.length; i++) {
6       if (input[i] > largest)
7         largest = input[i];
8     }
9     System.out.println("Largest number is: " + largest + "n");
10   }
11 }




                                                         Spoiling the Youth With Ruby
Finding the largest number from unordered list


DESCRIPTION IN PROGRAMMING LANGUAGE   Ruby
1 input = [1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19]
2 largest = input.first
3 input.each do |i|
4   largest = i if i > largest
5 end
6 print "Largest number is: #{largest} n"




                                                    Spoiling the Youth With Ruby
Finding the largest number from unordered list


1 input = [1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19]
2 largest = input.first
3 input.each do |i|
4   largest = i if i > largest
5 end
6 print "Largest number is: #{largest} n"




   largest ← L0
   for each item in the list L≥1, do
    if the item > largest, then
      largest ← the item
   return largest



                                                    Spoiling the Youth With Ruby
What can we explain with this example?
‣   Input / Output
‣   Variable
‣   Basic composite data type: an array (a list of items)
‣   Iterating over collection
‣   Block syntax
‣   Conditions
                                    # find_largest_number.rb
‣   String interpolation            input = [3, 6, 9, 1]
                                         largest = input.shift
                                         input.each do |i|
                                           largest = i if i > largest
                                         end
                                         print "Largest number is: #{largest} n"




                                                             Spoiling the Youth With Ruby
That’s... well, basic...




                           Spoiling the Youth With Ruby
BUT, YOU CAN EXPLAIN ALSO…



 The concept of a function (method)…
  # Function definition:
  def max(input)
    largest = input.shift
    input.each do |i|
      largest = i if i > largest
    end
    return largest
  end

  # Usage:
  puts max( [3, 6, 9, 1] )
  # => 9



                                       Spoiling the Youth With Ruby
BUT, YOU CAN EXPLAIN ALSO…



… the concept of polymorphy
def max(*input)
  largest = input.shift
  input.each do |i|
    largest = i if i > largest
  end
  return largest
end

# Usage
puts max( 4, 3, 1 )
puts max( 'lorem', 'ipsum', 'dolor' )
puts max( Time.mktime(2010, 1, 1),
          Time.now,
          Time.mktime(1970, 1, 1) )

puts max( Time.now, 999 ) #=> (ArgumentError: comparison of Fixnum with Time failed)

                                                                      Spoiling the Youth With Ruby
BUT, YOU CAN EXPLAIN ALSO…




… that you’re doing it wrong — most of the time :)


# Enumerable#max
puts [3, 6, 9, 1].max




                                          Spoiling the Youth With Ruby
WHAT I HAVE LEARNED




Pick an example and stick with it
Switching contexts is distracting
What’s the difference between “ and ‘ quote?
What does the @ mean in a @variable ?
„OMG what is a class and an object?“




                                               Spoiling the Youth With Ruby
Interactive Ruby console at http://tryruby.org



"hello".reverse


[1, 14, 7, 3].max


["banana", "lemon", "ananas"].size
["banana", "lemon", "ananas"].sort
["banana", "lemon", "ananas"].sort.last
["banana", "lemon", "ananas"].sort.last.capitalize


5.times do
  print "Hello. "
end



                                                     Spoiling the Youth With Ruby
Great „one-click“  installer for Windows




                                           Spoiling the Youth With Ruby
Great resources, available for free




       www.pine.fm/LearnToProgram (first edition)
                                            Spoiling the Youth With Ruby
Like, tooootaly excited!




           Why’s (Poignant) Guide To Ruby
                                       Spoiling the Youth With Ruby
Ruby will grow with you                   („The Evolution of a Ruby Programmer“)



1   def sum(list)
      total = 0
                                  4   def sum(list)
                                        total = 0
      for i in 0..list.size-1           list.each{|i| total += i}
        total = total + list[i]         total
      end                             end
      total
    end                           5   def sum(list)
                                        list.inject(0){|a,b| a+b}
2   def sum(list)                     end
      total = 0
      list.each do |item|         6   class Array
        total += item                   def sum
      end                                 inject{|a,b| a+b}
      total                             end
    end                               end

3   def test_sum_empty
      sum([]) == 0
                                  7   describe "Enumerable objects should sum themselve

    end                                 it 'should sum arrays of floats' do
                                          [1.0, 2.0, 3.0].sum.should == 6.0
    # ...                               end

                                        # ...
                                      end

                                      # ...



    www.entish.org/wordpress/?p=707                           Spoiling the Youth With Ruby
WHAT I HAVE LEARNED



If you’re teaching/training, try to learn
something you’re really bad at.
‣ Playing a musical instrument
‣ Drawing
‣ Dancing
‣ Martial arts

‣   …


It gives you the beginner’s perspective

                                          Spoiling the Youth With Ruby
3   Web as a Platform




                        Spoiling the Youth With Ruby
20 09




        www.shoooes.net
20 09




        R.I.P.   www.shoooes.net
But wait! Almost all of us are doing
web applications today.




                                       Spoiling the Youth With Ruby
Why web is a great platform?
Transparent: view-source all the way
Simple to understand
Simple and free development tools
Low barrier of entry
Extensive documentation
Rich platform (HTML5, „jQuery“, …)
Advanced development platforms (Rails, Django, …)
Ubiquitous
(etc ad nauseam)




                                            Spoiling the Youth With Ruby
All those reasons are valid
for didactic purposes as well.




                                 Spoiling the Youth With Ruby
CODED LIVE IN CLASS, THEN CLEANED UP AND PUT ON GITHUB




                http://github.com/stunome/kiwi/
                                                         Spoiling the Youth With Ruby
Why a Wiki?

Well known and understood piece of software with minimal
and well defined feature set (www.c2.com/cgi/wiki?WikiPrinciples)

Used on a daily basis (Wikipedia)

Feature set could be expanded based on individual skills




                                                   Spoiling the Youth With Ruby
20 10




Sinatra.rb

 www.sinatrarb.com   Spoiling the Youth With Ruby
Sinatra.rb



Why choose Sinatra?
Expose HTTP!                GET / → get("/") { ... }

Simple to install and run   $ ruby myapp.rb

Simple to write „Hello World“ applications




                                               Spoiling the Youth With Ruby
Expose HTTP




$ curl --include --verbose http://www.example.com


* About to connect() to example.com port 80 (#0)
*   Trying 192.0.32.10... connected
* Connected to example.com (192.0.32.10) port 80 (#0)
> GET / HTTP/1.1
...
< HTTP/1.1 200 OK
...
<
<HTML>
<HEAD>
  <TITLE>Example Web Page</TITLE>
...
* Closing connection #0




                                                        Spoiling the Youth With Ruby
Expose HTTP



# my_first_web_application.rb

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello, World!"
end

get '/time' do
  Time.now.to_s
end




                                Spoiling the Youth With Ruby
First „real code“ — saving pages




                                                .gitignore       |    2 ++
                                                application.rb   |   22 ++++++++++++++++++++++
                                                views/form.erb   |    9 +++++++++
                                                views/layout.erb |   12 ++++++++++++
                                                4 files changed, 45 insertions(+), 0 deletions(‐)



http://github.com/stunome/kiwi/commit/33fb87                        Spoiling the Youth With Ruby
Refactoring code to OOP (Page class)




                                                application.rb |    4 +++‐
                                                kiwi.rb        |    7 +++++++
                                                2 files changed, 10 insertions(+), 1 deletions(‐)




http://github.com/stunome/kiwi/commit/33fb87                        Spoiling the Youth With Ruby
Teaching real-world processes and tools




        www.pivotaltracker.com/projects/74202
                                          Spoiling the Youth With Ruby
Teaching real-world processes and tools




           http://github.com/stunome/kiwi/
                                             Spoiling the Youth With Ruby
The difference between theory and practice
is bigger in practice then in theory.
(Jan L. A. van de Snepscheut or Yogi Berra, paraphrase)




                                                 Spoiling the Youth With Ruby
What I had no time to cover (alas)



Automated testing and test-driven development
Cucumber
Deployment (Heroku.com)




                                           Spoiling the Youth With Ruby
What would be great to have



A common curriculum for teaching Ruby
(for inspiration, adaptation, discussion, …)


Code shared on GitHub

TeachingRuby (RailsBridge) (http://teachingkids.railsbridge.org)

Try Camping (http://github.com/judofyr/try-camping)

http://testfirst.org ?




                                                                   Spoiling the Youth With Ruby
Questions!
   

More Related Content

Similar to Spoiling The Youth With Ruby (Euruko 2010)

Forget Ruby. Forget CoffeeScript. Do SOA
Forget Ruby. Forget CoffeeScript. Do SOAForget Ruby. Forget CoffeeScript. Do SOA
Forget Ruby. Forget CoffeeScript. Do SOA
Michał Łomnicki
 
Introduction to Ruby & Modern Programming
Introduction to Ruby & Modern ProgrammingIntroduction to Ruby & Modern Programming
Introduction to Ruby & Modern Programming
Christos Sotirelis
 
FrontMatter
FrontMatterFrontMatter
FrontMatter
tutorialsruby
 
FrontMatter
FrontMatterFrontMatter
FrontMatter
tutorialsruby
 
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
jaxLondonConference
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
tutorialsruby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
tutorialsruby
 
OO and Rails...
OO and Rails... OO and Rails...
OO and Rails...
adzdavies
 
Fluid, Fluent APIs
Fluid, Fluent APIsFluid, Fluent APIs
Fluid, Fluent APIs
Erik Rose
 
ORUG - Sept 2014 - Lesson When Learning Ruby/Rails
ORUG - Sept 2014 - Lesson When Learning Ruby/RailsORUG - Sept 2014 - Lesson When Learning Ruby/Rails
ORUG - Sept 2014 - Lesson When Learning Ruby/Rails
danielrsmith
 
Good programming
Good programmingGood programming
Good programming
Won Kwang University
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)
Konstantin Haase
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
Thomas Asikis
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008
Brian Sam-Bodden
 
Invasion of the dynamic language weenies
Invasion of the dynamic language weeniesInvasion of the dynamic language weenies
Invasion of the dynamic language weenies
Srijit Kumar Bhadra
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
ppparthpatel123
 
Intro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady HackathonIntro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady Hackathon
kdmcclin
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
Curtis Poe
 
Top 10+ Things .NET Developers Should Know About Ruby
Top 10+ Things .NET Developers Should Know About RubyTop 10+ Things .NET Developers Should Know About Ruby
Top 10+ Things .NET Developers Should Know About Ruby
Jeff Cohen
 

Similar to Spoiling The Youth With Ruby (Euruko 2010) (20)

Forget Ruby. Forget CoffeeScript. Do SOA
Forget Ruby. Forget CoffeeScript. Do SOAForget Ruby. Forget CoffeeScript. Do SOA
Forget Ruby. Forget CoffeeScript. Do SOA
 
Introduction to Ruby & Modern Programming
Introduction to Ruby & Modern ProgrammingIntroduction to Ruby & Modern Programming
Introduction to Ruby & Modern Programming
 
FrontMatter
FrontMatterFrontMatter
FrontMatter
 
FrontMatter
FrontMatterFrontMatter
FrontMatter
 
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
Little words of wisdom for the developer - Guillaume Laforge (Pivotal)
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
OO and Rails...
OO and Rails... OO and Rails...
OO and Rails...
 
Fluid, Fluent APIs
Fluid, Fluent APIsFluid, Fluent APIs
Fluid, Fluent APIs
 
ORUG - Sept 2014 - Lesson When Learning Ruby/Rails
ORUG - Sept 2014 - Lesson When Learning Ruby/RailsORUG - Sept 2014 - Lesson When Learning Ruby/Rails
ORUG - Sept 2014 - Lesson When Learning Ruby/Rails
 
Good programming
Good programmingGood programming
Good programming
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008Ruby Metaprogramming - OSCON 2008
Ruby Metaprogramming - OSCON 2008
 
Invasion of the dynamic language weenies
Invasion of the dynamic language weeniesInvasion of the dynamic language weenies
Invasion of the dynamic language weenies
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
 
Intro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady HackathonIntro to Ruby/Rails at TechLady Hackathon
Intro to Ruby/Rails at TechLady Hackathon
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
 
Top 10+ Things .NET Developers Should Know About Ruby
Top 10+ Things .NET Developers Should Know About RubyTop 10+ Things .NET Developers Should Know About Ruby
Top 10+ Things .NET Developers Should Know About Ruby
 

More from Karel Minarik

Vizualizace dat a D3.js [EUROPEN 2014]
Vizualizace dat a D3.js [EUROPEN 2014]Vizualizace dat a D3.js [EUROPEN 2014]
Vizualizace dat a D3.js [EUROPEN 2014]
Karel Minarik
 
Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)
Karel Minarik
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
Karel Minarik
 
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
Karel Minarik
 
Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]
Karel Minarik
 
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Karel Minarik
 
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Karel Minarik
 
Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)
Karel Minarik
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational Databases
Karel Minarik
 
CouchDB – A Database for the Web
CouchDB – A Database for the WebCouchDB – A Database for the Web
CouchDB – A Database for the Web
Karel Minarik
 
Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)
Karel Minarik
 
Představení Ruby on Rails [Junior Internet]
Představení Ruby on Rails [Junior Internet]Představení Ruby on Rails [Junior Internet]
Představení Ruby on Rails [Junior Internet]
Karel Minarik
 
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
Karel Minarik
 
Úvod do Ruby on Rails
Úvod do Ruby on RailsÚvod do Ruby on Rails
Úvod do Ruby on Rails
Karel Minarik
 
Úvod do programování 7
Úvod do programování 7Úvod do programování 7
Úvod do programování 7
Karel Minarik
 
Úvod do programování 6
Úvod do programování 6Úvod do programování 6
Úvod do programování 6
Karel Minarik
 
Úvod do programování 5
Úvod do programování 5Úvod do programování 5
Úvod do programování 5
Karel Minarik
 
Úvod do programování 4
Úvod do programování 4Úvod do programování 4
Úvod do programování 4
Karel Minarik
 
Úvod do programování 3 (to be continued)
Úvod do programování 3 (to be continued)Úvod do programování 3 (to be continued)
Úvod do programování 3 (to be continued)
Karel Minarik
 
Historie programovacích jazyků
Historie programovacích jazykůHistorie programovacích jazyků
Historie programovacích jazyků
Karel Minarik
 

More from Karel Minarik (20)

Vizualizace dat a D3.js [EUROPEN 2014]
Vizualizace dat a D3.js [EUROPEN 2014]Vizualizace dat a D3.js [EUROPEN 2014]
Vizualizace dat a D3.js [EUROPEN 2014]
 
Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)Elasticsearch (Rubyshift 2013)
Elasticsearch (Rubyshift 2013)
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
 
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
Realtime Analytics With Elasticsearch [New Media Inspiration 2013]
 
Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]Elasticsearch And Ruby [RuPy2012]
Elasticsearch And Ruby [RuPy2012]
 
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
 
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
 
Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)Your Data, Your Search, ElasticSearch (EURUKO 2011)
Your Data, Your Search, ElasticSearch (EURUKO 2011)
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational Databases
 
CouchDB – A Database for the Web
CouchDB – A Database for the WebCouchDB – A Database for the Web
CouchDB – A Database for the Web
 
Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)Verzovani kodu s Gitem (Karel Minarik)
Verzovani kodu s Gitem (Karel Minarik)
 
Představení Ruby on Rails [Junior Internet]
Představení Ruby on Rails [Junior Internet]Představení Ruby on Rails [Junior Internet]
Představení Ruby on Rails [Junior Internet]
 
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
Efektivni vyvoj webovych aplikaci v Ruby on Rails (Webexpo)
 
Úvod do Ruby on Rails
Úvod do Ruby on RailsÚvod do Ruby on Rails
Úvod do Ruby on Rails
 
Úvod do programování 7
Úvod do programování 7Úvod do programování 7
Úvod do programování 7
 
Úvod do programování 6
Úvod do programování 6Úvod do programování 6
Úvod do programování 6
 
Úvod do programování 5
Úvod do programování 5Úvod do programování 5
Úvod do programování 5
 
Úvod do programování 4
Úvod do programování 4Úvod do programování 4
Úvod do programování 4
 
Úvod do programování 3 (to be continued)
Úvod do programování 3 (to be continued)Úvod do programování 3 (to be continued)
Úvod do programování 3 (to be continued)
 
Historie programovacích jazyků
Historie programovacích jazykůHistorie programovacích jazyků
Historie programovacích jazyků
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Spoiling The Youth With Ruby (Euruko 2010)

  • 1. Spoiling The Youth With Ruby EURUKO 2010 Karel Minařík
  • 2. Karel Minařík → Independent web designer and developer („Have Ruby — Will Travel“) → Ruby, Rails, Git and CouchDB propagandista in .cz → Previously: Flash Developer; Art Director; Information Architect;… (see LinkedIn) → @karmiq at Twitter → karmi.cz Spoiling the Youth With Ruby
  • 3. I have spent couple of last years introducing spoiling humanities students to with the basics of PR0GR4MM1NG. (As a PhD student) I’d like to share why and how I did it. And what I myself have learned in the process. Spoiling the Youth With Ruby
  • 4. I don’t know if I’m right. Spoiling the Youth With Ruby
  • 5. But a bunch of n00bz was able to: ‣ Do simple quantitative text analysis (count number of pages, etc) ‣ Follow the development of a simple Wiki web application and write code on their own ‣ Understand what $ curl ‐i ‐v http://example.com does ‣ And were quite enthusiastic about it 5 in 10 have „some experience“ with HTML 1 in 10 have „at last minimal experience“ with programming (PHP, C, …) Spoiling the Youth With Ruby
  • 7. Socrates is guilty of spoling the youth (ἀδικεῖν τούϛ τε νέουϛ διαφθείροντα) and not acknowledging the gods that the city does, but some other new divinities (ἓτερα δὲ δαιμόνια καινά). — Plato, Apology, 24b9 Spoiling the Youth With Ruby
  • 8. Some of our city DAIMONIA: Students should learn C or Java or Lisp… Web is for hobbyists… You should write your own implementation of quick sort… Project management is for „managers“… UML is mightier than Zeus… Design patterns are mightier than UML… Test-driven development is some other new divinity… Ruby on Rails is some other new divinity… NoSQL databases are some other new divinities… (etc ad nauseam) Spoiling the Youth With Ruby
  • 9. Programming is a specific way of thinking. Spoiling the Youth With Ruby
  • 10. 1 Why Teach Programming (to non-programmers)? Spoiling the Youth With Ruby
  • 11. „To use a tool on a computer, you need do little more than point and click; to create a tool, you must understand the arcane art of computer programming“ — John Maeda, Creative Code Spoiling the Youth With Ruby
  • 12. Literacy (reading and writing) Spoiling the Youth With Ruby
  • 13. Spoiling the Youth With Ruby
  • 14.
  • 15. Spoiling the Youth With Ruby
  • 18. Literacy To most of my students, this: File.read('pride_and_prejudice.txt'). split(' '). sort. uniq is an ultimate, OMG this is soooooo cool hack Although it really does not „work“ that well. That’s part of the explanation. Spoiling the Youth With Ruby
  • 19. 2 Ruby as an „Ideal” Programming Language? Spoiling the Youth With Ruby
  • 20. There are only two hard things in Computer Science: cache invalidation and naming things. — Phil Karlton Spoiling the Youth With Ruby
  • 21. The limits of my language mean the limits of my world (Die Grenzen meiner Sprache bedeuten die Grenzen meiner Welt) — Ludwig Wittgenstein, Tractatus Logico-Philosophicus 5.6 Spoiling the Youth With Ruby
  • 22. Ruby as an „Ideal” Programming Language? We use Ruby because it’s… Expressive Flexible and dynamic Not tied to a specific paradigm Well designed (cf. Enumerable) Powerful (etc ad nauseam) Spoiling the Youth With Ruby
  • 23. All those reasons are valid for didactic purposes as well. Spoiling the Youth With Ruby
  • 24. Ruby as an „Ideal” Programming Language? Of course… not only Ruby… Spoiling the Youth With Ruby
  • 25. Ruby as an „Ideal” Programming Language? www.headfirstlabs.com/books/hfprog/ Spoiling the Youth With Ruby
  • 27. Ruby as an „Ideal” Programming Language? 5.times do   print "Hello. " end Spoiling the Youth With Ruby
  • 28. Ruby as an „Ideal” Programming Language? Let’s start with the basics... Spoiling the Youth With Ruby
  • 29. An algorithm is a sequence of well defined and finite instructions. It starts from an initial state and terminates in an end state. — Wikipedia Spoiling the Youth With Ruby
  • 30. Algorithms and kitchen recipes 1. Pour oil in the pan 2. Light the gas 3. Take some eggs 4. ... Spoiling the Youth With Ruby
  • 31. SIMPLE ALGORITHM EXAMPLE Finding the largest number from unordered list 1. Let’s assume, that the first number in the list is the largest. 2. Let’s look on every other number in the list, in succession. If it’s larger then previous number, let’s write it down. 3. When we have stepped through all the numbers, the last number written down is the largest one. http://en.wikipedia.org/wiki/Algorithm#Example Spoiling the Youth With Ruby
  • 32. Finding the largest number from unordered list FORMAL DESCRIPTION IN ENGLISH Input: A non‐empty list of numbers L Output: The largest number in the list L largest ← L0 for each item in the list L≥1, do   if the item > largest, then     largest ← the item return largest Spoiling the Youth With Ruby
  • 33. Finding the largest number from unordered list DESCRIPTION IN PROGRAMMING LANGUAGE C 1 #include <stdio.h> 2 #define SIZE 11 3 int main() 4 { 5   int input[SIZE] = {1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19}; 6   int largest = input[0]; 7   int i; 8   for (i = 1; i < SIZE; i++) { 9     if (input[i] > largest) 10       largest = input[i]; 11   } 12   printf("Largest number is: %dn", largest); 13   return 0; 14 } Spoiling the Youth With Ruby
  • 34. Finding the largest number from unordered list DESCRIPTION IN PROGRAMMING LANGUAGE Java 1 class MaxApp { 2   public static void main (String args[]) { 3     int[] input = {1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19}; 4     int largest = input[0]; 5     for (int i = 0; i < input.length; i++) { 6       if (input[i] > largest) 7         largest = input[i]; 8     } 9     System.out.println("Largest number is: " + largest + "n"); 10   } 11 } Spoiling the Youth With Ruby
  • 35. Finding the largest number from unordered list DESCRIPTION IN PROGRAMMING LANGUAGE Ruby 1 input = [1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19] 2 largest = input.first 3 input.each do |i| 4   largest = i if i > largest 5 end 6 print "Largest number is: #{largest} n" Spoiling the Youth With Ruby
  • 36. Finding the largest number from unordered list 1 input = [1, 5, 3, 95, 43, 56, 32, 90, 2, 4, 19] 2 largest = input.first 3 input.each do |i| 4   largest = i if i > largest 5 end 6 print "Largest number is: #{largest} n" largest ← L0 for each item in the list L≥1, do if the item > largest, then largest ← the item return largest Spoiling the Youth With Ruby
  • 37. What can we explain with this example? ‣ Input / Output ‣ Variable ‣ Basic composite data type: an array (a list of items) ‣ Iterating over collection ‣ Block syntax ‣ Conditions # find_largest_number.rb ‣ String interpolation input = [3, 6, 9, 1] largest = input.shift input.each do |i| largest = i if i > largest end print "Largest number is: #{largest} n" Spoiling the Youth With Ruby
  • 38. That’s... well, basic... Spoiling the Youth With Ruby
  • 39. BUT, YOU CAN EXPLAIN ALSO… The concept of a function (method)…   # Function definition:   def max(input)     largest = input.shift     input.each do |i|       largest = i if i > largest     end     return largest   end   # Usage:   puts max( [3, 6, 9, 1] )   # => 9 Spoiling the Youth With Ruby
  • 40. BUT, YOU CAN EXPLAIN ALSO… … the concept of polymorphy def max(*input)   largest = input.shift   input.each do |i|     largest = i if i > largest   end   return largest end # Usage puts max( 4, 3, 1 ) puts max( 'lorem', 'ipsum', 'dolor' ) puts max( Time.mktime(2010, 1, 1),           Time.now,           Time.mktime(1970, 1, 1) ) puts max( Time.now, 999 ) #=> (ArgumentError: comparison of Fixnum with Time failed) Spoiling the Youth With Ruby
  • 41. BUT, YOU CAN EXPLAIN ALSO… … that you’re doing it wrong — most of the time :) # Enumerable#max puts [3, 6, 9, 1].max Spoiling the Youth With Ruby
  • 42. WHAT I HAVE LEARNED Pick an example and stick with it Switching contexts is distracting What’s the difference between “ and ‘ quote? What does the @ mean in a @variable ? „OMG what is a class and an object?“ Spoiling the Youth With Ruby
  • 43. Interactive Ruby console at http://tryruby.org "hello".reverse [1, 14, 7, 3].max ["banana", "lemon", "ananas"].size ["banana", "lemon", "ananas"].sort ["banana", "lemon", "ananas"].sort.last ["banana", "lemon", "ananas"].sort.last.capitalize 5.times do   print "Hello. " end Spoiling the Youth With Ruby
  • 44. Great „one-click“  installer for Windows Spoiling the Youth With Ruby
  • 45. Great resources, available for free www.pine.fm/LearnToProgram (first edition) Spoiling the Youth With Ruby
  • 46. Like, tooootaly excited! Why’s (Poignant) Guide To Ruby Spoiling the Youth With Ruby
  • 47. Ruby will grow with you („The Evolution of a Ruby Programmer“) 1 def sum(list) total = 0 4 def sum(list) total = 0 for i in 0..list.size-1 list.each{|i| total += i} total = total + list[i] total end end total end 5 def sum(list) list.inject(0){|a,b| a+b} 2 def sum(list) end total = 0 list.each do |item| 6 class Array total += item def sum end inject{|a,b| a+b} total end end end 3 def test_sum_empty sum([]) == 0 7 describe "Enumerable objects should sum themselve end it 'should sum arrays of floats' do [1.0, 2.0, 3.0].sum.should == 6.0 # ... end # ... end # ... www.entish.org/wordpress/?p=707 Spoiling the Youth With Ruby
  • 48. WHAT I HAVE LEARNED If you’re teaching/training, try to learn something you’re really bad at. ‣ Playing a musical instrument ‣ Drawing ‣ Dancing ‣ Martial arts ‣ … It gives you the beginner’s perspective Spoiling the Youth With Ruby
  • 49. 3 Web as a Platform Spoiling the Youth With Ruby
  • 50. 20 09 www.shoooes.net
  • 51. 20 09 R.I.P. www.shoooes.net
  • 52. But wait! Almost all of us are doing web applications today. Spoiling the Youth With Ruby
  • 53. Why web is a great platform? Transparent: view-source all the way Simple to understand Simple and free development tools Low barrier of entry Extensive documentation Rich platform (HTML5, „jQuery“, …) Advanced development platforms (Rails, Django, …) Ubiquitous (etc ad nauseam) Spoiling the Youth With Ruby
  • 54. All those reasons are valid for didactic purposes as well. Spoiling the Youth With Ruby
  • 55. CODED LIVE IN CLASS, THEN CLEANED UP AND PUT ON GITHUB http://github.com/stunome/kiwi/ Spoiling the Youth With Ruby
  • 56. Why a Wiki? Well known and understood piece of software with minimal and well defined feature set (www.c2.com/cgi/wiki?WikiPrinciples) Used on a daily basis (Wikipedia) Feature set could be expanded based on individual skills Spoiling the Youth With Ruby
  • 57. 20 10 Sinatra.rb www.sinatrarb.com Spoiling the Youth With Ruby
  • 58. Sinatra.rb Why choose Sinatra? Expose HTTP! GET / → get("/") { ... } Simple to install and run $ ruby myapp.rb Simple to write „Hello World“ applications Spoiling the Youth With Ruby
  • 59. Expose HTTP $ curl --include --verbose http://www.example.com * About to connect() to example.com port 80 (#0) * Trying 192.0.32.10... connected * Connected to example.com (192.0.32.10) port 80 (#0) > GET / HTTP/1.1 ... < HTTP/1.1 200 OK ... < <HTML> <HEAD> <TITLE>Example Web Page</TITLE> ... * Closing connection #0 Spoiling the Youth With Ruby
  • 60. Expose HTTP # my_first_web_application.rb require 'rubygems' require 'sinatra' get '/' do "Hello, World!" end get '/time' do Time.now.to_s end Spoiling the Youth With Ruby
  • 61. First „real code“ — saving pages  .gitignore       |    2 ++  application.rb   |   22 ++++++++++++++++++++++  views/form.erb   |    9 +++++++++  views/layout.erb |   12 ++++++++++++  4 files changed, 45 insertions(+), 0 deletions(‐) http://github.com/stunome/kiwi/commit/33fb87 Spoiling the Youth With Ruby
  • 62. Refactoring code to OOP (Page class)  application.rb |    4 +++‐  kiwi.rb        |    7 +++++++  2 files changed, 10 insertions(+), 1 deletions(‐) http://github.com/stunome/kiwi/commit/33fb87 Spoiling the Youth With Ruby
  • 63. Teaching real-world processes and tools www.pivotaltracker.com/projects/74202 Spoiling the Youth With Ruby
  • 64. Teaching real-world processes and tools http://github.com/stunome/kiwi/ Spoiling the Youth With Ruby
  • 65. The difference between theory and practice is bigger in practice then in theory. (Jan L. A. van de Snepscheut or Yogi Berra, paraphrase) Spoiling the Youth With Ruby
  • 66. What I had no time to cover (alas) Automated testing and test-driven development Cucumber Deployment (Heroku.com) Spoiling the Youth With Ruby
  • 67. What would be great to have A common curriculum for teaching Ruby (for inspiration, adaptation, discussion, …) Code shared on GitHub TeachingRuby (RailsBridge) (http://teachingkids.railsbridge.org) Try Camping (http://github.com/judofyr/try-camping) http://testfirst.org ? Spoiling the Youth With Ruby
  • 68. Questions!