028 RR Beyond the Web with Dave Copeland

This episode was recorded at the Ruby Midwest Conference.

Special Guests: Dave Copeland

Show Notes

This episode was recorded at the Ruby Midwest Conference.
Special Guest: Dave Copeland.

Transcript

 
JAMES:

I'm James Edward Gray II, this is the 28th episode of the Ruby Rogues. Josh Susser is going to be mad at me for saying it like that. He hates the ‘th’ on it. So like I said, this is episode 28 of the Ruby Rogues. With me today, is Avdi Grimm.

AVDI:

I am Avdi, and I blog at Avdi.org/devblog about Ruby and other development things.

JAMES:

Also, with us today is Dave Copeland. Avdi told me he wanted to talk about Ruby, outside of web development today. And so, I was like, “We got to find somebody who uses Ruby outside of web development.” Actually, we will settle for somebody who uses Ruby on anything, but a social coupon site.

[Audience laughs]

But I found a guy -- the one guy -- who uses Ruby, outside of web development. So Dave Copeland, introduce yourself.

DAVE:

So I'm Dave Copeland, and I'm writing a book about Command Line applications with Ruby. I love using Ruby on the command line, that’s why I learned it but [inaudible] [Laughter]

JAMES:

Never mind. Do over. So like I said, this is the Ruby Rogues safari… I mean, Ruby beyond web development. That’s what we are going to talk about today. We thought we’d chat for about 20 minutes or so. It's pretty short for us; we usually talk to close to 40, but we'll cut it in half, because I'm sure you guys wanna get lunch eventually.

We'll chat for about 20 minutes or so, and then we'll take questions, because that’s the cool thing we can do when we have a live audience – and we don’t, normally. Oh, which by the way for the people listening to the podcast, we really do have 200 of our closest friends in this room who’s with us right now, so make some noise. Prove you are here.

[Audience cheers]

We are going to put all of those people on the panel.

Okay, so Avdi, tell us what you had in mind when you chose Ruby Beyond Web Development.

AVDI:

So when I got started with Ruby, it was long before the Rails era, and there were people doing like CGI scripts and stuff like that with Ruby, but it was still kind of wide open what we are doing use this language for. And actually, a lot of the usage before Rails, were kind of in the vein of what you would have done with the Perl script -- only use Ruby instead, because Ruby seemed to be much more awesome. And that’s some of the stuff that I got started with, so I was managing files and stuff like that. And I just got to wondering who is still doing interesting stuff beyond the web with Ruby.

JAMES:

So what particular projects have we worked with that were Ruby, but not necessarily on the web? Dave, do you wanna go first?

DAVE:

So I have similar as Avdi, I used to do Perl, then I thought Ruby was great for that. And I think the homebrew for me, kind of like captures like what’s great about Ruby on the command line, because it sets up your system, it does all kinds of crazy stuff that you would normally do like autoconf or something like that, but it's all in Ruby and it's extensible via object orientation. So it kind of demonstrates for me like, how great it is to do Ruby on the command line.

AVDI:

So the first thing that I recall doing was like part of my job – I wasn’t just playing around -- was I wrote a program for processing prom images… how many people does that actually ring a bell for in this room?

One hand.

JAMES:

[Chuckles] there's a couple.

AVDI:

A couple of hands. So back before all devices had flash memory on them, and USB ports and stuff like that, you used to have devices that the only way to reprogram them, was to actually take a chip off the board. It was made to be pried off the board, and you would put it in a special PROM burner machine, and you would load up a PROM image, that you had prepared of the program, that was supposed to be running on this device, and you would hit go on the PROM burner. It will sit there for like 20 minutes, doing its thing, and then you'd pull the chip off, and you'd carefully label it and then you'd jam it into the board.

And I was working on an old radar system that you still had to program with these PROMs, and there was this horrible prom preprocessing program that you had to use that would get all the memory segments in the exactly the right locations in this PROM image. And it was this nasty old C program that was so legacy, that parts of it were just like a compiled object file, that nobody has the source code for or the compiler for anymore and so you just had to link with that, because there was no way to change it.

