Ruby and japanese

7,368
-1

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,368
On Slideshare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Ruby and japanese

  1. 1. RUBY AND JAPANESE Makoto Inoue LRUG December 2010
  2. 2. WHO ARE WE (NORMAL)?
  3. 3. WHO ARE WE(TODAY)?
  4. 4. ME @ RUBYKAIGIhere http://image.gihyo.co.jp/assets/images/news/report/01/rubykaigi2010/0003/thumb/TH400_IMG_1253.jpg
  5. 5. TOPICBasic JapaneseObject Oriented (OO)FunctionalJapanese Programming in Ruby
  6. 6. BASIC JAPANESE Step 1
  7. 7. WATASHI HA RUBY GA SUKI DESU Kanji Katakana HiraganaKanji eg: ,Katakana eg:Hiragana eg: , ,
  8. 8. HiraganaKatakana Each Japanese alphabet is a combination of vowels(a,i,u,e,o) and consonants(k,s,t,n,h,m,y,r,w). Total of Hiragana and Katakana are 46 each. The number of possible Kanji in use in Japan is around 50,000 , though around 2000 ~ 3000 are in common use.
  9. 9. Kanji => Hiragana KanjiHiragana
  10. 10. Kanji Kanji => KatakanaKatakana
  11. 11. WHAT’S YOUR NAME? How JapaneseAlphabet interpret Katakana Hiragana Kanji Makoto makoto Vivian bibiann Oliver oriba- Max makkusu
  12. 12. BUILD YOUR OWN http://kanji-fandom.com/
  13. 13. WHY SO MANY WAYS?Kanji = To import Chinese wordsHiragana = To suit for domestic useKatakana = To adopt new words
  14. 14. WHY SO MANY WAYS?To import OO & FunctionalTo suit for ScriptingTo adopt New Concepts
  15. 15. OBJECT ORIENTED Step 2
  16. 16. JAPANESE & OOhttp://satoshi.blogs.com/life/2004/09/post.html
  17. 17. ENGLISH (SVO) I like RubySubject Verb Object
  18. 18. (SOV)Watashi ha Ruby ga Suki desu Subject Object VerbI Ruby Like
  19. 19. CUI(SVO)
  20. 20. GUI(SOV)http://satoshi.blogs.com/life/2004/09/post.html
  21. 21. RUBY# Proceduralopen("box")open("car")# OOBox.new.openCar.new.open
  22. 22. FUNCTIONAL Step 3
  23. 23. Japanese is a politicians language Makoto Inoue (Me) - 2010
  24. 24. POLITICIAN....does not commit to anything unlessnecessarymeans different things depending oncontext
  25. 25. PREPOSITIONSprepositionnoun Grammara word governing, and usually preceding, anoun or pronoun and expressing a relationto another word or element in the clause,as in “the man on the platform,” “shearrived after dinner,” “what did you do itfor you
  26. 26. POSTPOSITIONSpostpositionnoun Grammara word or morpheme placed after theword it governs, for example -ward inhomeward.
  27. 27. POSTPOSITIONS IN JAPANESE S OWatashi ha Ruby ga Suki desu(I Ruby Like) O SRuby ga Watashi ha Suki desu(Ruby I Like) ORuby ga Suki desu(Ruby Like) Postposition is used to decide the role of noun which it supports. This enables you to change the order of structure very flexibly, chain as many sentence as you like, and also let you to omit subject.
  28. 28. ABUSING POSTPOSITIONS Don’t Read !! ” ” Confusing, vague, and long sentence without much point (Could be powerful)
  29. 29. FUNCTIONALLazy evaluationhigh order function
  30. 30. RUBY % 10000.timesEnumerable => #<Enumerator: 10000:times>Arel User.order(users.id DESC).limit(20).includes(:items)Block File.open("/tmp.txt").each do |line| puts line end
  31. 31. JAPANESE PROGRAMMING IN RUBYRUBY1.9 https://github.com/makoto/japanize Step 4
  32. 32. DEMOhttp://screenr.com/F9L
  33. 33. GRAMMAR# -*- encoding: utf-8 -*-module Japanize module Grammar VERBS = { => :+, # tasu => :-, # hiku => :*, # kakeru => :/, # waru } POSTPOSITIONAL_PARTICLES = [ , , , ] def ; POSTPOSITIONAL_PARTICLES; end def ; NUMBERS; end def ; VERBS; end
  34. 34. GRAMMAR# -*- encoding: utf-8 -*-def parse @sequence.split().map do |s| s.split(/#{ .join("|")}/) end.flatten.map do |s| if [s] [s] elsif [s[0]] NumberConverter.convert(s) end endend
  35. 35. PARSER# -*- encoding: utf-8 -*-describe Parser do it "must divide a phrase into words" do Parser.new(" "). parse.must_equal [1, 2, :+, 4, :*] endend
  36. 36. GOOGLE TRANSLATION
  37. 37. EVALUATORdescribe Evaluator do it "must calculate all operands" do Evaluator.new([1, 2, :+, 3 , :* , 1, :-, 2, :/]). evaluate.must_equal ((((1+2) * 3) - 1 ) / 2) endend
  38. 38. REVERSE POLISH NOTATION [1, 2, :+, 3 , :* , 1, :-, 2, :/]http://en.wikipedia.org/wiki/Reverse_Polish_notation
  39. 39. RubiMaVM RUBY VM ON RUBYhttp://jp.rubyist.net/magazine/?0007-YarvManiacs
  40. 40. METHOD MISSING# -*- encoding: utf-8 -*-def method_missing (*obj) if [obj[0][0]] parsed = Parser.new(obj[0].to_s).parse Evaluator.new(parsed).evaluate else super endend
  41. 41. SO WHAT? :-)
  42. 42. WHY SO MANY WAYS?To import OO & FunctionalTo suit for ScriptingTo adopt New Concepts
  43. 43. MATZ @ SAPPORO RUBY KAIGI http://regional.rubykaigi.org/sapporo03”In future, I want Ruby to keep being the lightwhich brings new concepts and ideas to people.I also would like people to see such light, add theirown, and spread it to other people.” http://igarashikuniaki.net/tdiary/20101205.html
  44. 44. WHAT CAN YOU DO? http://www.igvita.com/2010/12/02/concurrency-with-actors-goroutines-ruby/http://www.pragprog.com/titles/btlang/seven-languages-in-seven-weeks http://www.rubyinside.com/ruby-refinements-an-overview-of-a-new-proposed-ruby-feature-3978.html http://rubykaigi.org/2011/en
  45. 45. MERRY CHRISTMAS &HAVE A HAPPY NEW YEAR!! & !! hello 2011 http://www.railsonwave.com/assets/2006/12/21/screensaver_1.jpg
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×