January 2005 Archives

ruby2c mailing list

| | Comments (0)

Since we are only hours/days away from a public beta, I just set up a ruby2c mailing list for those interested in the project. See??? I was paying attention during the basecamp workshop!

Sign up and get involved!

January Seattle.rb is crazy

| | Comments (0)

Having a ruby celebrity come to your meeting has its advantages. Because of the 37 signals Basecamp workshop, David Heinemeier Hansson of Ruby-on-Rails fame has come to our meeting this month. We just had 6 extra people (from vancouver it turns out!) come in to an already large group. I don't want to sound like I'm (mis-)quoting clerks here, but... SIXTEEN! This is, by far, our largest Seattle.rb meeting (without offering food).

Also very nice is to be able to get face to face time with the man. I'll be able to ask all the questions I've had in the past.

Make that 17.

I think we need more celebrity coders to show up to our meetings!

One of the outcomes of our meeting is our codefest proposal. I'm awaiting responses from the PDX folk (sorry I've been so tardy, I'm catching up, really) and I'll have it done and in on time. I hope. :)

R2C, RSN (no really)

| | Comments (0)

I'm probably a bad person for doing this. I'm sitting at the back of the room of the basecamp workshop here in Seattle. DHH and company are at the front talking about basecamp and how to launch / promote web apps and the like. I'm back here coding on Ruby2C. I've got Eric sitting next to me, coding on his stuff, and helping me on mine. Dave Thomas sitting next to him, being good and actually paying attention to the workshop.

We just hit something HUGE. We just broke our 80% translation threshold for release:

 667/ 667 ( 81.71%): pass yaml.rb

Out of 667 files in ruby's library and my own code, we translate 545 of them. That doesn't mean that the C code is perfect, or even compiles for that matter, but it is sooo close we can taste it.

I've got some polish I need to put in, rdoc and the like, and then we are releasing.

R2C, RSN... really.

An Introduction to Ruby2c

Automatic Translation of Ruby Code to C

This is an extract from our keynote presentation / PDF that we have online. If you've already read that, then this will bore you. Otherwise, read on...

The Problem

  • Simply put, writing ruby internals in C requires a mental context switch every time you go from ruby to C and back.
    • C sucks.
      • This makes the internals harder to understand.
        • Which makes it harder to recruit otherwise good coders to work on ruby internals.
          • Which slows down ruby’s development.

Our Proposal

  • Implement the whole thing in ruby, and translate to C.
    • No more context switching.
    • Able to test changes live in the system.
    • More understandable internals.
    • More accessible to others.
    • Must be in a subset of ruby that is easily translatable to C.

Current Status

We currently have code that can convert the following example code:
  def hello(n)
    1.upto(n) do
      puts "hello world"
    end
  end
into the following C code:
  void
  hello(long n) {
  long temp_var1;
  temp_var1 = 1;
  while (temp_var1 <= n) {
  puts("hello world");
  temp_var1 = temp_var1 + 1;
  }
  }

An Extra Goodie

I wrote a 13 line class and now can do the following:
  class MyTest
    def factorial(n)
      f = 1
      n.downto(2) { |x| f *= x }
      return f
    end
  
    inline(:Ruby) do |builder|
      builder.optimize :factorial
    end
  end
and dynamically replaces the ruby version, in this case, an 8.8x speed-up with zero effort!

Want to Help?

  • Know what you are getting into... read the propaganda.
  • Respond on my blog, send me email, talk to me on IRC, or contact Eric Hodel.
  • A ruby2c subset spec is coming soon.
  • Lots to write, and much of it should be fun!

Parse Tree Visualization

| | Comments (0)







parse tree of 1+1 parse tree of 1+1

This is what I worked on today. Automatic graphing of ruby parse trees using my package ParseTree and with a small (56 line) graphing library that I wrote yesterday and a new sexp processor (80 line) to drive the graphing library.

This is just the output of 1+1. The whole graphing library is ginormous.

Not bad for just 136 lines of ruby.


You have 323 books from 363 authors and 67 publishers, 274 CDs from 120 artists, 44 DVDs from 40 directors, 2 games on 2 platforms, filed in 26 categories and located in 6 locations.

that is the front page of my latest webapp. A learning project to learn Ruby On Rails, a very nice web app framework that combines MVC, dynamic coding, and ruby rather well.

milestone 1) book title and author - 10 minutes

milestone 2) separate author and book tables - 20 minutes

milestone 3) real data from my website + location and category tables - 30 minutes

one hour and I had a rather well functioning library app w/ all my books in it. Really.

several milestones later and I have a VERY well functioning library app, fully normalized using utilities I added to help me with that (FINALLY! LoC can bite my ass!), supporting books, music, video and games with all my data in it.

It even looks pretty (not that grayson thinks so...bastard):

library screenshot

Anyone who's coded with me knows that while I try to make my code pretty, I don't do interfaces. But... rails made it so easy to do everything else that I actually bothered to make it pretty.

To top it off, I started a side project. Using the latest (internal) version of omnigraffle and an applescript I wrote, I now have automatic SQL generation. No more SQL for me!

Check out the schema:

library schema

This was made with OmniGraffle (very very easily I might add, using OG4, which is not publicly available yet) and then automatically converted into an SQL schema via applescript.

Just to drive it home... I did this in 845 lines of ruby. (I think that number is model/controller only, not view):

+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers          |   665 |   558 |      14 |      92 |   6 |     4 |
| Helpers              |   212 |   189 |       0 |       8 |   0 |    21 |
| Models               |   113 |    98 |      13 |      11 |   0 |     6 |
|   Units              |   120 |    84 |      12 |      12 |   1 |     5 |
|   Functionals        |   867 |   670 |      26 |     123 |   4 |     3 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                |  1977 |  1599 |      65 |     246 |   3 |     4 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 845     Test LOC: 754     Code to Test Ratio: 1.1:1

Initial musings on this blog

| | Comments (1)

This is just a test to see if I like MT or not.

Really, this is my planning-to-plan phase. I've got a lot of things bouncing around in my head and I need to set them in motion or I'm gonna explode.

1) I'm going to port all of my ruby-only posts from LJ over to here, to see how well it works. That should be enough data to get a feel for how well this thing works out for my overall plan.

2) Once I decide to stick with it, I'm going to officially spell out my real plan. Sounds nefarious, doesn't it? Nah, I'm just saving the typing in case MT doesn't work out very well.

[Editorial Note: Yes, I decided upon MT. Yes, I hooked it into Artima. No, I did not intend for as many test messages ported from LJ to be published to artima. I had deleted them, but artima had them cached already. Le sigh.]