iPhone app, data layers, & database servers - ios

I found a lot of similar questions out there but none that really answered specifically some of the questions I have. I will be working on an iPhone app shortly that will be accessing data from a database server running windows sql server. I'm not sure what language would be best do write the API in. I prefer Ruby on Rails, but I've read that there are hurdles setting it up with sql server. We could do the API in .net, but I've heard that setting up JSON is a bit of a pain.
What do you suggest? And if I'm doing this the wrong way, let me know the best way. I'm sure most of this is just up to personal preference but I'd love some input.

I dont have much idea about building a JSON api in .NET, but if you are planning to use rails there are couple of options to connect to a SQL Server database from Rails.
a) Use JRuby and a jdbc driver like jTDS . I do want to mention that JRuby is a tad slow when running specs as bootstrapping the rails environment every time takes longer compared to MRI. (this experience based on working in a project couple of years ago, so please try it on your own).
b) Use the MRI ruby with tiny_tds

Related

Clarifications about Rails and Node.js

Up to now I've always used PHP with or without a framework but a month ago I decided to start something new: Ruby and Rails, I found them quite easy and similar to PHP and some PHP frameworks in how they works but using a simpler syntax and many other advantages.
Some days ago I started reading about Node.js, Node.js vs Rails, "why node.js is better"...
I'm a bit confused but my objective is to learn something modern that will not become obsolete in a few months so:
What are the main differences between Rails/Ruby and Node.js and a framework based on it like Express.js (except that one is written in JS and the other in Ruby)?
What are the main advantages/disadvantages of using Node.js and framework based on it instead of a Ruby based solution like Rails?
Thanks!
There aren't enough differences between Node.js and Rails for it to practically matter.
A lot of what Node.js can do can be pulled off in Rails with things like EventMachine and Pusher. So unless you are really familiar with Rails' limitations, and know you'll be pushing the boundaries, you'd be hard pressed to make something a seasoned Rails developer couldn't do.
Having built apps in Node and Express I can say that they alone aren't enough to make a sexy application. They can seem just as old and stale if you don't have an outstanding frontend UI to facilitate the backend possibilities. Instead of comparing backend servers, I think the real future of doing amazing things is in front-end JavaScript frameworks like Backbone.js that use Express/Rails/Node.js on the backend.
I have chosen to go in the direction of Backbone.js with Rails as my backend API server. Because it's so easy to rapidly create a very nice RESTful backend server in Rails. Rails also makes working with CoffeeScript and precompiling/organizing Backbone code a breeze. There are already decent Backbone.js gems out there for Rails.
The Rails core is also able to acknowledge and embrace the fact that frontend JS MVCs are logically a good next step, and they have been working to strengthen the bond between the two. For those same reasons they have also worked to make Rails an even better API server so that it can work with frontend JS easier. Node.js and Express aren't putting as much effort to coordinate with frontend JavaScript MVCs as the Rails community is.
Being good with a JavaScript frontend MVC and Rails as a backend makes you also great for both worlds in terms of getting a job. You will easily be able to hop onto a Node.js project and add value to that team with your superior frontend experience, and you can also roll with the punches on a Ruby on Rails team and add value to them as well.
As official Node.js website explains it:
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
On the other hand Ruby on Rails official website says:
Ruby on Rails is an open-source web framework that's optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.
Given this I guess that it is more appropriate to compare Ruby and Node.js, but even this is not quite right given that Ruby is programming language and Node.js is NOT. You could probably compare JavaScript with Ruby but I guess that is not what you meant to ask with this question :)
So, for me, key point in understanding what Node.js truly tries to accomplish is well described on Node.js about page. Key Node.js idea (for me) is described in this sentences:
Node is similar in design to and influenced by systems like Ruby's Event Machine or Python's Twisted. Node takes the event model a bit further—it presents the event loop as a language construct instead of as a library. In other systems there is always a blocking call to start the event-loop. Typically one defines behavior through callbacks at the beginning of a script and at the end starts a server through a blocking call like EventMachine::run(). In Node there is no such start-the-event-loop call. Node simply enters the event loop after executing the input script. Node exits the event loop when there are no more callbacks to perform. This behavior is like browser javascript—the event loop is hidden from the user.
What this should enable you, is that you should be able to easily write highly concurrent programs without even thinking about concurrency using JavaScript syntax and callback functions as basic concurrent runnable units.
Your fear that either Rails or Node.js will be gone in a week is unfounded. Rails has a large community and will be around for a very long time even though currently (early 2012) it's getting a bit of hate thrown its way. Node.js is just getting started and has so much attention I don't think it will have any problems getting to the Rails level some day.
That said I've been evaluating Node.js and Rails as options for a project and the reasons I choose Node.js over Rails are:
"The Rails Way" - In my (admittedly limited) experience with Rails it really seems like you either do it the Rails way or you are going to be in for a world of pain. A big part of the Rails way is to use the ActiveRecord model. The advantage of this is that there are a lot of gems that work with your code happily because they know you'll be using ActiveRecord. The disadvantage is you are mixing your data access & model. I am not a fan of this idea so the Rails way for me still seems a bit.. off.
JavaScript is a key part of client side web development and the idea of using it on the client and server is interesting. I'm not super strong at JavaScript and I can't imagine a better way to get better then to have to use it everywhere.
My project has real time communication needs which while I'm sure can be done in Rails there seems to be quite a bit of positive mention on Nodes ability to handle this with socket.io being the front runner option.
At the end of the day no matter which you choose you will have a great time & learn a ton of new stuff that will change how you write code. If you're not on a big time crunch I'd recommend building a small project management tool in both and see which you prefer.
Either way.. Good Luck!
2 things - performance & productivity.
Performance (more details here)
(source: jslang.info)
Productivity (how fast you can build that app)
Ruby on Rails is specialized and highly productive tool for creating so called Web 1.0 and Web 2.0 applications (99% of internet sites are such apps). In my subjective judgement and experience in this area Rails about 2-4 times more productive than node.js or express.js.
For Web 3.0 apps (realtime things, client-side MVC, etc.) this isn't true, RoR doesn't keep its advantage there.
So choice depends on use case and priorities.
I know a lot more about Node.js than I do about Ruby. That being said, Ruby is much more widely adopted. It is currently a very hot skill to have in the work place. Some may argue with me on this but I think that Node.js is still "under development" and will be for a little bit longer. It has a lot of promise but just hasn't been adopted by many companies and projects yet.

