Friday, February 3, 2006

Wednesday, February 1, 2006

OldPosts: Time travel

Quote from http://forums.lycaeum.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=9&t=000979 :

How can something move in time? It can move along the x-axis and it's velocity is dx/dt. If it moved along the time axis it's velocity would be dt/dt or 1. dimensionless one, at that. There can be no time travel.

(IMHO = in my humble opinion / OTOH = on the other hand)

Defining Travel : travel is a movement in some dimension. A movement is a change in the position of that dimension(s). A change can't happen on it's own; it must follow some external change. One would ask, the external change would need another change too. Yes, IMHO that it is an infinite loop. The change in X would affect Y which will affect Z which on the end would affect X and so on.

So to describe movement, we need to describe what changes can affect it. Before we do that we must say how was the movement described before. It was described in terms of displacement. But displacement is not enough. Because it does not uniquly identify a movement. I can move 10 meters north, or west, each is a different movement. So we need to make it more specific. We add direction. Which as may jump to the readers mind as a vector of X,Y and Z. Yes. But this is also not enough. One moving to USA in a plane at 500 KM/H and one is also moving but in a boat of 50 KM/H. Is not analogous types of movement though at the end will be the same place. At this point we needed velocity (speed). First, we ask, now we have that movement depends on displacement, thus if change in displacement = 0, there will be no movement. Direction depend on movement; if there is no movement there is no direction. Velocity introduces a new parameter. Time. If change in time = 0, there will be no displacement. But what does changes time ?

So far we defined Movement as undirectly depending on changes of time. Thus time restricts movement. There is some different argument : if movement = 0, will time change ? Some one will say 'Sure'. It may be changing. But how can you tell ? Movements will exists as long as time changes. So, if one can STOP movements, all movements. He theoritically will STOP time. OTOH, argument would say : which by contradiction, is proved if larger changes of Movement will cause time to change with the same amount. Einstien proved that, as one approaches light speed, time will shrink until it reaches zero. This is contradictory. As meaning if you are Moving in light speed, you will STOP time. But as concluded earlier this will make Movements = 0. As far as i conclude, this means that once you reach light speed, your speed will equal zero. OTOH, as your speed increase, time changes will dicrease. which lead to dicreasing in your speed. Actually time shrinking will not make your speed dicrease. If speed = dx/dt, as dt approaches zero, speed approaches infinity.

From the above one can conclude that if your speed increase then the displacement is still the same. Directly from what did Einstein proove. Given that time changes depend on the speed, and speed depends on the displacement per time unit; meaning that speed is inversly proportional to time unit. That is true if Displacement per time unit is constant. But in real life, speed only increases when the displacement per time unit increases. Which means that if we can increase the speed, while keeping the same displacemnt per time unit, then we can decrease the time unit. which will force us to recursivly decrease displacement to keep the ratio constant. When displacement reaches zero, time unit will equal zero. This is undefined as displacement zero is undefined. This was to shrink the time unit. Shrinking the time until means that we move faster relative to other slower entities. Ironically, in a race moving faster means that you reach the finish line first, which is other racers future . Meaning if you can increase the speed and decrease the displacement you will move to future. Descreasing the displacement is only meaning to decrease the new disp/t after t decrease, so it means slowing down while you increase your speed. This is moving to future. Moving to past means jumping over the zero time barrier, which is met when you are moving at the speed of infinity and not moving out of your place (note that this means going to infinite future). Jumping over the barrier requires you moving at negative infinity , while you are moving "inside you place" (displacement zero). As you reach -n speed where n <>

This all is an argument which expresses the conditions for Time travel IMHO. It shows a lot of contradictions. Which if sometime is solved it might happen to travel through time.

Thursday, January 26, 2006

OldPosts: RDBMS - a 'sql' server of my own

RDBMS : Relational Database Management Systems.
Actually this idea came to me while i was thinking of what project to do in the compilers course; that was last summer. It was orignally about parsing SQL, but it was extended to a full idea of a DBMS.
I liked the idea. Overtime, ideas to implement and how to implement it started to accumulate. Until it had to burst out. Knowing how to do something, and wanting to do it, is a powerful force. So i started seriuosly thinking about implementing it this vacation. I started by reading some book called "Database management systems, 2nd edition". A great introduction which gave me a great backgroung on the basics of the database theory and Relational algebra and calculus ( search for it in http://wikipedia.com ).
There is different kinds of DBs, i will mention the names only, not diving in details. Old systems includes Navigational databases. Then about 70s they invented the well-known commonly-used Relational databases. Now there is Object Databases, supporting OOP. This is NOT the whole list, it is just what i could remember for the moment.
What really made me think seriously about making one myself, is an articel i read on Mohamed Meshref's Blog about one student who made one server which can -under some circumstances- execute some queries faster than Oracle's.
With all that information on my head, i opend Visual C++, created an empty header file, gazed at the screen for about 10 minutes trying to figure how to start. As from experience i knew that all systems starts small, i did that. I made a small program that saves an array of structs in a file. And then focused my "grey brain cells" -like Agatha Christie said- on how to generalize that to any user input; on the same struct ( username, pk, and age ). I figured it needs a SQL parser, so i left that part, and went in the other direction, how to generalize the struct contents first ?. I found a great one here http://groups.google.com/group/comp.lang.c/browse_thread/thread/527b451b96ce957a/d612253f370e6aab?q=variable+length&rnum=3#d612253f370e6aab . So i started designing the datastructures required.
I forgot to mention that in coincidence i read in "Introcution to Algorithms" about B-Trees and how they are used in DBMS to index tables in order to minimize disk I/O. Imagine thay can minimize disk I/O for a billion-record table from 32 IO read ( using binary search ), to only 3 IO reads ( of course it traded-off to 3000 comparisons ).
The second step after designing the data structure is defining the way of altering a table's content. Then after that build a way to handle 'parsed' queries and mapping them to these APIs. Parsing SQL is not an issue, some hours with Yacc/flex, and BOOM we have one.
The only remaining part, is what is required "exactly" from a DBMS. The basic implementation/engine is defined by Relational calculus. Other parts will just complay to any SQL standard, i have chosen SQL-92.
As usual i feel this is too short article, maybe i will follow up sometime with part2 or something continuing the in-depth details of the data-structures and how i 'will' -isA- handle the data integrity checks, and table altering, and the indexing problems - B-Trees is not easy to implement yo know !
I'll just go complete the data-structure heirarchy now, wish me luck!

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.