8 ms·
Volt: A Ruby web framework where your Ruby runs on both server and client
- desireco42 12y agoJust idea of it, I like it. I am big fan of JS and think it has great future on both sides, but just on initial description of this, I really like it. I will try to give it a spin in next few days to have a more realistic experience. Thanks for making it.
- robertk 12y agoOpal is a really neat gem for translating Ruby to JavaScript. For those who know some math, I used it to convert some Ruby code I had written to perform finite field arithmetic (https://github.com/robertzk/FiniteFields https://github.com/robertzk/FiniteFields) into an interactive webpage (http://therobert.org/finite_fields/ http://therobert.org/finite_fields/). It would be just as trivial to do with Volt.
- manojlds 12y agoJust to make it explicit - Volt makes use of Opal.
- roundpizza 12y agoSo why not just use JavaScript to begin with?
- PaulRobinson 12y agoBecause Javascript is a horrible language to code in and debug. If you're a Ruby programmer, you don't need to learn a new language, and you can have confidence that the Opal guys have looked after a lot of the issues you're not experienced enough to understand. Your question is like asking a C programmer "why not just use assembler?" or an assembly programmer "why not just toggle 1s and 0s in, because ultimately your code is going to get turned into binary eventually, right?" Abstractions and different models of describing a problem solutions are helpful for a multitude of reasons.
- eyko 12y agoIt has been my experience that JavaScript is a high level language. In this particular case, Ruby is not being compiled to JavaScript but being transpired.
- LBarret 12y agoit's a mix, some stuff is high level (closure), some is low level (for loop before ECMA6). This is very uncomfortable when you're learning it, you never know on which side you are.
- dragonwriter 12y ago> In this particular case, Ruby is not being compiled to JavaScript but being transpired. First, "transpiled" not "transpired". Second, "transpiled" is a special case of "compiled", so you can never correctly say that something is not being compiled but is being transpiled, in the same way you can't say something is not a rectangle but is a square.
- philwelch 12y agoWhile JavaScript is a terrible language to debug, machine-generated JavaScript is little better, and leaves you guessing which code you need to change and how in order to affect it.
- mercurial 12y agoIt can be better if it is compiled from a strongly-typed language. This gives benefits you'll never get from raw Javascript.
- nightpool 12y agoWow, as someone who hates JS and loves the server-side, this looks really really cool. I might have to learn Ruby just to try this.
- laumars 12y agoThere was discussions last week of compiled C++ being used on the client side too: https://news.ycombinator.com/item?id=8287700 https://news.ycombinator.com/item?id=8287700
- alttab 12y agoI would like to reach a point in web programming where JS, or something that eventually compiles into JS doesn't have to be written or maintained explicitly. GWT comes to mind, and this does something similar with Ruby it seems. Interesting take for sure...
- KaoruAoiShiho 12y agoThis is the holy grail. Investigation begins...
- snitko 12y agoThis thing would be million times more useful with Dart, which runs both in the frontend and the backend and is a stable language with some rich features. Still, a move in the direction though, I like it, but I think I'd never use this.
- sergiotapia 12y agoThis is the interesting bit for me personally: Instead of syncing data between the client and server via HTTP, volt uses a persistent connection between the client and server. When data updated on one client, it is updated in the database and any other listening clients. (With almost no setup code needed) --- In .NET land, I used SignalR when it first came out and it has since been baked into ASP.Net. In Rails, I use Pusher, a paid for service because it's just easy to use and iterate. If this works like it says on the tin I am excited! Beyond excited! My one question though is how many users can it support? How many people can be 'listening' for a broadcast.
- brogrammer90 12y agoVery cool! Would it be safe to say Volt is Ruby's Meteor?
- ChristianBundy 12y agoAbsolutely. I haven't contributed to Volt, but I've lived Meteor for the past year or so. Volt looks like an interesting option, to say the least.
- Chris911 12y agoWhy is this "released" now? The projects seems to be semi-dead (only a couple bug fixes since last April) [1]. [1] https://github.com/voltrb/volt/commits/master https://github.com/voltrb/volt/commits/master
- ryanstout 12y agoChris, I'm the main developer. So I haven't pushed much because I have been doing a big refactor on the reactive stuff and did get a little side tracked with some other stuff. The refactor is almost complete (400+ commits that should be out next week or the week after). From there there's just a few more things let and I think it will be ready for people to start building on. (After that I'll need to do a bunch of tutorials and videos)
- Chris911 12y agoCool. Thanks for answering here. Great project I will surely give it a try at some point.
- bglusman 12y agoAwesome, though why wait to push commits? Just put in a branch people can play with/watch until it's ready to merge to master or whatnot. Dunno if I'll have time but I'd love to play and see where it's going, much easier if latest stuff is online and visible :-)
- juanplusjuan 12y agoWhat's the problem that this framework is trying to solve? I can't imagine that Ruby code will correctly compile into every possible use case for JavaScript. Even if it does I won't be able to leverage any gems, which is the real power of a mature server side language. It seems like this is just a crutch for Ruby web developers to use a familiar syntax and avoid learning JavaScript, which seems valuable if you want to do anything beyond a basic web page. Please tell me if I'm missing something. I'd genuinely like to know.
- glesica 12y agoThe interesting thing here is not that Ruby runs on both the client and server. The interesting thing is the client-server data synchronization, at least that was my perception having seen a talk on this a few months ago.
- Igglyboo 12y agoYep I'd have to agree. While I'd rather use meteor for this task since it's native javascript on both ends, the killer feature for meteor is really the data binding across the client/server gap and not the ability to write js in both places.
- ryanstout 12y agoI'm the lead developer on Volt. The goal here isn't to keep people from learning JS. I've been doing JS development since long before I found ruby. Just some thoughts on it I had been working on for a blog post: In web development today, JavaScript gets to be the default language by virtue of being in the browser. JavaScript is a very good language, but it has a lot of warts. (See http://wtfjs.com/ http://wtfjs.com/ for some great examples) Some of these can introduce bugs, others are just difficult to deal with. JavaScript was rushed to market quickly and standardized very quickly. Ruby was used by a small community for years while most of the kinks were worked out. Ruby also has some great concepts such as uniform access, mixin's, duck typing, and blocks to name a few. While many of these features can be implemented in JavaScript in userland, few are standardardized and the solutions are seldom eloquent. Uniform access and duck typing provides us with the ability to make reactive objects that have the exact same interface as a normal object. This is a big win, nothing new to learn to do reactive programming. -- Also, just as a side note, Opal does a great job of compiling ruby to JS. The code is easy to understand, supports source maps so chrome for example can bring up your ruby code in the console and show line numbers in the ruby code. While many gems won't work without some porting, a lot do. Opal currently runs rspec (a very complex ruby project) with only a few patches. Really though, typically front-end solutions do different things than backend solutions.
- whistlerbrk 12y agoI was just talking about wanting something like this the other day. Wow, this is great.
- willsulzer 12y agoI'd have to say this is very exciting, and something that from which the Ruby web community could benefit greatly. Having the boiler plate cases covered for data binding and synchronization across the client and server could really increase productivity for modern web application. For anything else that doesn't fit that mold, a developer could always degrade to using their front end framework of choice with Websockets or AJAX back by REST APIs where appropriate.
- deleted 12y ago[deleted]
- imslavko 12y agoVery interesting! I am interested in how data synchronization works. What data stores does the ORM currently support (my guess is mongodb so far)? How was it implemented? Would it work with multiple servers? I am not proficient in Ruby code, reading some code didn't give me a lot of information :) https://github.com/voltrb/volt/blob/master/lib/volt/models/persistors/model_store.rb https://github.com/voltrb/volt/blob/master/lib/volt/models/p... (edit: I probably need to note here that I contributed to a similar part of Meteor, that has data-sync to persistent storage too)
- marknadal 12y agohey, I do all sync stuff too, shoot me an email (you don't have yours listed in your profile), I have some pretty interesting solutions and I would like to compare notes.
- sgonyea 12y agoThis is great! I've always wanted to hire Ruby developers who disdain JavaScript, and other impure "others", to maintain my website. Why let not knowing what you're doing hold you back? Just because you don't understand how the frontend works shouldn't stop you. Or inspire you to learn new things.
- tazjin 12y agoSounds like rubish to me.
- abdullin 12y agoThis reminds me of Lazo.js from Walmart labs (https://github.com/walmartlabs/lazojs https://github.com/walmartlabs/lazojs). That is also a client-server framework with code shared between client and the server. Although Ruby is obviously harder to share, than JavaScript.
- clubhi 12y agoI'm sure Walmart labs is no joke. I can't think of a worse word association though.
- chadcf 12y agoYou realize it is walmart right? There is no bad word association. Any company the size of walmart, regardless of how you feel about their core business, is likely doing some cool things with technology.
- abdullin 12y agoLazoJS is quite nice. It is definitely more polished than RendrJS from AirBnB (equivalent framework for building SPAs that have fast first page load and are SEO-friendly).
- thomasfl 12y agoThe persistent connection makes volt a promising alternative to meteor. I guess I can't run pry debugging sessions in the browsers javascript console? Server generated Javascript has come a long way since it was introduced in Rails, abandoned and then reintroduced again with opal. DHH wrote about opal one year ago https://signalvnoise.com/posts/3697-server-generated-javascript-responses https://signalvnoise.com/posts/3697-server-generated-javascr...
- consultutah 12y agoKind of funny that you selected a name so similar to Microsoft's attempt at doing the same with .NET: http://en.wikipedia.org/wiki/Microsoft_Live_Labs_Volta http://en.wikipedia.org/wiki/Microsoft_Live_Labs_Volta
- mattangriffel 12y agoThis may be an ignorant question, but why not use the <% %> syntax popularized by ERB instead of { } for view bindings?
- vidarh 12y agoHandlebars/Mustache syntax is also widely used. And <% %> might very well confuse people into thinking the contents is raw code, as opposed to handlebar-style directives. (Handlebars/Mustache restrict what actions you can take on view data substantially - you have to explicitly expose functionality in most implementations)
- dstarh 12y agoReading over the source on the example apps, the first thing that jumps out at me is _underscore _prefixed _variables and it just looks odd in ruby, especially with :_symbols
- obsurveyor 12y agoYeah, it looks like a Python refugee's code or something. I also don't like the .cur name that you have to use everywhere. It's not descriptive enough by itself. I wonder why .value wasn't used as the obvious choice.
- ryanstout 12y agoobsurveyor, I'm the lead developer. I've been doing ruby forever. The .cur is going to go away, along with .or and .and I'm in the middle of a big refactor of the reactive stuff to simplify all of that.
- dstarh 12y agoThen why the _'s everywhere, ruby is snake case but I don't think I've ever seen anyone do :_foo => "bar" or _foo: "bar"
- ryanstout 12y agoSo the models in volt basically let you read and assign attributes with an _ We could use the model[:key] instead, but the nice thing with using _ is that you can then define your own getters and setters easily in the model class. The _ is sort of a quick prototyping tool, allowing you to start using attributes without defining them in the model. We're going to add it where you can say something like: model_attr :field_name, String then do: model.field_name = 'something' (without the _) The _ keeps people from calling a method that isn't defined, since ._something will return nil if its not defined yet. But if you called .something, it will still raise an exception. Does all of that make since?
- jguimont 12y agoLooking at this, it seems something that sits between the view (html) and the controller (data) would be needed. I understand the reactive html is used for now, but that would not work for complex UI interactions.
- mark_l_watson 12y agoI like Meteor, which seems to be similar except that Meteor also supplies a synced datastore (MongoDB on the server and a light weight equivalent in the browser). I will definitely try this out, especially since I have already played with Opal (used in Volt).
- mark_l_watson 12y agoOne day later: I had time to try Volt, and I really like it.
- netghost 12y agoJust out of curiosity, I noticed that mongo is used in all the demos, and seems to be the only DB supported. Any thoughts on how or whether this would be support other backends like redis or more traditional sql databases like postgres and mysql?
- lkrubner 12y agoHandling complex JSON documents is not easy with traditional sql databases like postgres and mysql. My team just got done building a large site with AngularJS, and using MongoDB (or any document store) allowed us an easy way of saving denormalized JSON documents. If you have a JSON object that contains an array of other objects, and each of those objects has arrays of other data, so you have a complex document that is 4 dimensions deep, with MongoDB (or any other document store) you simply put the document in the document store, but with MySQL or PostGre you would break that document up and store it in normal form, which means breaking it up into at least 4 database tables, maybe more. That is a lot more work and, crucially, that is much more likely to be impossible to automate. The code can not automatically know what deeply nested array of objects maps to some database table. The requirements for automatic normalization go beyond the features of your normal ORM. There has been an explosion of these systems lately that automate the synchronization of frontend and backend. As far as I know, they all rely on document stores such as MongoDB.
- karmajunkie 12y agoMongo may be the right call for your team, but just as an aside, the use case you're describing is perfectly doable with Postgresql using either text columns or json columns, and moreover, table denormalization is just as much of an option for relational users as for document store users.
- deleted 12y ago[deleted]
- beginrescueend 12y agoHow does something like Phonegap / Apache Cordova fit in to VoltRB?
- segphault 12y ago"If the user hits a URL directly, the HTML will first be rendered on the server for faster load times and easier indexing by search engines." If I'm understanding this right, it sounds like an incredibly cool feature. Being able to use the same templates for both server-side rendering and a client-side SPA-like experience would be a huge win.
- iamgopal 12y agoI have been waiting for years for something similar in Python