Ruby on Rails for Javascript [duplicate] - javascript

This question already has answers here:
Is there a JavaScript MVC (micro-)framework? [closed]
(30 answers)
Closed 10 years ago.
I have some experience in Ruby on Rails and I want to keep the MVC way to go in my client side Javascript project.
There is any Rails-like framework for Javascript? It should have the following features:
MVC
Easy integration with REST web services
Javascript-driven templating system
Models and validations
Testing framework
A solid documentation is a must!

I discovered backbone.js today. It's worth a look. It appears to be a lightweight abstract MVC system and uses underscore.js and jQuery
As for client side testing this isn't included. There are many standalone unit testing libraries out there.
Just add in any client side testing library you want. With these 4 you really shouldn't need anything else.
There are more heavyweight alternatives like SproutCore or Cappuccino#
Also see a large thread here on the topic by people in the know
I think node.js is worthy a mention aswell in case you want to delegate some of your framework to the server but keep it in javascript. You'll have to look into some of the big libraries running on node though.

Try http://emberjs.com/. It's very ambitious Javascript framework with cool things like UI Bindings and Auto-updating templates. It plays well with jQuery ;)

Javascript MVC is pretty full-featured and has a lot of good testing tools included: http://javascriptmvc.com/
Check out this answer for more info:
Is there a JavaScript MVC (micro-)framework?

Related

