Author Topic: Ruby/Ruby On Rails  (Read 7100 times)

Listener

  • Hipparch
  • ******
  • Posts: 3187
  • I place things in locations which later elude me.
    • Various and Sundry Items of Interest
on: October 15, 2007, 06:45:02 PM
I was reading up on Ruby and Ruby on Rails today after seeing scads of books about it in the bookstore on Saturday.  Is this the new hot programming language?  I thought VB was the Next Big Thing.

Any Ruby programmers able to give me a layman's explanation of the real differences between other languages and Ruby?  Is it something that might be worth learning, or is it better to stick with what I know (JS, VB)?

"Farts are a hug you can smell." -Wil Wheaton

Blog || Quote Blog ||  Written and Audio Work || Twitter: @listener42


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #1 on: October 15, 2007, 07:16:10 PM
Is it something that might be worth learning, or is it better to stick with what I know (JS, VB)?

To me Ruby seems to be even competition to VB and it comes down to what you want to learn and if you like/dislike big MS. I'm a Java guy myself and I honestly think that Java is a good place to get some experience especially if you know Ruby or VB. I have been contemplating digging into Ruby as well, but for me is really has come down to what gets me the next job and Ruby hasn't fallen into my field of vision.

I think Steve does Ruby so perhaps he has some insight into Ruby and why a VB or Java developer might want to pick it up. I for one would like to know as well.



Heradel

  • Bill Peters, EP Assistant
  • Hipparch
  • ******
  • Posts: 2938
  • Part-Time Psychopomp.
Reply #2 on: October 15, 2007, 07:25:55 PM
VB being Visual Basic?

I Twitter. I also occasionally blog on the Escape Pod blog, which if you're here you shouldn't have much trouble finding.


Listener

  • Hipparch
  • ******
  • Posts: 3187
  • I place things in locations which later elude me.
    • Various and Sundry Items of Interest
Reply #3 on: October 15, 2007, 07:33:28 PM
Is it something that might be worth learning, or is it better to stick with what I know (JS, VB)?

To me Ruby seems to be even competition to VB and it comes down to what you want to learn and if you like/dislike big MS. I'm a Java guy myself and I honestly think that Java is a good place to get some experience especially if you know Ruby or VB. I have been contemplating digging into Ruby as well, but for me is really has come down to what gets me the next job and Ruby hasn't fallen into my field of vision.


Ruby seems to me to be object-oriented PERL, and I don't know PERL.

Mostly I like VB because, to me, it's the most plainly-formed programming language in terms of syntax.  But again, that's just me.  (Except for Dim instead of var, but you can't win 'em all.)

"Farts are a hug you can smell." -Wil Wheaton

Blog || Quote Blog ||  Written and Audio Work || Twitter: @listener42


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #4 on: October 15, 2007, 08:27:49 PM
Ruby seems to me to be object-oriented PERL, and I don't know PERL.

Ouch OO Perl? That sounds like it would hurt. My experience with perl made me glad there are many other options! OO is a nice thing to have though I find that even in the OO Java world there are so many that write procedural Java that it makes you wonder what the point is.

There isn't anything wrong with VB really though I would get kicked out of the Java club for saying it. :) Actually I started off as a VB coder back in the VB3 days. I've seen enough good and bad code to know that the language is hardly at fault or to be credited for mistakes made in development. :)

VB being Visual Basic?
Yup VB is Visual Basic, though it is all .Net these days.



Heradel

  • Bill Peters, EP Assistant
  • Hipparch
  • ******
  • Posts: 2938
  • Part-Time Psychopomp.
Reply #5 on: October 15, 2007, 08:37:25 PM
Is it actually a respectable language these days? Last time I used it was my freshman year in HS (6 years ago), and that was because it was required.

I Twitter. I also occasionally blog on the Escape Pod blog, which if you're here you shouldn't have much trouble finding.


Listener

  • Hipparch
  • ******
  • Posts: 3187
  • I place things in locations which later elude me.
    • Various and Sundry Items of Interest
Reply #6 on: October 15, 2007, 08:37:56 PM
Ruby seems to me to be object-oriented PERL, and I don't know PERL.

Ouch OO Perl? That sounds like it would hurt. My experience with perl made me glad there are many other options! OO is a nice thing to have though I find that even in the OO Java world there are so many that write procedural Java that it makes you wonder what the point is.

There isn't anything wrong with VB really though I would get kicked out of the Java club for saying it. :) Actually I started off as a VB coder back in the VB3 days. I've seen enough good and bad code to know that the language is hardly at fault or to be credited for mistakes made in development. :)

I find that if I need to code something fast, I can do it faster in JS, but if I want to build a good app, I have to do it in VB.

"Farts are a hug you can smell." -Wil Wheaton

Blog || Quote Blog ||  Written and Audio Work || Twitter: @listener42


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #7 on: October 16, 2007, 01:53:16 PM
I find that if I need to code something fast, I can do it faster in JS, but if I want to build a good app, I have to do it in VB.

