Categories
Uncategorized

Enumerating Enumerable: Enumerable#drop_while

After the wackiness of the past couple of weeks — some travel to see family, followed by a busy week of tech events including DemoCamp 18, Damian Conway’s presentation, FAILCamp and RubyFringe — I’m happy to return to Enumerating Enumerable, the article series in which I attempt to do a better job at documenting Ruby’s Enumerable module than Ruby-Doc.org does.

In this article, the eighth in the series, I’m going to cover a method introduced in Ruby 1.9: drop_while.

I’m going through the Enumerable‘s methods in alphabetical order. If you missed any of the earlier articles, I’ve listed them all below:

  1. all?
  2. any?
  3. collect / map
  4. count
  5. cycle
  6. detect / find
  7. drop

Enumerable#drop_while Quick Summary

Graphic representation of the \"drop_while\" method in Ruby\'s \"Enumerable\" module

In the simplest possible terms Given a collection and a condition, return an array made of the collection’s items, starting the first item that doesn’t meet the condition.
Ruby version 1.9 only
Expects A block containing the condition.
Returns An array made up of the remaining items, if there are any.
RubyDoc.org’s entry Enumerable#drop_while

Enumerable#drop_while and Arrays

When used on an array, drop_while returns a copy of the array created by going through the original array’s items in order, dropping elements until it encounters the an element that does not meet the condition. The resulting array is basically a copy of the original array, starting at the first element that doesn’t meet the condition in the block.

As in many cases, things become clearer with some examples:

# In Canada, and in fact in all but 2 countries in the world,
# the weather report gives temperatures in Celsius!
temperatures = [28, 25, 30, 22, 27]
=> [28, 25, 30, 22, 27]

# The block returns true for the FIRST two elements,
# and false for the third.
# So drop_while returns an array like the original,
# but starting at the third element.
temperatures.drop_while {|temperature| temperature < 30}
=> [30, 22, 27]

# The block returns false for the first element,
# so drop_while returns an array like the original,
# starting at the first element
# (in other words, a copy of the original).
temperatures.drop_while {|temperature| temperature < 28}
=> [28, 25, 30, 22, 27]

Enumerable#drop_while and Hashes

When used on a hash, drop_while effectively:

  • Creates an array based on the hash, with each element in the hash represented as a two-element array where the first element contains the key and the second element containing the corresponding value, then
  • goes through each element in the array, dropping elements until it encounters the first element that doesn’t meet the condition in the block. The resulting array is an array of two-element arrays, starting at the first element that doesn’t meet the condition in the block.

Once again, examples will make this all clear:

# We're basically taking the array from the previous example
# and dressing it up in a hash
city_temperatures = {"New York" => 28, \
                     "Toronto" => 25, \
                     "Washington" => 30, \
                     "Montreal" => 22, \
                     "Boston" => 27}
=> {"New York"=>28, "Toronto"=>25, "Washington"=>30,
"Montreal"=>22, "Boston"=>27}

# The block returns true for the FIRST two elements,
# and false for the third.
# So drop_while returns an array based on the hash,
# but starting at the third element
# (and, of course, the key-value pairs turned into
# two-element arrays).
city_temperatures.drop_while {|city_temperature| city_temperature[1] < 30}
=> [["Washington", 30], ["Montreal", 22], ["Boston", 27]]

# This is a more readable version of the line above
city_temperatures.drop_while {|city, temperature| temperature < 30}
=> [["Washington", 30], ["Montreal", 22], ["Boston", 27]]

# The block returns false for the first element,
# so drop_while returns an array based on the hash,
# starting at the first element
# (in other words, an array based on the original hash,
# with key-value pairs turned into two-element arrays).
city_temperatures.drop_while {|city,temperature| temperature < 28}
=> [["New York", 28], ["Toronto", 25], ["Washington", 30],
["Montreal", 22], ["Boston", 27]]

Enumerable#drop_while’s Evil Twin, Enumerable#take_while

I’ll cover take_while in detail in a later installment, but for now, an example should suffice:

city_temperatures.drop_while {|city_temperature| city_temperature[1] < 30}
=> [["Washington", 30], ["Montreal", 22], ["Boston", 27]]

city_temperatures.take_while {|city_temperature| city_temperature[1] < 30}
=> [["New York", 28], ["Toronto", 25]]

Categories
Uncategorized

Pardon Our Appearance

\"Technical diffculties - Please stand by\" title card from The Simpsons

I’ve had to make some quick changes to the appearance while I investigate how someone managed to hack my blog to include a giant list of invisible porn spam links (apparently, “Fart Porn” really exists and isn’t just something that South Park made up). It was spam-a-riffic enough to make Google send me an email that could be summarized as “Fix this or we’re de-listing you!”

I’d like to spend a special “thank you” to Thomas Hurst, who pointed out that Global Nerdy had been hacked.

Categories
Uncategorized

I Have an Advance Copy of Neal Stephenson’s “Anathem”!

I Have an Advance Copy of Neal Stephenson’s “Anathem”! It just arrived at the office, and I’ve written about it here.

Categories
Uncategorized

RubyFringe: Day 2 Notes, Part 3


Photo by Carsten.
Click the photo to see it on its Flickr page.

Pete Forde Break

- When the idea for this first started, it was much simpler:
  "Let's throw a merb conference, it would be awesome!"
