 who else here considers themselves adjournment? Okay, quite a few hands. Who here thinks he doesn't know what adjournment means? Okay, so I always thought through hands as well, so it looks like not a lot of people thought into the idea of craftsmanship. But I'll tell you how I believe in the soft start craftsmanship, which is really just the idea of that. You couldn't shoeboard learning software development by following a formal process and say, I have a university degree, I actually have three university degrees and that was still not sufficient. We actually learn on the job every day through practices like credit programming and learning through mentors. That's what we need by craftsmanship. So anyways, the topic today though is about whatever happened to desktop development in Ruby. I want to give a short answer of how many people here actually do desktop development in Ruby today. Okay, so that's a little surprise. There's only two hands that went off. This is not a Rails conference, and yet I only saw two hands for desktop development. Who here has had any sort of experience with desktop development for any language? Okay, that makes sense. So the trend in the industry did move more toward web applications. However, desktop applications are getting pumped out every day. And then the best example of that is that Apple just opened a Mac store, a new online Mac store for the Mac platform itself as opposed to the iPhone or the iPad because the model proved itself. So those applications are being written. But why are they not being written in Ruby? That's what this talk is about today. People are using Objective-C, they're using .NET, they're using even Java, based technologies, but not Ruby. Why is that? So this has been my motivation. So what I want to do is basically go through... I want to go through the current frameworks and libraries that are available in Ruby and then cover these three specifically, Shoes, Light and Light and Blender, because these are the three frameworks that take the most advantage of Ruby in order to provide the development of DSL to simplify desktop development. Other frameworks are more like veneers on top of existing C libraries and such. So let's first start by talking about what desktop apps are just to be on the same page. So a desktop app typically starts without any online connection. Consistent widgets like buttons, texts, labels, tabs, etc. They can be maximized and stored zoomed, minimized, closed, so they're windowed in general. And you know, they usually are actually possible with an icon. My definition explicitly excludes full screen 3D games, how I deal with OpenGL or anything that's not what I'm talking about today. Widgets, gadgets. I'm not talking about that either and I'm not talking about grueless command and add applications. So what has been my motivation behind this desktop about Ruby? I've had about four years of experience doing desktop development in Java for the most part. I did a C++ before that but it was mostly Java. And this is an example of the syntax we have to write for a simple program that's as simple as the whole world. So as you notice, there's a lot of code over there. A lot of it is not necessarily relevant to the UI. There's a lot of boilerplate code as well. And then if you look at the code, it's actually imperative, so it goes line by line to describe as opposed to say something more like how people work with user interfaces on a web. They usually declare user interfaces with HTML in a hierarchical syntax that nests forms within divs, within body, within whatever. Just more visual syntax as opposed to imperative syntax. Alright, here is the WX Ruby which is one of the frameworks that sit on top of WX. Or it sits on top of existing older desktop library in order to let you write desktop applications with Ruby. And this is the newer sugar syntax which they actually try to improve their existing WX syntax and make it a little cleaner. But still, it's very verbose. It doesn't feel like they're pushing Ruby to the boundary of what Ruby can offer you. Okay, here's the example of the same example written with glimmer. There's a DSL library in Ruby that lets you write user interface code by relying on the Java SWT library behind the scenes. It actually runs on top of JRuby. That's how it works. If you notice the syntax, the words that are used are actually the minimum number of words needed in order to specify the user interface. Not no more, no less. So we got this shell text property that says lower with tackle. It's got a single label and then the text parties the labels as the lower. And then at the bottom there's an open method that opens it up and shows the window to the user. So in a way, this is like the minimum basic syntax possible or needed to specify the UI. So why shouldn't it bother us by any more code than that? I wanted to do this talk today in order to open people's minds about what possibilities are going on in Ruby as opposed to something like Objective-C. As well as talk about different frameworks and the leading frameworks nowadays and what they offer over each other. So this is just a brief overview of the frameworks out there. The ones I'll be covering on the three at the bottom. So Shoes. We have some of Shoes. Shoes is the oldest of those three and it was one of the first that actually tried to take advantage of Ruby's capabilities for building hierarchical DSLs that represent the user interface. So it was created by Wibrolacky Stiff and his thing about it was basically he hated all the other libraries and he thought they were really bulky and their code was not nice and didn't take advantage of Ruby and as well as he's not a big fan of the app look in general. So he wanted something that could enable more web branding or web design on desktop applications. That's why he created Shoes. So he actually wrote the native platform which is support from the ground up. So it supports the tackle as well as Linux. It's got to be able to field. It supports 2D drawing, animation and then applications are usually launched in the Shoes corner. So before I continue let me just launch a quick application and let's open up the Shoes. So when you install Shoes on a platform there's usually a Shoewrunner a Shoewrunner that actually comes with it enables you to basically right click on a Ruby file, say open with and then you take the Shoewrunner that's a clock, an animated clock and go back to the slides. So how does Shoes code look like? So the main application is declared Shoes.app and then attributes can be either set with hash keys hash parameters kind of like high to width or background is more set to the method approach. It's a different ESL style to background, RGB, etc. And then within it you can ask the different widgets they want to show like the buttons in this case and then there's the label of the log. There's also a paragraph widget which is the purpose of this talk is not to give you a tutorial but more of an overview so I will not be going too much to the details of how the syntax works but this is just a quick overview of how Shoes syntax works. So it's got weblike features they not only support buttons and they use them in faces but also hyperlinks it's got support for images and colors margin and padding so you can build desktop applications to have more of a look and feel that resembles the web as opposed to just a plain, great application. It only supports two layouts and I believe why did that for simplicity he thought he could lay everything out in two ways in one of two ways either a stack or a flow let's go over the layouts first so a stack layout plays things on top of each other it's as simple as what you see in the user interface a flow layout is more like creating words in a book things go from the left side and you go to the right and once they get to the end of the line they drop to the next line so why is the vision of this is that with a combination of stacks and flows you can accomplish any layout you want whether that holds up a practice I'm not sure if totally holds up but for the most part it works there are a few cases where that can cross the thing widgets supported by shoes or buttons text edit widgets product orders, scroll orders, dialogs and then there's also event handling hovering, leaving, clicking a table from trees I do not find support for them and these are the two fundamental widgets for business applications so that's one thing missing from shoes however shoes is still being maintained despite the disappearance of weather like I said and I've gotten in contact with the maintainers of shoes a few times and they're pretty prompt with their responses they're actually working on fixing quite a few things including the framework we already saw an example of animation so I'm going to throw too much into that shoes that work shapes paths curves and transformations one thing about animation is it's got this CPSL where you can say animation 8 I think that means 8 frames a second and then it runs in both that block every time then in that block you can do what happens on every frame that's how you can animate it so it's pretty straightforward to test this is a slide keyboard complex example open it up there you go so this is a slide keyboard I just wanted to show you you can do more interactive stuff too alright next framework limelight anybody here heard of limelight so limelight was conceived by Micah Martin he's a son of Bob you've heard of a very deliberate speaker on software best practices as well as software design and Micah's thing was basically he hated how on the web in order for the developer to get a job done as opposed to in the desktop world you have to work not only one language you have to do like five languages like you have to do the server side language the client side language there's the HTML language for the user interface the CSS language for the styling and then you know the SQL as well so his idea was Ruby is such a good language for building VSLs and a very good example of that is Rails 3's new support for example for SQL alternative where you can write your queries in Ruby syntax for the most part and avoid SQL unless you need a very deep customization so Ruby is a great language for facilitating the ability to write code in Ruby yet be able to process things like user interfaces queries many other things so why does the developer have to work with five languages and in my mind what I agree with him about is that developers accepted what they were hesitant because of historical reasons we were handed JavaScript because of historical reasons and however for any reason Ruby was the language of choice we would have been doing Python today on the browser on the client side web applications otherwise Ruby was the language of choice we would have been in heaven now we would have been doing Ruby both on the server on the client in fact I've met a developer his name is Chris Powers he's actually building a server side framework in JavaScript that lets you do an MVC to minimize the server side code in one language the reason that's important is really to minimize friction because the more things you have to put in your mind as a building software the more friction is in your head and the less flow you will have as you're working so in a way it kind of drives down the productivity so Maika came up with this theater metaphor to make desktop developers a bit more fun as well as well to encourage developers to think more about interactive aspect of it so desktop applications in this theater metaphor can be thought of as productions that consist of stages each stage is a window we're here so stages define windows and then each window has scenes scenes are transitions in a stage that happen on the stage and scenes usually consist of props so props are the widgets that you see on the window and then styles so styles are kind of like the CSS as well as players players are actually the models that pack the props in order to get the job done so this is very comparable to does that remind anyone of a pattern pattern that everybody follows in the software development so it's pretty much an analog to NBC except that's more tailored to the interactive desktop applications so what he did is he basically allowed the ability to build all those layers in pure Ruby so he can build the user interface in Ruby to replace HTML he can do the styles, he has a CSS like syntax in pure Ruby as well and then you can build the models in Ruby which are the players in this case and as well as the and then you can configure the app in Ruby that's kind of like how Rails does your part in RB, Limelight also gives you the files like environments in RB to configure that with Ruby as opposed to the Java world X amount this framework also supports Ruby in animation and applications are launched with the Limelight command and it also offers a platform which supports the Java Swing library so it also runs with J-Luby so let's open a quick actually I don't know if it works yeah, it's just a support app something special however, if you want to think of it as a production the window is the stage the buttons are the props and then there's players that back the props basically and perform the logic that happens when we press the buttons so let me go over the quick basically so if you look at the folders structure so focus on passing later production in RB is the file that defines the application so that's kind of like environments in RB in Rails stages are the defines the stages so these are two configuration files the purity and then you got a fold and directory per scene there's only one scene in this case it's actually a directory per stage so I don't have to say and then props styles of players so let me open and start looking so this is the props this is the interface this is the styles that's like the CSS button in RB defines the model that backs one of the buttons and then here defines what happens when you click the mouse this is an example of stages in RB which defines the stages and production in RB so useful commands in limelight are limelight create is like the generating command in Rails it lets you generate the limelight structure for you limelight open launches the app limelight app is very interesting it lets you package the app to be able to distribute it without people seeing your ruby code what's nice what's really nice about it though is the ability to launch out the dishes over the web you can package your limelight as an LLP file put it on an ACP server and then give people an LML file limelight hit file and then if they call limelight open production.lll which contains a URL to where the LLP file is and launch the application over the web let me demonstrate there's one file called playbuilds.lll that's launched there you go so this is an application that was launched totally over the web it actually also gives you this app is built to demonstrate other apps so it lets you also launch other apps hangman is actually one of the nicer more interactive apps that are built for limelight that's an example of an interactive application let's go back all right glimmer so I actually wrote glimmer a few years ago because I was very unhappy with the way we wrote code and java for my project and I really I was jumping on the rails back then in my impact at the time I was very interested in ruby and I wanted to bring what ruby gets rails to the desktop room and I saw shoes it was a bit unhappy with the fact that shoes wasn't very business friendly it was more about interactivity less about business applications my work in desktop was mostly about business apps I did not care as much about looking field and branding I really cared about tables and trees being able to represent data without writing a lot of code so the key thing about programming is model view presenter pattern and sometimes a variation of it is called model view view model pattern so I wanted to have built-in support in order to do that I wanted to add data binding support to a framework in ruby that has the smallest syntax possible for user interface offering so I was built on this SWT library in java which gives a native look and feel it's got data binding support and applications are just launched as regular ruby or j ruby applications so data binding lets you buy fields on a form to fields on a model it's that simple it's kind of like data binding in rails except on the desktop it happens bi-directionally and instantaneously there's no on the web you usually have to submit a page for data binding on the desktop as the user is typing data is getting transferred to the model media team and then as processing on the data in the model happens it goes up on a view media team so as a developer you don't have to manage any of the data transfer between the model and the view if the data binding was intact this is a more sophisticated example this is where it really shines the desktop development I remember writing pages in java to get a table to display data from models like seriously it was a page with no exaggeration it was like some of the hideous most hideous code that the goal I delivered was basically dividing it with one line where you just say I want to bind that table to this collection of models and I want the columns to come in this order that's it so that's what Neumer offers a short and very quick example so let me first show you the code so again you start with a shell the composites are like this and then we have labeled text, label text we're using the SMBT grid layout with two columns so if I were to look at the user interface it's laying them out in two columns and then afterward the table shows up that's the table it's got three columns first pane, last pane, and email to specify the width for each finally this is the one statement that does with that binding that's all you need to make it display the data as well what we're saying here is bind the items of the table to the results collection on the presenter model with this order with the power properties being ordered this way so these are the properties that get picked up from each instance of the results meaning each one of the rows and half the table so from that point on if I go and hit list meaning list me all the contents or if I even filter and then type find the code doesn't need to update the view explicitly because binding takes care of that all I have to do is invoke the list method on the model or the find method and then the model can be completely oblivious about the view not even know about it so if we already open the model it has no reference to any of the widgets any of the views so it's completely decoupled and clean and focused on the business logic that's just performing the find operation or in the case of lists it's just listing all it does is it updates the collections value to the new rows that should show up to the user and binding takes care of the rest so that was really the key goal about Bloomer is to have as clean separation as possible between logic and the view so that by the way that supports all the basic widgets or basic fields effects, buttons, thinning, other things power box contents and selection are supported list contents and selection, single or multi table data loading table selection is not supported yet means if you want to select a row or select a cell that's not supported yet and Tweet Tweet and binding is not supported yet these two things are in progress it's just a resumption of the model view presenter pattern or model view view model so what happens is that instead of basic MBC there's a mediator that performs the binding between the view and the model so it's something that sits in between does the binding that's just another example I'm not going to go into it so let's not go over a comparison of the pros and cons between all frameworks because each one of them offers things that the others don't so let's see let's go over that because that'll help you figure out what you want to pay for your next mini project or bigger project depending on your needs so choose is the easiest to get started with it's got it comes with a package that lets you package your apps and distribute them easily I haven't played with it myself but I know it's there I've learned my colleagues used it quite a bit syntax is straightforward 2D animation support is nice and that builds it to grab your applications so that might be fine but that's not the problem what is missing support for updating attributes on widgets is a bit restricted so you couldn't update the text of the bottom on the fly dynamically that was true a month and a half ago I reported it to the maintainers of the project and they said they haven't just like to work on it there's no support for choosing tables no built-in support for application modelization if you're a very comfortable web designer or comfortable with structure programming and you know how to break your app where your code is not manualed you'll be flying regardless of that but otherwise choose doesn't give you a pattern like Rails gives you and we see in order to support your environment or like Vibranth gives you the here the metaphor or dilemma gives you the data binding support so often choose programs that I've seen as far as mixing logic concerns or view concerns so that's something to watch out for now some of the samples I ran crashed occasionally and maybe once ended in their logic and not necessarily the shoe score but since it's only stuff I couldn't tell so I have to put that on okay, light light it also has an aperture as I've demonstrated it's the one that actually has an application so you can be able to point it online separation of styles and layout you can do it with a CSS like syntax I'll do the architecture with the theater metaphor and then building aspect support with a generator launching apps over the world Theater metaphor can be a bit daunting to live in here but otherwise it helps if you're building a bigger than a small like not too small application it's reliance on swing makes it use potentially a lot of memory that's something to watch out for it may not be a problem but it's just something to watch out for also on Windows and Linux swing doesn't have many different fields glimmer syntax is very minimalistic, makes me a follow data mining support and MVP pattern I think makes it glimmer on glimmer as far as business applications are concerned especially if you write on the logic test first and you want to keep it as cool as possible for business applications now it's not my forte to automate things like how to set up glimmer on your machine so I don't have a one click installer so if anybody would like to open that I'd appreciate that so I would say glimmer is not as easy to start with as live life for shoes right now just because you have to deal with bringing the SWT library separately and piecing things together before you can use that as an example data mining support is still incomplete no T support for example there's still no official support for DSL and 2D animation it actually comes with SWT so you can get access to it but there's no DSL for it and that's something I've experimented with in the past I haven't released any version of it yet I had a syntax that was similar to jQuery syntax for animation at all points but I didn't release it because I wasn't happy with it yet that's it if you have any questions hit me up on Twitter or just check out the blog with a lot of information about the project over there thank you everyone thank you very much