Thank you all for the posts. They were all helpful and inspiring. I am
neither live in States(I live in Turkey) nor a native speaker and Louis
Scoras presented my problem beautifully much better than I could. So I
especially thank him for that.
First of all, I would like to say that the problem is valid for all
variables. You can mistype a local variable name in the same block and
just create a second variable instantly. You can create an instance
anywhere in the class by adding @ in front of the variable name. If you
mistyped an instance variable name in a method, probably the one you had
properly initialized in your constructor, oops, sorry, you just created
new variable and had a brand new bug. If you are agile guy, and spent
time writing test for every little functionality, hopefully you would
it soon. Nothing protecting us from these kinds of errors. For global
variables, constants they have all the same problem.
What I have understood from all the posts, is that; there is no
way for predeclaration of variables. All the solutions that you have
provided includes partial solutions to the problem and includes some
of error handling or conventional code and using them consistently
do not want. According to me, they look ugly in such a consistent
language. Besides that kind of custom solutions, according to me, just
increase the complexity of the code.
I would like to comment against posts which simply emphasizes that the
interpreter can not think for us. I know that of course. What if we
tell the interpreter by saying that these are the variables that I am
to use in the class scope, in a block, in a method or in global scope
and ask the interpreter not to allow any other variable usage in the
specified scope? Then the interpreter would definitely know our intent?
What I liked most about ruby how easy to write classes. While using ruby
had to mind shift myself persistently for using object oriented
in even small scripts. Writing classes, using objects are no longer
The built in attr_* removes all burden of getters and setters etc. For
example to write a class in perl, java, c++ one has to implement all the
getters or setters. In perl, one can use some custom modules from cpan
creates a class for you, but all of which all are non-standard
some of the most widely used ones come with the distribution, but they
not part of the language) There are many other jewels that ruby has
or in its standard libraries. Ruby made unconventional, custom
implementations made public and mainstream by making them built-in to
language as in attr_* example. On the other hand, for the problem that I
present in my post, I am required to implement custom solutions which
partially solve the problem. The problem that I stated here is one of
biggest sources of unintentional bugs. Ruby is supposed to cut down
development time and reduce the unintentional complexity dramatically.
one of most high level languages I have encountered. So I believe ruby
should have not missed this feature. I really hope to see that ruby
supports these with a new set of keywords in its next releases.
do not think that ruby would be able get of out scripting and the
lightweight web world or get into world big production systems. I
ruby has a capacity to go forward if these kinds of doors could be
Of course, I talk without understanding the language guts. I know that
variables are just references and everything is dynamically decided etc.
may not be easy to implement this. I do not know. But as the
of ruby, I find that my development time does not dramatically increased
much as I expected. Yes I develop faster, but I lose the time that I
in coding in testing. I prefer testing the functionality and the
requirements not the guts. If I can run the code, I expect that language
issues must be solved. I am very much suprised when I receive a no
error. Why do I have to run the statement just to see that object does
have that method implemented. I would like to deal with bugs that are
by the misapprehension or misimplementation of the problem. I expect the
compiler, interpreter to handle inconsistencies in the language usage
itself. Ruby currently mixes the problem domain with the language
because it does not let developer inform itself about language set the
developer wants to use. I do not expect the language to be as strict as
by default but it should let the developer to configure how strict the
interpreter should be. In perl, a developer can dynamically command the
interpreter how strictly interpret the code. If perl can, whose latest
release about 12 years old, ruby has got to do this.
I prefer a language that loudly shouts at with discriptive information
I do something wrong instead of running but producing erroneous results.
Just because of this I have the habit of using zillions of assertions in
code when I developed in other languages. I have not been able to find
assertion module in ruby by the way (yes I know, you do not need it
it is very easy to write one or hey, another answer why do I ever need
it…:)). I really admire you all guys because of your self confidence.
Yes, as the Pickaxe books says strict typing made some code less
and less reusable, but I am ready to make that compromise most of the
if my name depends on the correct functionality of the software I wrote.
My comments are not to criticize ruby language and its community but to
contribute to it’s perfection. I already feel myself as rubyist but
want this language make its way more broader domain, even better to my