Ruby and japanese
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
6,042
On Slideshare
2,995
From Embeds
3,047
Number of Embeds
17

Actions

Shares
Downloads
12
Comments
0
Likes
1

Embeds 3,047

http://blog.new-bamboo.co.uk 2,275
http://new-bamboo.co.uk 559
https://www.new-bamboo.co.uk 75
http://feeds.feedburner.com 55
http://localhost 36
http://blog.new-bamboo-website.dev 21
http://blog.localhost 5
http://blog.new-bamboo-website.local 5
http://theoldreader.com 3
http://translate.googleusercontent.com 3
http://feeds2.feedburner.com 2
http://www.new-bamboo.co.uk 2
http://www.newsblur.com 2
http://new-bamboo-website.dev 1
http://www.clipboard.com 1
http://cache.yahoofs.jp 1
http://twitter.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. RUBY AND JAPANESE Makoto Inoue LRUG December 2010
  • 2. WHO ARE WE (NORMAL)?
  • 3. WHO ARE WE(TODAY)?
  • 4. ME @ RUBYKAIGIhere http://image.gihyo.co.jp/assets/images/news/report/01/rubykaigi2010/0003/thumb/TH400_IMG_1253.jpg
  • 5. TOPICBasic JapaneseObject Oriented (OO)FunctionalJapanese Programming in Ruby
  • 6. BASIC JAPANESE Step 1
  • 7. WATASHI HA RUBY GA SUKI DESU Kanji Katakana HiraganaKanji eg: ,Katakana eg:Hiragana eg: , ,
  • 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. Kanji => Hiragana KanjiHiragana
  • 10. Kanji Kanji => KatakanaKatakana
  • 11. WHAT’S YOUR NAME? How JapaneseAlphabet interpret Katakana Hiragana Kanji Makoto makoto Vivian bibiann Oliver oriba- Max makkusu
  • 12. BUILD YOUR OWN http://kanji-fandom.com/
  • 13. WHY SO MANY WAYS?Kanji = To import Chinese wordsHiragana = To suit for domestic useKatakana = To adopt new words
  • 14. WHY SO MANY WAYS?To import OO & FunctionalTo suit for ScriptingTo adopt New Concepts
  • 15. OBJECT ORIENTED Step 2
  • 16. JAPANESE & OOhttp://satoshi.blogs.com/life/2004/09/post.html
  • 17. ENGLISH (SVO) I like RubySubject Verb Object
  • 18. (SOV)Watashi ha Ruby ga Suki desu Subject Object VerbI Ruby Like
  • 19. CUI(SVO)
  • 20. GUI(SOV)http://satoshi.blogs.com/life/2004/09/post.html
  • 21. RUBY# Proceduralopen("box")open("car")# OOBox.new.openCar.new.open
  • 22. FUNCTIONAL Step 3
  • 23. Japanese is a politicians language Makoto Inoue (Me) - 2010
  • 24. POLITICIAN....does not commit to anything unlessnecessarymeans different things depending oncontext
  • 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. POSTPOSITIONSpostpositionnoun Grammara word or morpheme placed after theword it governs, for example -ward inhomeward.
  • 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. ABUSING POSTPOSITIONS Don’t Read !! ” ” Confusing, vague, and long sentence without much point (Could be powerful)
  • 29. FUNCTIONALLazy evaluationhigh order function
  • 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. JAPANESE PROGRAMMING IN RUBYRUBY1.9 https://github.com/makoto/japanize Step 4
  • 32. DEMOhttp://screenr.com/F9L
  • 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. 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. 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. GOOGLE TRANSLATION
  • 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. REVERSE POLISH NOTATION [1, 2, :+, 3 , :* , 1, :-, 2, :/]http://en.wikipedia.org/wiki/Reverse_Polish_notation
  • 39. RubiMaVM RUBY VM ON RUBYhttp://jp.rubyist.net/magazine/?0007-YarvManiacs
  • 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. SO WHAT? :-)
  • 42. WHY SO MANY WAYS?To import OO & FunctionalTo suit for ScriptingTo adopt New Concepts
  • 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. 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. MERRY CHRISTMAS &HAVE A HAPPY NEW YEAR!! & !! hello 2011 http://www.railsonwave.com/assets/2006/12/21/screensaver_1.jpg