Liquid Fire Posted April 6, 2007 Share Posted April 6, 2007 What is your opinion on Ruby on Rails. I have been told by a few poeple at work that this is going to be the future of web development instead of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/ Share on other sites More sharing options...
bcamp1973 Posted April 6, 2007 Share Posted April 6, 2007 that's a pretty strong claim. Ruby on rails has lots of great qualities but it's not perfect either. It's quite a bit more resource intensive than PHP from what I understand. Also it's syntax isn't "typical"...so, if you're new to programming it's supposed to be easier to pick up. However, people with a fair amount of experience will have to rethink things a little. You might spend some time on the official website (http://rubyonrails.org/) and also review some of the rather heated threads on http://slashdot.org regarding Ruby/Rails. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223113 Share on other sites More sharing options...
Liquid Fire Posted April 6, 2007 Author Share Posted April 6, 2007 I know that PHP was orignally designed for Web Develpment, is Ruby designed for specfically Web Development? Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223121 Share on other sites More sharing options...
zq29 Posted April 6, 2007 Share Posted April 6, 2007 Be careful here, Ruby on Rails is not actually a language. It's a framework for the language Ruby. Do you work for a web development company? If not, what makes your colleagues so qualified that they can make a statement like that? Sounds more like they've grabbed hold a a buzz-word to me... Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223142 Share on other sites More sharing options...
per1os Posted April 6, 2007 Share Posted April 6, 2007 If you ask me, due to the fact that Ruby is "easier" for coding would make it less appealing than PHP. Simply because PHP right now is very powerful for the language. The only thing more powerful to me is PERL. Ruby may be a breakthrough for people who do not know how to program very well, but for the "real" programmers who know C++, C, Java, and PERL will not want to be limited by "kiddie" language. That is just my opinion. I have not tried Ruby due to the fact of it's nature. I do not like the fact that it might limit me in what I can do. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223145 Share on other sites More sharing options...
Liquid Fire Posted April 6, 2007 Author Share Posted April 6, 2007 Be careful here, Ruby on Rails is not actually a language. It's a framework for the language Ruby. Do you work for a web development company? If not, what makes your colleagues so qualified that they can make a statement like that? Sounds more like they've grabbed hold a a buzz-word to me... Yes, i do infact work with poeple who are web programmers, we maintain a couple of very popular springbreak/school trip sites that run tours. The person who is tell me this is the head of IT and he does know web programming. he was telling me that something that would take 100 lines in PHP would take 10 in ruby on rails. Is there a simliar framework like rails for PHP? Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223155 Share on other sites More sharing options...
redbullmarky Posted April 6, 2007 Share Posted April 6, 2007 The person who is tell me this is the head of IT and he does know web programming. there's a contradiction in terms if I ever heard one anyway. you seem to have missed the point. and if it's your IT teacher, then so is he and should be fired. Ruby = language. PHP = language. Ruby on Rails = framework built USING the language. therefore, Rails and PHP ARE NOT COMPARABLE to eachother. Ruby is also NOT an easy language to learn, contrary to what people say. Sure - there's a "how to build a blog in 3 seconds" video tutorial, which to be honest makes Rails seem easier than scoring in a brothel, but that's Rails - not Ruby alone. CakePHP/Zend/CodeIgniter are frameworks modelled around the same MVC pattern as Rails. CakePHP is (was?) significantly based on Rails and therefore allows you to write the same 'Hello World' and 'Blog apps' in 10 lines of code or whatever. The whole point of frameworks is to cut down the amount of code written for each and every project - helping to minimize effort on common tasks. Stuff like parsing input, validation, database access, etc - most of it's done by the frameworks. Don't get me wrong at all - Ruby looks like a nice solid language and Rails is a nice framework that to be honest is probably the only reason Ruby is what it is today - but yeah, it's a buzzword to go next to "Web 2.0" in the buzzword dictionary. I keep saying this also, but what you need to remember is that both PHP and Ruby (irrespective of frameworks) are far more superior/powerful than their output (HTML) - so the choice between the two often generally boils down to what you already know. Cheers Mark Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223214 Share on other sites More sharing options...
Liquid Fire Posted April 6, 2007 Author Share Posted April 6, 2007 there's a contradiction in terms if I ever heard one What do you mean by this? Anyways, I have been reading on php and ruby and was thinking that there are other frameworks for PHP and why nobody ever talks about them, almost every topic i see is PHP vs Ruby on Rails. Also when i look at ruby code is just looks so wierd to me(I started with C/C++ and the did PHP when i started web prorgramming). Another thing i read is that Ruby is complete OOP, even variables are objects. This seems the the big difference from C++ and C#. I don't know why but i don't like that to much(just liek i perfer C++ over C# for the same reason. It just seems to i lose some of the power that PHP gives me. I just trying to research both of these becuase i am current designing a web-based project management application and wondering if it would be worth moving to ruby for rails. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223226 Share on other sites More sharing options...
redbullmarky Posted April 7, 2007 Share Posted April 7, 2007 there's a contradiction in terms if I ever heard one What do you mean by this? well - at least with our teachers - we soon realise the difference between "being able to teach" and "being able to do". Anyways, I have been reading on php and ruby and was thinking that there are other frameworks for PHP and why nobody ever talks about them, almost every topic i see is PHP vs Ruby on Rails. They do talk about them lots - it's just that PHP is more popular than any of its frameworks, but Rails is more popular than its language. I've been doing PHP for a good couple or 3 years now I guess, and yet only came across Cake/CodeIgniter/Zend Framework/Symfony, etc when I started digging around for stuff about MVC and OOP. Most topics about PHP vs RoR also tend to try and point why comparing a framework to a language isn't fair. current designing a web-based project management application and wondering if it would be worth moving to ruby for rails. read my other comment - PHP, ASP, Ruby, you name it - they're all far superior and more powerful than their resultant HTML, so it really doesnt matter. If you're using to PHP, stick with it. If you like Ruby because of Rails, then stick to PHP and get a framework like one that I've mentioned above. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223234 Share on other sites More sharing options...
akitchin Posted April 7, 2007 Share Posted April 7, 2007 If you're using to PHP, stick with it. If you like Ruby because of Rails, then stick to PHP and get a framework like one that I've mentioned above. and there's the crux of the discussion here. all framework considerations aside, i doubt ruby or its rails framework will ever knock PHP off the face simply because so many people already know and love PHP. i personally haven't played with ruby or rails; it isn't because i have some sort of grievance with rails, it's just because i'm comfortable and well-established with PHP. furthermore, rails is quite a bit harder to find a competitive host for. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223274 Share on other sites More sharing options...
Liquid Fire Posted April 7, 2007 Author Share Posted April 7, 2007 Which PHP framework would you recommend? The onlything i really care about is the license, i want to be able to sell my product that uses the framework without worry about not being able to selling it. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223326 Share on other sites More sharing options...
tomfmason Posted April 7, 2007 Share Posted April 7, 2007 I am a fan of code igniter. Most of these guys will probably say that CakePHP is better and I would agree, to a degree. It is also not very well documented and is more complicated but it is more flexible then ci. I could be wrong but I think you can sell your code with most good frameworks without worry. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223331 Share on other sites More sharing options...
redbullmarky Posted April 7, 2007 Share Posted April 7, 2007 Cake is closer to Rails than CodeIgniter but CodeIgniter is initially easier to use and is packed with tonnes more stuff out of the box. Personally I like CodeIgniter too but used it as a stepping stone to learning Cake quickly - both are somewhat similar. CakePHP is released under a MIT licence so selling code won't be a problem. CodeIgniter have their own here: http://codeigniter.com/user_guide/license.html Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223503 Share on other sites More sharing options...
tomfmason Posted April 7, 2007 Share Posted April 7, 2007 Yeah I just looked at that and there license sucks. I guess I am not going to use code igniter anymore just because of that. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223525 Share on other sites More sharing options...
steelmanronald06 Posted April 7, 2007 Share Posted April 7, 2007 I have been told by a few poeple at work that this is going to be the future of web development instead of PHP. What most people don't realize is that Ruby has been around almost as long as PHP. The only reason it has started making a bang on the programming world is because of Rails. Now, as for what do I think of Ruby and its Rails framework? Ruby itself is okay, and with the Rails framework it is no doubt powerful. One thing I didn't like is the syntax and the compiler for it seems really slow. For PHP, I just have to do minor optimization on my code for it to run at an efficient level, but I had to do a lot of optimization in Ruby to make a noticeable change. :-/ I guess, what I'm trying to say, is that Ruby is catching up to PHP, but that is only until we get a PHP on Rails. Which we now have CodeIgnitor, CakePHP, and Zend Framework. If one of those would just kick it into high gear, get people using them, and make themselves popular enough, PHP would make a come back. I think the main problem with it, though, is that people were programming for a long time in PHP before any type of Framework hit the market. Now that it has some people don't want to bother with learning a framework or they have a hard time so give up. That is only because they learnt to code without a framework at first, and now their trying to re-learn their coding standards. With ruby, it really didn't catch on till Rails came out, and so when people picked it up they were learning Ruby with a framework all at once, so it was easier and that is what they thought they liked about it. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223574 Share on other sites More sharing options...
steviewdr Posted April 7, 2007 Share Posted April 7, 2007 Nice thread discussion on PHP Frameworks, and also licence info! I didnt see any mention of symfony. I read a little on it a few weeks back and I think it was more enterprise and heavy-weight. CakePHP seems to be the one of choice. Keep it rolling.*steviewdr waits with anticipation -steve Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223782 Share on other sites More sharing options...
Liquid Fire Posted April 8, 2007 Author Share Posted April 8, 2007 Ok maybe i am missing the point and someone can correct it. I mean framework should make coding easier but all the examples i have seen seem like that same amount of code i would have coded if i created my own classes or used free open source classes from places like http://www.phpclasses.org/. I thought frameworks should cut down the amount of code i need to write. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-223878 Share on other sites More sharing options...
redbullmarky Posted April 8, 2007 Share Posted April 8, 2007 they DO cut down the work. Consider a real life example. Imagine you have a forum. Now imagine how many SQL queries you'll be making throughout the entire lot - for dealing with logging in, retrieving usernames, etc, etc - the list goes on. Now - consider an example from something like Cake or Rails (both of which work in a similar way) UserModel.php <?php class UserModel extends Model { // no code here needed! // all methods are inherited, but this model will // automatically attach itself to a table called // 'users' due to the classes name. } $user = new UserModel(); // load all users $all_users = $user->findAll("active = 'y'"); // load just record based on username // uses method overloading - specifically the __call method. $just_me = $user->findByUsername('redbullmarky'); // create/update a user based on $_POST array // validation is done by the Model class itself and returns errors // how many lines of code would this NORMALLY take? $user->create(); if (!$user_id = $user->save($_POST)) die('error saving'); ?> think how many times you create login/validation/cleaning/saving code in each project, time after time, and how mundane it is. at the end of the day though, whilst they DO cut down the amount of code, don't just expect them to do everything for you - you still need to put the graft in, and if you're not prepared to, then maybe a CMS like Drupal, etc would be much better for the task at hand than a framework. I didnt see any mention of symfony. I read a little on it a few weeks back and I think it was more enterprise and heavy-weight. CakePHP seems to be the one of choice. My main reason for picking Cake and CodeIgniter was just the fact that both seemed logical to me. Not that the others aren't, but these two just seemed comfortable and straightforward. Symfony just seemed a bit too complex for me. Also I liked the fact that Cake enforced a structure on me for my application files - the sort of kick up the arse I need to make sure I don't produce a mess, but also in a way makes it easier to learn as no confusion as to where everything should go etc. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224044 Share on other sites More sharing options...
Liquid Fire Posted April 8, 2007 Author Share Posted April 8, 2007 Ok well maybe someone can explain something for me. How can findBy<FieldName> overload __call? To me that just does not make sense. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224080 Share on other sites More sharing options...
redbullmarky Posted April 8, 2007 Share Posted April 8, 2007 i'm not sure what you mean... you'll find most of the info here: http://uk3.php.net/overload the way i use __call in this way is pretty much like: <?php class test { function __call($funcname, $params = null) { if (substr($funcname, 0, 9) == 'findAllBy')) { echo 'you wish to find all user records by ' . substr($funcname, 9); echo '<br />the parameters you want to send also are:<pre>'; print_r($params); echo '</pre>'; } } } $mytest = new Test(); $mytest->findAllByUsername('redbullmarky'); $mytest->findAllByOccupation('Freelancer'); ?> does that help or did i miss the point of your question totally? Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224088 Share on other sites More sharing options...
Liquid Fire Posted April 8, 2007 Author Share Posted April 8, 2007 Well i think it helped alittle if i understand correctly. So with __call defined if i call a method that is not defined(like you did with findAllByUsername and findAllByOccupation) if is going to be processed through the __call method? I was just confused when you said overloading since PHP does not support overloading. overload to me(coming from a C++ backround) is when you have 2 functions named the same with different parameters. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224100 Share on other sites More sharing options...
redbullmarky Posted April 8, 2007 Share Posted April 8, 2007 overloading to me is a little sketchy to talk from a technical POV since I guess I use it the best way I know how - how C++ do it is beyond my scope but yeah you got it in one. it's very handy for setting up "pseudo-methods" like this. PHP 5 natively allows use of the __call method. PHP4 does support it to an extent with just the attition of the overload function. One that Steve mentioned, Symfony, also uses the __call method in this fashion to handle table columns - and now I use it myself, I honestly think it's very useful to have. For further reference, you could do worse than checking out CakePHP's impementation of models - which does bring much of the Rails-type functionality to PHP. My own framework is heavily based on Cake, but differs in some ways - but here's a basic outline of my login method in my Users class that I now use for EVERY site I do. function login() { if ($this->input->post) { if ($user = $this->User->findByUsername($this->input->post['username'])) { if ($user['User']['password'] == md5($this->input->post['password'])) { // login succesful } } } } compared to the huge amounts of validation, etc I used to use, it really cuts things down. Also, my registration - all I do is specify what fields need validating and what they should contain (which doesnt differ much from project to project so I can generally get away with minor tweaks). As a result, my entire registration script (method) is a bit like: <?php function register() { if ($this->input->post) { $this->User->create(); // start with a blank // try and save the user. the model will do my validation for me. if I do need // additional validation, I'll do it before doing the following. if (!$newuser = $this->User->save($this->input->post)) { $this->view->set('errors', $this->User->errors); } else { // success! redirect to "thanks" page and prompt user to login or something. // i COULD also automatically log the user in or prompt for activation $this->redirect('/users/welcome/'); } } } so you see that my entire registration script page is tiny (obviously there's a template involved, but that's just HTML and another story) - all the validation is done for me, all the cleaning up of "attacking" code is done also, and I can pretty much knock up the PHP code for a login page in 2 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224103 Share on other sites More sharing options...
448191 Posted April 8, 2007 Share Posted April 8, 2007 Well i think it helped alittle if i understand correctly. So with __call defined if i call a method that is not defined(like you did with findAllByUsername and findAllByOccupation) if is going to be processed through the __call method? I was just confused when you said overloading since PHP does not support overloading. overload to me(coming from a C++ backround) is when you have 2 functions named the same with different parameters. These magic methods more accurately facilitate 'object member overloading', sometimes referred to as 'object overloading'. I unfortunately do not know how that works in C++, but I reckon the concept is the same regardless of the syntax: a request is intercepted, and commonly delegated to a second object. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224179 Share on other sites More sharing options...
448191 Posted April 8, 2007 Share Posted April 8, 2007 I refreshed my memory and will try to explain it to you. Method overloading in C++: multiple methods have the same name, but their calling routine differ by number of arguments and/or their type. The method to be used is chosen by the compiler. Class member overloading in PHP: methods with predefined names intercept requests for undefined class members at run time, again allowing different length argument lists and types. User defined code may decide what to do with the request depending on the type of the arguments and the name of the memeber requested. The most common application is to delegate it to another class member, object, or another class' static member. Delegation to aggregate object: <?php private function __call($name,$params){ //Overload method call. if(method_exists($this->doc,$name)){ return call_user_func_array( array($this->doc,$name),$params); } else { throw new FooException( 'Unable to satisfy request to "'.$name.'".' ); } } ?> Internal class delegation: <?php class Foo{ public function method1($arg){ echo 'Executed the method with one argument'; } public function method2($arg1, $arg2){ echo 'Executed the method with two arguments'; } private function __call($name,$params){ $delegateTo = $name.count($params); if(method_exists($this,$delegateTo)){ return call_user_func_array( array($this,$delegateTo),$params); } else { throw new FooException( 'Unable to satisfy request to "'.$name.'".' ); } } } class Foo{ private function methodForHandlingEmailAdress($arg){ echo 'Executed methodForHandlingEmailAdresses'; } private function methodForHandlingNAWList($arg){ echo 'Executed methodForHandlingNAWList'; } private function __call($name,$params){ $delegateTo = $name.'ForHandling'.get_class($params); if(method_exists($this,$delegateTo)){ return call_user_func_array( array($this,$delegateTo),$params); } else { throw new FooException( 'Unable to satisfy request to "'.$name.'".' ); } } } ?> So yeah, it isn't the same as in C++ or Java, but it can behave similarly, and is definately very flexible (although probably less efficient, but that is just a guess). One might argue that it is less robust - the payoff for flexibilty - but it is as robust asyou make it. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224228 Share on other sites More sharing options...
Liquid Fire Posted April 8, 2007 Author Share Posted April 8, 2007 so would this be correct: <?php class CTest { private function __call($name, $param) { if(substr($name, 0, 5) == "GetBy") { //get the field we are check for, this will always be lowercase wether or not the method is $field = strtolower(substr($name, 4)); $mysql_object = new MySQL(); $query = "SELECT * FROM test WHERE {$field} = '{$param[0]}'"; $result = $mysql_object->GetOne($query); } return $result; } } //so the __call method will process this method, correct? $test = new CTest(); $test->GetByID(123); ?> I mean this is kinda cool and diffidently an interesting feature of php that i did not know about till now and this seems perfect for me as some of my classes were going to have to use 20 different Get method and 20 different Set Methods and 20 GetBy Methods and so on and this will really help cut down the code for that, all i need is just a sperate lopp inside the function instead of a method for each one(right there is 60 methos alone). I don't think i will be using any framework for my project management site i really don't see if help me but maybe that is just becuase i don't understand them fully. I mean already have a work mysql class i built myself, just need to add security stuff and other stuff but i think i will try to use Cake for the "Website" portion on my project. Quote Link to comment https://forums.phpfreaks.com/topic/45930-ruby-on-rails-vs-php/#findComment-224351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.