And so I thought, we’re rapidly iterating on [inaudible] this hardware. We keep having to move things around in memory. And if I have to keep modifying this stupid C program, I'm going to go insane. So I basically just rewrote the parts of it that’s actually needed in Ruby, and using it's stability like pack and unpack and that was PROM processor.

JAMES:

So I'm kind of embarrassed to admit that I've been thinking the whole time, of ideas I can bring projects that I've used Ruby for, and it was not web development. And some of my greatest ideas have been happening in the last ten minutes, because people have reminded me of them.

So Avdi’s talk about PROM imaging. This chair right here, when I got this new chair, they showed me that you can stick in an SD card on the side of the controller, and it will write out the programming on the chair on this SD card in its binary format, and they can take it and reprogram it. They should have never showed me that.

[Laughter]

That’s a completely bad idea. So I used Ruby, and I reversed engineered the binary format that it stores it's programs in. And I would sit there and manipulate settings to see what effect they would have, and stuff like that. So you can actually reprogram your wheelchair with Ruby if you want to – just FYI. Not recommended. So I have thought about doing a training, where I invite students to do that, and run their program, but I think it could be dangerous, you know?

So that’s one use. Then, as some of you probably know, I do quite a bit of work with Textmate. And working with that team, and it completely skipped my mind until doctor Nic reminded me about two minutes before we came up here to do this, that we use Ruby all over the place in Textmate; all the bundles make heavy use of Ruby. So, that’s the other example of it.

Finally, one of the projects I'm working on right now, is a simulation for a vaccination company. We are testing several new vaccinations, and wanna show the effects of different vaccinations on populations; so they simulate populations, they introduce viruses and infections, and stuff and run those through. And then they introduced vaccines, screening and things like that. Show the effects of vaccination on the population. So that’s one of the cooler projects I've worked on that is using Ruby, in a totally non-web environment.

It has has some interesting challenges; First of all it's really cool to write a simulation in Ruby, because it models it so well with the right objects system and things like that. But of course as we all know, Ruby is not the fastest thing in the planet, so when we’re doing very large numbers -simulating very large populations – we sometimes have to go really creative with that algorithms and memory usage to make it more friendly. But I like that, because I get to try new stuff. So I enjoy that too. So those are some of the uses I had in mind.

So Dave, aren’t you kind of writing a book about using Ruby in non-web situations?

DAVE:

In fact I am, and I was inspired by writing a similar question to what the two of you have been talking about… I worked with a company before, that generated lots of PDFs that got mailed out to people, and the QA was we would email out like a ten thousand page PDF, and everyone in the company would go through it, looking for problems.

So instead of that, what I did is I wrote a Ruby script that would go in, and do some boundary value analysis on the data, and produce PDFs only for people who kind of fit in the certain categories of weird data. And then you only look at say hundred PDFs, instead of ten thousand. So after doing a really terrible job of writing that program, and having it come back to bite me in the ass later, I decided to redouble my efforts and learn how to really write a good command line program. And I

thought like I had a whole book’s worth of stuff to write about that, so I've been working at that at the past year for the Pragmatic programmers.

JAMES:

So what is your book called?

DAVE:

It is called Build Awesome Command-Line Applications in Ruby. And I gave them the outs and not use the word “awesome.” I thought it was a little hyperbolic, but they were cool with it, so yeah.

JAMES:

Well, I think it's awesome.

DAVE:

Yeah, me too. [Chuckles]

JAMES:

So in that book, you are going to cover all the different… you’re just going to cover techniques in the Ruby language, or are you also going to cover some libraries like tor that usually gets used for that task?

DAVE:

Yeah, so I try to keep it not as a bunch of instructions in libraries and sort of concentrate on like what is the gist of how to interact with the [unintelligible] with the users, and what you want your applications to do. But there is some of that stuff, so like OptionParser, things like that. And then, there is going to be an appendix that basically shows the example programs using a couple different command line parsers, just so you kind of… you know in Ruby, there's like ten ways to do everything, which are what you feel comfortable, and so I like to demonstrate all those things at least.

JAMES:

Very cool.

AVDI:

What would you say makes Ruby particularly handy for that kind of command line work?