- We love you people a lot
- This has exceeded our expectations
- Meghann: I see her every morning when I arrive, and she works late
- Rubyfringe has become like a monolith in space for us
- Meghann did all the heavy lifting
- [standing ovation for Meghann]
- Rubyfringe next year? In Portland, next year, it's going to be awesome!
- But seriously, maybe we'll have one again next year. We'll have to think
  about it.

Ruby.rewrite(Ruby) (Reginald Braithwaite)


Photo by Libin Pan.
Click the photo to see it on its Flickr page.

- I'm happy to be here with the smart people and good people
- Being interested in the same things that smart people are interested in
  is not the same thing as being smart
- I had no idea what Pete was thinking when he came up with the
  "RubyFringe" concept -- did he mean the fringe of the Ruby
  community, or did he mean the fringe of the Ruby language
- The conference seems to be a nice mix of both

- andand
    - Groovy has an andand built in; it's called the Elvis operator
    - The Haskell people said "Reg is just inventing the maybe
      monad in Haskell"

    [shows code]

    - There has to be a better way
    - If returning nil -- method_missing
    - "Yes, I know because I heard the guy who wrote it says it sucks"
    - I'm using it because I'm hardcore

    - Problem: we've opened up the Object class
    - andand is really slow
        - This is not a performance bug
    - A Haskeller will tell you that the problem is solved
        - Haskell has lazy evaluation
        - Haskell never bother evaluating stuff that will always be nil
        - Ruby isn't "turtles all the way down" -- it doesn't give
          you all the tools it has for itself

    - @logger.debug is expensive
    - Make it a block!
    - Or do if defined?

    - This is going to sound smarmy -- you know, the way it sounds smarmy when
      people say "I don't know how to do this" or play dumb to seem more "real",
      but I swear this is true: I'm not good with IDEs
    - I think that when IDEs give you some kind of wizard or other feature
      to simplify some aspect of programming, it's a sign of a defect in the
      language you're using

    - Ruby's open classes and "eager eval-by-default" are problems
    - There are probably a number of ways to get around it -- my way was to
      use macros
    - Using Rewrite gets around the open class problem
    - Yes, it turns your code into this shit [shows slide]
      but better by far to have the code do it than your IDE
    - [shows benchmarks] As you can see, it performance is far better than
      doing it by opening up the Object class
    - Rewrite version of andand doesn't execute the shit

    - Okay, this is tather nichey stuff
    - You know the saying that people don't by drills or drill bits, but they
      buy *holes*? Think of Rewrite as diamond dust that you use to make
      drill bits. Maybe you'll make use of it, but most people won't

- Just a quick note -- in his presentation, Giles [Bowkett] renamed lambda as
  L because he needed to use it a lot.
- Having to do that is a code smell
- Never mind making it shorter -- get rid of it entirely!

[Joey note: Reg corrected himself in a blog entry written after RubyFringe,
 stating that having to rename lambda is *not* a code smell;
 it's a *language smell*. Giles is simply using the best workaround
 available to him.

 See his blog entry at
 http://weblog.raganwald.com/2008/07/l-is-not-code-smell.html
 ]

- Why does Ruby read from left to right?
    - I have a lot of unpaid Demeter speeding tickets
    - thingy.thingy2.thingy3.thingy4
    - Because this OOP paradigm, even Ruby goes from left to right
    - From time to time, people want to go from right to left
    - blitz.not.blank?
    - not is really a adverb
    - There's really no place for adverbs
    - Adverbs modify verbs, and since OOP is in the Kingdom of Nouns,
      they get short shrift. I'd like to see more support for adverbs.

- Take a look at ruby2ruby, created by the folks at seattle.rb
- It asks "Hey, interpreter, what are you actually working with?"
- It does a lot of cleaning up of Ruby's s-expressions.
- Lisp's s-exps are like the nice flat-pack furniture you get from IKEA;
  Ruby's are the furniture you find in the dumpster -- and that's the stuff
  left over after a couple of people have been through it first.
- In the end, Ruby is like Lisp. Except you do all this work up front,
  and you do all this work on the back, and it's morepainful.
- But aside from that, it's like Lisp!

- Abstraction solves every problem except for one: the problem you have
  when there are too many layers of abstraction
- If working with the tool is worse than the problem, then the tool is bad
- Maybe you've been taken in by Home Depot -- they sell you on how easy it is to
  do the job. Many tools make the job part easy to do, but often they make
  cleaning up after the job more difficult
- Need to consider this when using or building tools

- I know that I don't have the best solution for this
- I *do* know that we have don't have enough competing solutions
- I don't believe that "open classes" is sustainable

Conceptual Algorithms (Tom Preston-Warner)

- When I was 7 years old, I'd fight with my brother over the TV
- I vividly remember a time I was so frustrated that I ran to the top of the
  stairs, took off my shoe, and threw it at my brother's face.
- Naturally, this led to a "time out" -- we were both sent to our rooms and
  told to think about what we'd done and if there was a better way to
  handle things...
    - What happened?
    - Are there better ways to resolve it that shoe-throwing?

- Problem solving can be broken down into these steps:
    1. Think about the problem
    2. Proposed solutions
    3. Evaluate the benefits and consequences of those proposed solutions
    4. Select the best soltuion

