Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tomoisyourgod

macrumors regular
Original poster
May 3, 2007
239
0
Liverpool, UK
I heard this is shipping with Leopard...?

I currently develop all my websites using PHP and am looking into deploying other languages... I've read some interesting messages on this forum about it, does anyone use this?

What's the pros and cons - and is there any suggested reading for learning this?

I'm familiar with Pascal and C, and use PHP to a high end (getting into the gritty with Joomla!) would this experience allow me to quickly adapt?

Thanks for any info you guys have - much appreciated
 

Mantat

macrumors 6502a
Sep 19, 2003
619
0
Montréal (Canada)
I'm familiar with Pascal and C, and use PHP to a high end (getting into the gritty with Joomla!) would this experience allow me to quickly adapt?

Hi,

I am a RoR developper and about to release my first webapp as soon as I can fix all the CSS bugs in it :-S.

RoR is a real joy to use because of its mantra "convention over configuration", it makes you save a lot of time and remove all the dull tasks. Also, Ruby, the programming language used to create Rails, is extremely powerful, much more so than C and Java. By powerful I am not talking about raw speed (ruby is slow, but Rails is fast, and ultra scalable) but what you can do with it. I dont want to go too much into the details, but let say it is a real OO language, even a number is an object, you can type something like this:

3.times do {|count|
puts count.to_s
}

and it would output:
1
2
3

This is a small example but shows well how a real OO language can increase readability of the code.


Now the bad part... I am sorry to tell you this but you experience in PHP is probably going to play againts you. Maybe you are an exception (and I dont know the framework you talked about) but I have never seen anything made in PHP that was using design partern and was structured. The language itself isnt made to be OO so it is normal and expected.

But dont despair! The learning curve is steep but once you understand the basics it is very easy to gain speed until you hit the meta-programming concept, which you dont even need to understand...

The best book you can get to learn RoR is Agile Web Development with Rails from pragmatic programmers. There are also some screencast made by Topfunky at: http://www.peepcode.com which I totaly recommend. Finaly, check the various (free) screencast at http://www.railscasts.com once you understand enough of RoR since they deal with specific issues.

Hope this helps. I really need to setup a referal account at Amazon with all the publicity I am making for books there!

If you have questions, just reply to this thread.
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
what exactly does "powerful" mean, and how are C and Java lacking in "power"?

Not to presume I know exactly what Mantat had in mind, but...

I think he meant that Ruby is more "powerful" in the sense of how fast and easily one can build applications. The language itself is extremely intuitive and it helps that everything is treated as an object.

I don't know much Java, but I know that C is a very rigid and low-level language that you sort of have to spoon-feed unless you're working with an awesome API. Ruby feels more like English to me, if that makes any sense, and you're working on a much "higher" level.

For some examples of how easy it is to build a functioning web application with Ruby on Rails, check out the screencasts from the official website: http://www.rubyonrails.org/screencasts

Of course, in terms of raw speed, both Java and Ruby are crushed by C.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
Not to presume I know exactly what Mantat had in mind, but...
i appreciate your thoughts on the matter. i'd still like to hear mantat chime in.

C is a very rigid and low-level language that you sort of have to spoon-feed unless you're working with an awesome API.
"powerful" is such a subjective term, it can be applied to the strengths of any language, i reckon. C is "powerful" because of that low-levelness, and operating systems have been written in the language. you could also say C is "powerful" because of the lack of runtime checks, allowing one to get away with the equivalent of computational murder.

i'm not sure in what regard C is rigid and needs spoon-feeding.
 

kitki83

macrumors 6502a
Mar 31, 2004
804
0
Los Angeles
Hey that looks fun, but for someone who never got training in web dev/prog It was kinda confusing. But overall looks very easy once the basics are understood.
 

Mantat

macrumors 6502a
Sep 19, 2003
619
0
Montréal (Canada)
Powerful: able to do something that other langues cant, or at least cant do as elegantly.

Ex:
In Ruby you can dynamicaly add methods to class. Nothing new for C and Java. But in Ruby you can add methods to INSTANCE of class dynamicaly.

Ruby handle multi-inheritance with mixin which are much better than the solution available to C and Java.

EVERYTHING is an object. In java and C, strings and numbers for exemples are native variables.

Type casting is Ruby doesnt really exist. you just call the method on the object. If it doesnt have the required method, it will execute the method_missing method which you can overwrite dynamicaly to act the way you want. That is insanely pratical. Doable in other languages but require much more code.

And now the big one... YIELDing. Basicaly, you pass a function as an argument to another function. If it is possible in Java/C I would like to see that because I never went that far in the language.