DAVE:

Yeah, I think it's because a high-level language, has all these great abstractions like objectorientation, and all these metaprogramming, where you do really powerful things, but you are still really close to the middle and can run some commands, access the Unix system, stuff like [inaudible] lets you write what looks like a bash script, but still Ruby, so you get kind of the best of both worlds.

JAMES:

That’s a really good point. So we did some asking around on the internet too, we’ve just heard about this technology stuff, and it's so cool. So, we did some asking of what other people are using Ruby for in non-web scenarios and we got some cool answers, so let’s hear what some other people use them for.

AVDI:

Let’s see here. So Ara Howard, did some work at NOAH, for processing satellite imagery.

JAMES:

I actually know in that particular case, I used to work with Ara from time to time, and in that particular case I believe, he was analyzing satellite images from hurricane Katrina. And doing the processing with Ruby’s image libraries and stuff, to detect things like power outages and stuff like that.

AVDI:

Chris writes, “We use JRuby in a system for a robotic tape library. Tim, uses Ruby in aerospace company to validate test imagery for Kepler’s space telescope. There are some other mentions of NASA-related work.

JAMES:

NASA does use Ruby quite a bit. Bill, has been in the community more so in the past I think, than current days. And he's a NASA employee and always using Ruby for all kinds of awesome avenues in NASA.

AVDI:

There's a Ruby interface to Arduino.

JAMES:

You guys make Arduino projects?

No? Nobody? Homework? You guys have homework?

AVDI:

Do you wanna briefly explain what that is?

JAMES:

Sure. It's like for hardware hacking, if we do this software side,, the Arduino boards are circuit boards that make it easy to hack in to all kinds of things, and you can find recipes on line. There are awesome sites, which has unbelievable things you can build from cool fountains that have lights in them that oscillate in cool patterns, to old style gaming cabinets, then you put hardware that you write software on and stuff. So really neat stuff. Kind of a neat combination of hardware and software hacking.

AVDI:

And then there are some mentions of some other command line stuff like an earthquake, a command line Twitter client, and of course, there's sys admin stuff, so there’s Chef and Puppet, use Ruby.

JAMES:

That’s a good point. It really seems kind of slowly getting into this sysadmin side of things, as far as like Perl’s penetration, but then Chef and Ruby, I think did turn the table.

AVDI:

I feel like Ruby is maybe the perfect sys administration language, because you can take a script from like the messiest one-liner -- which works, in works like one-liners in Ruby -- and then it gives you this really nice gradual series of steps working that were more general, and more and more nicely factored and abstract, as you add things like classes and modules, and you add a proper OptionParser, instead of something hacky with [unintelligible] and then you can start factoring files out of it, and you can keep the whole thing in your test. Other languages, it's like, it's really nice little [inaudible] or really [inaudible] with high level programs, but Ruby, you get to have all the [inaudible] in between.

DAVE:

I tried convincing the sys admins in my last job, but they were really in to bash so much, that the lead sysadmin schedules four hours every Friday afternoon for bashing time, and it's on his calendar and he just writes bash scripts. And when he heard I was writing this book, he like redoubled his efforts to like really learn bash and show me how awesome it was. And I´ll just give him a free copy of the book, and see if it changes his mind.

JAMES:

[Chuckles] That’s awesome. I use Ruby a lot in just my day to day work. I think we always end up doing some kind of introspection on something, and with servers and stuff. And I'm so-so with the command line, mediocre with bash. I know tools like [inaudible]and stuff of course that we all use for that. The second I get out of my comfort zone, I immediately default to just using Ruby. And I´ll write one-line script and I´ll use the flipflop operator. I'm sorry. So I´ll write a quick one-line script, and just go after the data in that, just because I'm so familiar with that stuff.

And actually, speaking of the flip-flop operator -- maybe we should go here -- but Ruby has a whole bunch of really scary features, for doing work at the command line beginning end locks, the flip-flop operator. All kinds of things like that. And I really do encourage you to like to look in to some of those. If for no other reason, it will kind of expand your brain a little bit. You'll see Ruby in some ways you never thought you'd see it before -- and that’s for sure. So it borrows most of those features from Perl by the way, so if you came from Perl, you’re probably pretty used to a lot of them, already.