Using Rails as a framework for a large website

I've been playing around with Rails (version 3) for a few months now and I understand the framework fairly well. However, I have yet to develop a large website which offers lots of database access and user interaction.
I'm fairly skeptical of the following:
The Speed and Scalability of Ruby (I've heard that its up to 10 times slower than most other server-side languages).
The extra background processing that Rails as a framework (multiple levels of abstration).
The lack of enterprise-level web apps that run on Rails (the only ones that I can think of Groupon, Github and Hulu).
The complexity of the environment (nginx > mongrel > rails > ruby > website).
The behind-the-scenes SQL operations (I know that these can be optimized, but I'm sure that I'll miss some).
For these reasons, I'm unsure whether to continue using Rails or to switch to something that is built ontop a more performant language .. say Java Spring.
Please advise :)
There are tons of large sites and infrastructures in production that use Rails. This question has also been asked to death over the years of Rails being actively used for all manner of web apps, large and small.
Short version is that it is not the fastest language around but despite that scales fine if you know what you are doing. And you should have enough money to hire people that know what they are doing if you actually have any problems of scale.
Scaling any webapp is hard, use the language/framework you know. Programmer happiness is king.
You can get good performance with Ruby. Easy:
require 'inline'
inline :C do |builder|
builder.c <<-C_CODE
void run() {
// Write your entire application in C here
}
C_CODE
end
run
Problem solved ;)
Not the speed and scaling discussion again?
In webdevelopment the things that are the slowest is the network communication (receiving the request, getting al your data back), the database (getting all your data from the database), and most of the times it is not about the computation time at all.
While it is true that Ruby and Ruby on Rails seem more focused on programmer happiness, I think that every decent web-application built in .NET or Java has as many levels of abstraction.
The complexity of the environment? I think you mean deploying? There are a lot of options, but the most used options are Passenger (very easy deployment on top of an apache or nginx), or Torquebox.
Torquebox for the moment is the fastest, best scaling solution (based on JBoss Application server), and several big names in the Ruby community are calling Jruby the implementation of choise to deploy your applications. While AFAIK the commonest deploy still is using REE (Ruby Enterprise Edition) and Passenger.
Unless you know you are going to have to do serious mathematical, cpu-intensive operations, I think the question you should ask yourself is: which framework/language will give me the quickest result?
If you are very proficient in Java/Spring, that might be the answer for you. But if your only worry is performance in general, I would say: do not hesitate and go for Ruby on Rails. It is a pure joy to develop in. The ruby community is really awesome if you would encounter any issues: support is just a post away.
And to conclude, I want to add a few very big sites using Rails: LinkedIn is using rails (and jruby), and Twitter still is using Rails for their frontend.

