Ruby on Rails

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
http://www.rubyonrails.com/

This video (2 hours and 160MB!) is very cool, and the project all around is pretty spiffy. It almost seems like it could make me not hate web development. I absolutely abhor PHP, and I've done a fair amount of web dev in Python (on moin), which was better, but still often ugly. Rails seems to really have it together. (and really, it has nothing to do with Python vs. Ruby -- as far as I can tell, Rails could have been done in Python in a pretty similar fashion)

What do you guys think?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I've actually seen alot of comparisons between r-o-r and java on theserverside.com. I don't know exactly what it's all about, or if it really is comparable to java, but most of what I've heard has been pretty good :)
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Not too hard, since Java is f@#$king nasty. :D

Kinda funny that on one extreme you have the very "fast and loose" (to the point of being messy) PHP, and on the other end Java, which is so over-designed it's ridiculous. I guess it was only a matter of time before something popped up to fill in the gap.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
How's java 'over-designed'? I'm not trying to start a big debate or anything, I'm just curious about what in particular makes you say that.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
public classy pubic bone {
public static final chocolate creamy puff(String yadda) {
SuperMegaObjectifierFacility whatever = new SuperMegaObjectifierFacility((ElEmEnOhPee)yadda);
...
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
And while I could explain it more than that, I don't have the energy. The language just seems so ridiculous to me that I can't imagine any reasonably experienced programmer not seeing it.

(not that it's worthless -- dear god java people, don't lambaste me! admit it! the language is ridiculous!)
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Sounds like your main complaint is that highly abstracted, reusable, extensible OO code gets wordy. In that case, you are correct, but it isn't a java 'over-designed' thing. Any OO language will end up looking like that if you have an experienced developer (with the goals of abstraction, reusability, and extensibility).
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Kilrsat
Sounds like your main complaint is that highly abstracted, reusable, extensible OO code gets wordy. In that case, you are correct, but it isn't a java 'over-designed' thing. Any OO language will end up looking like that if you have an experienced developer.

Then it's odd that Java is the only language I've seen that was so wordy.

And verbosity is not my only issue -- it was just a good opportunity to be silly.
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: BingBongWongFooey
Originally posted by: Kilrsat
Sounds like your main complaint is that highly abstracted, reusable, extensible OO code gets wordy. In that case, you are correct, but it isn't a java 'over-designed' thing. Any OO language will end up looking like that if you have an experienced developer.

Then it's odd that Java is the only language I've seen that was so wordy.

And verbosity is not my only issue -- it was just a good opportunity to be silly.


Pick up any Design Pattern book, in a language of your choice, you'll see the exact same thing.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Hey. Back to the original topic. I believe it says "Ruby on Rails", not "Java is over-designed"! ;) <edit> And my aplogies for pulling it off course in the first place </edit>

Tell us more about it. I was under the impression that it was a tool for object oriented persistence (similar to hibernate) but I'm not aware of it's web capabilities. Does it work as an apache mod? Does it have it's own web server?
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0

Originally posted by: kamper
Tell us more about it.
Well I'm not an expert. :) I'm just getting into it myself.

I was under the impression that it was a tool for object oriented persistence (similar to hibernate) but I'm not aware of it's web capabilities.
Sounds like you might be thinking of something else. It's a framework for web apps, using pretty standard MVC concepts but seemingly done in a very concise and ingenius manner. You create a DB table called "tasks" with columns "id", "name", and "description", and generate a class stub called "task", and your task class now automatically has id, name, and description properties. You can assign to them and call the object's .save() and it'll save it back to the database. It also makes it extremely simple to set up relationships between tables, and even sets up those sub-instances -- like "some_person_instance.assigned_task.name". It's an implementation of the "active record" design pattern. (*nudge nudge Kilrsat*)

Then you have the templating system which is simply ruby embedded in HTML a la PHP, except that you only put layout code in them. The business logic is in the model backend.

And then you have controllers which map requests to business logic and ways to display them, also doing things like filters. (like an "auth" filter which ensures for every request that the user has the right credentials, or a caching filter, etc)

But this is just the stuff that I've absorbed so far. I've done no coding other than tutorial hello world type stuff. But it looks like I will probably be using it at work reasonably soon.

Does it work as an apache mod? Does it have it's own web server?
In development "mode," it simply operates via cgi. You can set up mod_ruby or fastcgi for production, if you need more performance. There's also a simple built-in webserver. (also mainly just intended for development, not production, AFAIK)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: BingBongWongFooey
I was under the impression that it was a tool for object oriented persistence (similar to hibernate) but I'm not aware of it's web capabilities.
It's an implementation of the "active record" design pattern.
Which makes it exactly what I thought it was ;) (plus all the other stuff like the controller and view layer that I didn't think it was :eek:)

 

notfred

Lifer
Feb 12, 2001
38,241
4
0
On the "java is overdesigned" thing... C# does a lot of what java does, but it does it better. You don't have to do this:

try{
some simple code that will never fail
}
catch(SomeStupidExceptionThatYoullNeverGet e){
// trash
}

if you don't want to.

You don't have to write a whole new class to do a simple event handler.

Java has some problems.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Zugzwang152
very "fast and loose" (to the point of being messy) PHP

give me an example of this, where PEBKAC != true.
The standard library. The history of PHP's creation and evolution.

I love how PHP people are always flabberghasted when I say bad things about it, and yet, countless times, I have seen programmers (as opposed to web developers) who used PHP for a while and grew to despise its messiness. The guy in the rails video touches on that once or twice. I love that guy.
 

fs5

Lifer
Jun 10, 2000
11,774
1
0
Originally posted by: BingBongWongFooey
Originally posted by: Zugzwang152
very "fast and loose" (to the point of being messy) PHP

give me an example of this, where PEBKAC != true.
The standard library. The history of PHP's creation and evolution.

I love how PHP people are always flabberghasted when I say bad things about it, and yet, countless times, I have seen programmers (as opposed to web developers) who used PHP for a while and grew to despise its messiness. The guy in the rails video touches on that once or twice. I love that guy.

I'm going to have to agree. I've used java servlets, python + clearsilver, PHP, and perl.

Out of those 4, python+cs was the best environment for me. I'm going to have to check out RoR. I've been hearing a lot about Ruby lately.
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
Originally posted by: BingBongWongFooey
Originally posted by: Zugzwang152
very "fast and loose" (to the point of being messy) PHP

give me an example of this, where PEBKAC != true.
The standard library. The history of PHP's creation and evolution.

I love how PHP people are always flabberghasted when I say bad things about it, and yet, countless times, I have seen programmers (as opposed to web developers) who used PHP for a while and grew to despise its messiness. The guy in the rails video touches on that once or twice. I love that guy.

eh, well i don't think PHP was ever meant as a true programming language. it is tuned for use as a web scripting language, and it does its job amazingly well. having no experience with it outside this realm, i can't object to what you're saying.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Zugzwang152
Originally posted by: BingBongWongFooey
Originally posted by: Zugzwang152
very "fast and loose" (to the point of being messy) PHP

give me an example of this, where PEBKAC != true.
The standard library. The history of PHP's creation and evolution.

I love how PHP people are always flabberghasted when I say bad things about it, and yet, countless times, I have seen programmers (as opposed to web developers) who used PHP for a while and grew to despise its messiness. The guy in the rails video touches on that once or twice. I love that guy.

eh, well i don't think PHP was ever meant as a true programming language. it is tuned for use as a web scripting language, and it does its job amazingly well. having no experience with it outside this realm, i can't object to what you're saying.

I can agree with that. If PHP stuff stayed small and simple then it'd be fine, but the problem is that oh, we need this feature on our website, oh and this thing too, oh and and and .. then you end up with thousands of lines of code. The only difference in my mind between "web scripting" and "programming" is the amount of code involved. Some single webpage that does some fancy stuff with a form is a script, but an entire website doing all kinds of things and having thousands of lines of code is ridiculous to try and accomplish with "web scripting" without having an utter mess. When your code gets to a certain size you really need to have a "true programming" language if you want to maintain your sanity.

IMO!
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
Originally posted by: BingBongWongFooey
Originally posted by: Zugzwang152
Originally posted by: BingBongWongFooey
Originally posted by: Zugzwang152
very "fast and loose" (to the point of being messy) PHP

give me an example of this, where PEBKAC != true.
The standard library. The history of PHP's creation and evolution.

I love how PHP people are always flabberghasted when I say bad things about it, and yet, countless times, I have seen programmers (as opposed to web developers) who used PHP for a while and grew to despise its messiness. The guy in the rails video touches on that once or twice. I love that guy.

eh, well i don't think PHP was ever meant as a true programming language. it is tuned for use as a web scripting language, and it does its job amazingly well. having no experience with it outside this realm, i can't object to what you're saying.

I can agree with that. If PHP stuff stayed small and simple then it'd be fine, but the problem is that oh, we need this feature on our website, oh and this thing too, oh and and and .. then you end up with thousands of lines of code. The only difference in my mind between "web scripting" and "programming" is the amount of code involved. Some single webpage that does some fancy stuff with a form is a script, but an entire website doing all kinds of things and having thousands of lines of code is ridiculous to try and accomplish with "web scripting" without having an utter mess. When your code gets to a certain size you really need to have a "true programming" language if you want to maintain your sanity.

IMO!

well that's true to a point. how much can you blame on the language and not on the programmer though? A crafty programmer will code towards the language's strengths, imo. however, there is strong evidence of your point. Highly interactive and complex sites very rarely use PHP, in fact most use aspx that i can tell, even the AT forums now... but there are very few of these sites comparatively, as compared with the millions and millions of individuals and small to medium sized companies that can leverage PHP a lot easier and cheaper than a commercial language. In the end though, I can't fathom a PHP program/script that would take a significant amount of code more than something written in a different language.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Zugzwang152 Highly interactive and complex sites very rarely use PHP, in fact most use aspx that i can tell, even the AT forums now... but there are very few of these sites comparatively, as compared with the millions and millions of individuals and small to medium sized companies that can leverage PHP a lot easier and cheaper than a commercial language.

But! The whole point of this thread is that it's not just big buzzwordy commercial solutions vs. PHP. There are other solutions and Rails seems like an extremely excellent one.

In the end though, I can't fathom a PHP program/script that would take a significant amount of code more than something written in a different language.

I can. Look at any of the Rails examples and show me a PHP equivalent done in less code or even nearly the same amount of code, while still achieving the separation of layers and other things that make it more clean, sane, easy to test, etc.

I've done significant amounts of web stuff in both PHP and Python and with PHP I constantly run into things that feel painful, while not so much in Python.

Silly things like not being able to do function_that_returns_array(someargs)[0] and instead having to do an array_pop around it or whatever (I'm pulling this out of memory but you get the basic idea). PHP's heredoc string syntax is awesome for doing <<<SQL
INSERT yadda
THIS is correctly SYNTAX HIGHLIGHTED IN VIM! woohoo!
SQL;

But you can ONLY end a heredoc with a semicolon. Want a comma or some other stuff? <<<SQL
TOO bad
SQL
, some more args...); # barf

Escaping db query strings is ugly and painful. Gotta check for these "magic" (ugh) quotes and then maybe addslashes or stripslashes. Of course if you're doing anything serious you should probably use something higher-level like Pear DB, but the add-on dance gets pretty old, and for something as intrinsic as formatting SQL queries, it's kinda silly that the built-in stuff is so flaky.

I'm babbling and I should cut myself off here. The specific reasons don't even matter, really. It's the generalities that matter, and for PHP to ever be a "generally" good programming language, it would have to reinvent itself. My main issue is that it's always promoted as being the end-all be-all of web development and that it's perfectly ok to write entire web applications in it.
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
But! The whole point of this thread is that it's not just big buzzwordy commercial solutions vs. PHP. There are other solutions and Rails seems like an extremely excellent one.

I agree, I meant PHP as a generalization for OSS or otherwise free solutions vs. commercial products. PHP is still the most popular for web development at least. :)

Silly things like not being able to do function_that_returns_array(someargs)[0]

I wasn't aware that this wasn't possible, however I don't consider this to be a significant disadvantage. it adds a single line to dump the result of the function into a variable and access variable[0]. True, it will add up in a complex (non-web) application, but the performance hit is negligible to non-existant, and it doesn't deteriorate readability of the code either.

PHP to ever be a "generally" good programming language,

I am very close to certain this well never happen, because it would lose focus on its intended function of web scripting. it is, after all, called PHP: Hypertext Preprocessor. :D
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Zugzwang152
Silly things like not being able to do function_that_returns_array(someargs)[0]

I wasn't aware that this wasn't possible, however I don't consider this to be a significant disadvantage. it adds a single line to dump the result of the function into a variable and access variable[0]. True, it will add up in a complex (non-web) application, but the performance hit is negligible to non-existant, and it doesn't deteriorate readability of the code either.

That's why I said that specific examples are kind of a waste of time. Yes this one thing is not a huge deal, but there are these "little" things everywhere and they end up changing the whole experience.