Yea, same here, I usually knock off simple things with JS and JSP and build out serious app s in mostly Java, though its hard to ever get away from JS. JS would be great if only the browsers has consistent support. Never have liked having to retest everything in IE and FF or Netscape back in the day.



Listener

  • Hipparch
  • ******
  • Posts: 3187
  • I place things in locations which later elude me.
    • Various and Sundry Items of Interest
Reply #8 on: October 16, 2007, 04:19:04 PM
I find that if I need to code something fast, I can do it faster in JS, but if I want to build a good app, I have to do it in VB.

Yea, same here, I usually knock off simple things with JS and JSP and build out serious app s in mostly Java, though its hard to ever get away from JS. JS would be great if only the browsers has consistent support. Never have liked having to retest everything in IE and FF or Netscape back in the day.

Back in the day?  I just had to write two versions of a toaster ad because one works only in IE but breaks Firefox and Opera, and the other doesn't work in IE but is fine in FF and O.

*sigh*

"Farts are a hug you can smell." -Wil Wheaton

Blog || Quote Blog ||  Written and Audio Work || Twitter: @listener42


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #9 on: October 16, 2007, 04:38:01 PM
Back in the day?  I just had to write two versions of a toaster ad because one works only in IE but breaks Firefox and Opera, and the other doesn't work in IE but is fine in FF and O.

*sigh*

I feel your pain! I usually debug in FF because the JS debugging tools are more accurate then ie6 (mandated here), so here I am coding to the last minute for a director meeting and in I got to demo on IE and I forgot to dbl check the changes... sigh. The browser is the best and worst client on a computer.



SFEley

  • Hipparch
  • ******
  • Posts: 1408
    • Escape Artists, Inc.
Reply #10 on: October 16, 2007, 08:56:47 PM
To me Ruby seems to be even competition to VB and it comes down to what you want to learn and if you like/dislike big MS.

Umm.  My perspective differs a bit.  I've worked in a lot of languages and platforms, and as development languages go, comparing Ruby and Visual Basic is like comparing apples and brake fluid.  VB, even in .NET, is a very high-level semi-structured language used primarily for rapid Windows development.  (Yes, I know you can create Web apps with it in ASP.  Most people I know try not to.)  Ruby's a platform-independent scripting language much more like Perl or Python.  They have almost nothing in common syntactically, and their major uses are completely different.

...That said, yes, I know quite a bit about Ruby and Rails.  The new full-time job I just picked up has me developing in it, in fact.  That was one of its selling points.

Things I like about Ruby:  It's a very elegant scripting language.  Cleaner than Perl, more efficient than Python.  It's totally object-oriented, much like Smalltalk: every single variable, constant, string, function, integer, etc. is an object.  So you can call, for instance, "3.methods" and find out all the things you can do with the number 3.  It also has a special sort of "code block" syntax I've never seen in an other language -- you can pass your own code as parameters to functions, and have those functions run your code in different ways.  It's weird at first, but once you understand it there's a sort of Taoist sense to it that makes it beautiful.  I never want to do iterators any other way again.

Things I like about Rails: Rails is a Web application framework -- its purpose is to take care of all the database access, request handling, etc. scutwork in your applications so you can focus on business logic.  There are a lot of these in the world today; the benefit of Rails is that it comes closer to telepathy, to guessing what you want, than any other framework.  For example: let's say you have an object you need to work with called Person.  All you need to do is declare:

class Person < ActiveRecord::Base
end


