alexander Posted July 12, 2006 Report Posted July 12, 2006 PHP, Perl, Python, Java, ASP, are all good (some arguably, but i'll call it good as in usable) languages for web development today. Yet you can already see some languages dissapear more and more, like Perl and Python. Some very rare, like Java, some very crappy, like ASP, the world of web is going into PHP/AJAX era, but how long will this streak last, and what could break it, that is what i will attempt to ponder upon in my next little bit. PHP is a solid online development language, since version 4 it has gained massive popularity for its speed, and efficiency. Version 5 brings new aspect of programming for most PHP users: OOP, and with it more people (web-developers) are drawn into the new and developing world of PHP. And now the only battle for PHP is Java, as ASP slips into 3rd place. But there is a language that has been picking up steam in the web world lately, its following has been dramatically increasing, projects growing, that has the potential to really dominate the web world in the next few years. Talking about Ruby ofcourse :thumbs_up Ruby is cool, it is a fully OO scripting language, its quick, agile, and is compilable into byte code for faster speed and efficiency, much like java. Although there are differences with it and Java, mainly there is no 300 meg platform that needs to run with the application. But Ruby would be a and was a regular programming language like Perl or Python and would not make it out to such a wide community of people, if it wasn't for Rails. Rails or Ruby on Rails is an OO database-driven MVC(Model-View-Controller) architecture that allows for easy development, deployment and maintainement of web applications. The beauty is that each peace of your code has its own place within the project, its Python-like synthax is concise without being overwhelmingly tense, that makes for easy to write and easy to read code, Ruby also has some Lisp-like abilities too, you can easily create methods that act as synthax extenders. Ruby follows the Dont Repeate Yourself rule, following the convention Ruby applications can be shorter then an XML configuration file for a typical Java app. Rails provides Development, Testing and Deployment platforms, which is cool to say the least. What can Ruby do? Well, since it is a computer programming language with a web framework, ruby can do stuff like handling Linux clustering, processing image data from satellites, student asessment evaluation for students in school districts, to a podcast search website found here:http://www.odeo.com/ in any case, it is worth doing some reasearch on, ruby, i think is the next big thing that will happen to the world of web programming, and with stuff like ajax generation, i think i wont be too wrong when i say that it may be the next PHP... Quote
CraigD Posted July 12, 2006 Report Posted July 12, 2006 I like Ruby – learned about it here, thank you. However… IMO, while the coming years may see a succession of “next big languages”, frameworks, and what have you, nearly all current software suffers from a crippling lack of visibility and extensibility. I think the chief culprit is the concept of source-to-object[-to-executable] compilation itself. The next big language, I think, will be a purely interpreted language implemented as a native operating system, similar to an odd relic from late 1970s and early to late 1980s, MIIS, as implemented on Data General “Eclipse” series minicomputers. With the increase in CPU speed and growing disparity between register, cache, and main memory access speed, the performance justification for compiled languages over interpreted ones is nearly invalidated. Unfortunately, interpreted language development isn’t an attractive field, with only a small number of fairly nitch vendors in the private sector, and little coming to my attention out of the academic (though I’ve fallen terribly out of touch with academic computing in the past decades). If only I had a few uninterrupted years, I’d illustrate what I mean by implementing it. As my professional and academic life stands at present, I can only dabble :thumbs_up PS: My awe with wikipedia grows daily – it has a MIIS entry – a very small one, but accurate. Quote
alexander Posted July 12, 2006 Author Report Posted July 12, 2006 well, Ruby is an interpreted language, it can i beleive be compiled if you want to, but it is mostly interpreted... as to extensibility, as i said, you can actually extend synthax with ruby, the lisp-like model allows you to do that by creating extender methods to the already created ones. Ruby is a breed, or bastard child of Perl and Python, but its Object Orientation gives it qualities that neither of the languages really posess. And ruby can be cpu/processor/register interactive, ruby does have a web framework, but it still is a scripting language, and it is a powerful one at that as well, making it certainly capable of doing magic... P.S. did you check out that podcast website? their podcast web-based player is sick :) Quote
alexander Posted July 17, 2006 Author Report Posted July 17, 2006 ok, hopefully this will get read by more then one person, just to showcase the crazyness of ruby development... lets build a small application... say starting points of a shopping cart... Ready, set, go. ok, start:>rails cart mmm, file managementlets go into cart/db and create a new sql file ok database: drop database cart_development; create database cart_development; drop database cart_testing; create database cart_testing; drop database cart_production; create database cart_production; grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on cart_development.* to 'user'@'localhost'; grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on cart_testing.* to 'user'@'localhost'; grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on cart_production.* to 'user'@'localhost'; use depot_development; create table products( id int not null auto_increment, title varchar(100) not null, description text not null, image_url varchar(200) not null, price decimal(10,2) not null, primary key (id) ) looks simple enough, now run it:>mysql -u root -p <db_create.sql time to point ruby to the databases:the file is located in the config directory generated under the cart folderso open up and edit database.yml: # MySQL (default setup). Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysqlqw # On MacOS X: # gem install mysql -- --include=/usr/local/lib # On Windows: # There is no gem for Windows. Install mysql.so from RubyForApache. # http://rubyforge.org/projects/rubyforapache # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql database: cart_development username: user password: host: localhost # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: mysql database: cart_test username: user password: host: localhost production: adapter: mysql database: cart_production username: user password: host: localhost now that was simple, what is next?generate the admin environment...>ruby script/generate scaffold Product Admin and what does that do? lets just say, that this has just generated a basic admin interface to our database... and you have written no code... hmm, lets test this> ruby script/server that starts up a simple server on the port 3000test this: http://localhost:3000/admin click on add new item... mmm, adminilicious ok, now this wont actually validate input, but its a start. now lets add data validation...we edit app/models/product.rb class Product < ActiveRecord::Base validates_presence_of :title, :description, :image_url #make sure that fields arent empty validates_uniqueness_of :title #make sure title is unique validates_numericality_of :price #make sure price is a number #check image_url for image file extension validates_format_of :image_url, :with => %r{.(gif|jpg|png|jpeg|tiff)$}i, :message => "You must include a gif/jpg/png/jpeg/tiff file" protected #this will generate a pretty error message if price is not a positive integer def validate if price.nil? || price >= 0.01 errors.add(:price, "price needs to be more then 0(zero)") end end end now, there is error checking as well... hmm, next...perhaps we want a client side of this app as well...>ruby script/generate controller Store index well, if we go to the store, it has a link to index... but there is no index because we have not created it, so lets go and create index in store_controller.rb def index @products=Product.show_items end but we have no show_items so def self.show_items find( :all, :order => " title desc") end hmm, perhaps we should pretty it up a bit, no?all we have to do is go into app/views/store/index.rhtml <h1>Product Listing</h1> <table cellpadding="5" cellspacing="0"> <% even_odd=0 for product in @products even_odd= 1 - even_odd %> <tr valign="top" class="ListLine<%= even_odd %>"> <td> <img src="<%= product.image_url%>"> </td> <td width="450"> <span class="ListTitle"> <% h(product.title) %> </span> <br /> <small> <%= product.description %> </small> <br /> <strong>$<%= sprintf("%0.2f", product.price) %></strong> <%= link_to 'Add to Cart', :action => 'add_to_cart', :id => product %> <br /> </td> </tr> <tr><td colspan="2"><hr/></td></tr> <% end %> </table> now, we need a stylesheet... public/stylesheet .ListTitle { color: #ffffff; font-weight: bold; font-size:larger; } .ListLine0{ background: #e0f8f8; } .ListLine1{ background: #f8b0f8; } there there, now refresh, and magic.... (this will be in app/views/store/index.rhtml) wont go into much more functionality... but tell me if there is any other language that upon writing under 100 lines of code you can have a database, admin interface with error checking to it and a customer view of the database? aint Ruby cool now? Quote
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.