- I wrote chronic, god, fixture scenarios, fuzed, grit
- I work at Powerset -- now Microsoft
- Just realized John Lam and I are colleagues! I'm going to have to catch up
  with him when I get back
- I co-founded GitHub

- Conceptual Algorithm: Scientific Method
    - Geoff covered in his philosophy talk
    - It's one of the most powerful conceptual algorithms ever devised

    1. Define the question
    2. Gather info and resources
    3. Form a hyptothesis
    4. Analyze and interpret the data
    5. Plan
    6. Publish the data

    - How *not* to do science
        - To fix a memory leak in god.rb, I didn't use a reasonable methodology
          at first.
        - I just tried commenting stuff out to see if eliminated the leak
        - It was random and didn't get any real results

    - Then I tried the scientific method
    - Go see "science and god.rb" -- my use of the scientific method
      to fix a bug in god.rb is documented at:
      http://groups.google.com/group/god-rb/browse_thread/thread/01cca2b7c4a581c2

- Conceptual Algorithm: Memory Initialization
    - George Dantzig
        - Imagine a situation where you come late to class and everyone's
          already gone, but there are two math problems on the blackboard.
          You copy them down, take them home, find the solutions and
          hand them in, under the impression that it's just an overdue
          assignment
        - Now imagine that a little while later, you discover that those
          problems were strictly for display because they were considered
          unsolved problems by the mathematics community at large!
        - Everybody wants to be that dude -- and George Dantzig was that
          dude at UC Berkeley

    - The "memory initialization" algorithm works like this:
        - "I have a problem"
        - "I am going to disregard everything I know about a problem"
        - When you don't know about a problem domain, you often bring in a
          new perspective, no limits and no limits
        - Rather than look at existing work when developing chronic,
          a Ruby natural-language date parser, I worked from first principles
        - Sometimes coming in "fresh" and working from first principles
          gets you results!

- Conceptual Algorithm: Iteration
    - In making what is considered to be the best vaccuum cleaner in the world,
      James Dyson -- actually SIR James Dyson -- built 5127 prototypes
    - He said: "Making mistakes is the most important thing you can do"
    - Knighted for his efforts

- Conceptual Algorithm: Vaporset Corollary
    - Hard problems take a long time to solve
    - When harangued about why you haven't got any results yet,
      ignore the wankers
    - In the end, your long, hard work can pay off:
      Powerset sold to Microsoft for $100 million

    - Charles Darwin
        - Took 20 years on his evolution research
        - He published his finding only when his colleague Wallace said
          "Hey! You should publish this!"
        - [shows picture of Darwin] Look at those sideburns! He's awesome!

- Conceptual Algorithm: Breadth-First Search
    - There are over 2500 programming languages. Why just explore only
      2 or 4?
    - My original title was "Sapir-Whorf for Robots", but I didn't think
      it would catch on
    - For developing Fuzed, I tried using Erlang
    - The most important thing about trying a new language is to
      just accept the syntax. A strange new syntax often turns off
      developers -- tell yourself: "The syntax is okay"

- Conceptual Algorithm: Imagining the Ideal Solution
    - There's an example of this in god's config file
    - If you're creating a language, don't model it after English.
      That's retarded.
    - Config files are just big lists. You can't do loops or other things
      that we take for granted in programming languages
    - god config files are just Ruby

- Conceptual Algorithm: Dedicate Thinking Time
    - You should set aside some time to just think
    - Sometimes the best things come from this
    - One example: Gravatar, the avatar system -- this came up during my
      thinking time, and I did all right selling it to Automattic last year

    - A guy who devoted a lot of time for thinking: Rene Descartes
        - He's fringe to the max! I know Babbage is RubyFringe's mascot,
          but I think Descartes should've been the guy
        - Many accomplishments: a major philosopher and the father of
          analytic geometry
        - He got on the  Pope's list of prohibited books! How cool is that?

- Conceptual Algorithm: Cash Filter
    - There comes a point when you need to build something that makes you money

- Conceptual Algorithm: Deathbed Filter
    - Imagine yourself on your deathbed
    - Think about a decision you have right now
    - Think about yourself in the future -- imagine yourself looking back on
      that decision. Would it be a good memory or a bad memory?

Sinatra (Blake Mizerany)

- Sinatra is a micro-framework
- Less than 2K LOC in GitHub, including blank lines and comments

- Sinatra "hello world" is simple
- Rails was too slow
- Multiple Mongrel handlers getting cumbersome to maintain
- Same reasons as most for starting a new framework

- Camping is awesome, but...nuff said

- Freaks
- Islands on Second Life
- git-wiki by Simon Rozet

- Ultimate REST client
- RESTClient + Sinatra
- No longer have to use curl

7 WTFs of Sinatra
- Why am I falling for Sinatra?

Be Good (Leila Boujnane)

- People have been asking how I've been doing, and I've lately been saying
  "not too good"
- Some kind of aphasia-like symptoms [Get well sooon, Leila!]
- Founder of Idee Inc., which makes image search

- I'm probably the only person at this conference using notes
- Martin: here from Copenhagen
    - Needed a break -- working really really hard
    - Really really tired
- Couple of days, realy tired
- Use giant Post-It notes to think process
- Have been having trouble writing ideas down -- a sort of aphasia

- "If you make enough money in this world, you can smoke pot all day and have
  people killed." -- Patton Oswalt
