Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Sunday, November 4, 2007

RubyConf 2007: Cleanliness Is Next to Domain Specificity

Ben Scofield is a senior developer at Viget Labs (blog)

There really has been no discussion of why you would want to create a DSL.

Part 1: Linguistics

Categories
  • Language (for the sake of discussion, it is Vocabulary and Grammar)
  • Dialects
  • Jargon
  • Pidgins and Creoles
Regional Dialects Example: Generic Names for Soft Drinks
Regional Dialects Example: Little Bunny Foo Foo
Jargons Example: Waitress-speak
Cants Example: Class languages in D&D
Pidgins and Creoles: linguistic hacks and evolved linguistic hacks, respectively

Most "DSLs" are not different languages, because they only have a different vocabulary, and not a different grammar.
  • ActiveRecord
  • RSpec
Who cares? DSLs intimidate and frighten.
Write a Parser? No, thanks (Matz did it already).
API vs. Dialect

Sapir–Whorf hypothesis (and programming languages)
  • Linguistic Determinism (the strong version; it's crap)
  • Linguistic Relativism (the weaker version; influence instead of determine)
The Great Eskimo Vocabulary Hoax (Wikipedia)

Color Perception
  • Direction of Causality (language and thinking)
  • Degree of Influence (were you able to distinguish the colors before being given the words)
RSpec loves Sapir-Whorf. Specifications come first. RSpec leads you in the right direction. Domain Specific Dialects (DSDs) are built on Linguistic Relativism. Keep your head in the domain (foo/bar/baz vs. roll/pitch/yaw).

Part 2: Refactoring

Proviso: when dealing with domain-specificity, tastes vary.

Finding a ticket. Some sites became travel search site aggregators (kayak.com, sidestep.com). Kayak provides a search API and a Ruby sample. Someone from the audience: It tastes like burning. It looks like PHP. Strategy when writing a DSD: start at the end.

I want to find flights from CLT to RDU leaving today and returning in one week.

find :flights, :from => :CLT, to => :RDU, leaving => Date.today, returning => Date.today + 7

What is sent from their API to their web service? Set up expectations (mocks). When writing domain-specific code, you will never be done (modeling reality problem). There is always room for improvement.

Tips
  • use symbols (reads like English; quotes would distract you)
  • optional parenthesis (looks like a sentence)
  • blocks for all
  • splat operator (* arrays from anything)
  • optional braces (not that common; Rubinius guys don't like this)
Keys
  • Start modestly
  • Stay in the domain
  • Get better
http://www.extendviget.com/
http://www.culann.com/

We throw around the word language too easily and don't use it precisely, as Ben does (with his linguistic background).

Domain-Driven Design

RubyConf 2007: JRuby in the Wild

Kyle Maxwell works at CastTV

Video Search is hard.

$ jirb -rjava
> import java.util.TreeMap
> map = TreeMap.new
> map[1] = 4
> map[2] = 7
> map.inject(0){|memo, (key,value)|
> memo += key + value
> }
# 14


Why use it? Yet another war (deployment). Familiar tools (java).

JRuby is not perfect. Use the right tool for the right job. There are organizational (are you already a java shop?) and situational concerns.

Ruby is missing a few things in its current incarnation: performance and library support. There is some room for improvement, but not by us. You can make the choice of moving things down to the C-level. Want to solve the problem in the highest-level language possible. Java.

Choices I've made:
  • Rails (sticking to MRI, for now)
    • possible performance issues
    • regex library
    • already working in CRuby
    • experience with standard deployment
  • Search (JRuby/Java)
    • Decided to take an open source search engine and build heavily upon that
    • initially tried MRI/ferret (extending the C was a nightmare)
    • then tried CRuby/Solr (didn't want the extra overhead of another java server and concerns about maintainability)
    • finally Lucene/JRuby (easy to maintain; clear method of extension; less to break; JRuby is an active project)
  • Spellchecker (JRuby/Java)
    • performance is at a premium (look at the performance of your algorithms before you look at the performance of your language)
    • ternary search trie algorithm
    • tried it in ruby first (creating a million nodes takes ten seconds; also, there was a large memory overhead)
    • same reasons as above for skipping C
    • java (tried to do inline java and it was too painful; access java objects from ruby)
port, api, or binding?
  • never port anything (most overheard and is error prone)
  • api has the overhead of building the needed layers
  • binding had least overhead
an off-the-cuff benchmark (load the unix dictionary into a hash, ten times)
  • MRI 12.9s and 144MB
  • JRuby (with J-server) on the Sun 1.5 JVM 9.0s and 72MB
  • Java 1.5 4.1s and 61MB
  • Perl 4.1s and 19MB
getting started
  • easy install (personally, works off of trunk)
  • jruby -S [gem, rake, ...]
    • unless it is a gem that requires a C extension, it will work (hpricot was ported)
  • get the extras
  • textmate not advised (personally, works in eclipse)
  • a sane build strategy
  • jar2gem.rb
gotchas
  • casting can be tricky (e.g. float, arrays (see to_java))
require "java"
A.new 1.99 # will be passed as a double and won't cast
A.new java.lang.Float.new(1.99) # works


Is there anything you wanted to do in JRuby, but couldn't? Yes, and this will hopefully be fixed. Interacting with POSIX operating systems (file permissions, etc).

Have you evaluated Groovy? No.

We're running all our JRuby processes as standalone daemons.

Man, I really need to work on my public speaking skills. I sputtered through asking my question to Kyle.

Have you dealt with JRuby in the context of a legacy (non-greenfield) Java System? Any problems there? No. Someone from the audience brings up the issue of the production staff only dealing with java deployments. I have a feeling that there have to be issues, just no one here has run into them. Related to this is that there don't seem to be many language agnostic people here.

RubyConf 2007: Ruby and Identity: OpenID, CAS and Information Card

Justin Gehtland is the president of Relevance.

There will be twelve slides and then we're going to code.
  1. rails myapp (camping, whatever)
  2. ruby script/plugin install acts_as_authenticated
  3. There is not step 3!
This leads to redundant implementations, no shared authentication, and comingled storage (sensitive and non-sensitive data in the same place).

What do you get for giving $2 million to RSA? Someone to sue.

Two types of central authentication: private and public. The difference? Trust.

OpenId (public)
  • free, open central id
  • vendor-supported, but not controlled
ruby-openid has dependencies on
  • net transports
  • yadis (openid + directory service)
CAS (private)
  • central authentication service
  • foss
  • java-based
rubycas-client and rubycas-server

What about
  • LDAP?
  • NTLM?
  • Commercial SSOs?
Ruby has bindings for these (ActiveLDAP, rldap, ...).

OpenID demo.

Caveat: the shipping openid plugin returns :false (the symbol), if the user is not logged in.

This is all authentication. NEVER punt authorization rules to a third-party server. They are coupled to the domain or application.

CAS demo.

You need a certificate to run the server. All traffic to a single sign-on must go over SSL.

rubycas-server is done in camping.

Biggest problem he has seen in rails shops is domain explosion. Example: a notes application is released and now the business people want a memo application, but you can't make a separate application because that would necessitate multiple logins.

CAS uses ssl for everything, except token generation: "#{Time.now.to_i}r%X" % rand(10**32)

RubyConf 2007: Next-Gen VoIP Development with Ruby and Adhearsion

Jay Phillips

Asterisk telephony development sucks. Painful configuration. Tons of jargon (What? Any discipline has jargon. He even uses some jargon during the talk.). Hacky culture. Few good programmers. Software quality fluctuates. Too many disparate pieces. Geezers. Wow, this guy is making some broad sweeping statements.

Fun VoIP projects:
  • Your mobile as a universal remote or gamepad
  • Home automation
  • Phone controlled Roomba
Mischief:
  • spoofing caller id (easy)
  • confuse automated telemarketers
  • third party call control, so you aren't making the outgoing call
  • "Get Things Done"
Benefits:
  • abstract
  • simple
  • extensible
Adhearsion 0.8.0 is in the svn trunk.
  • call routing dsl
  • FreeSWITCH integration
  • better rails app integration
Co-authoring "Ruby and Telephony"

TODO:
  • Richer abstractions
  • Capistrano to configure Asterisk
  • Phone provisioning
  • Gaining more control with Asterisk 1.6
  • Seamless FreeSWITCH integration
  • VoIP functional tests
  • "Pure-Ruby" VoIP features
Demo

RubyConf 2007: Behaviour Driven Development with RSpec

David Chelimsky works at Articulated Man, Inc. Dave Astels works at Google.

Test Driven Development
  • incremental process
  • drives implementation with tests
  • results in an exhaustive regression test suite
  • should focus on design
  • should focus on documentation
  • should focus on behavior
Behavior Driven Development is like TDD, but with the following added:
  • includes focus on design
  • includes focus on documentation
  • includes focus on behavior
Short demo on ping-pong pair programming. You write the smallest test you can to cause failure. The other person writes the simplest code to make the test pass.

Overview of the BDD/RSpec Timeline.

November 2007 (knock on wood): RSpec-1.1.0
  • Introduce Story Framework
  • Beginning of Test::Unit compatibility
    • More work on this for 1.1.1 release
Customer to Code Agile Process:
  • Domain Driven Design
  • Acceptance Test Planning
  • Test Driven Development
  • Start by specifying at the highest levels
    • He starts out with the views, mocks out everything, and goes from there.
Story Framework - Executable User Stories

Something about rbehave flashed on the screen.

Demo of the Story Framework. Testing that read as prose (same concepts as Hoare Logic, but reads better). This looks pretty cool and useful.

Demo of a tool in its infancy that Tech Support, QA, and business people can use to poke the system.

Quick look at RSpec Results. You can have pending tests.

Something about integrating with legacy projects flashed on the screen.

miniunit/minirspec will be shipped with Ruby 1.9.

New hosting: rspec.lighthouseapp.com

Q1 2008: "Behavior Driven Development in Ruby with RSpec" (The Pragmatic Programmers)

RubyConf 2007: Use Ruby to Generate More Ruby - RubiGen is Everywhere

Dr Nic

Opening Theme: A-Team

Ryan Bates' video on writing your generator

He's moving too fast for me to live blog.

He pulled generators out of Rails, so that Ruby projects can make use of them.

It's been integrated into Merb, NewGem, RubyCocoa, and Airake.

Pseudo-live, he modifies sow to make use of generators, instead of printing text directly to a file.

TODO:
  • replace rails_generator with rubigen dependency
  • gereators pick dependencies based on which scopes are available (different ORMs and different test suites)
I love it when a plan comes together.

Saturday, November 3, 2007

RubyConf 2007: Keynote by Matz

Part I Language Matters or Not

Turing Theory => Language does not matter, at least in theory. Twitter On Rails. Trouble illustrated by a lolcats photo. There has been a 1000% performance boost since January 2007. What made the difference? MySQL, Solaris and dtrace.

What makes the difference? Not the language itself. It's the attitude of the users. Python users believe in the one true way. Ruby users like diversity. I said that I liked all programming languages, except for a few. As proof, Matz is wearing a python shirt.

People matters. Motivation Matters. Enthusiasm Matters.

Martin Fowler said, "Ruby people are nice." There is a Love/Hate Ratio graph. Ruby, Lisp and Python are the top three. We are using the most beloved language in the world.

Thank you!

Part II What's in 1.9, or What's not in 1.9

We will be releasing 1.9 this Christmas. Unfortunately it is not as stable as we would like. The Grand picture is that 1.8 is the long term stable release, 1.9 introduces major incompatibility and will be the bleeding edge for a time, and 2.0 is the driving force.

1.9 Incompatibility

Some will be severe, and some will be trivial. Severe #1: block arguments are changed. They are local variables only. Blocks are scoped more strictly. Severe #2: string is no longer enumerable. What will be iterated over needs to be specified explicitly (lines, chars, bytes). Severe #3: M17N Unicode is introduced. Character-based indexing ("ABCaio"[0] returns "A" and [3, 1] returns "a"; the preceding "aio" should be read as Japanese Hiragana, because I don't have Japanese support on this computer). Encoding aware comments. You can specify UTF-8 in a special comment at the beginning of your script. You can open files of other encoding formats.

Trivial Incompatibilities: lots of changes, some deprecation, and even more enhancements. Some new features:
  • "->" lambdas ("->" is a mutation of the lambda character)
  • ".()" to call
  • multiple splats in an argument list
  • mandatory arguments after optional arguments
  • built-in enumerator
  • external iterator (e1=[1,2,3,4].each e2=[10,11,4].each loop{p e1.next+e2.next} #prints 11, 13 and 7; loop will catch the end of iterator silently; inherited from the language named Satan?)

Part III Implementations

Realistic alternatives: JRuby, Rubinius, and IronRuby. All are faster than MRI. Finally, we succeeded in getting rid of Matz (It's ok; I'm a designed of languages). Also, we have YARV, the fastest Ruby VM ever. Praise should go to Koichi. In 1.9, Ruby goes on a major memory diet.

Part IV Where are we from? Who are we? Where are going?

Where are we from? Many languages.
Who are we? Rubyists.
Where are going? World domination.

Beware of a bubble economy and the cycle of tragedy (humble start, success, pride, conflict/war, drop to nothing, repeat). We are at success.

Where will we go? Enterprisey. I don't want to, but I can't help it. The suits are surrounding us.
Where will we go? Scalability. It is not a language issue. It is a system issue (data size, access frequency, program size, and number of CPUs).

Q & A

1.8 has green threads. Will 1.9 have native threads, due to the move towards multi-core CPUs? I envision multi-core CPUs will use multiple processes.

No one is working on a shim library for 1.8->1.9 as there was in 1.6->1.8, because of the massive differences.

What will required arguments after optional arguments look like?
def foo(a, b=24, c)
...
end
foo(1,2,3) # a =1, b=2, c=3
foo(1,2) # a=1, b=24, c=2

def bar(a, b=1, c=2, d)
...
end
bar(1,2,3) # a=1, b=2, c=2, d=3


You talked about named arguments at another conference. What is the status on that? We didn't have enough time to complete that for Christmas. You will have to wait until 2.0 for that.

Why would you want the ability to have required arguments after optional arguments? It is useful with named arguments. Fill the required arguments at the front of the list, then at the end of the list, and finally fill in the optional arguments.

Are you worried about the niceness scaling as the community grows exponentially? I was worried when the conference went from 60 people to 500 people. I think it has been a success so far. It is kind of like a miracle.

With the external iterator throwing an exception at the end of the loop, is there a stack trace associated with it and is it a performance consideration? Someone from twitter answered that the bug they found had an exception thrown with a 400 level stack trace. If you aren't doing anything crazy with the iterator, you should be fine.

Will the 1.9 byte code be frozen anytime soon? Deferred to Koichi. No.

Will there be an AOT compiler in 1.9? Deferred to Koichi. Not in the Christmas release. Sometime in the future.

What would you like to see in Ruby 3.0? 3.0? Class box. We should be able to isolate our changes to a class in a name space. Looking to do that in 2.0.

Why does method wrapping (aspects) keep getting punted? I feel that the features in Aspect/J is application-level or maybe framework-level. The language should provide primitive features.

How will future pressures of forking be dealt with? Fortunately or unfortunately, Ruby is difficult to implement. People implement lisp once or twice. I implemented Ruby once; never again. Ryan Davis shouts, "How many people have implemented lisp?" 10% of the room raises their hands.

Have you given any thought to passing multiple blocks to a method? I tried several times, but was never successful. It is important to keep the simple syntax that the Ruby block has.

Speaking of crazy syntax, do you like list comprehensions in Haskel? No.

That's all folks.

Disclaimer: I might have misheard any portion of this.

RubyConf 2007: Conversations vs. Laws: What do we mean when we say Ruby is dynamic?

Francis Hwang is a member of NYC.rb

This talk is meant to be provocative. He gives a forewarning, "I am not comparing Java programmers to slave holders."

For the sake of discussion, types are abstract, and classes are concrete.

Platonic idealism. There are the things you see in this world, and there is something abstract behind that. A specific palm tree or evergreen tree vs. the idea of a tree.

Linnaean taxonomy. The different categories are up to debate, except for species. That category is testable: two things are in the same species if they can interbreed. Exception to the rule: ring species (laurus gulls).

He goes into race and taxonomy as a comparison of type and class.

Does anything that matters have a fixed definition? Are types real? No.

Now to the code ...

array.rassoc(key) "Is this a list? Is it a stack? Is it a map?" (Elliotte Rusty Harold) Type doesn't matter to dynamic language programmers.

Ruby is a low social contract language (no spec).

...

He brings up quotes of dysfunctional companies that have broken feedback loops.

Toyota Kaizen Approach.

Programming team ability versus results. Businesses who talk about core competency look at only a small slice of this curve. Is it possible to hire a crap Ruby team that will ruin your company? Absolutely.

Nothing is permanent.

RubyConf 2007: Maximizing Productivity (or How to Hack Well)

Most of Eric Hodel's six years of Ruby experience is mostly in open source, covering about forty projects. He is a member of the Seattle Ruby Brigade.

Two key elements to what Eric does:
  • Have fun.
  • Cartman: Whateva! I do what I want!

Coding and Testing

Be selfish; fix your problems first. KISS (keep it simple stupid) & YAGNI (ya' ain't gonna need it). YAGNITAGAFI (... they ain't gonna ask for it). Test. Autotest. Keep everything in sight (code, test, autotest, and terminal all in one screen, with chat window in the gutter). Heckle. Automate everything you do (automatic setup, migrations, common tasks). Know your editor intimately. Pair Programming.

I'm seeing repetition from the Seattle Ruby Brigade member's presentations.

Releasing

Documentation (README and rdoc). Bug Tracker (no anonymous reporting because there is no possibility of feedback). Review (get constructive criticism from someone else). Pre-Hoe was not fun. Hoe (packaging, uploads, emails, and blogs are automated). Release early and often.

Relax

Balance out your life.

Maintenance

Bug Tracking. Gardening (iterative with simple goals and small changes,; keeping it well organized). Some people refuse to use a bug tacker. Grep through ruby-talk and sphincter? Search technorati. Be responsible (file good bug reports and be responsive to the developer). Versions (don't care, but be consistent). Know when to break up your code into seperate packages.

Inspiration

I write software for me. I don't owe you support (this second). Criticism (My software sucks. That's ok. People complain. That's ok. Maybe they'll be motivated to fix it.) Hacking Night is helpful. Pain-killers (automate something you do by hand).

RubyConf 2007: Tightening the Feedback Loop

Phil Hagelberg belongs to the Seattle Ruby Brigade.

Slides link

I left the other room because the topic was misleading and I wasn't really interested in what it turned out to be. The talk was originally called, "Writing Client and Desktop Applications in Ruby," and was changes to "Deployable Ruby Runtimes." The talk was about release a wholly standalone ruby application.

Testing
  • good - manual tests
  • better - test::unit / rspec
  • better still - autotest
  • a bit better
    • Flymake was released with the last emacs. It throws your buffer at gcc with warnings turned on. There is a port to ruby that throws your code at ruby -w.
    • test-unit.el gives you the some info from autotest, but provides better visualization
You want to tighten the feedback loop of breaking something and being notified of that breakage. You care about your code's accuracy. You use/write tools to help you measure your code's accuracy. You are notified when things go wrong. As you go down the list above, the delta between breaking something and being notified about it goes down.

What to measure?

Accuracy - syntax highlights, indentation, and test/specs. The first two happen automatically in the editor. Tests/specs should be shown there too.

Meta-accuracy - how accurate are your accuracy checks? Use rcov (caveat: don't think this means you are fine) and heckle.

Maintainability - Martin Fowler said, "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." It can't be programmatically measured, but it is correlated to complexity, which is measurable. Use flog (caveat: the scores are relative). How to use it? Measure on a per-commit basis (no patch bombs).

Performance - black box response times (Julian? had a presentation at the last RailsConf that dealt with this. The code was about 50 lines. You should write your own.) and measure test suite times

This talk isn't giving me anything that I didn't hear in Ryan Davis' talk.

He kept bringing up how often do you want to be notified, in each of the categories.

Keep a history of your measurements, so that you can chart your personal growth.

The pragmatic programmer says to learn your editor. You should also learn what you can do for it.

There's a demo of Augment being used in emacs.

RubyConf 2007: Profiling and Tuning Ruby 1.8

Ed Borasky

Slides

The project name on RubyForge is Cougar.

Things you will not hear Ed say:
  • Premature optimization is the root of all evil
  • Dynamic languages are inherently slow
Is Ruby 1.8 slow?

Benchmark and collect the results. Settle on a common unit. Take the geometric mean (n-th root of (A1 * A2 * ... * An)) of the numbers. Alioth Shootout Results.

Hemibel Thinking

The art of only caring about ratios greater than a hemibel (half of a bel (magnitude of an order of 10) = sqrt(10) ~= 3). Modifying the Alioth Shootout Results to deal with hemibels, shows that in practical terms, perl, yarv, python and php are about the same speed. "Ruby is sort of slow."

But that's an oversimplified answer. Is there a "geometric standard deviation"? Yes, but box and whisker plots (boxplot) are more interesting. Yarv shows very little variation, followed by python and ruby. Although, yarv has some outliers.

Ok ... it's sort of slow ... now what?
  • Throw hardware at it?
  • Wait for 1.9?
  • JRuby?
  • IronRuby?
  • Rubinius?
  • Cardinal/Parrot?
  • Tune Ruby 1.8?
Let's tune it
  • Collect a benchmark suite
  • Profile the Ruby 1.8 interpreter on the benchmark suite
  • Identify the bottlenecks
  • Remove them
Ruby 1.9 has a benchmark suite included that will let you compare yarv with your installed ruby. There is also pet store from thoughtworks. The JRuby team is using it. gprof is one of the earliest profiling tools. The output of all the runs on RubyForge site: cougar/ProfilingAndTuningRuby/benchmarks_profiles. Surpisingly, most of the time executing Ruby is spent in the interpreter and not the actual work being done. Ed's added benchmark test of doing Matrix operations in rational arithmetic, rather than in floating point. The function that returns the remainder of bignum division was nowhere near the top of the list (sorted by relative time spent in function).

Using gcc/gcov, he does some lower level analysis on the function where most of the time is spent. There is a switch statement that has 86 branches. The top six or seven branches cover 77% of the time spent in this function. The interesting thing is that these are not the first six or seven branches in the switch statement (they are actually near the end).

Acovea is a genetic optimizer over GCC compiler flags. Although, it is unlikely to do better than "march=athlon64 -O3".

This is the second time I've been in an afternoon session where I've heard applause coming from the other room, making me wonder what I am missing. The other time was while I was in the Ropes talk.

He delves into some more advanced techniques.

This was an interesting talk from an academic perspective. This talk was more for the ruby core team.

Have you tried profiling it with valgrind and cachegrind? No. He mentions code analyst.

RubyConf 2007: Rubinius 1.0

What is the end game for Rubinius, JRuby, IronRuby, or any other the other implementations?
Total
world
domination
For Ruby!

Rubinius effectively began at last year's RubyConf, in Denver, Colorado. Rubinius comes from SmallTalk, with Ruby syntax and behaviors added. Also, throw in some crazy cs papers to the mix.

CS Nerd Attack Mode! (blitznerdo) Zeropunctuation technical details.

Runtime and Kernel
  • MRI 1.8 - 80k lines of C and 0 lines of ruby
  • MRI 1.9 - 120k lines of C and ~50 lines of ruby (prelude.rb)
  • IronRuby 1.1aplha1 - 48k lines of C-Sharp and 0 lines of ruby
  • JRuby 1.0.2 - 114k lines of Ruby and ~1000 lines of ruby
  • Rubinius - 25k lines of C and 14k lines of Ruby
Rubinius is Ruby for Ruby programmers. Eating your dog food (using the tools you are developing) provides a feedback loop.

Who gets paid to write Ruby on a daily basis? About 90% of the room raises their hands. Someone form the audience asks, what about only those writing Ruby and not Rails? About 25% of the room raises their hands.

1.0 should be done about now. Why isn't it done? Worried about architecture and design decisions made now, that will affect the long term growth of the project. Mistakes were made.

His talk is focusing on the community, rather than on the technology. Rubinius has been able to garner weekend patchers and code-junkies alike. Free flowing commit bit (provide one patch and you get open commit rights) was borrowed from the perl community.

Engine Yard is funding Evan Phoenix.

Backtraces are cleaner than with MRI. Rubinius also gives you stacktraces for segfaults in C extensions.

Demo about MethodContext, Continuations and spaghetti stack. Do you plan on making the MethodContext serializable? Yes.

RubyConf 2007: JRuby: Ruby for the JVM

Charles Nutter and Thomas Enebo. They are working at Sun as full-time JRuby developers. Also, they are working on dynamic language support, in general, for the JVM.

What is it? Not just Ruby for the JVM. Ooh, looks like they are going to go in-depth.

Two days ago 1.0.2 was released. Last night 1.1b1 was released, during the town hall discussion.

Topics of discussion: Basics, Lexer and Parser, Design (Core Classes, Interpreter, Compiler, Performance Optimizations, Threading, Extensions and POSIX, Java Integration)

Hand-written lexer. LALR parser, Jay, a Bison for Java. DefaultRubyParser.y => DefaultRubyParser.java. Abstract syntax Tree similar to MRI's.

For demos, they arere using NetBeans. All the completion and formatting is based off of the parse tree.

For now, eval'ed code is always interpreted.

New in JRuby 1.1, there is full bytecode compilation.

There is a demo of the JRuby compiler, showing speed differences between interpreted and compiled mode.

ObjectSpace optimization. each_object is difficult to support on modern VMs. Have to save a weak reference to every object created during execution. Sucks two to five times as much as running normal code. Only real use is in TestUnit, where it looks for all TestCase classes. Someone from the audience asks what about the profilers and memory tools out there? Yes, but those are narrow in scope (Ruby only). Limited control over GC.

Another optimization is custom core classes. Yet another is with regexes. Ola Bini ported MRI's regex engine. There is also Joni, Java port of Oniguruma. It is in progress, but could be the holy grail. It will grow the size of JRuby ~25%, so it is a big project.

JRuby supports only native OS threads. They are heavier than MRI's green threads, but are truly parallel. In 1.1, there will be pooling of OS threads, to minimize spin-up time.

Do you support C extensions? No. Maybe in the future, but the Ruby API exposes too much. Native libraries are accesible with Java Native Access (JNA). It is used for POSIC functions not in Java, like file access.

Java Integration: Popular Use Case: Swing GUIs. Ruby magic simplifies most of the icky/tricky bits. Java is too verbose. No consistent cross-platform Ruby GUI. There are a few ways of going about doing this: direct (Charles' standard demo), cheri (builder approach; dsl), profligacy (targeted fixes; Zed Shaw), MonkeyBars (tool-friendly).

Other big domain is web applications. JRuby on Rails. ActiveRecord-JDBC. GoldSpike/Warbler for app server deployment. GlassFish gem for Mongrel-like deployment.

Upcoming: ActiveHibernate, Ruvlets (Ruby Servlets).

Another use case is Test and Behavior Driven Development. Test Driven Development is hard in Java. RSpec makes it easier.

RubyConf 2007: State of IronRuby

Team: John Lam, Haibo Luo, Tomas Matousek, John Messerly

Why? I didn't hear an answer to this.

Effecting change is hard.

It is under the MS-PL (Microsoft Public License).

He also plugged IronPython, Dynamic Language Runtime, and F#.

A third goal is performance. I missed points one and two.

22 minutes after the talk began, the PR part is over.

Laguages running on the DLR: JavaScript, VisualBasic, php, ruby, python, lua, boo apc, perl, coldfusion

One point where this is slower than mri? is raising exceptions. But that's not a concern.

side note from IRC: I remembers a time when running through an array in Java without an end condition and using a try/catch of the ArrayIndexException for the end condition was a common "optimization"

When writing C-Sharp code that will be generated into Ruby code, with the DLR, you need to have some metadata strewn throughout your program (CalcOps.cs):

[RubyConstructor]
public static Calc CreateCalc() {
  return new Calc();
}

[RubyMethod("add")]
public static Calc Add(Calc self, int val) {
  self._total += val;
  return self;
}


He goes over Silverlight and XAML.

He didn't have much content about IronRuby. There was a lot of talk about Microsoft and tangentially related topics like Silverlight and the CLR. Also, he was either attacked by the BSD devil, or was making a jab at the fact that he works at Microsoft, with the tail he was wearing.

Friday, November 2, 2007

RubyConf 2007: Schedule for Day Two

Breakfast

9:00am State of IronRuby (John Lam)
10:00am JRuby: Ruby for the JVM (Charlie Nutter)
11:00am Rubinius 1.0 (Evan Phoenix)

Lunch

1:00pm Profiling and Tuning Ruby 1.8 (Ed Borasky)
2:00pm Writing Client and Desktop Applications in Ruby (Bruce Williams)
3:00pm Maximizing Productivity (Eric Hodel)
4:00pm Conversations vs. Laws: What do we mean when we say Ruby is dynamic? (Francis Hwang)

Dinner

7:00pm Keynote by Matz

RubyConf 2007: Day One Wrap Up

A lot happened today. It went by so fast, that I didn't have enough time to reflect on everything. I'll be revisiting the posts that I made today to clean them up and add more comments.

On the way to lunch, there was a marching band for some football team in the area. Is there some rule that there must some sort of marching band at every Ruby conference?

I wonder where the presentation slides will be posted?

RubyConf 2007: Town Meeting with Matz

For those of you not familiar, Yukihiro "Matz" Matsumoto is the creator of Ruby.

First person complains about File.exists? changing to File.exist? and asks, as a "real" programming language, shouldn't it be backwards compatible? Sometimes we need to break compatibility. File.exists? was introduced around 1.4 and should have been removed earlier. The room did not like this question.

Someone from the TI calculator division is looking to put Ruby as an interpreter on TI's next line of calculators.
  • When will 1.9 be production ready? Christmas. (Ah, but what Christmas)
  • When will there be a version of Ruby not encumbered by the GPL?
Next person doesn't see significant gains in performance with Ruby 1.9. He says that Fixnum and a few other classes are optimized. I'm not sure what the answer was.

What do you think of the other VMs trying to run Ruby (JRuby, Rubinius, RubyCLR)? What do you think of the competition? Dealing with Ruby on the VM side is hard. He wants to compliment these teams on their accomplishments.

Does working on Ruby still make you happy? What is one of the most enjoyable moments? Started development in 1993. One of the initial things was to enjoy making it. The enjoyment of designing, implementing, and coding in Ruby continues.

What is the Ruby community like in Japan? Pretty much the same as here. Does the increase in Ruby usage have much of an impact on you?

What editor do you use? emacs

When can we expect to see a 1.9 feature list, so that we can start making changes to JRuby? Maybe before mid-November.

When it comes to Ruby, do you consider yourself to be a scientist? Hobbyist.

Can we expect the parse tree to be made available to normal programs, at some point? Probably not. It would be tough for us to support in the future.

What other languages are you paying attention to at the moment?

...

Leopard has a ruby with dtrace built-in. Have you or others on the core team used it? Never used dtrace by itself.

Do you want to join us next year for the European Ruby conference? Maybe.

Rails has propelled the popularity. Do you see another project that could boost Ruby in the same way?

Is there a time when you say to yourself, "Ruby might not be the right tool for the job"? There is some weakness on projects that have large teams (100 or so) and run for a long time. The rules of the game are changing, though. Team sizes are getting smaller and smaller to produce an effective tool.

I'm having trouble hearing Matz's responses.

Trotter: In the essay on Beautiful Code, you say that beautiful code is familiar. Is there anything that you haven't done in Ruby, because you want it to stay familiar?

What is your second favorite programming language? I love all programming languages except for several.

What would you remove from Ruby? ................................from Ruby?!

Someone from NASA asks have you ever studied the Toyota Production System in terms of dealing with defects?

Are continuations in or out in 1.9? You have to require additional libraries in 1.9. It is out of the core language, but will be available.

Can we settle on a final 1.8 spec? How about 1.8.6?

Are there any parallelism plans with the language?

You talked about selector namespaces in Ruby 2.0, what are your thoughts about it now? It's hard to do efficiently?

What is the difference between 1.9 and 2.0? 1.9 is the transition from 1.8 to 2.0. Ruby 2.0 will be a major enhancement with little to no thought about compatibility.

Is there any other project you would like to work on, besides Ruby? An emacs GMail reader.

Is there anything that you would like to see someone in the community make, that you don't have time for? Better the issue tracking and bug reports. Don't want it on trac with the python.

So, you've come to be called the Benevolent Dictator in the ruby community. There have been other imitators (JRuby, Rubinius, etc.) that may have other goals in mind. Have they taken some of your control away? How do you feel about that? If you design a language, you might be punished. For all the enjoyment he gets from Ruby, it is a cost he has to pay.

Do you see a difference between the code written by people in the states, or in Europe vs that written by people in Japan?

...

You mentioned that you were interested in the Io programming language. In Io there are no keywords; everything is a method. Is this the way that Ruby will be going? Not the way that Ruby is going.

...

Have you considered bundling some of activesupport into Ruby? Some of it will be coming in 1.9, but 2.days.ago will not.

What do you think of people with no programming experience, picking up Ruby as their first language? Ruby is designed for programmers. I am a programmer, so Ruby is designed for me. Might not be suited for an introduction to programming. Some parents don't give their children very sharp knives, but some do.

Someone might come into Ruby and use CSV.rb, where everone else is using fastcsv, because it is better. How do you see the standard library over time? Diversity is a good thing in general, so competing implementations can be useful over time. They can lead to confusion, though. Should there be someone watching over the standard library? Wish people would coordinate before they create a duplicate project.

...

Last year, internationalization was a hot topic. Where does that stand today? It still is a hot topic.

Question about book publishing in Japan. What books are coming out over there, but not here (like cgi programming with ruby)? Are there more books being seen in Japan? Publishers used to send Matz a copy of new ruby books; not any more. In a small town, there are 50-60 Ruby books in the bookstore.

...

What kind of programming do you do day-to-day? Uh, Ruby.

What is your favorite movie? I don't know. Matrix.

Confreaks Videos

Confreaks: RubyConf 2007 (in progress)
RubyConf 2007 website

Confreaks: MountainWest Ruby Conference 2007
MountainWest Ruby Conference 2007

Confreaks: Ruby Hoedown 2007
Ruby Hoedown 2007 website

RubyConf 2007: Hurting Code for Fun and Profit

Ryan Davis belongs to the Seattle Ruby Brigade.

This talk is more about improving yourself than it is about improving your code.

Ruby sadism (deriving pain from inflicting pain on software; especially bad software).

Ruby asceticism (self-restraint)

Introspection Driven Development (self-introspection, that is)

It starts off with a hilarious story about a developer going to a new place (project, department, company, etc). Legacy code is any code you haven't written yourself. After moving to a new place, developer finds a rats nest of code. Developer has two options:
  • kill the coders who wrote the code and maim the others
  • hurt the code
Moral of the story: People will press charges if you hurt them; Code won't. (You have to see the video of this talk for the full impact.)

Examples of hurting code:
  • Write a test for a bug you found
  • Ripping out cleverness
  • Squashing bad design
For some reason, people love complexity.

Introduced ruby asceticism with a clip of the monks from Monty Python. It is where you eschew needless complexity and overly-clever code.

As his favorite manager says, "big alligators, little alligators, swamp." Before building a castle on a swamp, you need to take out the big alligators before you take out the little alligators,

You need to improve yourself. Read quality technology books and blogs. Analyze yourself. Feedback loop.

He raves about c2.com.

Tools to help you:
  • autotest
  • flog
  • heckle (fuzzing, but meaner)
Coverage tests do not ensure the quality of the tests.

He uses something that reads his meta comments (refactor, fix, ...) and gives him a report of the most painful files.

You have to love or hate your code. Either is preferable to apathy.

This is by far the best talk of the day.

"What do you do when you work with someone who writes bad code?" Effectively he said to distance yourself from them and code around them. Is there a better answer?

"Is pairing useful to you?" Yes. He finds there is about a 250% output benefit when pairing, as opposed to coding alone.

RubyConf 2007: Ropes: An Alternative to Ruby's Strings

Eric Ivancich has the website LearnRuby.com.

Mentioned on Ruby Quiz. It was an IFCP contest, before that. What about using a linked list to solve this? Appending to the end is O(1), but inserting a string into the middle is O(n), and the problem states that this should be achievable in better than linear time. People using C++ had an easy out: http://www.sgi.com/tech/stl/Rope.html. Also, Haskell Data.Sequence.

Mapping a Rope to a File. Not the first time that this term was used today, but build the tree lazily and read the file lazily.

LazyNodes contain closures to maintain the reference to where the string came from.

The project on rubyforge was just created this morning: http://rubyforge.org/projects/rope. There is a lot of work that needs to be done on Rope, most of which is optimization. There is no regex support.

"
Rope is a RubyGem that implements the rope data structure. Rope is an alternative to String, optimized for time & memory under certain operations. Essentially in a Rope the data is broken up into blocks, and those blocks are stored in a binary tree."

Ropes are more useful than String when you are performing string concatenation and slicing, rather than accessing or in-place replacement.

Someone brought up the piece table data structure.

How does this compare to skip lists? They act as a binary tree. They can probably have the same lazy evaluation. He couldn't find any reason ropes were better than skip lists, on the spot.

Another talk where I wish he went more in depth on guts of it.