 So, like I said, this is episode 28 of The Rooey Roads, with me today is Avdi Graham. Hi, I'm Avdi, and I log at Avdi.org slash DevVlog dot Ruby and other development things. Also with us today is Dave Copeland. Avdi told me he wanted to talk about Ruby outside of web development today. And so he, you know, it's like, we're going to find somebody who uses Ruby outside of web development. Actually, what is that? For somebody who uses Ruby on anything but a social coupon site. But I found a guy, the one guy who uses Ruby outside of web development. So, Dave Copeland, introduce yourself. Hi, I'm Dave Copeland. So, I'm Dave Copeland, and I'm writing a book about command line applications in Ruby, because I love using Ruby on the command line. That's where I learned it. But I must admit, I do work at the big social. Never mind. We'll see you over. So, like I said, this is the Ruby web safari, I mean, Ruby beyond web development is what we're going to talk about today. We probably chat for about 20 minutes or so. It's pretty short for us. We easily talk for close to 40, but we'll cut it in half because we got, I'm sure you guys want to 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 that 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. That's right. So, make some noise. Prove your hair. Of those people on the panel. Okay, so, Api, tell us what you had in mind when you chose Ruby beyond web development. 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 were going to use this language for. Actually, a lot of the uses before Rails were kind of in the vein of what you would have done with a Perl script. Only use Ruby instead, because Ruby is so much more awesome. And that's some of the stuff that I got started with, so I was munging files and stuff like that. And I just got to wondering about who's still doing all kind of interesting stuff beyond the web with Ruby. Gotcha. So, what particular projects have we worked with that weren't Ruby, but not necessarily on the web? Okay, if you want to go first. Well, I have a, still, I'll see y'all. So, I have a similar intro to Ruby as Abdi, you know, used to do Perl, and so then I got to talk to that, and Ruby was great for that. And I think Homebrew, for me, kind of like captures what's great about Ruby on the command line, because it sets up your system. It has all kinds of crazy stuff that you normally would do with Autocon or something like that. But it's all in Ruby, and it's extensible via object orientation. So, it kind of demonstrates for me how great it is to do Ruby on the command line. So, the first thing that I recall doing that was part of my job, it wasn't just playing around, was I wrote a program for processing prom images. Does that even ring, how many people does that actually ring a bell for in this room? One hand. There's a couple. A couple of hands, okay. So, back before all devices had flash memory on them and USB ports and cool 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 this 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 and it would sit there for like, I don't know, 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 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 had 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, you know, we're rapidly iterating on an u-version of 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 I actually needed in Ruby and just using its ability like pack and unpack to fiddle with memory and to do binary layouts. And that was that I wrote this prom preprocessor which would sort of munch the prom images in the way that the device needed. So I'm kind of embarrassed to admit that I've been thinking the whole time of ideas I could bring up projects that I've used Ruby for and it wasn't web development. And some of my greatest ideas have happened in the last 10 minutes because people have reminded me of them. So I'll be talking about prom imaging. This chair right here, when I get this new chair, they showed me that you can stick an SD card in the side of the controller and then write out the programming on the chair under this SD card in this binary format where they can take in reprogramming. They should have never showed me that. So I used Ruby and I reverse engineered the binary format that it stores its programs in and you know I can sit there and manipulate settings to see where in effect they would have and stuff like that. So you can actually reprogram your wheelchair with Ruby if you want to. Just have one. I'm not recommended. Although I have thought about doing a training where I invite students to do that and then run their program but I think it could be dangerous. Not sure. 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 Dr. Nick reminded me about two minutes before we came up here to do this that we used Ruby all over the place in TextMate. All the bundles used make heavy use of Ruby. So that's another example of it. Finally one of the projects I'm working on right now is a simulation for a vaccination company. They're testing several new vaccinations and they want to show the effects of different vaccinations on populations. So they stimulate populations, they introduce viruses and infections and stuff and run those through and then they introduce vaccines and screening and things like that show the effects of vaccinations on populations. So that's one of the cooler projects I've worked on that is using Ruby in a totally non-web environment. It 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 object system and stuff like that. But of course as we all know Ruby's not the fastest thing in the planet. So when we're doing very large numbers simulating very large populations we sometimes have to go a little creative with the algorithms and memory usage to make it more friendly. But I like that because I get to try new stuff and see so I enjoy that too. So those are some of the uses I've had in mind. So Dave are you kind of writing a book about using Ruby in non-web situations? In fact I am and I was inspired by writing a program similar to what the two of you have been talking about. I worked at a company before that generated lots of PDFs that got mailed out to people and the QA was we would email out like a 10,000 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 certain categories of weird data and then you only had to look at like say 100 PDFs instead of 10,000. 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 like really really write a good command line program and I found that I thought I had like a whole books worth of stuff to write about that so I've been working on that for the past year for the pre-mitted programmers. So what is your book called? It is called Build Awesome Command Line Applications in Ruby and I gave them the out to not use the word awesome I thought it was a little hyperbolic but they were cool with it so yeah. Well I think it's awesome. Yeah me too. So in that chapter or in that book you're going to cover all the different like are you just going to cover techniques in the Ruby language are you also going to cover some libraries like Thor that are usually used for that task? Yeah so I try to keep it not as a bunch of instructions for libraries and sort of concentrate on like what is the gist of how to interact with the users and what do you want your applications to do but there is some of that stuff so like option parser things like that and then there's going to be an appendix that basically shows the example programs using a couple different command line parsers just so you can kind of, you know in Ruby there's like 10 ways to do everything and feel comfortable and so I'd like to demonstrate all those things at least. What would you say makes Ruby particularly handy for the that kind of command line work? Yeah I think it's because it's a high level language that has all these great abstractions like object orientation and all this metaprogramming where you do really powerful things but you're still really close to the metal and can run system commands, access the unique system. You know something like FileUtils lets you write what looks like a bash script but it's still Ruby so you get kind of the best of the variables. It'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 are using it for. Let's see here. So Aira Howard did some work with NOAA for processing satellite imagery. I actually go on that particular case. I used to work with Aira 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. It's pretty new stuff. Chris Umbel writes we use JRuby in a control system for a robotic tape library. Tim Heath has used Ruby at an aerospace company to validate test imagery for the Kepler space telescope. There's some other mentions of NASA related work. NASA does use Ruby quite a bit. Go Club has been in the community more so in the past I think in current days and he's a NASA employee and always using Ruby for all kinds of awesome happenings in NASA. There's a Ruby interface to Arduino. You guys make Arduino projects. Homework, you guys have homework? Do you want to briefly explain what that is? Sure. It's like for hardware hacking. If we do the software side, the Arduino boards are circuit boards that make it easy to hack into all kinds of things and you can find recipes online. There are awesome slides with just 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 in there that you can write software on and stuff. Really neat stuff, kind of a neat combination of hardware and software. Then there are some mentions of some other command line stuff like an earthquake, a command line Twitter client. And of course there's sysadmin stuff. So both Chef and Puppet use Ruby. That's a good point. Ruby seems kind of slow to get into the sysadmin side of things as far as like Perl's penetration but then Chef and Ruby I think did turn the tables on my good exposure there. I feel like Ruby is maybe the perfect sysadmin administration language because you can take a script from like the messiest one-liner which works and works like one-liners in Ruby and then it gives you this really nice gradual series of steps where you can make that more and more general and more and more nicely factored and abstract as you add things like classes and modules and you add a proper option parser instead of something hacky with R&D and then you can start factoring files out of it and you can keep the whole thing under test. It's just a really nice, other languages it's like it's really nice for those one-liners or it's really nice for those high-level programs but Ruby you get to have all of the steps in between. Yeah, I try convincing this sysadmin to my last job about that. They're really into 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 redoubled his efforts to really learn bash and show me how awesome it was. And I'm just going to give him a free copy of the book and see if he can use this mind. I use Ruby a lot and I just find day-to-day where 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 and I know the tools like wrapping and stuff of course that we all use for that but the second I get out of my comfort zone I'd be at redefault to just using Ruby and I'll write a one-line script and I use the flip flop operator I'm sorry a lot. So I'll write a quick one-line script and go after the data I'm at just because I'm so familiar with it and stuff and actually speaking of the flip flop operator Ruby has a whole bunch of really scary features for doing work at the command line beginning to end blocks the flip flop operator RGF all kinds of things like that and I really do encourage you to look into some of those if for no other reason that they'll kind of expand your brain a little bit you'll see Ruby in some ways you never thought you'd see it before 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 we need to say about that or should we just start taking some questions? All right. You guys had some time to think them up so we expect good ones. Give the hard ones today, I'll handle the rest. So how do you mitigate the cost of forking a brand new Ruby interpreter every single time you use something on the command line? So the question is how do you mitigate the cost of forking a new Ruby every time you use it on the command line if it goes to you're going to run a command line program it's going to fork a process every time, right? So you don't, okay. What's the alternative? You've got a review interpreter over here and you send your script to it. Yeah, that's interesting I guess. But I mean... If you don't load ActiveRecord I mean is the load time really bad? Ruby starts up very, very fast, right? ActiveRecord might come in on my scripts a lot. Maybe J-Ruby has a little slower start up. It's going faster. Yeah, that's gotten a lot faster. But MRA, we need to sit down in time at them. I'm pretty sure it's a sub-second start up, it's very fast. Yeah, it's a very, very fast start up so 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 look into using autoload and only load the libraries as you need them. Also, check out Ruby193 which was just released very recently. They applied a patch to it that fixed a big file stat problem they had when loading lots of gems and stuff. I think in Rails's case in particular it increased the boot time of Rails by less than 30% I think. They definitely are making big happenings there when you are loading massive amounts of libraries. Next question? Way over there. Yeah, so the running command line program, once you're out of the visibility of parsing the command line what's your favorite library to do that? So the question is what's our favorite command line parsing library? I think we can all give our own answers. I like option parser and 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. I like main by A.R.T. Howard. Check it out. Main is pretty cool, I agree. It's a cool library I've used it a couple of times. You can usually just use our option parser because it's in the standard library and I do it really well. You mentioned when you first started writing a script, you felt some pain you looked at your, you didn't like what you've done can you give an example of what you since learned that you did originally that you don't like anymore? So the question is what were some of the painful things I did that I didn't like and how did I fix them? So, you know, going into Arc V directly instead of just biting the bullet and using option parser, I mean that's like the number one offense and just formatting the output usefully, not checking error codes, exit codes of things. It's like it's just the worst when someone else is running your program and they get a back trade is something that's just no excuse for that. I've definitely done things I've regretted on command line I'm sure most of all destroying directories and stuff but usually mine involved having too many permissions that I shouldn't have had running that particular command so I definitely need to be careful. Vibraries like F, Bywood Utils has a drive run mode I love that mode where it'll go through and show you everything it's going to do before you actually use it really important. Other questions? About using Ruby and non-web scenarios? Mac Ruby, right? That's not maps, I don't do that but that's a non-web scenario. That is a non-web scenario, that's a good point getting more popular with Mac App Store and stuff. Have you ever been submitted to the Mac App Store? I believe you have. We don't see Ruby use as much in desktop. Does anybody building anything on the desktop? Yes, there's a hand in the back. Oh, I know that guy. What are you building? The website for clean coders the video stuff that we're doing is written in closure but the control panel stuff that we use for administrative it is all written in Ruby a desktop application that we use to put up graphs and control the site and we're using the Limelight framework for doing essentially J-Ruby swing applications driven by Ruby, it's very cool. I believe your son did a talk on that at RubyConf, I recall. Yeah, he's the author of Limelight he did a number of talks on that. Yeah, it was very interesting. So it doesn't get used to the desktop environment maybe just not as much. Anyone else? Go for it. Mirror and Pinda, I'm doing Android or Java development using Ruby to facilitate that. Is that kind of fun? In a sadistic kind of way? Fun, I'm looking for Android using Mirror and Pinda. You said Pinda? I've got a question for you guys. Have you ever tried to apply Ruby to a problem outside the web and said, no, this is a mistake. I'm going to use something else. I think Ruby's pretty bad at lots of hardcore mathematical processing type stuff. The last place I worked there was an analytics team that tried it because I was, yeah, Ruby's awesome and they're like, we have to go back to Python, sadly. It's a good point although I will say on that mathematical processing side there's a very underappreciated library called NRAE which basically lets you borrow C's number types and then do massive operations over large sets of them. I had one library that was doing some image processing so it was basically just a cube of numbers that we were churning through and switching it to NRAE was just a ridiculous speed up. It can be good for number processing. And James, I believe you did a talk on that, right? I talked about it at Lowland Star once but there's a video of that so we're checking it out. Yes, I see a question in the back. Wait, so you're saying soap was a total disaster? Do I understand that correctly? Yeah, yeah. No, I definitely felt the pain on exactly that issue that ruby soap library is just not the same as, you know, in other environments and stuff where they, you know, configure themselves so much from the wisdom and it seems that it does some of that but also it's all black box so even when it does some of that you have no idea what it did do, you know, and you try to figure that out it's pretty horrible so I kind of agree with the idea of just using like a Java tool or something like that. I've actually used ruby, it's been a couple of years but I've used ruby with the Win32LA library to automate Excel and Power 1 on a Windows box. That's kind of cool. So there was Win32 OLE to like automate Excel to take data out of a database and put it into Excel actually I've more recently done one where I'm just taking ruby pulling data out of my SQL and using the spreadsheet gem to just write it into an Excel compatible file so I don't have to have a Windows box or a license of office but so just to report that to repeat that for the room and for the recording it'd be easier to these days it'd be easier to just like if you just need to write some Excel data you can just use the spreadsheet gem to write a file instead of actually automating Excel from a Windows box. It's funny because you actually like you gave me flashbacks there and you reminded me of something else I've done with ruby a long long time ago which was exactly that it was it was driving Excel using Win32LA Windows machine. I use ruby for lots of daily data munging needs if I have some data or some source I want to spit it out in different sources just the fastest way I know how to do it. I see him, bring him back there. Yeah, this is Jim again. You mentioned Arduino earlier. I don't use ruby to program the Arduino but I do use ruby to build the code that goes into there. If I could replace the main files with great files and in general anything I build like that I use ruby slash write to do that. If I could break something going on there that's a great point. I use rake for everything because I've really checked out rake. The thing you never see people using is rake file tasks. Those are awesome. You can use a file task and then give a block of code needed to build that file when it's not present. You can just do all kinds of things and check out rake's file tasks. Anyone else? I'm curious about what GUI libraries or framework people are using in ruby and I think maybe shoes are still around. The question was about GUI libraries and our good friend Uncle Bob was talking about Limelight, which is one. Other than shoes I don't know what else there is. Cherry and monkey bars, I think they're just making up names right now. Those are Java swing libraries, right? That's right. Then of course there's the old standards QT, TK what's the third of that? TK QT and TK the prize had a short Friday book on QT a while back and it seemed to get a little traction at that point and then just kind of follow up the map again and I kind of think because those older kids are kind of a pain they're about to use or not really can be. Shoes, I think Steve Klopman resurrected it and has been a lot of work on it so it is still around the minus there being that I think you're using a forked ruby interpreter in that case so there's kind of some penalties to add in. Oh, okay, I may be wrong. That may be old info. So those are the libraries that I love but yeah you know I think probably the swing libraries have the most uptake as far as being used. Yeah. That was the other one I was trying to think of. Yeah, exactly. All those old libraries. Okay, we'll take one more question then I guide the way you guys go. They'll be mad at me. Yeah, good bye. 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 does quite a bit of usage there thanks to things like Roboto and the aforementioned Android libraries. That's a good point. So what he was saying was mobile development which was mentioned earlier with Android and Android. Alright, thanks. Good, have lunch.