Setting up a Ruby development environment [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am currently trying to set up a development environment for learning Ruby. The environment will primarily be for getting to grips with the language, but I will most probably move on to development with Rails after long. With web development a target, I would like to hear about preferred web servers and databases.
I plan on setting up the environment on a virtual machine, so I'm not worried about trashing the thing. Therefore, I am open to using a Linux distribution, OSX or Windows as the operating system.
I'm moving from C#, so I'd like to be forced into the Ruby way of thinking to a certain extent. Obviously, that's easier said than done.
What OS do most Ruby developers use?
What is the easiest IDE to get to
grips with coming from a background
of using Visual Studio?
Which
database is used most within the Ruby
community?
Which database is most
likely to be supported by most web
hosts?
Which web server is the
easiest to configure? To get up and
running in the shortest amount of
time.
Hopefully I have provided all the information needed and hopefully this will aid others in setting up their own environments.
Thanks
Edit:
Thanks guys. Some really good
suggestions so far, all of which I'll
take on board. I'm currently wading
through the copious articles surrounding
initial RoR setup on Linux, as I like to
understand how things work and are
tied together. Also, because it's all
free...
I'm currently putting together a
virtual machine (so I can break stuff)
using:
Ubuntu
SQLite
No webserver, I plan on using whatever development server comes with Rails out of the box, initially
Redcar Editor
Edit 2
I have setup a couple of environments
now.
I have the ubuntu setup running in a
Virtual Machine on Windows and decided
to try decking my Mac out for ruby
development too.
Overall, I'd have to say setup for the
mac was a lot less painful than the
linux setup. On the mac I'm running
with:
SQLite that comes with OSX out of the box(!)
TextMate (trial version, but loving it)
Mongrel web server
I've progressed from learning the ways
of Ruby to writing some simple
websites with Rails and am finding
development with Rails really simple
to use. I have also set up a GIT
repository on my working directory and
am currently trying out Heroku.
Thanks for the help, everyone.
If anyone would like any more information about setting up on either environment, I'd be happy to provide more detail.
What OS do most Ruby developers use?
Mac OS for most, but any Linux distro will do (Ubuntu/Fedora etc).
What is the easiest IDE to get to grips with coming from a background of using Visual Studio?
Textmate is quite popular if you're on Mac. Netbeans and Aptana are there if you need something similar to enterprise world. Emacs/Vim is ok too.
Which database is used most within the Ruby community?
So far most Ruby / RoR guys I know use open source databases. sqlite for local development while Mysql or Postgresql for production. My advice, sqlite is easy to learn, while give a try with Mysql or Postgresql, you might not know when your clients going to ask you to develop on them. Mysql is very popular. Postgresql I think has lot more features (personal preference).
Which database is most likely to be supported by most web hosts?
Mysql is most supported by shared hosting hence the M in LAMP (Linux/Apache/Mysql/Php). But Postgresql is getting more support too. Some hosting companies even support both but Rails developers usually prefer to use VPS (slicehost.com/linode.com) and manage all these themselves. Checkout heroku.com too for deploying your Rails app without needing much knowledge in sys admin stuffs.
Which web server is the easiest to configure? To get up and running in the shortest amount of time.
Developing with Rails you'll get webrick as a development server where you can test ur app locally. But for production I prefer modrails.com where you can choose between apache/nginx. I prefer to use apache since that is what I'm used to.
You'll want to look at RVM from the start, this takes away a lot of the pain of managing Ruby versions and gems.
Judging from the laptops I saw at Railsconf last June, Rails developers are about 90% OSX, 9.9% Linux, and there's like 1 or 2 guys on Windows.
Personally I use Textmate when I'm at home on OSX and gedit and redcar when I'm at work on Ubuntu Linux. I use sqlite for development mainly with mysql in production, but mongodb seems to be the new hotness, but I haven't done much more than some sample apps with it so I can learn it.
Virtual hosting providers will probably give you a choice of whatever database you want. Heroku is awesome and is used for deploying Rails applications via git, and uses postgres but has plugins to use mongodb if you want to go that way.
For what the community at large is doing, check out Thoughbot's survey results at: http://robots.thoughtbot.com/post/308239139/2009-ruby-survey-results
You might have a look at the Bitnami installer, which claims to create a full Ruby/Rails stack. There's also a VM version, so in theory you could just grab their VM and start coding your app. (YMMV -- personally I haven't tried it).
OS
Most ruby developers seem to gravitate towards Macs for some reason, with a few linux and some windows devs. That said, I use windows for all my ruby work and haven't really run into any huge roadblocks. Your safest option will probably be a Mac, if you want to be on the same side as most of the community.
IDE
You don't really need a full-blown IDE for ruby, as you would for something like C#. Most mac users seem to use textmate. I personally use redcar. It's not fully completed yet, but it can be used on Windows, Linux or Mac, and I've yet to run into a feature I need that isn't provided. It is written in ruby, can be extended through plugins, and supports textmate themes and snippets. To supplement redcar, I've actually written a shell in ruby for my own use. It's still in alpha stage, but I've got features like grep and ls working, and capabilities for working with and manipulating files. You can extend it with ruby, and actually use any ruby command inside the shell. It's hosted here, and is currently for use on windows. After I get some more features in, I might start looking at Mac or Linux ports.
Database
Open source options like sqlite and mysql are used widely. I don't have enough experience on them to really comment on the differences. For what it's worth, Heroku (which is great for hosting) uses Postgresql.
Server
You should use a lightweight server like Thin for development, to test your app. For production, have a look at modrails.com (as a few other answers have suggested).
Good luck with whatever you choose.
OS
80-20 Mac-Linux. I've seen one Windows ruby dev so far. If you use and debian (ubuntu is a debian), take a look at rvm, because debian cripples rubygems.
IDE
You can code ruby without an IDE, grab an editor of your choice. We've got emacs, vim, textmate, gedit here. If you really want an IDE, get rubymine.
Depends on how good your shell-fu is ;-)
DB
sqlite >:)
Server
For development, rails server should do. For production, my recommendation is unicorn, paired with nginx.
Further stuff:
http://github.com/edgecase/ruby_koans
And go for rails 3 beta.
Tutorials
ruby-lang.org/en/documentation/quickstart
Ruby community
ruby-lang.org/en/community/
I think Linux(Fedora) would be best for you
For data base mysql is very popular
most prefered web server
http://www.modrails.com/
http://github.com/fauna/mongrel
Ruby mine is good IDE
http://www.jetbrains.com/ruby/