Anything else you guys wanna say about that, or should we start taking some questions?

All right, you guys have some time to think them up, so we expect good ones. [inaudible] the hard ones today, Avdi and I will handle the rest.

DAVE:

So the question is how do you mitigate the cost of forking a new Ruby, every time you use on the command line, as opposed to… I mean, your command line program, it's going to fork a process every time, right?

[inaudible]

That’s interesting, I guess. [inaudible] with CGI and Perl or something.

JAMES:

Right. If you don’t load active record, I mean is the load time really bad? I mean, Ruby starts up in very, very fast, right?

DAVE:

I use active record in my command line scripts a lot.

JAMES:

Maybe JRuby has a little slower startup, but…

DAVE:

It's gotten faster.

JAMES:

Yeah, it's gotten a lot faster. But MRI, I'm pretty sure it's a sub second, so it happens really really fast.

AVDI:

It's a very, very fast startup. That’s not something that worries me too much, but there are a lot of… once you start building your script up, you might start requiring more and more. And one thing I´ll say to that is, if you don’t need all of those libraries for every path that your script might take, looking to using all the load, and only load the libraries as you need them.

JAMES:

Also, check out Ruby 1.9.3, which was just released very recently. They applied a patch to it that fits a big file problem stack problem they had when loading lots of gems and stuff. I think in Rail’s case, in particular, they increase the boot time of Rails like less than 30% I think, so they definitely are making [inaudible] when you are massive amounts of [inaudible]. Next question?

DAVE:

So the question was what is our favorite command line parsing library? I think we can give our answers. Mine, I like OptionParser. And then I wrote one called, GLI, so since I wrote it, I like to use it all the time, but it's pretty much like commander.

AVDI:

I like Main by Ara T. Howard. Check it out.

JAMES:

Main is pretty cool. I agree. It's a cool library. I usually just use OptionParser because it's in the standard library. Another question?

DAVE:

So the question was what were some of the painful things I did that I didn’t like, and how did I fix them? So going into [inaudible] directly, instead of just biting the bullet and using OptionParser, I mean, that’s like the number one offense. And just not formatting the output usually, not checking error codes, exit codes of things. It's worst when someone else is running your program, and they get a backtrace. I mean, that’s something that’s just no excuse for that.

JAMES:

I've definitely done things I've regretted on the command line, I'm sure most of all. Destroyed directories and stuff. Usually mine involved having too many permissions I had when I was running that piece of command. Definitely be careful. Libraries like [unintelligible] utils has a drive run mode. I love that mode. Where it will go through and show you everything it's going to do, before you actually use it, really important. Other questions about using Ruby in non-web scenarios?

DAVE:

MacRuby, right? I don’t do that, but that’s an on-web scenario.

JAMES:

That is an on web scenario. That’s a good point. It’s getting more popular on Mac Appstore and stuff.

DAVE:

Can you create a MacRuby app, and submit it to the Mac Appstore?

JAMES:

I believe you can. We don’t see Ruby used as much in desktop [unintelligible]. Yes. There's a hand. Oh, I know that guy. What are you building?

MEMBER:

So the website… the video stuff that we are doing is written in Clojure, but the control panel stuff that we used for administrating, is all written in Ruby. And it's a desktop application, that we used to put graphs and control the site, and we are using the limelight framework for doing… it's actually JRuby’s swing applications [inaudible] by Ruby. It's very cool.

DAVE:

I believe your son did a talk on that at Ruby Conf, I recall?

MEMBER:

Yeah, he’s the author of Limelight, which is [inaudible]

DAVE:

Yeah, it was very interesting.

JAMES:

[unintelligible] Anyone else?

MEMBER:

I'm doing Android or Java development using Ruby and things like that. It was actually quite fun – in a sadistic kind of way.

JAMES:

Fun. Developing for Android using Mirror and Panda, you said?

AVDI:

I've got a question for you guys. Have you ever tried to apply Ruby into a problem outside the web? And said, no I'm going to use something else.

DAVE:

