浏览 3808 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-09-25
是ruby官方网站写的,比较了其他主流编程语言和ruby的异同之处,给出了ruby比较有特点的功能介绍,相当棒!推荐 http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/ What to Expect: Language X to Ruby * To Ruby From C and C++ * To Ruby From Java * To Ruby From Perl * To Ruby From PHP * To Ruby From Python Important Language Features And Some Gotchas Here are some pointers and hints on major Ruby features you’ll see while learning Ruby. 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-09-29
http://www.railscn.com/viewtopic.php?t=1961
狗尾续貂 时间: 2006-9-07 周四, 上午10:07 标题: 理性PK-PHP, Rails, Java, ASP.NET Comparison 引用回复 编辑/删除文章 删除这篇文章 http://www.shawnwashere.com/blog/?p=28 Common Web Platforms: A Pragmatic Comparison Bookmark post on del.icio.us A Preface about Databases If it is imminent that a company will be using MSSQL, then PHP and Ruby should probably be ruled out all together. At least this is true at the time of writing. MSSQL connectivity from a linux/unix platform is very limited. Freetds.org does have a driver, but its way behind and uses deprecated methods of communicating with MS SQL Server 2005. I tested linux based MSSQL connectivity in the past and found it to be terribly slow compared running the application code on a windows machine. Simply put, in my experience, when dealing with MSSQL server it is best to run everything else on Windows, except for Java. Java has pure type 4 drivers that are pretty darn fast from any platform, but rarely as fast as native drivers. Unfortunately, other architectures like PHP and RoR depend on open source drivers like freetds or unixODBC (I believe ODBC is terribly slow hack to connect to a database and maintain database independence), which is not up to spec. Sure, one could could run PHP or RoR on Windows but this is not the optimal production environment for these languages. Furthermore, ntwdblib.dll is deprecated and this is the library that is used by PHP and RoR to connect to SQL Server on Windows. If ASP.NET is your web platform choice, then yes, MSSQL server would be a wise choice of a database due to integration with the development platform. Java to MS SQL Server communication is robust, but a database platform and its tools trickle down to the application development level. There are combinations of technology that work better or worse with a given database. If your not going to use a database to its fullest, then what is the point of moving to another database. Your database and toolset do go hand in hand, regardless of how hard we try to abstract which database platform our code is talking to. This abstraction costs development time and money, and most of the time businesses don’t switch databases because it costs so much money to rewrite and retest all the DB specific SQL code. Oracle has the widest support for all of these technologies due to its great linux/unix support, but costs a small fortune to scale with. Companies which use Oracle and SQL Server normally scale vertically with multi-CPU machines, many times up to 32 processors, before attempting to anyone tries to scale these databases horizontally. I assume this is due to minimizing overhead from database replication. MySQL on the other hand scales horizontally, but you need to be clever about how you do it. There is a link in the references to an article on Flickr architecture which explains this creativity. This article might be a bit out of date due to MYSQL 5.1 being in Beta. If a company must use MSSQL Server as their database platform, its decision makers should strongly consider ASP.NET and Java, with a thorough consideration for ASP.NET. I elaborate more on this in the comparisons below. PHP Pros * Large developer base * Excellent Documentation * Easy to learn and manage * Rapid no compile development as with many scripted languages * Cheap to implement and maintain - Digg, Flickr, Jobby maintained by 1 to 4 developers * Its relatively fast performance wise. As fast or just behind java developed web applications. Many times PHP is faster tha Java if Java framworks use layer upon layer abstraction * Yes its scalable - But just like Java or anything else it has to be written correctly. “Share Nothing” Architecture ensures scalability in PHP. Sessions are shared through the database or file system. Nothing else should be stored or shared between requests at the level of the PHP application. * Version 5 adds full OO support * View centric nature allows rapid development without getting lost in layer upon layer of abstraction as in J2EE * Logical 3 tier development architecture can be obtained using Smarty templates for view and PHP objects for business logic. Frameworks like WASP give you full Model View Controller support. * Free open source technology stack, LAMP(Linux, Apache, MySql, PHP) * C/C++ integration * May expose services by using Hessian, REST or SOAP * Great library of tools including AJAX, Web Services Cons * MSSQL Server 2005 support is very lacking, best running against mysql or oracle. * If you write PHP code into a singe logical layer, as in embedding all logic in many html pages, your going to have a large mess for enterprise projects. * No namespaces * If you stray away from LAMP it will not be optimal for production, with the exception of using Oracle. * Mainly meant for web applications/services. I know there is a command line interpreter, but who uses this for backend business processes? * Remoting limited to layers like Hessian, REST or SOAP * If you write service logic into php applications, you could have to re-implement logic in another language to reuse the code in backend business processes. * Distributed Transactions must be coded manually if needed. * Cannot fork php processes when used as an Apache Module * PHP is bad for background daemon processes. More Info for PHP Flickr (1.5 billion pages view a day) and Digg (500 million pages views a day) and other heavy traffic websites prove PHP, and MySQL for that matter, does scale. Digg served 200 million page views a day on “3 web servers and 8 MySql database servers”. Comparatively, Myspace.com uses Coldfusion and handles 18.5 billion requests and has “2,682 Web servers, 90 Cache servers with 16GB RAM, 450 Dart Servers, 60 database servers, 150 media processing servers, 1,000 disks in a SAN (storage area network) deployment, three data centers and 17,000MB per second of bandwidth throughput.” Which shows how inefficient Coldfusion is. If you do some math you can guesstimate that Digg would need 28 web servers and 74 database servers to handle that load. That is just a rough guess using ratios. In my opinion, it would be best to hand off requests for long running processes to a Java server or J2EE service of some sort. This could be done via Hessian, REST, or SOAP. Hessian is preferable for performance. Ruby on Rails, and Ruby as a Language Pros * An MVC framework for Ruby helps separate presentation from business logic * Unit tests are built right in. * Don’t repeat yourself principle makes for less painful development * Rapid no compile development * Convention over configuration and meta-programming does away with all the xml configuration you have in a Java framework like Stuts. * Active Record Object Relational Mapper needs very little mapping configuration. * Heavy Ajax Support, Prototype and Scriptaculous helpers are in Rails * Built in XML Web Services * The Ruby language is pretty easy to learn. Everything is an object. Its clean and easy to read. * Easy model validations * Very quick to develop applications from the ground up when you have control over the database schema * Share nothing architecture. Session data is stored on disk or in the database so it could be shared amongst many nodes * Ruby is dynamically typed, which allows for easier development in my opinion since one can just check to see if an object has a method instead of worrying about what kind of type it actually is. * Classes are never closed so you can easily add methods to any class, even other apis. This allows active record to dynamically create method names for each database columns at run time. There is no need to update a mapping schema when you add a column to the database, the method is “magically” there. * Closures allow for dynamic behavior that would take much more code in Java. * It protects developers from common mistakes. It follows best practices which should be adhered too in new development. Also, since it scales by process you don’t have to worry about developers trying to create threads in the application container which could bring down the container. * Mongrel Server gives a Rails application its own container and speeds production requests greatly. * Ruby has been around for some time, first developed in 1993. Ruby is a language in itself was was not created to be web specific. Cons * Limited legacy schema support. You pay in added code for someone else using composite primary keys in the database schema. Not a show stopper, but you lose the quick development features of the ActiveRecord database model each time you have to account for this. * Freely available api documentation is seriously lacking. Books are fairly decent but they are having a hard time keeping up with the rapidly evolving framework. It makes it hard to know about deprecated practices. * If you cannot follow the best practices for some reason you are forced to solve the issues by hand. * Generated Scaffold code is pretty useless when working with a database that doesn’t follow the rails specs. You have to customize a great deal, then again the word is that we are not supposed to be using scaffolds for real development, which was one of the main selling points of rails. * Scaling by process can eat a lot of memory on the server. Memory is cheap though. * No built in internationalization support. * No plan to include better legacy database support. * SQL Server(all versions) support is very lacking and has the same problems just as PHP. I would not use it for production against SQL Server. * Rails is a fairly new framework compared to PHP and Java, so there are not as many developers, but many are eager to learn. * Limited IDE environments. Textmate is the best but it only runs on a Mac. More Info on Rails Just to keep it straight, Ruby is a language and Rails is an MVC framework for Ruby. 43things.com handles 40 million requests a day with Ruby on Rails. Like PHP, it would be best to hand off requests for long running processes to a Java server or J2EE service of some sort. This could be done via Hessian, REST, or SOAP. Hessian is preferable for performance due to its compact binary protocol. Java(Web Framework In-specific) Pros * Bytecode doesn’t have the overhead of the scripted languages. * Large user base. * Plenty of documentation * Too many web frameworks to mention (Struts, JSF, Spring Webflow) * Platform independent support for just about any database thanks to many tool vendors. * J2EE is a proven Enterprise solution * Excellent for background processes and services. * High performance, multi-threaded web applications can be built in java. * Scalable but you have to make sure you are writing it to be scalable just like any other language. * Supported on many platforms. * Netbeans and Eclipse are both great, free, IDE’s. * Java supports threads, as does ruby, but java is not limited by a framework like rails that doesn’t allow threads. * Excellent choice of open source and commercial containers, such as Tomcat, JBoss, Jetty, Websphere, Weblogic. * Large amount of open source and third party apis. * Many layers of abstraction can make for easy code reuse. Cons * More verbose syntax than Ruby or PHP due to its static typing. * Static typing doesn’t allow for the meta-programming that is prevalent in rails, so you end up with a great deal of xml configuration, which is getting better with annotation support. * Slower to develop a web site because there is more to worry about from a developer standpoint. Developers have the ability to create threads in the container and do things that could cause problems down the road. * Compile, Build, Deploy, Test can add development time without a nice ide that integrates with your development application container. * By far not the easiest platform I have development in. With platform independence and this much capability there is a lot to think about if you want to develop an application to scale. * Many layers of abstraction in many java architectures slow development greatly. More info on Java We cannot just assume that our code is scalable if we write it in Java. We have the same considerations as the other platforms. We must push for stateless code and minimize session usage. Passing state back and forth in hidden variables would be preferred to push the state to the client where it really belongs. This has worked well for me in the past. Many containers support session replication across nodes, but this adds overhead and network traffic. I believe it is best to minimize session usage. And there are many sites that run Java. Serverside.com and Javalobby both hit 40 to 50 million pages hits a day. Java.com does 1 billion page hits a day. ASP.NET(C#) Pros * Easy for Java developers to learn * Drag and drop development of web pages. * Windows dependence allows for great remoting since platform independence does not have to be taken into account. * Visual Studio is and always has been a nice IDE. * Integration with Office and the whole suite of Microsoft technologies. * Just as fast to develop in as Rails or PHP. * Easier development model with SQL Server due to tight integration with IDE. * Highly integrated with SQL Server 2005 * One platform, One container (IIS) keeps development simple * Large developer base Cons * Locked in to Windows platform. You pay for portability in the other development stacks on this page. * You have to use IIS on Windows, which is not as widely used as Apache, but its came a long way. * IDE costs $$$, $700 a head. * You must be careful with the drag and drop development, especially on the database side because data is immediately loaded into a Dataset by generated code. If youíre wanting to display a great amount of data in a report, don’t use this. Instead use a Reader to read the data row by row and build the web site, cut out some of the abstraction. * IIS Security? Windows Viruses? More info on ASP.NET You get a lot for committing to a platform. My Asp.net, C#, and .NET remoting experienced made me realize this. plentyoffish.com does ~24 million page views a day with 1 Windows IIS server and 1 MSSQL Server. http://www.readwriteweb.com/archives/plentyofcash.php. Sure the IDE costs dough, but $700 is not much when you consider how much development time costs. If we are going with SQL Server we will have the best integrated experience period with .NET. Java processes and systems can be accessed via Hessian, REST, TCP/IP, SOAP, which is common in overall architectures. References * http://www.eweek.com/article2/0,1895,1947684,00.asp * http://www.alexaholic.com/ * http://en.wikipedia.org/wiki/RubyonRails * http://scalewithrails.com/downloads/ScaleWithRails-April2006.pdf * http://www.oreillynet.com/pub/a/databases/2006/02/16/hamysqlcluster.html * http://www.niallkennedy.com/blog/archives/2004/10/flickr_architec.html * http://www.zefhemel.com/archives/2004/09/01/the-share-nothing-architecture * http://us3.php.net/manual/en/function.pcntl-fork.php * http://www.oreillynet.com/onlamp/blog/2006/04/diggphpsscalabilityandperf.html * http://www.onjava.com/pub/a/onjava/2003/10/15/php_scalability.html _________________ ------------------ 铁道珠宝中文站点大汇展 http://railscn.crispynews.com/ R4R读书会 http://r4rclub.schtuff.com/ 欢迎加入铁道播客,订阅铁道播客 http://feeds.feedburner.com/rorcast |
|
返回顶楼 | |