
Here is an old diagram that was in my slide deck at OSCON 2007. Sorry I managed to cut off the .WAR file suffix for the cruise build artifacts. Anyway, I am publishing it here for easy reference.
Going with Java is like driving a Ford Crown Victoria. The Vic. might not be much fun, but it is reliable, easy to find parts for, and boy, you sure can fit lots of stuff in the trunk. Going with Ruby is like driving a little roadster. It is fast, and you will have lots of fun with it until you try towing your boat. Oh, and by the way, finding a mechanic for that exotic Japaneese machine might be tough.The main point of the analogy is that from a developer perspective programming with Ruby is often far more attractive than programming in Java. But it makes some other points as well: Java is ubiquitous, it has a library for everything and it is embraced by enterprise. It also highlights how powerful Ruby is, and how much smaller the developer base is. Unfortunately depicting Ruby as a sports car makes it sound impractical. It really isn't. Oh, and if you really know what you are doing you'll have no trouble towing that boat. Stupid analogies.
"ruby
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
"improve autocomplete menu color
highlight Pmenu ctermbg=238 gui=bold
#!/usr/bin/env ruby
require 'drb'
class InvokeFromCruise
def run_rake
remote_runner = DRbObject.new(nil, "druby://seleniumbox:9999")
remote_runner.run
end
end
invoker = InvokeFromCruise.new
invoker.run_rake
require 'drb'
class StartSuite
def start
@rake_runner = RakeRunner.new
DRb.start_service("druby://seleniumbox:9999", @rake_runner)
end
def daemon
DRb.thread.join
end
end
class RakeRunner
def run
`ruby.exe C:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb smoke`
end
end
starter = StartSuite.new
starter.start
starter.daemon
<onsuccess>
<antpublisher buildfile="/path/to/build.xml" target="invokeSelenium" anthome="/path/to/apache-ant">
</onsuccess>
<target name="invokeSelenium">
<exec executable="ruby" spawn="true">
<arg line="${parameterized-path-to-executable}/build/invoke_from_cruise.rb">
</exec>
</target>
int pinStates[] = {HIGH,LOW,LOW};
int fullAddResult[2]; //ugh, global since i can't seem to pass arrays around
int halfAddResult[2];
int greenPin = 12;
int redPin = 11;
int bluePin = 10;
int inPin = 2;
int inPinVal = 0;
int prev;
boolean autoPilot = false;
void setup(){
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(inPin, INPUT);
prev = digitalRead(inPin);
}
//current, as in electrical current
int currentVal(boolean a){
if (a == true){
return HIGH;
}
else{
return LOW;
}
}
boolean boolVal(int a){
if (a == HIGH){
return true;
}
else{
return false;
}
}
int nand(int a, int b){
return currentVal(!(boolVal(a) && boolVal(b)));
}
int exor(int a, int b){
int ab;
int aab;
int bab;
ab = nand(a, b);
aab = nand(a, ab);
bab = nand(ab, b);
return nand(aab, bab);
}
// method implements a half adder
void halfAdd(int a, int b){
halfAddResult[0] = currentVal(boolVal(a) && boolVal(b));
halfAddResult[1] = exor(a, b);
}
// implements a full adder
void fullAdd(int a, int b, int c){
int ab[2];
int abc[2];
halfAdd(a, b);
ab[0] = halfAddResult[0];//Lame way of copying array values
ab[1] = halfAddResult[1];
halfAdd(ab[1], c);
abc[0] = halfAddResult[0];//Still Lame
abc[1] = halfAddResult[1];
fullAddResult[0] = currentVal(boolVal(ab[0]) || boolVal(abc[0]));
fullAddResult[1] = abc[1];
}
// implements a ripple carry adder
// MSB is the 0th element of the pinStates array
void increment(){
int temp[2];
halfAdd(pinStates[2], HIGH);
temp[0] = halfAddResult[0];
temp[1] = halfAddResult[1];
fullAdd(pinStates[1], temp[0], LOW);
halfAdd(pinStates[0], fullAddResult[0]);
pinStates[0] = halfAddResult[1];
pinStates[1] = fullAddResult[1];
pinStates[2] = temp[1];
}
void loop(){
inPinVal = digitalRead(inPin);
digitalWrite(redPin, pinStates[0]);
digitalWrite(bluePin, pinStates[1]);
digitalWrite(greenPin, pinStates[2]);
if (pinStates[0] == LOW && pinStates[1] == LOW && pinStates[2] == LOW){
autoPilot = true;
}
if (prev != inPinVal){
increment();
prev = inPinVal;
autoPilot = false;
}
if (autoPilot){
increment();
delay(500);
}
}
Question: Blah, blah, blah Economy?Hey there gal, you aren't running for Vice President of Alaska! What about the other 99.97 percent of Americans? Have you thought about us? I find her point of view irritating. While it is fine for her current job, it seems completely out of whack for somebody trying to become a representative for the entire nation.
Answer: No Problem, Blah, blah, blah Alaska.
Question: Blah, blah, blah Foreign Policy?
Answer: Blah, blah Governor of an energy-producing state, blah, blah Alaska.
Question: Blah, blah, blah your weaknesses?
Answer: None. Blah, blah, blah executive experience, blah Alaska.