 So for those of you who don't know me by now if you've not sat in on the code immersion sessions My name is Pat Maddox. I am primarily a Ruby Rails developer who at some point in the last six months or so discovered seaside which This is not doing what I want it to. Oh Well, I'll do without it so Seeside is a web application framework that came out or at least heard about it roughly the same time that rails did and for a number of reasons Rails gained a lot of traction, but seaside didn't quite so much but it turns out it's a pretty remarkable web framework and It's got some really unique features to it that you won't find in rails development and in the same way that rails Made a lot of things simpler about web development in general seaside Makes simplifies some other aspects of web development as well that are kind of difficult to handle in rails, so Just a quick overview it's a web framework, like I said, it's open source just like rails It's MIT license that means that you can take it use it in your own applications build upon it Use it at your business without any worries It's written in small talk. How many here identify as small talk programmers? two Two in the crowd. All right well, you're gonna find that small talk is a Beautiful language it beats the hell out of objective C as we're gonna see in a minute Trust me, I it's not even close I Small talk is or seaside is component based so instead of Setting up controllers and actions and requests and parsing stuff You've got components that manage their own state and pass control from one component to another similar to to trellis that the Brian talked about earlier today and then finally it uses continuations and By using continuations it manages a lot of your application state for you So that you don't have to be dealing with stuff in the session So you don't have to deal so you don't have to stuff things in the database in between requests and ultimately It allows you to write code that expresses the flow of your application So just to show you a quick. This is the canonical seaside example a little counter This is a fascinating web app, right? It's something in the browser You see we click a couple buttons and a number goes up and down So how does that actually get done? How are we incrementing and decrementing that number is it done with hidden form parameters or query parameters? Well, if we take a look at the HTML generated by By the little app that I wrote you'll see that it is pretty much what you expect We've got a we've got a header that shows the counter Number at that point line break and then we've got two links and the links you'll see have Very interesting URLs them probably ones that you were not going to sit out and code by hand, right? You see it goes through the slash WRWC counter has s query parameter and a k query parameter these correspond to the session and then a key within the session so kind of Well, it's actually the continuation key So at what point in the application session do you want to enter? So this will make sense in just a minute, but The important thing there is that we're not passing the value anywhere in between a form or even the query parameters We're not seeing zero. We're not seeing one. We're not seeing whatever. It's saying here's a session Here is the continuation key so It's managed in the session right, but If that's the case if we're just storing the counter ID in the session then How Do we do this? How do I open up a new tab in the same browser and You know increment my number here run through the counter example a little bit I can go back to the first instance of it Change the numbers in there and then I can go back and change the numbers. They're completely independent from each other So if you're used to Writing web applications where you store state in the session then you typically put you know a counter variable in the session And then you would look that up and then you would change it But in order to have two of those you need to do some special session handling right? You need to say that okay upon coming to this first page look up the first Counter or create a first counter variable in the session and then the second one that comes to it create a second counter variable in the session and then I To be honest I'm not entirely sure how you would do it because you would then need to encode at least something you would need to encode the Particular session counter ID that you're using in the URL so it knows which one to look up and that's what we deal with in a Rails application This is an example of the typical request response cycle that you'll see in a Rails app Client makes a request of the server the server loads any necessary state that it needs to process the request Then it handles the request it ships off a response to the client and then the interactions over done any state that exists at the end of Of this interaction then needs to be saved to a database or it needs to be stored in the session It needs to be filed out to this it needs to be saved somewhere so that when we make the next request the server can load the state again Typical stuff no surprises there. Well, we need these continuations that works a little bit differently Starts off the exact same way client makes a request of the server server loads the state processes the request and then sends a response back But now instead of ending the interaction it basically sits there waiting and it says okay after we've done this response The next line of code would be this or the next potential branches of code are these different ones? and it sits there and it waits and So it closes over the state just like closures that you're used to in Ruby It knows about the state at that point So when the next request comes in instead of starting at the top where it says loci instead of like fetching state from the database It basically starts at the bottom again right where the previous action left off so that allows us to write very clear Very clear very simple code. This is all the code that I had to write for that counter example now granted It is a very simple example but I just talked about the problems with Handling multiple counters in the session that you would have to write some kind of plumbing code to be able to look up Which counter I have to pass in a particular key This is all the code that I wrote to be able to load up two counters I can put five counters, you know, I can load up as many sessions as I want and This is small-time code. We're gonna look over the syntax in a little bit but as Ruby programmers I think that you know except for some of the specifics of you know How assignment looks and stuff this is should be pretty readable to you guys Right, and you'll notice that this is just a very basic class with an initialized method We've got an increment and a decrement method on it that increase and decrease the counter And then finally render content on is the method where we actually generate an HTML view to return to the client and You'll notice that all the HTML is generated programmatically using small-time code So we say I want a heading that corresponds to an h1 tag that we saw earlier a break is our br And then finally we have an anchor with a callback Now this is kind of interesting because the callback takes a block so the code inside of the the square brackets is a block in in small talk and So basically what we're saying is generate a link that when pressed Executes that block of code the semi-colon is For cascading messages, we're gonna look at how messages work just a minute But basically when we call this HTML as an object that represents a render anchor is a method that creates an h tag Callback says you know what's the action that you're gonna do it and then when I use a semi-colon the object that like When you call messages in small talk So we're sending the anchor message to HTML and then the callback message to anchor But now once callback runs if we put a semi-colon on it That means that the next message that goes through gets sent to the same to the same previous object that we use So in this case, we're sending two messages to anchor We're sending anchor callback and then anchor with okay, right? and so the the important bit here the interesting bit here is The callback and the block saying that when I click on this link execute this block of code That's pretty powerful stuff now one of the things that you'll find in dealing with web applications is Users hit the back button and how are you supposed to handle that? Well, let's look at this really basic example Again with the counter if I increase the number to six and then or five and then ID I hit back a few times Now I want to hit the plus link What am I gonna get on the screen? Evan says three any other guesses Six six over here. So we've got three and six raise your hand if you're in the three camp handful and six Smaller number, but the six is have it Now why is that well, let's look at a If I were to do this Exactly if I were to do this in Ruby, what would it look like this is if I have a counter control And I've got two methods on it increment and decrement And I call increment five times on it now I have saved in the database a counter with a value of five when I hit back a few times the Server or the client doesn't send any request to the server at that point It doesn't say now that I've hit back back decrement that number. We have modified the state in database So the next time I send Increment to it it increases it to six. Does that make sense? Is that clear no surprises there, but what if We do want it to be three So I got to six. I hit back a few times and then I hit plus. What if I want to do that? that you can imagine is a Very reasonable way to approach Application development that when I hit back I transition back in application state and then so I basically reverted the the changes that I made up to that point a Good example of this It remembers the state of the page at the time so once I go back Now I say when I click plus on it says okay using this continuation key now You know it we know that it's three at that point that I rendered this page So when you hit plus then it should now or sorry it was to now it should go to three Well, you are always passing the continuation key, but you never do it manually seaside handles all this stuff under the hood you never I Pretty much never look at the session key or the continuation key That's in the URL that's in the URL and the continuation key is actually the exact same as it was before so none of that changed the only difference is in How is it how I configured seaside so this component that I had now? It's that it tells seaside keep track of my states So every time I render a view these are the states that I want you to know about just in case somebody goes back okay, so this is of I Guess this is you could say That's the next slide well obvious This is one of the concerns that you have as an application developer how do you handle when somebody backtracks and there's not necessarily a correct answer in all cases most frameworks that you use Sort of push you into an answer and they don't give you much freedom With respect to how you want to handle this and in fact you'll look on many applications like loan applications There's stuff like that that say explicitly say don't use the back button here is a link to press if you want to go back Well, what happens if the user presses a back button, right? Then you're kind of host you know the example that I like to use is what if you're building a Web console for the president of the United States and he has two options He wants to perform on a country. He either wants to drop nuclear weapons or he wants to give them medicine and food Well, he acts he clicks on nuclear weapons in and his advisor comes in and says you know what that might be a bad idea But so we added the nuclear weapons feature to our aid package And then he hits back and then he chooses okay Let's give them medicine and food when he hits forward again and submit there's gonna be two things on the server State there's gonna be nuclear weapons and food so it's like boom Here's here's the medicine, right? You would like to be able to avoid that situation So seaside calls itself a heretical framework. This is from a great Simpsons episode called Homer the heretic Yes, yes when dealing with nuclear weapons always have test cases Seaside calls itself a heretical web framework in that it sort of shuns Some of the best practices that we have adopted as web developers for the most part it does not care about Fancy URLs about pretty URLs if you notice in the world has the session key It has the continuations key if you are making a product catalog for Sony and You say that the URLs are slash products underscore s 40 characters Underscore k another 30 characters. That's not going to fly right Seaside for the most part doesn't care you actually can send back pretty URL So you do have a nice URL in the browser that people can share But sort of the basis of this is that if you want to do crud if you want to do basic Websites if you want to just do resourceful stuff then Seaside is not that's not really what it's designed for you. Don't need continuations to do that You need active record. You need resource controller It also Gets away from the whole shared nothing architecture. In fact Seaside basically says share everything seaside is maintaining all your state for you So what that means is I can't go to one server and make a request and then go to a second server and make the following Request like I can in rails right in rails I can load balance across a whole bunch of different servers and because they all point to the same data set and because they all have To fetch every single bit of information they need to process a request on every single request I share none of the data so I can point to any of the servers. I want seaside on the other hand Because it maintains all the session state if I go to server one for a request I have to go to that same server for my follow-up requests now that Sounds crazy. And how do you implement that it turns out that load balancers have done sticky sessions for like 20 years so all you do is Set up your server farm throw a software or hardware load balancer in front of it turn sticky sessions on and You're good. So Doesn't care about clean URLs Doesn't follow the shared nothing architecture and then it makes some other opinionated decisions like how you generate html Which you saw it's all programmatic. How does that fit into traditional web shop? So why? Should you care about learning seaside? Why are you interested in this? Well? Why am I interested? I'll be honest when I first picked up the seaside book. It's a free book online. I Pretty much didn't talk to my girlfriend for a week It was and I you know by Wednesday Thursday I was finding movies for her to go to and Going online to movies yahoo.com and buying a tick for her and her friend So they could go hang out for the evening and leave me alone to code on seaside So the first first aspect of it is it is fun And it is addictive and it is cool the whole environment that you deal with is is an incredibly fun refreshing environment to develop in which is Which is kind of a weird thing to say that it's refreshing given that it's like 20 years old But it's fascinating to me that modern languages Still haven't really caught up now This isn't gonna be like a seaside's amazing everything else sucks thing because I still love coding Ruby and Rails But as you use this you're gonna see some cool new techniques I think it's very mind-expanding Sort of framework and gives you a fresh approach to web application development plus you can integrate it with your existing rails Applications and you can use it for some of the things that seaside is really good at that rails is not particularly strong So there's a lot of reasons use it, but honestly I say why not like rails is already a very heterogeneous Ecosystem we have different data stores are coming up now everybody's all on board the no sequel train You know there's what nobody I mean It's only very recent that people are using Apache to deploy rails stuff anymore We have a lot of alternatives in pretty much every single part of the rails application stack So my question is why not offload some of the business logic too? And that is where seaside shines is doing the business logic and also some really cool stuff like the Ajax support in seaside Is kick-ass and comment if you're not familiar with that basically allows you to open up a connection a persistent connection to the server and and and ship out Ship out content to all the clients that are connected to it. So basically a Real-time Internet chat program in seaside is four lines of code Unfortunately, I don't have that example, but Well, it is in that it's in the seaside books if you want to go to seaside But go to the comment chapter write it and then we'll hook it up, but I've got to get through a lot of stuff here, so It's really cool, but I you know I say why not give it a shot and Just for fun as a little example I showed those components how I can open three different tabs and do Counter side-by-side Well, here's those same components in a single page and you'll notice okay I increased that one right not too exciting But then I go to the second one and I see the first one keeps it state And then I can go to the third one. I can just kind of go back through them And I can Know follow any of the links in that component that we wrote earlier in the 13 lines of code to handle that Well, what so these components manage their own state every instance of that counter is a different instance of the component And it manages its own state It knows about its own continuations and the program that I wrote to do that three counter thing is this it's another what Nine lines of code right and I say so in my initialize I've got my multi counter page You know, it's really fancy and so I've got a list of counters I create three new counters and then when I render the HTML, I just say okay go through all the counters and tell them to render themselves and In doing that and I maintain the state so I can use the back button right We saw how I can use the back button and keep the state even once I've used the back button because seaside's handling the Continuations for us and managing the server state and so I Is that interesting to anybody is that cool that I can create that one component? I can reuse it in a completely different context and they all manage their own state and There's no mention of session Anywhere there's no mention of cookies. There's no URL parameters. In fact, it looks kind of like an application Go figure that is basically seaside's point is that instead of writing code that is You know process a request and then Process another request and how does all this stuff fit in together? If I've got workflow through an application, I want to actually see that in the code I want to represent it in the code and the fundamental difference between rails and seaside or basically anything any other web framework any Traditional framework anyone that doesn't use continuations Is in rails you're saying? Give me a link and then it has a URL so now the browser knows what you're well to go to next but in seaside You're saying give me a link and when I click this link execute this block of code This is obviously ruby code, but imagine how cool it would be in ruby to do that second line and you actually can there a couple Continuation-based frameworks. I think Idaho is one. Is that right, right? Iowa Iowa, and then then there was another one. I Don't know that I won't lie. I'm from California. The states are the same to me so Okay, we've had a little taste of seaside You know it's that little taste of the drug that makes you want to learn more before You can code seaside. You have to learn small talk small talk this big massive massive language Java 1.5 has 50 keywords Java 1.4 had 49 keywords. So feature bloat from version to version Ruby 1.8 has 38 keywords Small talk massive beast that it is has six and in fact it really is five It has self super true false and nil and then in modern Implementations of small talk it also has this context and in fact these aren't actually keywords. These are pseudo variables There is not a single keyword in the entire small talk system everything is an object and Everything is done with message sense. This is not particularly exciting to to rubies but when I say that there are no keywords in the system these are pseudo variables that the that the Virtual machine optimizes it optimizes nil optimizes true if you turned off optimizations you could change What nil is or what nil does and what true and and false to and so it's kind of like opening classes in Ruby, but but on a much deeper level and you can call Anything whatever you want because hey, there's no reserve words So small talk has support for littles everything's an object, but certain things are represented better Typically is literal so there are numbers and there are fractions. They have fraction support and there's decimal support this 85 at 26 is a point or a coordinate. I don't know if this is an all small talk, but it's in Faro and Squeak Dollar sign is dollar sign P represents a single character a String is delimited by single quotes and only single quotes And so if you want to use a single quote inside of a string you use Double single quotes and it took me about three minutes to get over that I was like that is really ugly and then it turns out it makes a lot of sense. It's cool hash and parentheses gives you a literal array and Finally, there are symbols provided with with Hash and a name works exactly the same way as symbols in Ruby and finally follow it up with comments, I guess you write comments and they go in double quotes Assignment in small talk is just slightly different than Ruby instead of an equal sign you have a colon and an equal sign and you can assign to local variables or Black-level variables or instance variables And that's pretty much it those are the variables Messages everything in small talk is done via a message send so it looks pretty similar to Ruby Except it doesn't have a dot well It looks similar to Ruby until you get to the third example, which is my favorite part of small talk Maybe which is something that objective C has but clearly not as nice So first three types of messages in small talk one is unary It is a single object receives a message with no arguments and nothing else to it So you see we can call one two three at string and it returns me a new object That is a string representation of the number one two three There are binary ones which are typically for math that are an object an operator and another object and then finally you have keyword methods the Method name in small talk is called the selector and in this case the selector name would be called between And and the two arguments that it takes Are our one and two hundred well of one hundred two hundred I mean it can be anything there right so that the part of the selector is a between colon and the ant Colon and though that message is sent to the object One two three now this is not like Ruby where it's a hash and you can just kind of pass whatever the hell you want to it The message name the selector name is between and it is only between and and it must come in that order And it must have those arguments So you have positional arguments like you have in Ruby when you call a method, but you also have keyword arguments so the Method is not just between one hundred comma two hundred something that's just you know difficult to understand when you've got a few Different things you actually write method names that read out nicely and then last little bit This is a cool bit of small talk syntax is cascading messages I whenever this briefly I send the paragraph message to html and now if I delimit it with a semi colon The next message I send will be sent to html as well And I can mix up any of the messages that I want so you see I'm sending three paragraph messages and finally Horizontal rule so this is a way to very concisely call multiple methods in sequence on a single object Blocks in small talk, of course first-class citizens just like they are in ruby although They are I guess even more first class because you don't have to do any kind of conversion from a lambda to a block You'll notice there's no lambda here anywhere. There's no conversion a block is Square brackets and in ruby I can evaluate a block by calling block dot call in small talk I do it by calling block value and You'll notice in the first example I assigned it to a temporary variable to use so I could call it but then my second example I just call value directly on the block and we see first and second those are your block level arguments that's what gets yielded to the block and I pass those values in by using Value colon so I'm saying this is a block that has two block arguments I want to call it and put one into first and two into second and then it returns the value of those two Yes Yes, absolutely And then blocks get passed into methods, it's very very common just like ruby I've got an array one two three and I pass it a block Collect should look familiar to ruby programmers So some things to know about small talk structure. It's class-based single inheritance Pharaoh and squeak squeak is a VM Pharaoh is a prettier version of squeak Basically could squeak was built to teach kids how to program or to let kids use computers And it turned out it was a pretty good tool for building real applications But people didn't like looking at orange and blue and yellow and big round fuzzy Things and seriously if you look at squeak, it looks like that Pharaoh is a far more professional Implementation, but it also has some really cool tools to it and it and so it has mixed it has traits Which is not a small talk standard thing. It is specific to squeak and Pharaoh There are implementations for some of the other VMs like gemstones so you can write portable code, but porting code from one VM to another is doable, but takes time Methods in small talk. There's no notion of public private or protected you can send a message to any object that you want and small talk programmers had this incredibly clever way of Figuring out how to not send private messages. They have what are called protocols, which is basically a tag It's a group of methods that Literally say like these methods go together So when you want to do this kind of operation on an object deal with this stuff So they create a private protocol and throw everything in there The point being that you can call a private method if you want to if it's in the private protocol small talk does not care, but Fair warning it's private. It may change over time So don't get to use it, but there's no notion of public private or protected no method access But everything is done via message sends you can't Do except for except for assignment you've got you've got three types of operations in small talk You've got method returns. You've got assignment, and you've got message sends and That's it. You can't dig into an object and get its instance variables like you can in Ruby, right? In Ruby a I can call a method to say give me that particular instance variable and I can dig into that But no way to do that in well actually, I'm sure there's a way to you can do everything in small talk You do have attributes you have instance variables, right so the the the instance and The the object structure is basically exactly the same as what you're used to in Ruby You have classes create objects objects have instance variables, right classes are objects And small talk does a very similar thing to Ruby and how it does the whole well Okay, if class is an object, then what is its class and what is the object type of that class and so Similar thing in in small talk So even the control structures are done be a via message sense. This is if and else in Small talk I say some number is that odd if it's true Then you know evaluate this block if it's false evaluate that block same thing happens with Ruby blocks aren't Whatever's in the content of that block is not evaluated until that block is actually called one cool thing You'll notice here is this is a single method with the selector if true it falls, but it takes multiple blocks So I can pass around a block anywhere. I can pass in any object You don't have special syntax like in Ruby for passing a block at the end of a method which Limits you by only being able to pass one block So if you want to have even more callbacks, you know, then you have to use lambda or you have to do all kinds of weird stuff But this if true if false one of the simplest Constructs in any language that is always always always implemented as keywords and as as special language constructs Follows the rules of small talk and then there's an object and there's a method And so if you were to do this in Ruby, this is what it would look like It's very simple under the hood. You've got a class that represents true and a class that represents false and The if true and if false methods both take blocks and Ruby I'm you know, I can use an implicit block So I don't care for the ones that are no ops, but I say on the true class on if true call the block But obviously the false class is not true. So they don't call the block that's passed in right? This is how small talk does True if and else Another difference the final I guess the biggest on different small talk is image-based so instead of having your source files and then Running them inside of an interpreter or having a compiler run and starting up a runtime Small talk is an entirely self-contained environment So the code and the runtime and all the tools to operate on the code live within This same environment. We're gonna look at what it looks like in Faro in just a minute But that is one of the things that is both a strong and weak point of small talk if you use Emacs or Vim and you are just so in love with them Then you are going to not like small talk quite it won't be as accessible to you I really laugh when people have Vim and Emacs Wars because it's just like you realize that both your editors Suck and Don't know anything about the code. They like sit and they parse. They're glorified regular expressions with with event handlers, right? Like that's what that's what Just wait so the Objects are living at runtime too and you can actually file them out So when I'm working if I create some objects and I'm just messing around with them They live inside of that image. So when I save my image, they all get serialized under the hood without me having to do anything So when I load my image back up all those objects are still there So small talk is a very very living Organic system. I guess you could say one of the cool things with Ruby is how discoverable it is and how much I can mess around with stuff on small talk because it's image-based and because the objects that are always live at runtime I can do some pretty cool stuff with it so the Environment that that I use and that you'll probably want to use is called pharo You can find it at pharo project that work or pharo dash project that work and this is what it looks like This is your small talk environment laid out so that I have the important tools up there although constrained to Relatively small monitor and not laid out nicely But I have in the top left my code browser in the top right a workspace Which is kind of like IRB, but more awesome test runner to run my unit tests and then Monticello Which is the version control system for pharo. We'll look at all these in detail This is the runtime this is the editor this is the data. This is the refactoring tools. This is this is it When you do not squeak not squeak, right? This is they took squeak and they made it good for for real programmers Yeah, they added a lot of tools like auto completion and stuff like that so out of the box It's a good development environment good developer good environment to develop in So the workspace like I said kind of like IRB. I just type small talk code in here and Then I can evaluate it so I can do stuff in here like this is my little sketch pad right when I want to Mess around with small talk. I do it in the workspace and I can just execute whatever code I want in there So there I was just messing with an array in this case I want to Assign a string to a local variable or a temporary variable and then I want to call the as uppercase method on it to To see what that does so this is you know when you're just playing around with stuff trying to to understand how some of the objects work then You use the shout workspace so it's like IRB in the sense that I can evaluate code in there, but The code that I run in there actually state like any data changes that I make like creating any objects are Stored in local in this workspace so I can reference those in subsequent Subsequent messing around it and playing with code and this is actually a really cool point to start your test driven development You write some code you copy it into Into a test case and then run that and go So it's fun. This is the class browser This gives you access to all the source code in the system and you see that on the left there We have the classes for all of the code. This is the entire VM Everything that implements everything including how message sends are done Including how collections are done all the way up to higher libraries like database access or seaside and eventually my own applications The refactoring tools are in there I'm looking at the protocols here that I mentioned and you see on the right that shows me the methods that belong to that protocol so I'm gonna scroll down to some code that I wrote and You'll notice like here's the class. I've got some buttons here that show me some stuff. I can look up my class hierarchy So I can say I know that I've got this RWC counter. It inherits from WA component There's the entire class hierarchy and on the right. I've got the methods that are defined in each level of the class hierarchy So at this point, I've got an insane level of Discoverability here. I can look at the variables that I have I just click in the variables and I see where they're referenced to So I've got a count variable that is referenced inside of render content on And it's also referenced and initialized and then increment and decrement and those I can basically keep following the chain And I say where is increment called from whereas render content all come from and I can start to explore all my code and really find You know find what I'm looking for or a lot of stuff that I'm not looking for I Can look up all the different implementations of a method name So this is every single implementation of that method render content on in the whole system So if I want to see how other classes implement this method, I can do it and then finally We're looking up inheritance Is that what that says I totally lost Track of what's going on right now. I Don't think that's that cool. So I don't know why it's there But I can look and I can see everywhere that render content on is actually called from So I've defined this method one of the cool things is one of the questions is now that I've got this method Where is it actually called from and here is every single spot in the entire VM? Where the method render content on is called now I can actually scope all these down I can say only look within this one package so I want to know where this method is called within this set of classes and that allows me to basically track down all the areas where Where where my method is called and what might be affected if I make changes? So that's a class browser it is You'll notice in the bottom pane here. That's actually where you edit your code That's the whole code editor for small talk when you click on a method It shows the method in the code you don't have really big-ass long source files And you can't get big-ass long source files. It's individual methods one at a time I'm going really fast. I might have missed it when I look down for just a second, but Do you have that's not a question, but Ken can can pharaoh show me where classes are reopened and methods are redefined in order So I could see for example all the monkey patching that may have gone on a particular Monkey patching as it exists in ruby is not quite the same in pharaoh What you have are okay? Well one cool thing is if I look at I was gonna stay away from line coving because as much as I like it I always screw it up one thing you'll notice here render content on has a little up arrow That means it's overriding a method from the superclass There's a method in somewhere up the hierarchy called render content on we're overriding it Similar thing happens if I go up the hierarchy and look at it I look at render content on it'll say that some class overrides it I well Sort of and I haven't used mixings in it So I don't know the answer to that so much what I do know is I'm trying to find if If I can find a good example of Wait, I have to pick the actual class so Okay, I don't have an example that I can think of off the top of my head that has it But in these protocols you see running and testing and private You can do what are called Extension protocols so I will look at this in Monticello, which is the version control system But basically I can say create these methods on This class so I actually can create new methods on one of the existing classes And when I look at it in the class browser It's going to show up in a special protocol that's going to have an asterisk and then the name of the package that it was Defined in so if I wanted to make you know my special RubyConf methods on string I Define them inside of string under the special package under under that special protocol now when I add it to Monticello It goes into version control along with it so I can pass that along right so any extensions that I make to the core system Oh, I have 14% battery Any extensions I make to the core system then Get shared, huh? I'm out of time Okay, can I go for a few minutes? Okay, we'll go to the battery guys Because there's some cool stuff I'm gonna show you some of the tools I know you should sell like benefits and not features But I think the features are cool enough here that you will look at them and figure out benefits for you This one's fun method finder. How do you upcase a string in cease in small talk? I don't know, but I know that I want to start with lowercase ASDF and end with the uppercase ASDF Okay, and then it tells me where it is. Oh It's string as uppercase. Oh Then I can browse it cool. Yeah, I know what blow your mind. Oh Oh God this is so much fun Refactor method that one line. I want to extract to something so I will just select it I will extract method. I will call it something that makes sense like render heading hit. Okay Small talk says is this what you want to do? I Say yes, that looks about right Okay, so I'll accept it Right and so now we see in my render content on it to find this new method render heading on extracted the source out We see that over on the right side. I can extract the rest of the source out So we'll just create a new method here For the actual counters. I like narrating my videos better than trying to do it live and then for my final Automated trick Let's start showing you the methods that I have okay I don't want to show this now because I want to skip past the refactoring But I think what I do next is I create a superclass of my component So I basically insert a new class to it And then I take the two methods that I had on that subclass and I push them up to the base class So in a matter of two minutes Going slowly because I want to demo it I am able to take some source code extract methods insert a new superclass and move methods around to the classes In which they belong refactoring is fun people don't do it in ruby because refactoring tools suck small talk has them I forgot which one this is oh This is the object inspector in which case I have an object and I can actually look at it And I can start to look at what's inside of it. So I have an array It's got some elements. I've got this little Interpreter down there that uses where self is the context of the object that I inspected So now I can just start to run methods on that object. I can click around through it I can look at it. Like I said very discoverable very discoverable. You can experiment a lot. It's really cool This is Monticello On the right are basically change sets. It's a completely different thing that what you're used to small talk doesn't work with get but Has its own advantages. I can look up the change that I can see all the code that's in there I can pull in little bits. I can merge it into my system. I can replace parts of my system with it Very very powerful. So on to seaside, which will burn through like I said programmatic HTML I have this one method where I write a bunch of small talk code and it creates this very ugly form added Form and you'll notice. I've got callbacks on there that say that when This basically the callback on text input says that when we submit the form take the value of Whatever's in that field and store it and call the method email which stores it in a local variable and seaside gives you kind of a Shortcut for that saying you know on and of and so that that's a shortcut for that now when I submit the form I have the data for the user. I want to validate it. I want to save it to the gateway I have a sign up by so again This is Specifying the code that you want to happen in the place that it should happen and seaside just sort of takes care of the Rest I have So why is this great? Well, it's small talk semantics. I can actually I'm writing in small talk, which is fun to do it produces a hundred percent valid XHTML I don't have to deal with square brackets or angle brackets and stuff like that. It's just done. It's refactorable That's the best part. I can take three lines of code. I can extract it. That's awesome. Why does it suck? Well, what happens here HTML personally? I don't care, but some HTML designers are really big on being able to edit their own HTML But you know one of the seaside's opinion is we generate the HTML you do the CSS Hey, wait, we have lunch, right? So I'm just gonna keep talking for a little while you guys feel free to go grab lunch Spoiler alert. This is the best part of the whole talk In case it's not in case it's not obvious This is Alexander Graham Bell on the left and there is Steve Jobs on the right saying holy cow My iPhone is so cool. I can actually receive telephone calls from Alexander Graham Bell So call and answer two methods provided by seaside on components They transfer call transfers control to a different component and answer returns control back to the calling component If it wants to are you hooking me up with power, Mike? Thank you We're See, I knew this was so thanks for scheduling it during lunch this is Okay, so What we have here is render content on again We're just generating the HTML and you'll notice in the first on the third line I have an anchor and my callback now instead of setting a variable it says call this other component and So I'm saying instantiate a new instance of this component and then call it and then Somewhere along the way doing that is going to return a value back to me that I then assign in this variable Well, what happens when I do that? I've got a second component the one the RWC value prompter that Just has a form it says enter a value and then in my callback I say answer with this value So what's going on here is when I click on the link like so I render the component the first time it'll show a bunch of HTML When I click on a link it'll transfer control to the other component It'll let that component do whatever it wants which could mean transferring control to another component And it could go down on and on and on until eventually this component says I'm done. Here's the value. Here's the response So the second component takes the callback once somebody submits the value it answers it back now What does this look like? Well, I click enter your value a new component comes on to the screen it returns it I move on to the second one Get the value return it and then I see the sum so if you look at the code again for that, right? I said get the first you know Get get the value of the first first number get the second one and then some them But the actual getting the value that entire control flow is not done in this component It just says transfer that off to another component. So this is insanely insanely powerful Now the closest thing seaside it doesn't really It doesn't think that NBC is all that it's cracked up to be Sometimes your view logic actually goes along with the data that it works on and so maybe you should put those two things together Well, the closest thing you get to controllers is this WA task Which basically allows you to define a flow control and then yield control to other components But I can write the actual control in a way that makes sense and represents the control and then let those components deal with the whole rendering the HTML and And getting the values So I can streamline All that code to this I've got a new method go which is what's on WA task and that whole R&C value requester or whatever that is actually something that I made up for the purposes of this example So you could see how answer works, but because that's such a common thing. It's built in to Seeside as self-request. So when I call self-request that actually Creates a new component. It calls it. It lets that component do its thing and then it returns the value back So once I've gotten the first number and I've gotten the second number now I can create another view that actually sums those together and I pass control off to that so in this way I'm able to Write code that represents the control flow through my application via my tasks and then delegate the actual user Interaction part to components that manage their own state and that are able to return values to the to the task and keep going So that looks the same Basically, I enter a number because that's what was requested. I enter another number and then I get a sum Yeah, so significantly shortened code So how do you use this with rails? Well This panda loves using rails for crud because rails is awesome at crud But you know whenever he does complex configurable workflows. It makes him sad I've done lots of complex configurable workflows and rails and it is a gigantic pain in the ass And you always have to go through some kind of judo to Like I've mixed in modules on the fly to the action and done all kinds of weird stuff And it's just not fun and this guy wants his backbone back He says I want control of how the user interacts with it. You know, maybe he's just a dotnet programmer So bad, so how do you actually do this? Well, you can integrate through the database that is like C side can actually Connect out to a database and it can you know use all the data in there And you can fetch it just like you can in a rails app and that works just fine But now you've got this interface that you didn't really define between the two applications You're working on a sort of fixed data structure And it's kind of brittle that when I make changes to that data structure I have to make sure that the the other side of it works and Small talk has much better ways of dealing with persistence anyway, so you don't really want to You don't want to go through the database So you can also do C side as a service Which you can do Jason and XML APIs or you can in your rails app use mechanized to go through and kind of click through I would have loved to have had a gem that just handles all this for you But frankly as I've been using this in my own work I've been coming up with different ways of doing it So it's still still sort of figuring that out But it works really well to what what I do is I make my initial request to see side I store the entire response document in the database and then I use mechanized to parse out the URLs I kind of transform those URLs on the rails side so that when I click a URL on the rails side it Rails goes and figures out which URL that was on C side. It makes the request and you know comes back So I basically I can delegate all my complex workflow stuff over to C side Maglev I don't know if you guys are familiar with this maglev is a project from gemstone that lets you run small talk Or let's you run Ruby on their VM and I was talking to Monty a little bit And I said it would be really cool if I could run one maglev instance and one Gemstone instance and basically run C side on gemstone maglev or ruby and rails on maglev And then have them share objects back and forth and apparently that's entirely possible at some point because what what maglev And gemstone do is let you run multiple VMs, and they just transparently share objects, right? And so what I could do if this happens when this happens and I'm pushing him for it is I can define my Validations in rails and then I can use C side for my complex workflows and because those objects are just transferred from one VM to another Automatically without me having to do anything that means my C side code actually uses the validations from rails That is a holy shit if we can make that happen that would be so Freaking cool to to be able to do this and it's going to totally change the way you develop software So hopefully this happens if you want to learn more about this stuff Faro project org is where you learn As where you get the VM C side ST is the C side web application framework. There's some free books for example You can download a free PDF Book C side ST is free online. You can also pay like $12 for a PDF Squeak source is the open source kind of like github for small talk Although it's really ugly and not as efficient. So it's more like sourceboards than as github Asked without I can think of so thank you guys for staying into your lunch break. I'll leave the resources up You know any questions? Any? Yeah? Yes Okay, so the question is in Faro. Can you add methods to an instance of an object? So like singleton methods in Ruby. I don't know Yes, it has regular expressions. There are a few different libraries. They are It's not quite as clean as As rubies I guess one of things Ruby basically if you looked at Ruby's history you could say that Ruby inherits from small talk and includes pearl, right? And so you've got them really nice pearl regular expressions in Ruby You do have regular expressions in small talk, but just not as nice Other questions Yeah, I haven't I haven't had in particular interest in building things other than seaside really So I do know that you can create OS specific binaries that kind of bundle the VM in there and they can hook into windowing systems I haven't done that. So I don't know I do know that there's a guy that Used squeak to write an iPhone app So and it was on the app store, and I'm not entirely sure how that worked given given their restrictions, but those restrictions are gone so you know All due respect to Evan who's not here so I can say this he just showed you objective C Hey, if you want to code Ruby or small talk on the iPhone I think that's probably gonna be a much more desirable route to go Yes Monticello is the version control system and It basically stores the change that's in more of a binary form then then then just text files But it has little packages that you can ship around and that you can push out to public Monticello servers And people can browse and people load it in so you don't use get you don't use a version You don't use CVS. You don't do any of that. It's all in the environment. Monticello is your version control system Is it easy is Monticello easy? Yeah, yeah, there's a good documentation for it and the only Question that that you ever have really is do I want to load these changes in and replace some of the code that exists there Or do I want to try to merge it in but in terms of using it? I like to save my own changes out and Create a nice version history totally doable I don't know if you rewrite history like you do and get but But it's more like you can cherry-pick versions and so I can say give me the latest version Which will give me everything up to that or I can say give me that latest version But ignore everything else and then Monticello will complain if the system is not capable of supporting it Because the new code change includes a call to a certain class or a method that doesn't exist So it will warn you for some of the stuff like that This it kind of takes a while to wrap your head around some of this stuff But you know if you take a week to go through the ferro by example book or the seaside book you pick up a lot of stuff And it should be pretty exciting. Yeah Sorry, can you speak up? How do you handle deployments is the question deployments in seaside are completely different than anything You've ever done before in rails and in fact there is no Single model that works for every application Basically the way you've designed your application has significant influence on how you deploy it so some things like Dabble DB which is is which is a cool tool built by obvi Bryant the dude who wrote seaside Their model is to have one image per customer because the customer data does not relate to each other at all People are just creating their own databases online Maybe sharing views with other people But if I want to get data for a particular customer I go to a single image now an image once you've stripped out all The development tools is roughly three megabytes plus whatever, you know massive data the soccer mom put in there You know making making her her call list over the weekend, so You know the point is hopefully you Are charging enough that you can afford to store three to five megabytes worth of data on your servers per customer And then they write some scripts basically to bring up the image into a VM process on the fly Depending on when the requests come in Other typically what you do is you have multiple multiple images running and If you want to share data between them you use something like an object database like magma or goods Which are both some of the persistence options all the persistent stuff is laid out in the seaside book By the way, and then you could of course use gemstone which kind of handles all that for you Transparently so the key point though is that you have to have a load balancer that does sticky sessions on there So that requests coming in that are part of the same session go to the same image because they don't share data unless you configure them to Yeah, you can absolutely handle many users in a VM. It's just kind of a matter or in a single image It's just a matter of how you want to to lay that stuff out I guess one of the sort of frustrating things is like how do you do persistence in this and like some questions of how Do I do this well? You'll Google it and there will be a blog that says oh, yeah persisting your entire object structure Is these nine lines of code and so you're like well How come there's nothing like active record that lets me just save stuff It's like literally because you can write your whole persistence mechanism for your entire for your entire data set in nine lines of small talk and the way you structure and design your app is going to have a significant effect on how you choose to persist it so There aren't really I mean There's some off-the-shelf solutions that that let you like goods and magma that are object databases that do this stuff for you But you know it is also nine lines of code to write it completely customized to your applications needs Mike, did you have a question? Are you telling me to shut up? You email Yeah You guys if you haven't seen maglev examples yet first of all maglev is on github the whole thing is not on there But you can install maglev and you can use it and It allows you to I don't have it configured on my machine because this is new and I was trying to set it up for this I had problems because I was using RVM instead of the I would recommend not using RVM for maglev, but You load up to IRB processes You define a class or an object in one of them and then it is available to you in the other one So they're two completely separate ruby VMs running, but they're sharing data back and forth So the question is can we do that between a small talk specific VM running seaside and a rail specific one? or maglev one running Ruby and the question or what you need to do is Email this dude Okay, who just emailed me. How about that? Right, so if you guys can see this can you see that I'll just I don't want to tweet it, but I mean he is on Twitter too If you email this guy and say so Pat Maddox was telling us about seaside And he said you can make it run Ruby objects next to a Ruby VM next to a maglev VM And we could just share our objects back and forth. When is it going to happen? I? Don't know. Maybe it goes bumped up on on the feature list Presumably they want to get it working rails in production and stuff first But this is absolutely one of one of the things that that they're considering right now, and he's on a BJ. Do you know his Twitter name? He's Monty Williams on Twitter too Right, so he's basically the guy running maglev at this point another question Right Right absolutely Totally so Comment is seaside is an object database It doesn't really fit into the whole rails active record rdbms mentality I do know from conversations with Monty that having database adapters that can at least go out to postgres in my sequel is A very high priority for maglev in fact it probably works in some in some state at this point So your so your maglev so your rails applications running on maglev can continue to run unmodified I Say screw the relational database. It's not interesting. It's a horrible horrible Place to store application state. It's phenomenal for reporting But when I want to store an object structure, and I want to store You know I want to store my application state It's not particularly great at it And it's only until you start messing around with objects and they just save automatically for you And you don't even have to think about you know them going to a sequel database that you go Oh, hey, this is a really really cool to write way to write software you deal with objects You write application code it all kind of just works, and then you absolutely write some Write some listeners for when stuff gets saved so you can write it out to reporting database and do your querying and reporting from that so Yeah, a big priority to have rails and active record working on maglev I say that that is not nearly as exciting as being able to totally change the way we white We write rails applications. Yeah follow Database people Well, they do in like financial systems right small talk runs like 60 to 70 percent of of big financial systems on The New York Stock Exchange and various different trading firms So, you know and that's where that's where Matt or that's where gemstone makes their money right now It's like those big enterprise applications that have complex domain models Complex business logic and then need to be able to share that across across many many servers. So In less my okay. Yeah So I was okay So the question is what kind of performance you see with this and especially I would say with the architecture that I came up with Which is have your act or have your action controller make requests to see side and then do some stuff with it. I Prepared a lovely benchmark that would prove demonstrably that it added 10% of overhead Maybe to make a request out to see side and do it and then when I ran the benchmark it totally pegged my VM so Turns out that that you know that grand idea of this was was not accurate But that was running with the VM in development mode So it has all those tools and so like the VM at the image with all the tools is like 45 megabytes And when you strip out all the stuff to only what you need to run see side in your application goes down to 3 megabytes so the Basically, you know me running running performance metrics benchmarking against the development environment was Like just didn't work So far, you know, I'm the places it won't when I've used it It's still just been in development. It's only applications that are in development there are There are applications in the wild that are using seaside successfully and I think they're under like seaside success stories and So you'll look at here. I don't have any Exact benchmarks. I do know that there are a bunch of companies that are using it for production stuff And if you look for for benchmarks, then then you'll get it seaside itself Head-to-head against rails is faster than rails because small talk is just a lot faster than rails It or then then Ruby is like the the VM has been tuned for 20 years and everything while it's a dynamic language Everything gets compiled down. So it's really really fast There is memory overhead with the continuations in In seaside, but they are not particularly slow if you do like a hella world in seaside versus rails hella world in seaside smokes it I've done that one and I Guess the other aspect is you know if I'm gonna treat seaside as a service and call out to it and use mechanized with it That follows the same rules as as any other kind of software as a service, right? I know like Amazon and and Kobe's team both both like write a ton of services and then have a rails app hit those so it's a Proven architecture right it works But you know if you have one service sitting on the other side of the country as as the client Then you're gonna be completely hopes right so you need low latency there Okay, I'm my voice is my throat is starting to hurt So unless I have any you know anybody is like dying to know something that that they that we can't do over email or Twitter You know after I get water Think I'll call it a lunch hour