because our client has some NDA agreement, and I think I can use sugarcrm as the example, consider you have some project large like this, 50+ files, every file more than several thousand lines, after that you just go crazy. not to whether you're writing extension points for it. And handling customized ORM rules, things like adding a field/relation/in ui, than the database will be filled with one more table, say your table is Contract, and the adding fields would be added to Contract_cust, and your ORM takes care of that, I just don't think ActiveRecord copes that well.
On Thu, May 5, 2011 at 9:01 AM, femto Zheng <femto...@gmail.com> wrote: > Yes, quite agree. > 'But the generated Ruby you show above would cause most > Rubyists to flee.' > Yes, I agree. If without those bizarre php's variable behavior, > I would just compile local variable to local variable, > > 'I'm still quite unclear on *why* one would want to rewrite a complete > > package like SugarCRM in Ruby; after all, PHP is supported practically > anywhere there's a web server, and any package big enough to be worth > translating is likely to have an extension API. Further, it's not like > it's going to be simple to extend the spaghetti that the translation > produces in Ruby...' > > First, we all agree that php's valid code, > > public function getHelper() > { > > if ( !($this->helper instanceof DBHelper) ) { > global $sugar_config; > > switch ( $sugar_config['dbconfig']['db_type'] ) { > case "mysql": > $my_db_helper = 'MysqlHelper'; > if ( (!isset($sugar_config['mysqli_disabled']) > || $sugar_config['mysqli_disabled'] == false) > && function_exists('mysqli_connect') ) > $my_db_helper = 'MysqliHelper'; > break; > case "mssql": > if ( function_exists('sqlsrv_connect') > && (empty($config['db_mssql_force_driver']) || > $config['db_mssql_force_driver'] == 'sqlsrv' )) > $my_db_helper = 'SqlsrvHelper'; > elseif (is_freetds() > && (empty($config['db_mssql_force_driver']) || > $config['db_mssql_force_driver'] == 'freetds' )) > $my_db_helper = 'FreeTDSHelper'; > else > $my_db_helper = 'MssqlHelper'; > break; > default: > $my_db_helper = 'MysqlHelper'; > } > $GLOBALS['log']->info("using $my_db_helper DBHelper backend"); > require_once("include/database/{$my_db_helper}.php"); > $this->helper = new $my_db_helper(); > $this->helper->db = $this; > } > > return $this->helper; > } > is perfectly beatiful, if php can support no '$' before variable. > before doing this project I think php is stupid language, but after this > I change my mind, actually php's code is quite well written and > encapsulated(if without that '$'). That's no wonder why DHH, who's > background is php, comes to ruby and writes out Rails, but no somebody > that with a java background comes to ruby and writes out Rails,that's not > without > a reason. Because php's just syntax noise more than ruby. Many mental > position > is still good.ps, we all know ajax right, coined by Jesse James Garrett, > after > that people know ajax, but before which the xmlhttp just exists there many > years > and going unnoticed.same for the php, php exists there many years and > neglected > by rails' guy and think it's spaghetti code. > > > For phuby you mentioned, I'ved checked out, > it says it requires php, it still needs you to download and compiles > php-5.3.0 to your box, so it's a simple wrapper around php? > the final code is still php? > No, our goal is makes your code Ruby/Rails, > say you download a simple php project, and puts it into your disk, > > e:\php-project\sugarcrm, > and then you just fire a up a rails application > and config.host = "e:\php-project\sugarcrm" > and it runs.It will compiles your accessed php file and to a related > .rb file > > so for the compilation part, > if you think _VARS["a"] perfectly equal to $a or(a in ruby's sense), > the ||={} is just coping with php's accessing optionally equals to hash, > then the whole mental model would be very simple.after that, when the > whose system can be running, then you can simply change/extend a > certain point, > we all know ruby's quite easy to extend, so may you put your custom > code in some /custom/include/dbmanger.rb > and requires that, (or you may wan to more put into rails > folder,app/controller/model or something) > self.helper = sugar_config['dbconfig']['db_type'] + 'Helper' if > ["mysql,mssql"].include?(sugar_config['dbconfig']['db_type']) > > Just like I claimed, tons of tons good stuff/wealth buries in php, > like say, > cssmin: > > class cssmin > { > public static function minify($css, $options = "remove-last-semicolon") > { > $options = ($options == "") ? array() : (is_array($options) ? $options : > explode(",", $options)); > if (in_array("preserve-urls", $options)) > { > // Encode url() to base64 > $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", > $css); > } > // Remove comments > $css = preg_replace("/\/\*[\d\D]*?\*\/|\t+/", " ", $css); > // Replace CR, LF and TAB to spaces > $css = str_replace(array("\n", "\r", "\t"), " ", $css); > // Replace multiple to single space > $css = preg_replace("/\s\s+/", " ", $css); > // Remove unneeded spaces > $css = preg_replace("/\s*({|}|\[|=|~|\+|>|\||;|:|,)\s*/", "$1", $css); > if (in_array("remove-last-semicolon", $options)) > { > // Removes the last semicolon of every style definition > $css = str_replace(";}", "}", $css); > } > $css = trim($css); > if (in_array("preserve-urls", $options)) > { > // Decode url() > $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", > $css); > } > return $css; > } > I know there'll be a ruby equivalent, I am just giving an example, > what if there's not a cssmin funtionality, but some other > fancy funtionality? > > > On Thu, May 5, 2011 at 12:44 AM, Ar Chron <li...@ruby-forum.com> wrote: > >> Femto Zheng wrote in post #996564: >> > Hello all, because most of php's application is feature rich than >> > rails's existing offer, >> > like say, crm solutions, sugarcrm, >> > I know rails have similar offering,( fat_free_crm), but unfornately, >> > this is really far >> > from the feature sugarcrm offers, >> > sugarcrm has been developed since 2004, all 7 years, and has been >> > funded >> > $2 million in venture capital, I just don't think anyone could port >> > that easily in >> > a short time frame. >> > >> > for hand-rewritten the php's application, well, that's at least >> > theoretically, >> > I've done that before, that's quite time-consuming and error-prone. >> > >> >> Possibly time-consuming, yes. Error-prone depends on the tests that are >> in place... But the generated Ruby you show above would cause most >> Rubyists to flee. >> >> If the entire application is translated with that amount of syntactic >> noise, what is your maintenance path? Edit the original php >> application, then translate again?!? >> >> I'm not knocking your accomplishment (Lord knows I've written code that >> writes some awfully ugly code), but there a wide gap between >> syntactic/semantic correctness and syntactic/semantic "elegance", and I >> think the "elegance" attribute is what has drawn many people to Ruby. >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk@googlegroups.com. >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > http://hi.baidu.com/femto > http://www.aisiming.com/ > > -- http://hi.baidu.com/femto http://www.aisiming.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.