- I am not one of those interesting individuals
- Here's something that was true when you were growing up and it's true today:
  Let's not have people killed. Let's be good.

- "What does a man need -- really need? A few pounds of food each day, heat and
  shelter, six feet to lie down in -- and some form of working activity that
  will yield a sense of accomplishment." -- "The Wanderer" by Sterling Hayden
- We have been brainwashed into belonging to an economic system that says you
  need more than that. Way more.

- How do we start to make the world a better place?
- I work long hours, seven days a week, and I love my job
- I love my clients
- Every day you walk in and have to make a set of decisions
- These are the early days

- Make something people want
- Paul Graham: "If you make people with money love you, you can probably
  get some of it."
- Idee: Gives people a better way to search for images
- Nothing more gratifying than an inbox full of messages from happy people
  who love what you make
    - It's satisfying -- you feel wanted and desired
- If you are not good at what you do, you end up resorting to being bad
    - You may have to cheat
    - Bully
    - Lie to your customers
- Your adoption rate is not tied to the number of people who you bully
  into adoption!

- Contrary to what a VC will tell you: don't focus on business models first
- Instead, focus on building something useful first.
- *Then* focus on the business model, *after* you've proven your usefulness
- Crappy products plus sales equals unhappy users

- It's all about happiness and being good!
Categories
Uncategorized

RubyFringe: Day 2 Notes, Part 2

Jabl: The Language You Will Hate (Hampton Catlin)

  • This is the best-case week we could have ever hoped for
  • JavaScript bugs the shit out of me!
  • Nathan is da man! He makes HAML what it is today and he played a big part in a lot of today’s stuff. I’m just some dumb shit with ideas.
  • If a lot of programmers really dislike an idea, but can’t give you a reason why, it’s probably a good one

  • I like writing languages! It’s super fun!
  • I’m not in love with Python, but I think indentation’s better! It’s one of the few things Python gets right.

  • People are really defensive about JavaScript. It’s like you punched their mom in the face.

  • It’s a fairly decent general-purpose language
  • I think it belongs more on the server side than on the browser
  • It got so beaten up. mocked and put down initially that when we discovered it was a real language, we came to defend it rabidly
  • JavaScript is a fucking terrible browser language, hence many people have created frameworks to overcome its shortcomings

  • The JS world has nothing to do with the DOM world. JavaScript and the DOM
    connect only because they’re glued together by the document

  • The DOM is a really cool thing!
  • CSS is nice — with it, we can talk about the DOM. Why are we not outraged that we can’t do this with JavaScript?
  • If you’re saying “I don’t want to learn a new language”, what the hell are you doing in this field?

  • Jabl compiles into jquery