How do Rails and Jruby relate?

Background: I have a java library that is accessed by many developers - usually via java. However, a few devs hope to access this via a Ruby API. I am gravitating in the direction of Jruby in order to implement a Java-Ruby API.
Questions:
My main concern is that these developers will not be able to utilize the API in their current, Ruby on Rails development framework; but instead will have to operate within Jruby's rails environment. Is this going to be the case?
Perhaps I'm missing a connection between Jruby and Ruby on Rails. But it seems that you can either work in Rails, or work in Jruby's rails - are these technically two different development environments?
I would really appreciate any light someone could shed on this..
Edit: Forcing developers (actually clients to be more specific) to make large changes to their projects in order to accomodate for this API is not really an option. So, if their Rails apps would have to be converted to Jruby on Rails apps, then perhaps someone could offer yet another alternative for me (other than Jruby)?
First, I should mention that Ruby on Rails is simply Ruby code, and the same code can run in the JRuby environment (on the JVM) or the MRI (written in C) runtime.
However, only JRuby can load Java classes and use a Java API. Asking your clients to switch their deployment environment to JRuby may not be feasible, but if you can set up a service in Java that speaks XML or JSON then they will be able to easily use it from Rails.
You might find the answers to a similar question helpful. Depending on your application it may be possible to seamlessly port your RoR app to run on JRuby subject to the caveats noted in that answer. But you'd want to be sure that the benefits of doing so balanced the effort and potential risks.
Alternatively you might consider making these Java library facilities available to your MRI Rails app as an internal web service (which could be Rails or Sinatra or similar) built on JRuby. That's way you would decouple the elements and de-risk the project. If you subsequently were comfortable with that working you might then consider collapsing them back together, all under JRuby-on-Rails if that made sense.
UPDATE: Adding more detail at questioners request
As I'm not familiar with what your application or Java libraries do this will be somewhat abstract but I trust you can fill in the blanks to suit your needs.
It seems that full porting of your Rails apps to run on Jruby is not feasible. Fine. So one idea would be to expose your Java library as a web service (e.g. RESTful) to your RoR application. Let's call this thing JLS. In this case it would run as a Java or Jruby network service, listening for requests, call into the library and send back responses (general waving of hands here but you get the idea).
Depending on what your developers are more comfortable with you can create JLS in Java running a Servlet container maybe. Or you could develop JLS in Ruby, running on Jruby (binding to your Java library) and use a framework like Rails or Sinatra to implement it.
On the RoR side, assuming you've made JLS RESTful (and I don't know if that's even appropriate in your case), you can use the ActiveResource facility for communicating with JLS.
In summary the RoR app and JLS run in separate memory spaces (maybe even different hosts). Each can be developed somewhat independently (with RESTful interface agreement of course) and your RoR app does not need to be disrupted or put at risk.
This suggested option comes with tons of small print but I hope you get the general idea.

