
Journal Com2Kid's Journal: Why don't people just add some syntatic sugar to C++? 5
I was reading a really old document and GCC has (had?) this C++ extension that lets you use the
This is one of the few things I liked about Ada, you get the nice little range operator! You won't believe how handy this is!
int intArray[1..10];
Hey look, no more off by 1 errors!
Now for some types of problems, 0 based arrays are REALLY nice, often times when doing stuff involving the modulus and what not. No problem
int modArray[0..9];
This is a very simple (stupid simple) thing for the compiler to implement. Heck it can be done already using pointers any ways, it is just a pain to set up.
Oh and vectors piss me off because I can't fix their size, anybody know of a data storage type in C++ that gives me the
I was reading some C++ stuff on the internet, and this C++ guru dude was bitching about how inefficent Java's syntax for allocating an object was;
ObjType myObj = new ObjType();
He said it was way too redundent and slowed down a programmer's overall coding speed.
Hey now, stuff is CODED once, and DEBUGGED forever-after.
Edit: C++ is internally consistent, in general something needs to be deleted only if it was newed, so that is ONE advantage of limiting use of the new operator. The disadvantage being that you end up with 4+ ways to declare and initialize a variable.
ObjType myObj;
instanciates an instance of myObj, depending on where you declare it at.
Of course, for pointers;
ObjType* myObj = new ObjType;
if you are not using the default constructor:
ObjType* myObj = new ObjType(param a, param b,
Now mind you for non-class types to get a variable assigned a value you do
Type myVar = someValue;
Compare this to Java, there are TWO and ONLY TWO ways to get yourself a variable with an assigned value.
Type myVar = someValue;
Type myVar = new Type();
first form for non-classes, second form for class types.
DONE DONE DONE DONE DONE
Without the equals sign it is ALWAYS a variable declaration NOT initilization, not like in C++ where if you do
ClassType myVar
in a
Fun, nope. Irritating.
Double edit: Oh and I just love how a foreward declaration of a class is not consistent with how classes are normally declared, since when a class is normally declared it gets initilized, like it or not. (yes this is proper OO in one sense, a class should always have a valid state, but on the other hand, if an uninitilized class is actually USED for anything the program is going to barf anyways, so it is not like data corruption is going to occur!)
Blech! Somebody needs to BASH SUN ON THE HEAD and have them standardize on a MACHINE CODE COMPILER for Java. Wipe the earth of these other languages.
Actually someone just needs to beat Sun upside the head in general.
Re:smoking something good? (Score:1)
True it is convenient often times, but other times it ends up requiring you do a constant "index - someVal" too all array accesses.
Non-standard personal APIs for data structures are generally not a good thing.
Re:smoking something good? (Score:1)
note to self, buy a copy. The class is using some retarded book from Walter Savitch who likes to describe things in the simplist cases (for instance he NEVER ONCE shows an example of using templates and classes together...)
Unfortunately getting the money together to buy any books not strictly required in my courses is rather hard.
Almost every other modern language has a .