These are just a few of the possible exemples. Basicaly, Ruby is stronger in the area of meta programming thanks to its OO design. Kinda like Smalltalk but more usable.

So that is why I said that Ruby is "more powerful".
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
"powerful" is such a subjective term, it can be applied to the strengths of any language, i reckon. C is "powerful" because of that low-levelness, and operating systems have been written in the language. you could also say C is "powerful" because of the lack of runtime checks, allowing one to get away with the equivalent of computational murder.

i'm not sure in what regard C is rigid and needs spoon-feeding.

I don't think anyone here has tried to downplay the importance of C, it's just pointing out how it's different than other languages.

To illustrate what I mean by "spoon-feed", I'll relate C to MATLAB (my most comfortable language). Since MATLAB is higher-level than C, one can get away with using fewer and more compact statements. This can make MATLAB more "powerful" or "useful" or "appropriate" than C for certain applications. Your choice of adjective ;)

For example, suppose I have a 5x5 array of zeros stored as a variable in memory. I want to change the second column to be all ones, instead of zeroes. In MATLAB, I write:

Code:
array(:,2) = 1

In C, I write: (my C is rusty, forgive me)

Code:
for (i=0;i<5;i++){
array[1][i] = 1;
}

Not a huge difference here, but it grows quickly. I recently wrote some finite element analysis software in MATLAB, which only took me a few days to do. It has a GUI, a visual display of 3D models, a slew of other features, and the best part is that the code runs flawlessly. This would have taken me weeks or months to develop in C.

The example above says nothing of how much it would take to write a program to actually implement this from scratch. In MATLAB, it would take a script of only two statements to declare a 5x5 array of zeros and then change the second column to ones, while it would take several statements and a few loops to accomplish the same in C (without using an API).

With respect to my "rigid" remark, I say this because of how picky C is about syntax. It is the most syntactically "rigid" language with which I've ever dealt. Ruby is far less rigid in this regard, so it allows for flexibility in expressions.

That said, languages like C are important for their lack of ambiguity and great speed of execution. Languages like MATLAB and Ruby are important for their flexibility and ease of development.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
Powerful: able to do something that other langues cant, or at least cant do as elegantly.
ha! so basically, every language is powerful.

you've got a hard-on for RoR, and that's fine. just don't make the mistake of thinking that because it works well for your use means it's automatically better than other languages. each problem demands its own solution.
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
For example, suppose I have a 5x5 array of zeros stored as a variable in memory. I want to change the second column to be all ones, instead of zeroes. In MATLAB, I write: <snip>
both you and mantat have referred to ease of language use as "power". and that's valid, but i usually think of "power" meaning what you can do with a language/technology, not so much the expression of the language.

for example, i'll say that assembler is pretty darn powerful, because you can do anything you can in another language, right? though that utterly fails your test for powerful.

i'm not saying either one of the definitions is right or wrong, i was looking for mantat to back up his statement.
 

elfin buddy

macrumors 6502a
Sep 16, 2001
608
0
Tuttlingen, Germany
both you and mantat have referred to ease of language use as "power". and that's valid, but i usually think of "power" meaning what you can do with a language/technology, not so much the expression of the language.

for example, i'll say that assembler is pretty darn powerful, because you can do anything you can in another language, right? though that utterly fails your test for powerful.

i'm not saying either one of the definitions is right or wrong, i was looking for mantat to back up his statement.

Like you said, "power" is one of these subjective words that means different things in context. You can certainly say that assembler is pretty darn powerful for those reasons, because it is in that respect. But in the respect of user-friendliness, it's weak.

Ruby is weak in terms of speed and userbase, but it's powerful in terms of development.

I'm not a programmer by trade, I just use it as a tool to speed up my work. So to me, it's very important for a language to make development easy. That's what makes a language "powerful" for me. Were I ever to develop commercial finite element analysis software, I would certainly write the program in C or one of its derivatives for the sake of execution speed.
 

iSee

macrumors 68040
Oct 25, 2004
3,539
272
3.times do {|count|
puts count.to_s
}

and it would output:
1
2
3

This is a small example but shows well how a real OO language can increase readability of the code.

Sorry, I agree with you generally, but your example is a terrible example of readable code! :D. LOL, here is the same thing in old-school BASIC--totally un-OO, but I think you've got to admit, much more readable:
Code:
FOR t = 1 to 3
  PRINT t
NEXT
 

Mantat

macrumors 6502a
Sep 19, 2003
619
0
Montréal (Canada)
Well, I want to add a few more points, not for trolling but for the sake of the discussion...

Mathlab is a Domain Specific language, that is why it is so powerful in a specific field: maths. And that is good a good thing.