...and Rails knows to look for a database table called "people" (yes, it's smart about plurals), make all of those table's fields available as attributes of Person, and have scores of cleverly named functions to let you access that data almost any way you can think of.  It does all of that automatically.  That's just one example.  It's a tightly integrated MVC (model-view-controller) framework, meaning that your data is always separated from the Web pages showing it, and one of the strongest operating principles is to make sure you never have to write the same code twice.  It's not perfect and it has its quirks, but you can get basic applications running very, very quickly with it, and it makes maintainability much easier for large applications.

In short, I dig it.

Is this the sort of thing you wanted to know?  Any questions?
« Last Edit: October 16, 2007, 08:58:35 PM by SFEley »

ESCAPE POD - The Science Fiction Podcast Magazine


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #11 on: October 17, 2007, 05:51:09 PM
Things I like about Rails: Rails is a Web application framework -- its purpose is to take care of all the database access, request handling, etc. scutwork in your applications so you can focus on business logic.  There are a lot of these in the world today; the benefit of Rails is that it comes closer to telepathy, to guessing what you want, than any other framework.  For example: let's say you have an object you need to work with called Person.  All you need to do is declare:

class Person < ActiveRecord::Base
end


...and Rails knows to look for a database table called "people" (yes, it's smart about plurals), make all of those table's fields available as attributes of Person, and have scores of cleverly named functions to let you access that data almost any way you can think of.  It does all of that automatically.  That's just one example.  It's a tightly integrated MVC (model-view-controller) framework, meaning that your data is always separated from the Web pages showing it, and one of the strongest operating principles is to make sure you never have to write the same code twice.  It's not perfect and it has its quirks, but you can get basic applications running very, very quickly with it, and it makes maintainability much easier for large applications.

In short, I dig it.

I have heard good things about Rails. I have worked with so many MVC frameworks and I have yet to hear anyone say that it was easy to use (Ironic since that's the point). Java is full of framework options and most are pretty disappointing due to config or ability.

The db to object conversion interests me, having to write that for every app is such a waste of development time though often unavoidable. It can boggle the mind to think that you often pull data from a database, convert it to an object only to then send it to an html client where you will then have to post updates back reversing the process of building an object and writing to the db. Anything that eliminates that sort of trouble would be nice. 

How does Rails work with legacy databases? I know that in Java Hibernate is fairly easy to use when working with tables designed with objects in mind, but older tables often create so much complication in constituting an object as to make the whole effort quite arduous.

Thanks for sharing some insight into Ruby/Rails I'll have to dig into it more!  Steve, how long have you been doing Ruby? Oh another interesting question, what are you using for AJAX, doesn't Rails have something built in or are you using Scriptaculous or something like that?

Oh back on the Ruby being able to take code functions as parms, JavaScript can do this as well though I don't imagine that JS and Ruby are all that comparable. I've always like that feature in JavaScript though.



SFEley

  • Hipparch
  • ******
  • Posts: 1408
    • Escape Artists, Inc.
Reply #12 on: October 18, 2007, 02:33:16 AM
How does Rails work with legacy databases? I know that in Java Hibernate is fairly easy to use when working with tables designed with objects in mind, but older tables often create so much complication in constituting an object as to make the whole effort quite arduous.

Not well.  For Rails to be efficient, the entire system really has to be built with Rails in mind.  It makes a lot of assumptions about naming conventions and structure, and while you can override those conventions most of the time, you start losing the advantages the more you do so.


Quote
Thanks for sharing some insight into Ruby/Rails I'll have to dig into it more!  Steve, how long have you been doing Ruby? Oh another interesting question, what are you using for AJAX, doesn't Rails have something built in or are you using Scriptaculous or something like that?

Rails is built to integrate with Prototype and Scriptaculous.


Quote
Oh back on the Ruby being able to take code functions as parms, JavaScript can do this as well though I don't imagine that JS and Ruby are all that comparable. I've always like that feature in JavaScript though.

Yes, a number of languages will let you pass pointers to functions as parameters.  Ruby code blocks (aka closures) are something...different.  The classic example is iterators.  In most languages, if you wanted to go over all the elements of an array you'd use some sort of loop structure, and Ruby will let you do that:

MyArray = [1, 2, 3, 4, 5]
for e in MyArray
     puts "The current number is " + e + "."
end


But you could also write it as:

[1, 2, 3, 4, 5].each {|e| puts "The current number is #{e}."}

That's a trivial example; there are much more powerful ones.  Rails is full of this stuff, for everything from table operations to building HTML forms.  And that's before getting into lambdas, which still make my head spin too.

Suffice to say that there's unusual syntax in Ruby, but it's elegant once you understand what it's there for.  I like it.

ESCAPE POD - The Science Fiction Podcast Magazine


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #13 on: October 18, 2007, 01:50:26 PM
Not well.  For Rails to be efficient, the entire system really has to be built with Rails in mind.  It makes a lot of assumptions about naming conventions and structure, and while you can override those conventions most of the time, you start losing the advantages the more you do so.
Sadly I had a feeling that Rails had the same issues as everyone with old DBs, sure no fault of Rails as its such a big problem. Actually who ever finally figures out that magic trick will be very wealthy. I think it's a bit odd how companies will dive into changing the front end to something very different and never consider changing the back end to support the front. Sure there are legacy apps etc etc, but of all the places I've been no one ever even give it a though to rebuild the DB to make the front end more efficient.

The classic example is iterators.  In most languages, if you wanted to go over all the elements of an array you'd use some sort of loop structure, and Ruby will let you do that:
Some of the iterator code looks like newer Java code, perhaps I have Ruby to thank for the more recent improvements in Java collection interfaces, that was something Java badly needed. I can see why you like Rails! Guess I will add that to my, "Learn Soon List"! Can you recommend any good websites to learn from?



SFEley

  • Hipparch
  • ******
  • Posts: 1408
    • Escape Artists, Inc.
Reply #14 on: October 18, 2007, 02:27:44 PM
Some of the iterator code looks like newer Java code, perhaps I have Ruby to thank for the more recent improvements in Java collection interfaces, that was something Java badly needed. I can see why you like Rails! Guess I will add that to my, "Learn Soon List"! Can you recommend any good websites to learn from?

Get the Agile book.  It's much better than anything I've seen online.

ESCAPE POD - The Science Fiction Podcast Magazine


gedion_ki

  • Palmer
  • **
  • Posts: 35
Reply #15 on: October 18, 2007, 03:09:45 PM
Get the Agile book.  It's much better than anything I've seen online.
Will do, Thanks!