Other Software > Developer's Corner
Why Ruby is so great and why I'll pass and wait for the next big thing..
Eóin:
Well I have to agree also that 20.minutes.ago is utterly ridiculous :D
mwb1100:
This snippet
--- Code: Ruby ---def shutter_clicked capture_image if @camera.on? && @camera.memory_available?end
--- End quote ---
reminds me of the "COME FROM" construct that was proposed to replace the 'evil' GOTO statement many years ago (from http://www.fortran.com/come_from.html):
Example:
--- --- 10 J=1
11 COME FROM 20
12 WRITE (6,40) J STOP
13 COME FROM 10
20 J=J+2
40 FORMAT (14)
Explanation:
In this example, J is set to 1 by statement 10. Statement 13 then causes control to be passed to statement 20, which sets J to 3. Statement 11 then causes control to be passed to statement 12, which writes the current value of J. The STOP statement then terminates the program.
--- End quote ---
The problem with using
--- Code: Ruby ---20.minutes.ago
is that even though it's obvious what the intent is, it's not obvious at all exactly what's going on so that I can be sure the contructs are being used correctly.
I would argue that the equivalent in .NET:
--- Code: C ---DateTime.Now.AddMinutes( -20);
I nearly as readable as far as determining intent, but it has the huge advantage that in the same instant that you determine the intent of the statement you also know exactly what's going on so you also understand the operations producing the intended result.
fro:
I would have written
--- Code: Ruby ---Time.now - 20*60
even though
--- Code: Ruby ---20.minutes.ago
is available through some librabry. :)
svv1999:
--- Code: Ruby ---def shutter_clickedif @camera.off? || @camera.memory_card_full? // the camera either got turned off by mistake or is full // TODO: write error handling and detect which problem // for now let's just return without an error. returnend // ok, camera is ready so let's capture the image // TODO: make sure to reset camera state later capture_imageend-mouser (May 23, 2007, 07:53 PM)
--- End quote ---
From this code fragment I conclude:
* The coder created his code on the fly
* The coder created his code from some sample, therefore the intents he expresses in comments might be wrong
* The coder might not know the generic prereqisites of "problem"
* The coder might not know the difference between detecting a problem and exploring its causes
* The choosen language has no constructs to signal incompleteness of the code
* The coder is a friend of trivial redundant comments
* The choosen language has no constructs for ad hoc protocols
* The choosen language might not have constructs for protocols at allIf there is some interest to discuss these points I will give further reasoning.
mitzevo:
I thought about giving RoR a go.. I don't really like the look of it.. And I don't want to learn another language..
Actually I'm quite happy with PHP and a framework or two.. There are a few RoR based frameworks for PHP, Akelos for example:
The Akelos Framework is a PHP4 and PHP5 port of Ruby on Rails Web Development Framework
--- End quote ---
Navigation
[0] Message Index
[*] Previous page
Go to full version