There are clearly things a language can do that others cant. The usefulness of that thing is what make it powerful or not. I think this is a definition that we can all agree on. So to be considered powerful, a language would need to have more useful thing than another.

Now if you go back to the previous list of things Ruby can do, these are all things that are very useful to developers. Hence the reason I like it so much.

Ruby also has a lot of other nice features, such as being more elegant, less caractere garbage (Objective C is the worst in that field!), etc...

Every people I have show Ruby to loved it, except one of my friend who is a Senior Java programmer who simply doesnt want to learn anything new :-S. So try it for a few days, or just watch the screencast at http://www.rubyonrails.com and you will see what I am talking about!
 

zimv20

macrumors 601
Jul 18, 2002
4,402
11
toronto
Every people I have show Ruby to loved it, except one of my friend who is a Senior Java programmer who simply doesnt want to learn anything new :-S. So try it for a few days, or just watch the screencast at http://www.rubyonrails.com and you will see what I am talking about!
no one's denying that Ruby/RoR is some combination of good/useful/expressive/rapid, but i think you're taking a rather myopic view.

what are you using it for, web apps? how does it do in other contexts? is it an appropriate middle-tier language? does it work well for embedded systems? would i write a database engine in it? or a compiler?

correct me if i'm wrong, as i've taken only a casual look at the technology (including buying a couple books), but RoR strikes me mostly as a 2-tier data presentation technology, with an MVC framework built in. have i got that right? or does it work well in other situations, as i described above? if i've got it right, well good on them for making 2-tier data presentation easier to do, but they invented neither that nor MVC.

or maybe i'm making the mistake of associating Ruby too closely with Rails. are you talking specifically Ruby, or are you talking about RoR? maybe Ruby has usefulness far outside of Rails with which i'm not familiar. so aside from language expression, why is Ruby/RoR so revolutionary? educate me.
 

CoreWeb

macrumors 6502
Mar 2, 2007
456
0
Edge of reason
And now the big one... YIELDing. Basicaly, you pass a function as an argument to another function. If it is possible in Java/C I would like to see that because I never went that far in the language.

I think it can be done in C by passing a pointer to the function. Not as elegant as Ruby or Javascript I'm sure, but it is possible. I don't know about Java's capabilities in that area - I have very limited experience in Java.

Every people I have show Ruby to loved it, except one of my friend who is a Senior Java programmer who simply doesnt want to learn anything new :-S. So try it for a few days, or just watch the screencast at http://www.rubyonrails.com and you will see what I am talking about!

I'm sure I would love Ruby. However, I'm rather locked into PHP right now. Thankfully, PHP is a pretty nice language, and pretty fast and powerful. I'm locked in due to a custom database system I created in PHP. The database system could be ported, I'm sure, and would probably work much better on Ruby than on PHP, but as I don't know Ruby and don't have the time to learn it, well... I can't.

However, despite the fact that I really like object-oriented programming C++(which while it has object-oriented capabilities is not overy object-oriented in itself) is one of my favorite languages. It is just so powerful. I disagree with you on the "power" argument. C/C++ can do almost anything. It may be a lot more difficult than in Ruby, but it is possible. The most "powerful" language is Assembler, which compiles almost directly into machine code. That is true power, though it takes too much time to really write whole programs in Assembler.

So, I doubt Ruby is more "powerful" than C or C++. It may or may not be more powerful than PHP. It is definitely NOT as powerful as assembler.

But I do want to learn it.
 

Gizmotoy

macrumors 65816
Nov 6, 2003
1,108
164
So, I doubt Ruby is more "powerful" than C or C++. It may or may not be more powerful than PHP. It is definitely NOT as powerful as assembler.

But I do want to learn it.

I think the problem is that people are using "powerful" to refer to so many different things. You should just say what you mean instead of abstracting it. Ruby/Rails is quick and easy to develop for (very high level), but runs slow. C/C++ is a reasonably fast middle-ground between being easy to use and fast. Assembly is slow to develop for, but can't be beat for speed. PHP is the closest thing to RoR that I can think of, and it works very well but database implementation isn't as painless as it could be.

Where RoR really shines is the simplicity of creating a database-based application quickly. For example, http://www.coverslide.com was up and running with basic functionality in about 6-10 hours, and that included learning both Ruby and Rails from scratch, as well as the Amazon APIs. It took another 30 hours or so to tweak, but that was mostly fighting CSS and Internet Explorer to get a consistent look because I was learning CSS as well. Unfortunately, I still don't like the look, but it is functionally complete. The Database is used for search statistics.

The major downfall of RoR is poor deployment options. If you're not using your own server, you're stuck with one of the few hosts that support RoR.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.