DB2 interface for Ruby progress
I’ve made progress porting the PHP ibm_db2 extension to Ruby. If you pick up the latest code and run it, you should now see
102 tests, 107 assertions, 0 failures, 0 errors
Some of the differences between Ruby and PHP (other than syntax):
- array and hash are separate types in Ruby, they are combined in PHP.
- some PHP functions, like
strlen
andstrtoupper
are methods in Ruby. - more automatic coercion in PHP: for example, string concat converts both arguments to string. String interpolation works fine in Ruby.
false
prints as a null string in PHP, and asfalse
in Ruby.false
can’t be printf’ed using a%d
format string in Ruby.- in PHP error messages go to the output. In Ruby, typically exceptions are thrown.
Interesting things found during testing:
- Ruby’s ALLOC doesn’t zero the storage. This means that something that passes when run individually may fail when run as a part of a suite.
- Ruby does garbage collection instead of reference
counting. This means that connections may not be immediately
closed, which can lead to deadlock. For now, I have defined a
teardown
method that callsGC::start
- And my personal favorite: in Ruby,
exit
means exit. Not only is the test case exited, but also the test suite, and even the entire rake process.