Archaeopteryx (Giles Bowkett)

  • I was going to have a contest to give away this book, O’Reilly’s “JavaScript: The Good Parts”. As you can see, it’s a small book.
  • Audience member: “Just give it to Hampton!”
  • During his presentation about jazz and programming, Nick didn’t talk about
    what I consider to be modern variants — hip-hop groups like A Tribe Called
    Quest and Roni Size’s drum and bass are things I consider to be jazz.
  • I have 496 slides. I don’t think I’m going to get through them all!
  • The Mainstream
    • The mainstream is not just lame, it can get you *killed*
    • Take a look at the life of Heath Ledger. Go check out his Wikipedia entry
    • Most people don’t know that in his youth, he was a chess champion
    • He had a lot of mental energy, and like such people, he suffered from insomnia
    • Insomnia is a solved problem: hypnosis works
    • But…hypnosis is on the edge, on the fringe, even though it has been around for and working for over 100 years
    • So they didn’t use hypnosis, but put him on pills, which killed him
  • At Railsconf 2008, David Heinemeier Hansson talked about “The Great Surplus”, in which he says that there’s still something missing from mainstream languages and tech that gives Ruby and Rails a surplus of power and
    capability, but that this surplus was limited.
  • DHH says people eventually figure out the cool tools and the surplus will go away.
  • I think he’s wrong: the mainstream *never* catches up — it’s too easy to be ordinary
  • The question should be: “Are we going to use that power for good, or are we going to use it for AWESOME?!”
  • People should be saying “This is going to be a wicked party: I’m going to bring my laptop”
  • What are we?
  • Are programmers artists?
  • Kai “Kai’s Power Tools” Krause would say yes
  • Steve Jobs’ said: “Real artists ship”
  • Leonardo da Vinci was a real artist, but there’s a lot of stuff he designed that he never shipped (the hang glider, helicopter, and so on)
  • One of his bridge designs was never built until this century when the Swedish government decided to build it. Talk about failing the “release early, release often” mantra!
  • In many instances, his genius was wasted.
  • How does genius get wasted?
  • In the old days, an artist would seek a patron
  • Patrons were rich nobles who wanted to look good
  • An artist with a patronage would create works in the name of or that glorified the patron
  • If you accept that programmers are artists, then VCs are patrons
  • Let’s talk about adventure for a moment
  • During the boom, working for a startup was often sold to prospective employees as an adventure
  • Let me tell you about adventures:
    • When I moved out of the house, I went to Chicago and lived in a ghetto because my need to create art was actually greater than my need for safety
    • When I lived in New Mexico, I found bear droppings not more than ten feet from my front door on a regular basis
    • I used to carry a .357 Magnum with me because the area was being prowled by a mountain lion. You need a big fucking gun to take down that kind of animal
    • I used to get calls from my parents where they’d tell me that they’d just caught a rattlesnake, killed it and threw it onto the barbecue and would you like to come to dinner?
    • [Something about “psycho rocks” — I was laughing so hard that I wasn’t able to take down notes at this point — Joey]
    • I’ve also done enough LSD to kill a herd of elephants
  • Now consider what you were doing when you were going on a dot-com “adventure”:
    • You get to sit for 4 years at a desk
    • Maybe, if you’re really lucky, your options might turn into something
    • Who are these weasel-brained Muppetfuckers?
    • These people who tell you that working for them is an adventure: they’re not fools; they’re *liars*
  • It all comes back to a system of patronage — this is just the modern version
  • Just as landed nobles gave artists money for the artists to look good, VCs give geeks money so that they can brag
  • [showing a picture of Julia Allison in a skimpy little dress, surrounded by admiring geeks]: This woman is wearing programmers!
  • You are just their pet monkeys!
  • If the company IPOs and you are lucky, you can start collecting pet monkeys of your own
  • I’m not kidding about the “pet monkey” thing. Think of Google, with their ball pit playpens and other niceties with which they coddle you: it is in their economic interest for their employees to think of themselves as Google’s children!
  • If not for the Muppetfuckers who couldn’t see the value of Leonardo’s hang-gliders and helicopters, we could’ve had them hundreds of years sooner!
  • As programmers, we get to create things that didn’t exist before
  • Why should we waste that on things like Pets.com and stock market price grafts?
  • So I learned to draw. I was a starving artist
  • But the people who run this industry are scum
  • Only 3 months prior, I was working at Morgan Stanley for $75/hour
  • At that time, 2001, I made $7.50/hour at a gas station
  • Here’s a picture of an RV that I lived in in New Mexico
  • VCs are:
    • the causes of economic instability
    • “stock puppets”
    • Because of these Muppetfuckers, someone you could have called a genius was instead just building bullshit back in 1997
  • The lesson?
    • Build your business with your money
    • With your money, you’re the boss
  • Consider the case of Engine Yard: the VCs need Engine Yard, not the other way aroung
  • It’s becoming more common: as startups get cheaper to launch,  VCs find themselves in the cold
  • The VC company Benchmark Capital says that open source enriches the ecosystem, which is why they backed MySQL, Red Hat, JBoss
  • Look at Jay Phillips — he leveraged Adhearsion to create consulting work — he is an internet startup
  • The probability matrix
    • Drum machines are simply matrix builders
    • Rows in the matrix represent individual drums
    • Columns in the matrix respresent a beat played at a given time
    • You want drum X to play at time Y? Just put a “1” in [X, Y]
    • In 4/4 time there are 4 beats ber par, and typically drum machines play music in 4-bar chunks making 16 beats
    • So the probability matrices are 16-element arrays
    • But rather than just either playing or not playing the drum at any given point, you assign a probability
    • You want there to be a 25% chance that drum X gets played at time Y? Put a “.25” in [X, Y]
  • It’s social software
  • Archaeopteryx generates rhythms through probability matrices
  • It’s open source. I’m not worried, because the name of the game isn’t locking people out, it’s providing superior service at the same or better price point and competing with people who are illiterate about an important part of their job
  • Maybe I won’t be able to say “My career is Archaeopteryx” I’ll be happy if I simply say “My career *includes* Archaeopteryx”
  • What wonderful things would we have seen?
  • What if the guy who built the board for Sasha open-sourced his design?
  • This DJ mixer is in a niche market
  • [At this point in the presentation, Giles’ allotted time had run out, but people stayed to hear the rest, and the organizers let him run with it because the audience was enraptured by this point. — Joey]
  • As such, it unleashes new creative possibilities
  • [Photo] Here’s his DJ mixer. It’s not a traditional DJ mixer, but a MIDI controller
  • [Photo of DJ Sasha] Here’s a DJ that gets paid $25K a night
  • One day, I want to be able to say “My career is Archaeopteryx”
  • Takes advantage of the fact that MIDI [Musicial Instrument Digital Interface] is cheap and ubiquitious, controlling more than just instruments, but lights, effects, visuals and other things
  • Lightweight
  • Archaeopteryx is a Ruby midi generator
  • Archaeopteryx
  • OOP
  • It’s irresponsible to use Ruby and not leverage its power
  • You should make your own OOP paradigms — that what Ruby is for!
  • Archaeopteryx uses lambda a lot — so much that I’ve had to alias “L” to lambda
  • Loads of lambdas in the code
  • In the OOP used in Archaeopteryx — objects act as host for methods, which can be redefined at any time
  • Goes to core of why mainstream is dangerous
  • Ledger just went with the crowd
  • There is absolutely nobody that does not do that
  • It’s incedibly meta
  • Altering rhythms is adding a lambda to an array of lambdas using a lambda picked out of a queue
  • It’s the use of the strategy pattern to play beats
  • There’s a strategy for deciding which strategy to use
  • “Ruby is like Cthulhu in that it goes beyond sanity”
  • I plan to use it at Burning Man and have it running continuously for the full 7 days
  • Archaeopteryx’s core MIDI code comes from “Practical Ruby Projects”
  • Vaporware alert! I’ve got 2 things planned for user-generated visuals in Archaeopteryx
    • 1. MIDI VJ software
    • 2. “Drum circle”
      • Take a number of drums and rig them with Bluetooth touch sensors
      • Use them to trigger JRuby/Processing
      • Use that input as a voting system for what beats to emphasize
      • Updating the probability matrix based on this is trivial
      • End result: people can influence the music in real time
  • Andy Warhol said “Good business is the best art”
  • “Steve [Jobs], you ridiculous douche…”
  • You don’t need an IPO, you don’t need an exit strategy, that’s fail 2.0
  • Computers are everywhere, which means that you can do anything
  • Language wars are bullshit — it doesn’t matter whether I’m doing music with Ruby or whatever other language is out there
  • It’s about passion
  • Maybe being a programmer is not a *what* but a *how*
  • Maybe being a programmer is about applying programming to your passions
  • Go and build! Build for yourself, not the VCs
  • And remember: real artists ship!
  • [Standing ovation]