JavaScript frameworks to build single page applications [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
My goal is to migrate an existing web application to a RESTful single page application (SPA).
Currently, I'm evaluating several Javascript web application frameworks.
My requirements are as follow:
RESTful data layer (like ember-data)
MV*-structure
Dynamic routes
Testing-support
Coding by convention
SEO-support
Browser-History-Support
Good (API-) documentation
Production-ready
Living community
Backbone
The current application is using backbone.js. Overall, backbone.js is a nice project, but I'm missing well-defined structures that determine where what has to happen and how things must get implemented. Working in a bigger team with changing developers this leads to some kind of unstructured code, difficult to maintain and difficult to understand. This is why I'm searching now for a framework, that already defines all this stuff.
Ember
I looked into ember.js the last days. The approach seems very promising to me. But, unfortunately, the code changes almost daily. So, I won't call it production-ready. And, unfortunately, we can't wait for it to be version 1.0. But I really like the idea behind this framework.
Angular
Angular.js is a widely spread framework as well, maintained by Google. But I could not get familiar with angular. For me, the structure seems kind of unclear, explanations are missing of the overall responsibilities of each part of the framework, and the implementations feel circuitous.
Just to get this straight: this is just my personal impression and might be based on missing knowledge.
Batman and Meteor
As I understood, both frameworks need a server part as well. And since we just want a RESTful backend - no matter what language, technic or software, this is not what we want. Further, the backend API does already exist (RoR).
Knockout, CanJS and Spine
I did not go any deeper into these three candidates. Maybe this will be my next step.
So my questions now:
Am I missing any good SPA-frameworks?
What framework would you suggest/recommend?
Would you avoid any of the mentioned frameworks?
What is your experience in bigger SP applications?
PS: I'd would like to recommend a great blogpost from Steven Anderson (core developer from Knockout.js) about the "Throne of JS"-conference (from 2012) and javascript frameworks in general.
PS: Yes, I know there are already some question on SO. But since the development is so rapidly and fast for SPAs, most of them are already out-of-date.
I recently had to decide on a JavaScript SPA framework on a project too.
Ember
Looked at Ember early on and had similar thoughts as you about it - I really liked it but it felt like it was still too early to use... about half the tutorials I read didn't work with the current version because something had recently changed in how templating works.
Backbone
Backbone was the first frameworks we seriously looked at. I'm not sure I understand why you think it doesn't have "well defined structures"? Backbone is pretty clear about how to divide up Model and View code. Maybe you mean there's not some kind of app template? Anyway, Backbone seems really focused on the model/REST-binding part, but doesn't really prescribe anything for view binding. If model binding's important to you and you're using Rails it should be a breeze to do this. Unfortunately, the web services for my app didn't really match up, and I had to write my own .sync and .parse methods for everything. The separation of Model and View code was nice, but since we'd have to write all our bindings from scratch it wasn't worth it.
Knockout
Knockout is like the Yin to Backbone's Yang. Where Backbone is focused on the Model, Knockout is a MVVM framework and is focused on the View. It has observable wrappers for JavaScript object properties and uses a data-bind attribute to bind properties to your HTML. In the end we went with Knockout since view binding was mainly what we needed for our app. (...plus others, as discussed later...) If you like Knockout's view binding and Backbone's model bindings there's also KnockBack which combines both frameworks.
Angular
Looked at this after Knockout - unfortunately we all seemed pretty happy with how Knockout did view binding. It seemed a lot more complex and harder to get into than Knockout. And it uses a bunch of custom HTML attributes to do bindings, which I'm not sure I like... I may take another look at Angular later, because since I've come across multiple people who really like the framework - maybe we just looked at it too late for this project.
Batman, Meteor, CanJS, Spine
Didn't really look too closely at any of these. Though I know Spine is a similar framework to Backbone with explicit Controller objects, and is written in CoffeeScript.
Afterword
As I mentioned, we ended up using Knockout because, for our project, focusing on view binding was more important. We also ended up using RequireJS for modularization, crossroads and Hasher to handle routing and history, Jasmine for testing, as well as JQuery, Twitter Bootstrap, and Underscore.js (and probably more libraries I'm forgetting at the moment).
Javascript app development is more like the Java ecosystem than the Rails ecosystem. Rails provides a solid core of stuff you're going to use for every app (Rails framework), and the community provides a lot of customizations on top of that (gems). Java provides... a language. And then you can choose Java EE or Spring or Play or Struts or Tapestry. And choose JDBC or Hibernate or TopLink or Ibatis to talk to the database. And then you can use Ant or Maven or Gradle to build it. And choose Tomcat or Jetty or JBoss or WebLogin to run it in. So there's more emphasis on choosing what you need and what works together than choosing THE framework to use.
it's been a year since we started development on our Cloud services project with numerous SPAs, so it was a big decision, which javascript framework to use for our UI to satisfy our RESTful architecture needs.
and after a lot of researches we ended up using Dojo framework .
main features you'll love:
educated community and a team that came up with a perfect design pattern. great conventions and modular/object-oriented architecture. with CrossBrowser programming attitudes :)
MV* structure. build UI widgets with external .htm templates and for production, build all your javascript & templates into a single, minified and small .js
build classes with inheritance. property setters, a lot of function tools.
pub/sub mechanism (named topics in dojo)
a lot of UI controls, from validation form control, dialogs/tooltips to a heavy featured, highly customizable (but lightweight) chart & data-grid solution.
a good unit test system named DOH. it also have a robot to reproduce mouse/keyboard actions.
a querying tool (like JQuery) named NodeList with all jquery features and even a lot of it's plugins.
and the good but not so complete part. it has a JsonRest module to use with your REST services. its a handy tool but it lacks a lot of features.
to overcome these issues, we developed an AJAX poller, error handling and universal, loading & notifications solution.
we did it very easily using dojo framework conventions and structures.
if you don't want to do that, perhaps you have to use another framework for this part.
looking at great SPAs around the web you'll find out all of them are customized and using multiple frameworks. but our experience with Dojo alone was fantastic. and therefore I suggest you to don't think of any other framework since all of them are incomplete for a SPA. but ultimately you have also another option (which I don't recommend and have no details information on). go with a JAVA framework that is capable of building SPAs, by automatically generating UI & javascript.

Ruby on Rails-like framework in JavaScript [duplicate]

This question already has answers here:
Is there a JavaScript MVC (micro-)framework? [closed]
(30 answers)
Closed 10 years ago.
I'd like to build an app in JavaScript that follows the MVC pattern using a framework that is packed with features like Ruby on Rails. I know Rails fairly well and having a "JavaScript port" of it would be nice. (When I say "JavaScript Port" I don't mean literally, just something similar.) I want to use JavaScript both on the client side and server side. I'm sure that unlike Rails, the client-side will be much heavier and that's fine. I imagine the server-side of it would run on Node but I'm open to other ideas.
My question is basically, what's the closest JavaScript framework to Ruby on Rails? If there is not one solution, what combination?
In 2012 was Railway Node.JS MVC framework based on ExpressJS, fully ExpressJS-compatible. It allowed you to build web applications in a similar manner as in Ruby On Rails.
In nowadays there is good frameworks like CompoundJS and Sails.JS
Server Side (for Node):
Geddy is very "railsy" http://geddyjs.org/
Client side:
Ember.js: http://emberjs.com/. There is also Rails integration gem. Yehuda Katz and Tom Dale are the main developers, you can know them from Ruby world :)
I would check out Meteor.js. It's JS on client and server side (using Node.js) and rather than an MVC framework, it binds your models to your views using web sockets so that changes to the server get pushed down to the client and the page is updated instantaneously.
Because it uses the reactive model rather than MVC, it's not quite like RoR, but the frameworks do have productivity and developer friendliness in common. Meteor uses smart packages (like RubyGems) that can seamlessly add functionality to your app, you can get something working very quickly, and you can deploy in the snap of a finger if you choose to put it up on meteor.com (and deploying to your own server is not much different than deploying any other app).
in the client side in the last few months I used Joosy - http://joosy.ws
It is super easy to integrate in rails (it is designed for RoR, and you can still continue using RoR as a backend).
from their website:
..is a javascript framework. Being a harmonious extensions to Rails it introduces everything you like about this framework right to your browser. Ready conventions set, extensive CoffeeScript, HAML support, Helpers, seamless backend integration, automatic code generation and more..
There is also an interesting comparison with BackboneJs and EmberJs here: http://guides.joosy.ws/guides/basics/joosy-vs-x.html
You can look at Backbone. This is developped by ROR developers I believe, it's not a MVC but an MV.
http://backbonejs.org
I haven't used Tower.js but it advertises itself as something similar to what you are looking for:
Built on top of Node's Connect and Express, modeled after Ruby on
Rails. Built for the client and server from the ground up.
http://towerjs.org/

Introduction to Local Storage Adapters

I am quite a novice when it comes to web application development. The projects that I have done thus far have purely been Client Side and Jquery powered.
Recently I made a discovery that Javascript has an MVC framework (http://backbonejs.org/)
This really excites me as about 90% of my experience to date has been with Javascript, so the possibility of using an MVC framework within a familiar coding language is actually quite awesome.
After some more reading and probing I discovered a local storage adapter for backbone:
http://documentcloud.github.com/backbone/docs/backbone-localstorage.html
Basically if I have understood this correctly - it will store and retrieve data in cookies
So the above framework (backbone) and addin (local storage) will allow web applications to operate in a "server-less" environment.
Before I get crucified by any techies - I do understand that this is a very generous, generic and simplified statement - but I am just trying to find out a few things at this point:
Is my understanding of the framework correct?
Has anyone had any development experience with the above?
Where can I get novice level tutorials on developing MVC Web applications that use Backbone.js
Looking forward to the discussion and your answers
Is my understanding of the framework correct?
First off there are several "mvc" like frameworks for Javascript besides for Backbone.js (assuming you consider backbone.js an mvc framework, take at look at this SO question as well as the official documentation) for example Ember.js, Knockout.js, JavascriptMVC. That said local Storage is a feature of HTML5 and isn't specific to backbone.js (so the browser would need to support it, here's a SO question with some more info on localStorage), what the backbone.js localStorage adapter does is saves the backbone.js data to localStorage instead of the server.
Has anyone had any development experience with the above?
Yes (you can take a look at the questions tagged with backbone.js here on SO for starters...).
Where can I get novice level tutorials on developing MVC Web
applications that use Backbone.js
Have a look at this site for some backbone.js tutorials.

Javascript coding guide with test driven development

I'm migrating from server side development (java, php) to client side - HTML, CSS, javascript.
Though I technically understand (mostly) how javascript works, I have not found a good guide to creating an application - particularly with regards to how to organise functions and objects and setting up a solid test framework for them.
I'm currently half way through the Ruby on Rails tutorial
http://ruby.railstutorial.org/
which is excellent - I now feel confident in understanding the standard structure for arranging all the code in an application, and setup good testing practices as I go.
Plus, the integration with heroku and git make for a really tangible real world example, making for a complete understanding of how to develop and deploy a rails app.
Can anyone recommend a similar kind of guide for JS/AJAX development?
One good way to write JavaScript is to do it in a modular fashion. For dependency loading, you would also need module loaders like RequireJS. As for structure, there are a lots of frameworks out there, I suggest you give BackboneJS a try. You would also want to make your JS scalable so that you won't ever have to worry about expanding. Here's more videos about it as well.
There are a lot of frameworks to choose in JS. Test them all out and create a stack which you feel comfortable playing with.
I don't think you'll find a similar tutorial as on Ruby on Rails about Javascript, because Rails is a framework and Javascript is just a language that has hundreds of different frameworks built around it. I don't know what kind of applications are you willing to develop, but Backbone.js is an MVC framework for frontend development and you could search some tutorials on it.
However, if you're just starting out with JS, you probably want to learn first on the basics of JS. Good source for that is for ex. MDN JS guide:
https://developer.mozilla.org/en/JavaScript/Guide
Then you might want to check out guide on JS design patterns for learning how to structure your code:
http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#designpatternsjavascript
Hope these will help!

Javascript + MVC + UI

I'm looking for fresh ways of programming in javascript. My goal is to create javascript application like GMail. I tried GWT but it seams so complicated and the code isn't stylish.
I found MVC patteren to be a good way of programming. I always have problems organizing the code in javascript. When I use CakePHP or RoR, everything is simpel :).
I'm looking for a javascript framework that would support MVC way of programming and would have good widgets like Adobe Spry Framework. What frameworks should I use? Thx!
A List Apart has an article about JavaScript MVC. I don't think you should necessarily use a framework, unless you're already familiar with one.
That article also points out to some MVC frameworks:
JavaScriptMVC
SproutCore
TrimJunction
You might want to take a look at Cappuccino: http://cappuccino.org
Check out AngularJS - http://angularjs.org
It will help you a lot with your app structure and strict separation between logic and view.
Full test environment (unit/e2e) and dependency injection included...

Categories