"Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof" - V for Vendetta
Thursday, January 26, 2006
OldPosts: RDBMS - a 'sql' server of my own
Wednesday, January 4, 2006
OldPosts: A new programming language
I've recently discovered a new programming language called Ruby ( in Arabic it means ياقوت ) http://ruby-lang.org. It have a very easy and intiuitive syntax. As it follows the POLS : Principle of Least Surprise its output is bug-free most of the time and you rarely need to debug.
A RAD ( Rapid Application Development ) web application framework for it called Ruby On Rails ROR is comparable to Apache Struts for Java. Using ROR you can be highly productive, a complete weblog system, like this one ( MSN weblog ), can be completed entirely from scratch including testing and administrative interface in 15 minutes. I did not believe this at first until i downloaded the movie in http://rubyonrails.org/screencasts .
ROR, just like Struts, employs MVC ( Model-view-controller ) pattern for its web applications. And one of its powerful features is that it automated ORM ( Object relational model ) for you. For example, after you create the database and create your web application ( not by typing anything, just by one click ) you'll find the web pages which displays the content and the pages modifies it is ready. If you added a column in a table in the database and just refreshing the page in your browser you'll find a new text area ( or the corresponding control to the new column data type ) is added and fully working in both the view and the edit pages!
All of the typing you will ever do, if you wanted, is that you'll just rename the page title,or reorder how the data is displayed only. Validations is declarative, not imperative. You just say "validate_exist field_name". Same with special relations like one-to-many you only say "has_many object_name". After that you will never have to write any SQL query, well, any SQL at all.
In the sample weblog he only wrote 58 lines of code. with 45 of them auto-generated. Which reminded me of a system i worked on before. It was a J2EE web application which handles the registration of a credit-hours college system. It was 3 months, 37 classes, and more than 2300 lines of code. I had to hand it with some known bugs because the college started and i had no time to fix them. After I've seen that ROR sample I estimated that all the work can be done in 30 minutes. This seems unbelievable, I know. Although I didn't actually rewrote it using ROR but we can count the time estimated. I will not include the time for database because it is already made. Say 1 minute to "click" to generate the solution, 10 minutes to navigate in the generated solution and change the "order" and "place" of data. Another 10 minutes to correct the "validations" and "test" them. This is total of 10+10+1 = 21 minutes. The other 9 minutes is for "yawning" and grabbing something to eat or drink a hot drink !! Now let's compare that to if it was done using J2EE ( not Struts ). First, create a list of the actions in the system ( 2 days ). Write the model - including a loooot of SQL statements and interfacing Java Date with SQL Data ( 3 weeks ). Implement the actions ( 2 weeks ). Implement the view - HTML/JSP pages ( 1 week ). Test ( 2 weeks, there is a lot of data to test ) [Note: ROR can generate tests for you too ]. In total of 3 + 2 + 1 + 2 = 8 weeks = 2 months ( and 2 days ). The other month was for learning Java and JSP and MVC. To be fair, i think using Struts it would take less than a week, excludsing the time needed to learn Struts. In ROR i didn't have to learn MVC nor JSP, and Ruby is so intiuitive that you can learn it in 15 minutes See: http://tryruby.hobix.com/ for a 15-minutes tutorial. Conclusion, the system can be made in 45 minutes, INCLUDING learning the langauge and ROR! ROR is so simple that it can be learnt from a few examples not even a tutorial.
I would like to write more about the origin of the language and its history with a detailed list of programming langauges popularity and Ruby's place in that list but i am really busy with the exams so I think I can add that later. Thanks for reading.