 Video equipment rental costs paid for by peep code screencasts Today's talk is about anvil desktop application framework in ruby Show of hands how many of you have actually done desktop application work That's quite a few quite a few that's impressive So the the goal of this talk is actually to get contributors So who's actually interested in desktop application work still good amount Okay, before we proceed Just wanted to do my little who am I plug this is me Actually my legal name is Lancelot It's not prefixed with sir, and if you don't believe me you can I'll show you my license after the talk Not quite as funny as John Clee is close, but not quite This is my consultancy. It's called ruby skills Shills, I'll have to fix that then And I'm actually I just finished or we're doing that we're in the editing phase on this book with Bruce Tate It should be released in October So for all the the new guys getting into rails, this is a perfect reference So back to The real topic This is the goal. We want you So what is it? It's It's common to say that it's an application framework, and when you define an application framework What is it? What is its goal? Its goal is to develop applications now. That's a very vague statement. It's in in this case It's also an integration framework It's taking all of the pieces that you need to do a successful application and putting them together At the moment there's a lot of fragmentation Well actually there's only there's only the one part that has kind of been fulfilled and that's the view part The toolkit part. There's no there's no hook into them to the data layer which on a lot of applications I think you deal with data unless you want to create, you know a timer application, which you can store in memory So it's an integration framework in addition to being an application framework These are the various GUI toolkits available in the Ruby space How many of you have actually used one of these? shoes WX Ruby FX Ruby What do you think of FX's looks? Cutie or cute. How do you pronounce it? I don't know GTK, okay Ruby Coco. It's kind of the same group. I see cool. Have you contributed to any of them? So the first one I'm actually gonna go into sort of an intro into where we are at with these GUI toolkits shoes is actually Very wildly popular toolkit right now in the Ruby space the premise is that you can develop desktop applications using a Ruby like syntax and With the the mindset that you're you're using sort of a web based layout like Some of the syntax Kind of resembles what it would look like in HTML like an image is The equivalent of an image tag is it just says image and then where the image is located So this is very elegant You're gonna see that some of the stuff that actually shoes was a huge inspiration for me for anvil Here's an example of a shoes app This is actually not one of the cooler ones. I just pulled this off the home page But you know, it's it's it's cool. It does it can handle Smaller applications. That's kind of what its use was for little widgets WX Ruby. This is what I started anvil on. It's a pain in the butt it has very C++ like syntax and I'll get into that later It also has some issues But they're getting there. Here's an example of a WX widgets application WX Ruby for all of you that don't know is actually a project that was created to wrap the WX widgets Platform which is already I think in C++ Python another example in Windows XP So it does it does a fair job at actually Emulating the native environment FX Ruby Now this one is interesting because I actually found that developing in FX Ruby Was the best experience I had at least from the syntax point of view Right You instantiate objects things are pretty clear, but it looks like this Right that that looks like Windows 98 Windows 95 We're getting bad So this is kind of what I feel about it cute Ruby now this actually the syntax was a little bit better All right, I mean just it's about it about the same status is FX Ruby is I'd say But there there are some pretty pretty big challenges to to actually get It to run on your machine if you're manually compiling it and But it looks really nice So I've actually decided to start developing in in cute Ruby first Because it I want to be crest cross-platform right off the bat And the goal of this is to really aim towards those enterprise guys Example of a of an actual a QT app that it looks really nice is Skype Skype is a QT app and it's cross-platform and I don't know it does does anyone think that Skype looks ugly This is KDE KDE runs on QT So if you if you can do KDE apps or if you can do QT apps you can do this kind of stuff It's pretty cool. There's no limit GTK is a actually pretty Small space. It's it's only for the gnome Windowing I Guess what would you call it? Manager, it's not a window manager. It's it's more of a style of desktop The syntax is not bad, but it's only actually that should be Ruby dash gnome to depending on Which version of gnome you want to develop for? But it's only for a certain a very specific niche, but there are people that like it. Here's an example of gnome applications So the problems The problems in the Ruby space Well, we have a lot, but I'm only going to address the ones. I'm Frustrated with in this space. We have a missing framework a Missing framework like rails like MIRB in this space. We're missing all the integration paths We're missing that that That thing that special goldmine Framework that that put that brings the community together and makes it really simple for the Average developer to get in there and start coding and get it excited about this because ruby is a beautiful language And actually we'll get back to that Another problem Toolkit identity crisis. It's pretty bad. I'll skip the slide so you guys don't have to look too much This is what I mean right Ruby doesn't have its own toolkit. It wraps everybody else, which is fine But this is not acceptable in my opinion If you're gonna develop in a language You need to follow the conventions Right They are trying they are moving in that direction still not what I would even even this instantiating objects and then saying, you know Title or text equals whatever I'll I'll get to the cool parts soon There's also a learning curve problem the majority of ruby developers right now and I largely Feel that rails is at fault our web developers and that's all you guys care about and That's fine But you can't neglect the power of client-side software and and there's several reasons why Here's one ego I love getting these kinds of pictures Right these guys everyone else is laughing at us Everyone Java has swing Python has a better implementation of WX widgets than we do We don't have anything solid yet So we need to catch up right now. They're laughing at us Small talk people would also say Of course, they've solved everything, you know That we're missing an editor and I would agree right how how did we fail? to create an Editor in ruby is it is it too challenging to create an editor in ruby? Is it Maybe there's not enough money in it but We're missing we're missing fundamental a fundamentally easy application to create and Extend right if if you have a ruby based editor the people using it Are coding in ruby and should know ruby and should easily be able to extend it the emacs developers use Use lists and they can easily extend their editor I think that you should you know if you're if you're stuck if you if you're in a language You should you should try to create your tool space around what you're doing and and be at least use the languages You're familiar with native client. I think it's ridiculous to have to have a client application that Looks like Windows in OS X. I think you should have a native environment a native client And I also disagree with the fact that okay, everything's going to the web everything's going to be a web application. We can just Completely make the browser do all of the heavy lifting we're treating the browser like an operating system and It's complicated it. We're we're stuffing These giant applications into We're trying to stick a you know a square into the a square peg into a circle one hole and I don't care how often you say that You know what everyone's shifting to web applications. I've heard that so many times But you cannot neglect the fact that there's still a client There's there there are reasons to to distribute some of that logic to the client and And you can you can create some amazing applications if you utilize the power of the client a Good example would be base camp and their time post to module Giving that kind of ability that the ability to from your desktop Record the amount of hours that you spent working Press save on your desktop and have it just send that to base camp. That's pretty powerful Extending your web applications like this for your customers is Going to provide a lot of value so some features and ideas Did a lot of thinking about this but I need I need some help on this not It's one one mind cannot think of all of these things This this framework is a very ambitious idea You and DHH didn't think of everything. I don't think one one key to success I think Will be being database agnostic and that's not that hard because We have active record. We have data mapper and we have sequel So I've already I've already seen that there's code that can do it and I think Plugging into that will be really easy Toolkit agnostic This one is a little bit controversial because Why not just wrap one toolkit? Why not just? pick one My argument is that None of the toolkits give you Exactly what you want You want Everyone has their opinion about how they want their application to look I don't want to limit people To one toolkit when they think well that that one sucks And if we can utilize the power of all of the toolkits and under one framework I think we are well beyond any other community Because we can say oh You know I can make a cutie app. I Can make a GTK app. I can make a ruby cocoa app Really quickly. I can take all of the business logic of an application stick it in a place in an anvil application and then and Then I can I can just let it run and it will it will use GTK It will use the native toolkit. It'll use whatever toolkit you want. I Think that's well beyond what anyone else is capable of capable of doing Plugins using ruby gems. This is not an old thing This is at MIRB Actually is exploring the space quite a bit It's I think fundamentally There are challenges to getting it to work as MIRB has seen but It's it's not a hard. It's not a hard problem to solve. It's solvable But I think that packaging plugins as gems is a better way Then packaging plug-ins and then sticking them in your vendor directory. I Don't know what you guys think take what you want leave what you don't MVC I Wanted to get the other picture the one where where controllers like but I Couldn't get the video frame to Guys should post pictures Model I already went into the details about being database agnostic I think that MIRB has already taken a pretty good stance on how to to to get this to work You just specify which Which ORM you want to use and then you can use that and then and then have your ORM decide in your database The animal file. Okay. I want to use postgres or whatever Usually in desktop applications. You want to use sequel light or something similar But all I mean all you just specify and then you you can have your model as You just inherit from Anvil's model class Not base Actually, yes I was gonna say you might yeah, you can't get away with that with active record because you have to inherit from active record base But not my fault Controller will be restful. Now. This is an interesting idea Why would you want Controllers to be restful in a desktop application when you're not confined by HTTP. I think fundamentally rest is a good idea I think making your M and your C just a service to your data is is is a good idea and that it forces you To be creative about the namespace and the business logic within your application rather than trying to just Get it done There should be more of a thought process There's some debate on this restful thing and I won't confine it to rest right convention over configuration but Fundamentally, I believe in rest even in the desktop application space That also helps rails developers because we already know how to do rest events similar to routes I'll get into more detail about that later and Delegation wouldn't it be nice to be able to delegate objects active record or data map or objects to a view and and just say render this kind of widget this pre-defined widget and then have it pre-populate everything else Powerful stuff Here's an example of a controller. I'm not stuck on this syntax, but I think this could be some powerful stuff Find all of your accounts delegate that object to the view Maybe it's a an accounts table widget and Then you just list all of your accounts in the view Pretty simple. Does this make you want to go and develop a desktop app? views There's going to be a standard DSL, so you don't have to worry if you're developing for cute cutie GTK Ruby Coco doesn't matter because it's all standard You worry about your business logic you worry about what you care about and that's you that's your application not This C++ syntax that in Ruby Kuby right they'll be reusable Like I said generalized and for the times when you have to customize There will be additional syntax to handle that because there are some native toolkit options that You probably wouldn't have in other toolkits That you might want to tap into Here's an example of a view I'm also not stuck on the syntax But it closely resembles Where I think will be Yes, but you'll use my standard DSL if you wanted to wrap shoes, which is kind of weird but you want to confine your business logic make that standard and Then not have to worry about what outputs at the other end Events this looks a lot like routes so Every time I click a button Maybe I'm gonna fire I fire off an event and then it handles it and it sends it to the show action on the Hello world controller Actually, this is the I knit Set up so similar to root in Rails When you initialize your application, maybe you want to create a splash initializer or You just want it to fire up the initial settings Code generators. I think these are important vitally important to getting a Framework adopted and making sure that these are up to date At the moment. I'm not so sure but You will be able to use the anvil dash gen gem. It's a plug-in testing All the fucking time our spec support is going to be included More to come soon. I'm an aspect fan If you guys want to integrate test unit or shoulda or whatever Sure packaging and distribution Now this is a problem actually that I Realized quite early going into this space Going into trying to figure out how to create desktop applications. This is similar to the rails problems We had with deployment Right. We were using dispatch dot fcgi you Right now we really don't have a good way to do this Wouldn't it be nice if we could package Your anvil application and all your business logic in addition to some ruby vm All of your gems etc in an exe or a DMG and Send that off and sell it. I don't know Where we're at with this. I've talked to Evan about it He seems to have some ideas We'll see But I think because we're web developers. We have not thought about this problem And we should I Was actually gonna I think I had a slide because I like inserted it after your talk Cool well send me an email keep me posted maybe you can insert a rake task into my project Open GL We can already do this But we don't have a good DSL for it, and I think there's some interesting things we can do with this Very intrigued to see what we can do with ruby to accomplish Cool open GL projects status quo I've pretty much finished the configuration and initialization classes and all that stuff. I Have a clear idea of how MVC is going to work the model has is missing But copying over some of the way Merb does it shouldn't be a problem controller that's There's only a few things that need to be there It's more of the gateway to the view But the view is a big problem because we have to wrap at least one toolkit Just to make sure that this thing is usable, and I'm working on Qt integration right now What's needed? Any designers in here cool Think you can Definitely need some contributors This is an exciting place. This is we Everyone is laughing at us like I said earlier because they're taking our our you know this whole industry and There's a lot of money to be had. Why aren't we there logo hornbeck hosting? So I'm gonna do a quick demo. So if you just run the anvil command should fire up your Environment this was actually originally Presented at you ruby con so I put Jim yrick in there back to the presentation. So you can see that you know, it's There's my demo And I'll show you the code in a minute if we can create the Trojan bunny and actually remember To be in the Trojan bunny for this industry, I think we will take them by storm And I don't think they'll know what's coming to them that they'll just We'll have more Java programmers. I don't know if that's a good or a bad thing, but we'll have more movement This slide came up because of you ruby con actually Neil Ford and a bunch of other guys were injecting Angela Jo Lee slides but So I had I have to tie it in somehow ruby is sexy, right if we create a Framework that is sexy which we've had we've done in the past People will love Programming again In deaths, I think Maybe maybe I'm being naive but maybe part of the reason people are scared of desktop application development Is because they don't enjoy it anymore and because I prefer blondes So contribute get off your lazy butt. Thanks And it actually I'm gonna show you Some code if you guys want There is a hello world and I've actually I've I've started I haven't gotten very far I I got a lot farther when I was doing WX widgets or WX Ruby Then I kind of tracked back because I was I just did not like WX Ruby. Maybe they've they've improved since then but So here's the hello world application that just kind of magically worked You have the application controller inherits from the anvil controller You have the hello world controller with an empty show because it defaults to whatever view you have Hello world and Then the show view This is empty, but this looks very similar to a rails app or a murbap. Here's the events Here's your init.rb where you will be able to specify use Whatever or M you want to use or And also specify toolkits. Do you guys have any questions? Maybe can you speak a little louder? Everything's gonna be a DSL to the view. So you I you would have actually a lot of the toolkits have native OpenGL support and That was G that was Gmail The Gmail notifier I Think that we will have a standard DSL for the OpenGL stuff And then that will just wrap whatever toolkit OpenGL we're using so cuz cute has its own OpenGL even Fox Despite its ugliness has OpenGL support I Think I saw some 3d models Any other questions cool if you liked my talk Vote for me on working with rails. I was number 69 I thought that was pretty pimp if I could preserve that I'd be happy but And then Ruby Anvil is the IRC channel Cool That's all I have video equipment rental costs paid for by peep code screencasts