CouchDB and Me (Damian Katz)

  • Sell my house, move my family and live off savings? WHY?
  • This is not a tech talk, but about the considerations behind this decision
  • [Shows photo of baby daughter to great applause]
  • Why jeopardize this beautiful young family?
  • I got laid off and had to look for a new job
  • I had a house and the associated mortgage
  • I looked around and didn’t see anything I wanted to work on

  • “Other people work on cool stuff…why not me?”
  • They’re out there, doing cool things they love — designing motorcycles, making music and creating art
  • How do people get jobs where they get to work on cool things, work on what they want, and get paid for it?
  • So I made my decision: sell the house, move someplace cheaper and live off my savings
  • Reasons for doing this:
    • It would be educational
    • I’d get to spend more time with my family
    • It would be a test to see what I can do
    • It would make for an interesting story
    • Moved to Charlotte, North Carolina. The cost of living was cheaper and we had family there
  • Change in Lifestyle
    • Thought I could live with fewer things, but the downgrade hurt!
    • Nobody wants to get wrapped up in a consumerist lifestyle, with the big house and the nice stuff
    • Had to go to the local Goodwill to buy furniture — being in there, thinking “I was better than these people”, but followed quickly by “What is wrong with you?” — these were just people trying to save money and get by. I wasn’t all that different and certainly no better than they were
    • Couldn’t shake that feeling that I was an unemployed loser
  • So what to build?
    • I worked on Lotus Notes for years
    • I thought: I’m going to extract the good stuff from Notes, get rid of the crap and maybe something good can result
  • The development process in the new environment:
    • I’m away from all my development friends
    • Developed in C++: storage engine, view engine, query language
    • Had trouble seeing past the complexity
    • Went into panic mode
    • I ordered “Code Complete” from Amazon, hoping it would help — (it *is* complete and about code)
    • Glad to *not* get new information out of it. The important thing is that it helped me to just push forward with the project
    • Decided to use Erlang –– “I knew Erlang before it was cool” (It was never cool)

  • In late 2007, my cash reserves were drying up
  • I looked heavily at VCs and angels and discounted them quickly
  • I decided that I didn’t want to sell out CouchDB to commercial interests
  • Got a job — a cool one — at MySQL
  • There, I wrote the CouchDB that you know
  • IBM
    • I was approached by IBM
    • Wrote back to the guy who contacted me, saying that I was not interested because they had too many douchebags
    • Surprisingly, he replied with “Send me the same email, but clean up the language”
    • So I did: s/douchebags/vapid bureaucrats/
    • He sent it around his department
    • The result, they offered to pay him to work on CouchDB, and to keep it open, all the code I wrote for it went to the Apache Foundation
    • IBM really stepped up to the plate — they really helped CouchDB happen
    • As much I’m down on them, they’re a positive force in the tech industry. They’re big supporters of open source and big supporters of the tech industry in general
  • Q & A
    • When did it catch on?: When I added JSON

  • How’d the core team get together?I really don’t know
    • Only met one of them in person (Jan)
    • He’s been doing the evangelizing
    • They were basically volunteers who kept adding and it became “I guess you’re part of the project now”
Categories
Uncategorized

An Amusing RubyFringe Moment

This is funnier if you happen to follow the Ruby programming scene or know me and Zed Shaw:


Photo by Libin Pan.
Click the photo to see its Flickr page.

Categories
Uncategorized

RubyFringe: Day 2 Notes, Part 1

If Kant Had a Computer (Geoffrey Grosenbach)

- Super special trivia fact: Only speaker to wear utilikilt

- I was going to throw the word "philosophy" into the title of
  this presentation, but I remembered what Hawking wrote in
  "Brief Hisory of Time": his publisher said that for every equation he put
  in the book, he'd halve the readership

- This isn't going to be a super-practical talk
- My degree was in philosophy
- Had computers been around back then, some of the philosophers may have hacked;
  I think it would've appealed to them
- But since they did not have computers, they became mathematicians and thinkers
  instead
- A number of philosophy and programming concepts were the same

- Immanuel Kant's most famous work is "Critique of Pure Reason"
- Written in German, but it's so obtuse that even German students
  read the English translation, which is supposedly easier to understand
- Kant wrote easier-to-read follow-up in which he lambasted people for
  not being able to follow Critique of Pure Reason