I think Ruby is pretty bad at lots of hardcore mathematical processing type stuff. The last place I worked, it was an analytics team that tried it and like, “Yeah, Ruby is awesome.” And they are like, they have to go back to Python, sadly.

JAMES:

That’s a good point. Although, I will say on that mathematical processing side, there's a very underappreciated library called [unintelligible], which basically lets you borrow number C’s number types, and then do massive operations of a large sets of them. And I had one library that was doing some image processing, so it's basically just… numbers that we were churning through and switching it to [unintelligible] was just a ridiculous speed up. So it can be good number processing that way.

AVDI:

And James, I believe you did a talk on that, right?

JAMES:

I talked about it on Lonestar once a while ago.

AVDI:

There's a video of that.

JAMES:

Yes, on Confreaks. I see a question at the back.

MEMBER:

Yeah, So I wanted to use Ruby for a SOAP client application and I thought, “Oh cool, there’s a [inaudible] for that.” [inaudible] but it was a total disaster. If I have to do it again, I´ll probably just call java library like JRuby or something like that. Do you have any thoughts on this? [inaudible]

JAMES:

Wait, so you are saying SOAP was a total disaster? [audience laughs]

JAMES:

Did I understand that correctly? No, I've definitely felt the pain exactly on that issue that Ruby SOAP library is just not the same as in other environments and stuff, where they configure themselves so much from the [inaudible] it seems… it does some of that, but it also, it’s all black box so even if it does some of that, you have no idea what it did do, and try to figure that out. It's pretty horrible. So I kind of agree with the idea of just using like a Java tool for something like that.
That's kind of cool.

AVDI:

So that was [inaudible] to automate excel spreadsheet, just to repeat for the recording, these days it will be easier to just like, if you just need to write some excel, you can just you can just use a spreadsheet gem to write the file instead of actually automating [inaudible] from a windows box. It's funny, because you actually gave me flashbacks there. [Chuckles] you reminded me of something else that I have done with Ruby a long long time ago, which is exactly that. It was about excel, using [inaudible].

JAMES:

I use Ruby for lots of daily [inaudible] needs, if I have something against some source, [inaudible] it spits it out in a different source, this was the faster way, I know how to do it. I see a hand way back there.

MEMBER:

You mentioned Arduino earlier, I don’t use Ruby to program Arduino, but I do use Ruby to build the code that goes into Arduino. So I replace the main file with rake files, and anything I build like that, that use Ruby and rake can do that.

JAMES:

That guy has an unhealthy like of Rake, have you noticed that? Something going on there. No, that's a great point. I use Rake for like everything. If you guys really haven’t checked out Rake, the thing you never see people using is file tasks, those are awesome. You can like use the file task, and then a block of code needed to build that file when it's not present. So you can just do all kinds of ridiculously cool stuff with that. You should check out Rake’s file list.

Anyone else?

DAVE:

The question was about GUI libraries. Like bob is talking about limelight, which is one. Other than Shoes, I don’t know. Sheri and monkey bars, I think they are just making up names. [Laughter]

JAMES:

Yeah, those are Java swing library, correct? Yes. And then of course, there's the QT TK... that is part of that trio. The Prags had a short book on QT, I think a while back, and it seemed to get a little traction at that point, and then it just kind of fell off and back again. I think it's just [unintelligible] to use or not really.

Shoes is back. I think Steve Klabnik resurrected it, and spent a lot of work on it, so it is still around. The minus there being that, I think you are using a forked in Ruby in that case, so there's kind of some penalties for that. So those are the libraries that I know of, that yeah, I think probably the swing libraries have the most uptake, as far as being used.

That was the other one I was trying to think of. Yeah, exactly. All those little libraries.

Okay, we'll take one more question, and then I´ll let you guys go eat lunch.

That’s a good point. So what he was saying was mobile development, which was mentioned earlier with android, but mobile development is obviously a huge thing right now, and Ruby has quite a bit of a usage there, thanks to things like Ruboto and [unintelligible].

All right, thanks. Go have lunch.

[audience claps]

Album Art
028 RR Beyond the Web with Dave Copeland
0:00
27:55
Playback Speed: