00:00:17.160
I am about to start my presentation I would like to welcome all
00:00:23.279
of you it is a great honor for me to be here
00:00:30.960
please let me introduce myself first and let me introduce my
00:00:37.680
company my name is Ki taka both kji and taka are commonly used
00:00:46.039
a first name in Japan in my case Ki is
00:00:51.680
my first name and taka is my last name
00:00:57.320
please call me coji I'm a research engineer at Network
00:01:05.880
applied communication laboratory LTD the Japanese company that hire mat and
00:01:14.720
others as for me my work includes anything related to system integration
00:01:22.759
for example system design programming planning and meeting with the customers
00:01:29.520
and I will work are the leader of small
00:01:34.759
team I develop open source software during my spare
00:01:39.840
time I'm A mby and C committer in maby I am in charge of some
00:01:47.560
of the cor Parts in C I am in charge of the RM
00:01:56.880
mod you can contact me on email Twitter or
00:02:05.079
Facebook as I said previous previously my company's name is Network applied
00:02:12.080
communication laboratory LTD my company is also known as
00:02:21.519
n as you probably know N means salt salt
00:02:26.640
is necessary for all creature to live this this is why we Nam the company
00:02:36.760
n you can check out n homepage at www.
00:02:43.000
njp but almost all contents are in
00:02:48.760
Japanese NL is located in shiman prefecture in
00:02:55.560
Japan the company was founded in 200 and
00:03:00.680
one so 2011 is the 10th
00:03:06.480
anniversary by the way it's also my own 10th anniversary as an employee I'm very
00:03:16.959
happy oh thank you uh uh uh 15 uh uh 57 people uh work at
00:03:28.480
my company woo that's a lot of rubies is just
00:03:36.280
joking oh actually about half of my co-workers work using Ruby and six
00:03:43.040
people are C be commits the company works with system
00:03:50.000
integration training and so on please let me introduce the N way as
00:03:58.439
I see it this is our president his name is hirosi
00:04:06.879
in in a speech at my coworker wedding party he said to my
00:04:14.360
coworker first I want you to be
00:04:19.959
happy next I want you to make your family
00:04:25.759
happy or finally if you have more happiness like then please share it with our
00:04:36.880
company so I think the priority of my company is as
00:04:42.639
fors first the employees will being next the wellbeing of the Empire's
00:04:50.840
family and finally the company itself so
00:04:56.840
this is why I am my company yeah now let's continue on to the main
00:05:05.160
topic of today macro on
00:05:12.080
RS in my presentation I will explain how I modified maby to make it a suitable
00:05:19.479
foundation for running RS I would also like to explain some of the technical
00:05:25.360
internals that I discovered along the way
00:05:34.560
first I would like to First brief explain about
00:05:42.360
mroe mroe is a unique brand of Ruby 1.9 and Objective
00:05:50.639
C the goal of the M project is to be 100% compatible syntactically and
00:05:58.960
behaviorally with Ruby 1.9 oh this is Ruby
00:06:06.599
1.9 this system diagram shows the main building blocks of Ruby 1.9 the top side
00:06:13.880
shows the Brock blocks facing the user and the bottom side shows the BR facing
00:06:20.759
the hardware at the at the top we have the
00:06:26.560
applications made by the Ruby user below that we have Ruby 1.9 these are
00:06:33.800
Ruby's main building blocks we have Ruby BM Ruby B machine
00:06:41.080
which was previously called Yi we have the building garbage
00:06:46.800
corlection which uses Mar and seep then we have the building libraries
00:06:53.639
which includes the string class and the array class and so on
00:07:04.039
and then we have the standard rary which includes we Line open SSL and other
00:07:11.319
useful libraries below below Ruby we have the
00:07:17.160
system Ries and below the rary we have the operating system R 1.9 operates on a
00:07:25.520
number of different platforms among other Reax window do MOS stand and so on
00:07:33.080
so this is the structure of Ruby
00:07:39.639
1.9 so let's try to compare this with the system diagram as it looks for micro
00:07:46.759
where look at each element in turn the application stays as it is it
00:07:53.520
is naturally Ruby 1.9 becomes micro Ruby BM is replaced by
00:08:03.639
lbm the building garbage corlection is replaced by a mechanism provided by m
00:08:11.400
this m feature is called or zone or zone is a generation and threaded garbage
00:08:18.840
correction mechanism part of the Bing library is
00:08:24.280
replaced by a future called Foundation which is provided by Mark a
00:08:30.639
object array string hash and others are replaced this way the result is that
00:08:38.279
these classes get not only the functional functionality provided by Ruby but also the functionality provided
00:08:46.279
by foundation for instance a foundation method called
00:08:52.680
transform is add to the Ruby strength to class this method can convert the out
00:08:59.200
ver of my name kji into the corresponding Japanese hilana
00:09:08.440
characters the standard rers are more oress similar to Ruby
00:09:15.720
1.9 the system R are also unchanged and the OS is of course or Mar
00:09:24.440
Austin actually ma Ruby only runs on Mar atin
00:09:33.480
there so if we look at the whole well then it looks like this so now I have
00:09:41.160
done with my introductory explain of micro so let's continue with the main
00:09:49.000
topic M only so I'm going to talk about
00:09:54.120
making Ruby on R works or microbe
00:10:01.000
let's see what we can currently do with mcro on Riles creating a new red
00:10:09.920
project Genting a scaffold starting up the server and
00:10:16.680
showing the wecome page so it is currently possible to run a red application on micro without modified
00:10:24.880
modifying Le however it wasn't always like this oh
00:10:31.360
let's travel back in
00:10:36.639
time oh 7 months ago March
00:10:42.800
2011 in Japan I saw does rails work on
00:10:51.000
macbe I tried to install rails on MBE and I could
00:10:57.560
install so I saw okay it's install but I
00:11:03.480
didn't expect the red generators would work I tried to create a red Project
00:11:10.760
without much expectation and I
00:11:18.880
could not be my own eyes I tried to gener a
00:11:24.720
scaff then it fail and starting up the sub fa to after
00:11:32.519
all R didn't work on
00:11:38.040
micro so what did I do my Approach was to follow the five-step process showing
00:11:44.959
here repeat repeatedly first I learn ra as a next
00:11:53.639
step I see where it fails for instance segmentation Force about the programs
00:12:00.279
and so on the thir step is to research the cause of the
00:12:06.839
fair the first step is to c a patch that fixes Pro
00:12:12.399
problem and finally I Lear Ru Ruby spec to verify my
00:12:18.720
patch and repeat from the top if
00:12:25.480
necessary in uh in order to do this I need to know
00:12:31.360
about CB Objective C C++ and er VM when you just work with CB then you
00:12:41.040
only need to know about CB but when you want to code pches for M then you also
00:12:49.600
need to know about Objective C C++ and a
00:12:55.040
BM so I think that to code pches for mic is more difficult than to do so for
00:13:05.040
C now I like to discuss a couple of issues that I that I fixed in M for
00:13:16.760
examples let's have a look at the first case which is track issue number
00:13:24.160
860 and issue with catch and throw and EXP handling in
00:13:31.320
microbe this error can be reproduced by
00:13:38.120
Disco If you can run disc then the following error will
00:13:44.880
occur this kind of exception handling is used by Band so in order to make red
00:13:52.880
work we need to fix this error let me try to explain this reason
00:14:00.880
first we need to know a little bit about how exhibtion handling is done in
00:14:08.240
MCR have a look at Discord in this program we read and rescue twice let's
00:14:14.839
look at what happens when we learn this pro pro program on
00:14:20.480
MCR on line two we let exception
00:14:26.199
a or mro let exceptions are start in our
00:14:31.399
stack we call the stack the exception
00:14:39.920
stack on righty we rescue exception a and continue execution on line five
00:14:48.240
inside the rescue block we l extion b so exception B is pushed onto the stock
00:14:59.639
on line six we rescue extion B and continue ex executing the
00:15:06.360
cord on line seven we Le the end of the inner resue block so M pops one
00:15:13.759
exception of the stack and on line eight we lead the end
00:15:22.800
of the outer rescue block and again we pop an exception from from the St
00:15:29.759
exception stock so now we are done handling all all the exceptions read by
00:15:36.639
this program and the exception stack is empty this is a way that mro starts and
00:15:44.560
processes
00:15:51.759
exceptions so let's look at how exception handling with car out when it
00:16:03.040
throw have a look at this go in this Pro program we Define a catch block leled
00:16:09.160
full inside the catch block we have a begin rescue where we let an
00:16:15.800
exception and in the rescue block we use throw to jump out of the beginning
00:16:22.720
rescue let's step through the ex execution again to see what happened in
00:16:29.399
the microb exception stock just like we did in the last
00:16:35.040
example on L one we Define a rid block using catch after that if we call thr
00:16:42.040
with symbol who as an argument then we jump out of the
00:16:48.440
block on line three we let exception a so it is pushed onto the
00:16:57.079
St on on line five we call row with symol who
00:17:05.079
as argument so we jump out of the oh
00:17:10.240
sorry so we jump out of the rabbit broke the mro pops exception a from the
00:17:19.360
stock so this is how through house R takes out exceptions from the stock in m
00:17:32.360
before I patch it macr thr was implemented as you can see here this
00:17:38.840
code is from bm. CPP thr is implemented in
00:17:46.160
C++ the current exception function uh return the topmost exception from the
00:17:53.240
stock and the pop current exception function or pops one exception of the
00:18:02.799
stock now have a look at the code that reproduce the error once
00:18:09.280
again on line two we l exception a so exception a is pushed onto the
00:18:17.039
stck L four we call catch and throw then Mar pops one exception of the
00:18:24.440
stock and the stock is empty line five we Le the end of the out
00:18:32.320
rescue block and again we pop an exception of the stock however the stock
00:18:39.880
is empty therefore M ABS as you can
00:18:45.960
probably see that the cause of the ER of the eror has popped one exception of the
00:18:51.919
stack on R for let me explain how to fix the error
00:19:01.039
first let's look at what happens when we run this program program on macb after
00:19:07.760
we fix the error up until L three things work as
00:19:15.520
they always did however now things work a bit
00:19:22.880
different from line four now when we call catch then we
00:19:28.320
start a record of what is at the top of the exception s in this case exception
00:19:36.559
a next when we call through we compare the exception that we St with the
00:19:44.120
exception at the top of the exception stock
00:19:49.159
if these two exceptions are the same then mcrob doesn't do
00:19:56.320
anything if they are different then mro pops one exception of the sack
00:20:02.840
now in this case they are the same so Mac doesn't do
00:20:09.600
anything on line five MC pops an exception from the stock and then the
00:20:16.520
stack is empty so this is how the new implementation of throw
00:20:26.000
works so I change the implementation so that microb only pops exceptions when
00:20:34.240
needed so the code in the green Fram is where we compare the St exception with
00:20:41.960
the exception at the top of the stock and in this part M pops one
00:20:48.640
exception of the S so in short we keep popping exceptions of the sack until the
00:20:56.080
hard condition turn for or in other words until we reach the
00:21:02.960
recorded exception finally let's look at what
00:21:08.360
happens when we run a more complex program on macrobe with the fixed
00:21:14.120
implementation of St line two we read exception a so
00:21:22.559
exception a is pushed onto the stck right four we call catch and start exception a
00:21:30.840
line six we let extion B and push it onto the stock line eight we call row
00:21:39.320
then we compare the recorded exception a with exception B of the
00:21:44.480
St this a different so m b pops exception B of the stock then we compare
00:21:51.480
the recorded exception a with the new top of the stock which is now exception
00:21:56.679
a the are say so M doesn't do anything then we jump out of the r catch
00:22:06.760
block on line 11 M pops one exception of the stock and the pr program finishes
00:22:14.600
without aboring so this is how I modified the
00:22:24.000
program next let's look at another example of how I mod how I fix micro
00:22:31.919
this time we look at track issue number 11 192 which is related constant look up
00:22:39.000
in micro the issue was the micro fail to correct correctly look up constants in a
00:22:46.440
number of station when you use module era and class
00:22:53.480
ER this error can be repr reproduced by this disc code
00:23:00.679
if you run this SC then the following error will
00:23:05.799
occur please look at the line with object do class A in CB when we look for
00:23:13.320
the constant B we start looking within the green box so we are able to find constant
00:23:24.279
B however in the micro at the time we only looked within class a reer object
00:23:32.960
and since constant B isn't defined there the constant look up would fail in
00:23:39.880
micro constant lookup within a crass e or a modu e argument is widely used by
00:23:46.799
active support so in order to make R works we need to fix this
00:23:56.360
error to really understand on this issue you must have a detailed understanding
00:24:02.000
of how constant r c Works in Ruby and this is one of the parts of
00:24:08.679
Ruby's language specication that quiet hard to
00:24:14.279
understand and in most cases you can get along quite fine without knowing the
00:24:21.720
details of constant lookup in Ruby let's have a look at this call
00:24:27.880
where look look at it from the top and down line one we begin the defining of
00:24:35.720
modul and line two We Begin the def definition of module
00:24:43.000
b line three we Define a constant called Con in modu
00:24:49.520
b line four we open the top module a in other words the module a that we Define
00:24:56.799
in line one and finally on line five we print the
00:25:02.320
constant uh content of the constant con through the standard
00:25:07.880
output in this example CB would look for the constant con within the gra frame
00:25:15.360
green frame we call the scope represented by the green frame for elri
00:25:21.399
scope and cdb will find the constant const that is defined in module B
00:25:28.760
so you see the Conant lookup resolution is done in Le Scopes we call it Le
00:25:36.679
constant R up
00:25:43.799
Hereafter at the time maku had not implemented electrical constant
00:25:50.399
rup in this Cod on rine five maku only looks for the constant con Within modu
00:25:59.840
a therefore con cannot be
00:26:06.600
found next we have example with class and
00:26:12.200
C constru becomes even more complex when we use Class
00:26:18.919
A the behavior changes depending on whether we pass a block or a string as
00:26:25.240
Argent to class ER in the code example on the left hand we pass a block and in
00:26:33.240
the right hand example we pass a string except for the different
00:26:39.080
arguments the two example are identical first I'll explain about
00:26:46.520
coring class with a broke let me explain this code sequency from the top line one
00:26:54.279
we Define module a line two we Define the con con con line three we Define method
00:27:02.440
F line four we pass a block to class E Line five we print the Conant content
00:27:10.559
of con to the standard output line six we close the class a
00:27:17.039
block so when we call method F then line four to six we get
00:27:22.880
executed right then we Define class ke line 11 we Define another constant
00:27:31.440
called conster but this time inside Class
00:27:37.120
K as you can see on line 12 we extended
00:27:42.360
Class K with module a online St we call
00:27:48.320
module a f method as a as a result the
00:27:53.440
code in line four to six is called so can you tell home what scope the
00:28:00.559
constant Ro C starts in this
00:28:06.000
case in this case it is easy to tell we look for the constant con within the
00:28:12.120
green frame so in this case the P output the
00:28:17.519
string is
00:28:22.600
constant next let's look at performing cross EV with a storing argument
00:28:28.640
the code example only differs on line four to six line four we pass a string to class
00:28:37.120
E in the form of a here document on line five we print the con
00:28:44.320
content of const on line six we close the here
00:28:51.840
document just as before we call module as F method online set
00:28:59.399
so can you tell her what scope the constant uh lookup starts in this
00:29:10.159
case actually we would look for con within this green
00:29:16.120
frame let me explain the reason whenever we call module as ISX method we pass and
00:29:25.399
evalate the string that is passed or P to class E and the scope in which we
00:29:33.000
look for con is deter determined uh to be the scope in
00:29:39.880
which the method f is run therefore the lookup scope becomes
00:29:46.120
the content of Class K as you as you may know we call this kind of scope for
00:29:53.320
dynamic scope so in this in this case the the P
00:29:58.600
output the strength Case Case constant so let's look at the two cases
00:30:07.720
together we can see that the scope of the constant look G differs greatly
00:30:15.000
depending on the kind of argument passed to class
00:30:23.960
E it was not easy to fix this error I I had to start over twice and I was
00:30:31.519
finally able to find the satisfy Sol solution in the South
00:30:41.840
attempt I edit more than 3,000 lines of
00:30:47.600
call when I finally managed to fix this error Laurent who is the main developer
00:30:54.919
of macby wrot the following to to
00:31:00.120
me it's officially Ki is the hero of the day week
00:31:06.200
month his patches seem to fix remain lric con bags and that made me very
00:31:21.360
yeah however after enjoying a brief Victory I
00:31:26.760
soon found a new and difficult issue related to constant look up this error
00:31:33.799
can be reproduced by this score let me explain this code section from the top
00:31:39.880
line one we Define module a line two we Define con B and module a line five we
00:31:47.120
specify module a as receiver and core class ER with the do block
00:31:53.480
n line six we are inside the cross EV block so the current receiver is module
00:32:00.159
a therefore this means that we are defined the class method F or module
00:32:07.320
a line seven we out output the con constant B to the standard
00:32:15.799
output and on line 11 we call method F or module a this means that we are going
00:32:23.120
to have a look up constant B
00:32:28.480
we are now using a patched M which implements re scope this means that we
00:32:35.120
are going to start looking for constant B within the green frame naturally we
00:32:40.919
fail to find B within the green frame so we want to continue our search for B this time we
00:32:49.679
look in object for constant B this also means that we are going to look for a
00:32:56.360
constant constant cor B that is defined at top
00:33:03.399
R here I would like to add a word of caution Class E does not add its own
00:33:11.919
receiver to the constant lookup scope and this behavior is part of R's spef
00:33:19.399
specification so I expected that the search for constant B would fa
00:33:29.919
surprisingly C 1.9 F uh constant B in
00:33:36.080
module a so it succeeded to find the constant B even though it it should fail
00:33:43.519
according to the Ruby specification on the other hand Ruby 1
00:33:51.399
8.7 work as expected and F to find the constant B MBE pred as well so I asked
00:34:01.279
mat for advice about this
00:34:06.880
issue he said this is a b in CV
00:34:13.040
1.9 and soon therefore thereafter C 1.9
00:34:18.919
Behavior was fixed to match the behavior of Ruby 1.8 8.7
00:34:29.399
okay it's time to show you the result of my work making R works on mroe I will
00:34:37.879
demonstration Ruby on red learning on mroe I am using red
00:34:44.359
3.0.7 which is a bit old
00:34:58.480
first we are going to check makui and Red's
00:35:21.760
version okay uh m is 0.11 where is is
00:35:35.000
ra uh sorry uh we are going to create a new R
00:35:48.839
project please wait a bit
00:35:58.880
okay uh this is also
00:36:10.240
okay next we are going to generate a SCA
00:36:24.720
for please wait more
00:36:43.400
maybe my machine is
00:36:52.640
old uh it's a secret
00:37:04.319
this is related another B okay uh this is also okay next we are
00:37:13.240
going to start up the server
00:37:28.560
please vit
00:37:49.040
or okay
00:38:00.200
oh this is also okay finally we are going to show the welcome
00:38:25.280
page oh this is also okay this is cool isn't
00:39:16.400
up oh oh my God that's
00:39:25.079
happen iir uh whom this is
00:39:39.760
areed actually the S we about if you click this link on the welcome
00:39:57.839
making red work on M is more difficult than I expected perhaps even more
00:40:05.119
difficult than implementing RAR constant
00:40:11.839
R so the M uh train trip continues everyone please get on
00:40:19.680
board this is a URL for the M prodject
00:40:24.720
homepage this is M off Twitter account mro is on
00:40:34.400
GitHub this is the maku mailing list address so I would like to conclus
00:40:42.599
conclude this presentation with a quick summary of what I had said so
00:40:48.920
far m is a unique brand of Ruby 1.9 and Objective C the goal is to be one 100%
00:40:58.480
compatible with rup 1.9 mro only Les we are now able to show
00:41:05.079
the defa R will compage but there is still a lot of to
00:41:11.960
do L of all I would like to express my gr
00:41:18.440
gratitude toward the ruik K host and organ organizers for giving me the
00:41:25.880
opportunity to give give this presentation and I would like to thank
00:41:32.040
my coworker to Yamamoto s who helped me
00:41:37.319
with this presentation and finally I would like to thank my everyone here for
00:41:43.920
patent listening to this presentation despite my limited English thank
00:41:52.079
you thank you very much