- Don't worry: I found ideas from books that are easier to understand
  than Kant's

- The natural vs. the simulated
    - Philosophers like to think that their thoughts match up in the real world
    - a priori vs. a posteriori knowledge
    - Mythical Man-Month: We're building things out of pure thought-stuff

    - In philosophy, I learned about different ways of thinking, arguing
      and fallacies
    - I can see where this knowledge would help -- I recently read a
      "Rails doesn't scale" post in a blog, where the rebuttal in the comments
      went "Too much emphasis on REST and not enough on internationalization
      is why it doesn't scale!"
    - Philosophy teaches us that a single argument against something
      is not enough to refute it

- Consider these three points below. Where are they from?:
    1. Limit new features to a well-defined scope
    2. Implement the feature, analyze the result
    3. Take the result into account for subsequent features
- Did they come from a 37signals manifesto? Scrum? Agile?
- No, it's the scientific method!
- The method is centuries old: take an idea, test it, measure, record and report the results
- As developers, we're kind of detached from the process:
    - In many cases, we just do the implementation
    - Sometimes the idea's not ours
    - Oftentimes we don't do the analysis or consider the result for
      subsequent features
- Exercise for the reader: Contrast the scientific method with development

- Music
    - I play the double bass, a big instrument
    - Everyone knows what a cello is, but nobody recognizes an upright bass
    - Been playing for a while, but finally found a great jazz teacher
    - I learn by doing, being made to perform with other musicians in the class
    - Old ideas have been around for a long time
    - As a bass player (as mentioned in the jazz presentation yesterday),
      my is to provide the root. Typically, I want to play the lowest note
      possible
    - That's a constraint -- I'm working within a set of rules

- Working with Less
    - Miles Davis: criticized for playing too few notes
    - Improvising: instead of starting out by running through the notes,
      start with silence, play a note or two, and then just get on with it

- DeMorgan's Law:
    - not (p or q) = (not p) and (not q)
    - A useful identity!

- Recent study of PhD's: the philosophy majors were the most employed group
- Philosophy is just math expressed as statements of logic

- Terms, referents, proper names, designators, initial baptism
    - Saul Kripke: Naming and Necessity
        - Descriptivist theory of names
        - For any name, we can come up with a list of descriptives that
          identify that name
            - For example, for the name "Hampton Catlin", we can come up with
              descriptives like: "Works at Unspace", "Lives in Toronto",
              "Changes his hair frequently"
        - Causal theory of reference (advocated by Kripke): When a baby is born
          and given a name, from that point on we can have a causal sequence...
    - This also applies to programming:
        - Creating an object involves naming it
        - We can match up a name with the object it references
        - We also have the decriptivist theory of names with duck typing:
            - Consider the respond_to? method and other forms of introspection
              we use to get descriptives attached to a named object

- Natural Kinds
    - Philosophers like to ask themselves about the way we group or categorize things:
      Are the groupings we create inherent in the nature of the grouped objects,
      or are these artificial groupings that we have assigned based on some
      perception we have of those things?
    - In web development, we like the idea of REST
        - It's an artificial grouping
        - It's the result of a decision by a person that a certain way of
          grouping things is the right way to do it
        - You need to understand REST is not a hard-and-fast natural way of
          organizing things, but an arbitrary way

- Spinoza
    - He's a philosopher with an interesting life: born somewhat wealthy, worked as lens
      grinder, excommunicated from his church, ended up turning down a lot of honours
      in his life, gave family inheritance to his sister, died early
    - He said that the whole universe is just a single substance
      (you can spend weeks studying just what he meant by "substance")
    - Each of us is just different states and concentrations of this substance
    - Reminded me of cloud computing
    - Problem: under his philosophy, we have no free will
    - As programmers, we like free will (we like our programs doing
      what we intend them to do)

- The Sapir-Whorf Hypothesis
    - Go look up the Sapir-Whorf hypothesis if you haven't already heard of it
    - Benjamin Whorf's quote: "We dissect nature along lines laid down by our
      native languages. The categories and types that we isolate from the world
      of phenomena we do not find there because they stare every observer in the
      face; on the contrary, the world is presented in a kaleidoscopic flux of
      impressions which has to be organized by our minds - and this means
      largely by the linguistic systems in our minds. We cut nature up, organize
      it into concepts, and ascribe significances as we do, largely because we
      are parties to an agreement to organize it in this way - an agreement that
      holds throughout our speech community and is codified in the patterns of
      our language."
    - The practical upshot: language anchors thought (Kant thought the same
      thing)
    - Why I like Ruby: helps me organize my thoughts
    - Since a programming language can shape the way you solve problems, you
      should stretch yourself and:
        - Learn other programming languages, especially if their paradigms
          are quite different from ones you're used to
        - Write different types of apps -- if you're used to writing web apps,
          try writing a desktop app, and vice versa
        - Do you typically write apps? Try your hand at writing a library!
    - Stretch your thinking!

Ruby Beyond Rails (John Lam)

- John works for Microsoft, so it's fitting that they used the Imperial Theme
  from "Star Wars" to play him in

- I've been looking at the audience and making mental notes of yesterday's
  presentations -- I've decided to take a less conventional approach to this
  presentation

- In yesterday's presentation, Dan Grigsby said "You're not really on the Fringe
  if you work for the Man."