Rails & MSSQL 2008 - Will We Hit Barriers?

The company I am working for is looking to switch platforms from ColdFusion 8 / Windows to Ruby on Rails / Linux. Our database solution will remain as MSSQL 2008 on Windows. I will likely follow up with a series of questions relating to this migration separately, but for now I have a MSSQL & Rails specific question.
Back in 2006 when I was working with Ruby on Rails for the first time, support for MSSQL installations was pretty iffy. Things worked for the most part, but ActiveRecord couldn't cope with certain functions lacking from T-SQL. Primarily, I recall auto-paging not working due to a lack of an OFFSET keyword like the one found in MySQL.
I am curious if our primary DB server running MSSQL 2008 will be able take advantage of most of ActiveRecord's functionality. If there are particular features that are not available, I'd be curious as to what they are.
Yes, there will be pain.
We're running Rails/SQL Server in production at the moment. All of our develompent is done on OS X / linux, and deployed to linux app servers.
We went with JRuby in the end as connecting via JDBC rather than ODBC was much less painful. JRuby itself is a good platform, but we've had no end of trouble due to quirks with 3rd party gems and plugins which often don't work under JRuby (especially if they've got native extensions).
There are still holes in the support - paging is still iffy, but kind of works now. From memory there are some quirks around unicode and character encoding as well.
The only reason SQL Server is used is because that was what the IT infrastructure team mandated. MySQL/Postgres is a much better solution if possible. It all just works.

Resources