- I was in a meeting with "The Man": Steve Ballmer, talking about how to recruit
  young programmers straight out of school who might not think of Microsoft as
  an option -- perhaps they've bought into the hype about Google
- "Are you gonna go work at Google and just so you can increase their market
  share from 65 to 66%? Come to MS where every day is a glorious day!"
- I believe that if you want to change things, the best way to do so is work in
  difficult circumstances

- Three things I want to talk about
    - Go see Steve Jobs' Stanford commencement address
    - He talks about "connecting the dots backwards" in viewing his life
    - Looking at that path, he was able to see that he was going to end up where
      he was today
    - People talk about how they accidentally wind up where they are,
      but really, it's all a result of the choices you make

- Back when I was a kid, 6502-based machines were all the rage (Apple ][,
  Commodore 64 and so on)
- (I'm old but I have the Asian mystique working for me)
- I came up with a lot of things that I didn't know already existed
    - Metaprogramming
    - 6502 assembly very limited
    - Built a 16-bit interpreter kind of thing
    - All my 16-bit instructions were prefixed with a BRK (break) instruction,
      which triggered a call to an IRQ routine which would then start the
      interpreter
- Another thing I did as a kid: building bridges between tech
    - Commodore disk drives had their own processors
    - I used to build bridges to conenct these smart peripherals to all sorts
      of things
    - Kids today, they're spoiled! You have to remember that a floppy drive
      back then had throughput similar to a 1200 baud modem. Anyone remember
      those?
- Went to University for a while
    - Did not do computers in university, I did chemistry and got a doctorate
    - I used computers, but did not program them
    - Learned lots of skills, the most of important of which are:
        - Teaching
        - Writing
    - In undergrad, when you turn in a paper, you just get a grade and
      don't care about the feedback
    - In grad school you can't do this; your supervisor won't okay it
      until s/he likes it
    - When I graduated, I realized I didn't want to "do the science thing"
      and ended up doing computers
    - Looked to see of there was a hot new thing that people weren't doing --
      in a drag race, if there are fewer competitors, I'd have a good
      chance of winning
    - I took up Delphi
    - My advice: look for something that people aren't much into and link it to
      someething hard
    - I did this by building bridges between Delphi and COM
    - By doing this work, introduced to Michael Edigan, who ended up
      being a mentor who opened my eyes to new things, including GSL jam
    - One of these things was XML, which was trendy, hip and even
      fringe at the time
    - Ended up working with Don Box (SOAP spec, amongst other things) --
      SOAP was awesomeness if you looked at the original intent
    - This was all before I got into dynamic languages, so I built code
      generators to make my life easier

    - Does anyone remember the Treedragon blog? (a couple of hands go up,
      including mine)
    - I remember its author, Rhys, ranting about dynamic languages, saying they
      sucked
    - I truly believed this

    - I recommend this book: "Advice to a Young Scientist": P.B. Medawar
    - Back when I was getting started, wanted to build stuff for people to use
    - Like many people, the way I did this was via open source
    - There's an open Source entrepreneur problem: the belief that "if you
      build it they will come"
    - Building it might actually be the easy part; getting people to come to
      your solution may be the hard part
    - You can get around that by working for a big company
    - When I interviewed at Microsoft, they didn't tell me what I was
      interviewing for
    - I met with Scott Guthrie, who created ASP.NET, after my interview -- he
      told me about the plan to release a cross-platform version of the CLR
      and its support for dynamic languages

- IronPython is the fastest implementation of Python out there
- Of course, "fastest" needs to be defined. After all, there are three kinds of
  lies, damned lies and bechmarks
- It's fastest in terms of throughput, but its startup is slow
- It was harder to build IronPython than it should have been
- It took a smart guy (Jim Huginin) and a smart team to make lots of
  little decisions well
- Could we get a win the second time and extract a DLR -- dynamic language
  runtime -- from IronPython?
- To prove it would work, we would use the DLR to build other dynamic languages
- That was the ideal, then there's the reality
- Back in May, we demoed Rails running under IronRuby -- really slowly and
  consuming a lot of memory
- We're now working on performance
- Startup time turns out to be more important than you think it is
- Unit tests are the worst kind of code you want to run through a compiler
  -- many are run only once
- Realized that we had to go off and build an interpreter
- We were working backwards from a compiler
- In getting from the language front end to IL, you have to build two trees --
  a language-specific tree and a corresponding, more general DLR tree
- There's cost in building those 2 trees, and the DLR tree is 10x as costly
  as the language-sepcific tree
- The ideal: we could put effort into building the DLR
- We have a working interpreter, just not that fast
- Have to adjust goals

- The world of Ruby development is "a sea of Macs", which sometimes makes people
  wonder who the intended audience of IronRuby is
- Ask yourself: What parts of my app should I write in Ruby?
  What shouldn't I write in Ruby?
- You're on .NET because of the library
- If Rails were "done" -- for some level of "done" -- should portions of it be
  written in a statically-typed language?
- Why should you care what languages the libraries are written in?

- (See slide above -- a photo of balaclava'd protester kids rushing a police
  barricade)
    - Don't be one of these kids: it's all gesture, no result
    - If you really want to make change, you should "enter the belly of
      the beast"
    - Find an ally in the beast -- mine was Jim Huginin -- and make the
      change you want to see from within