You know you're in for a bad day of programming when....

When I started with BASIC (urghhh) the system/editor had a facility that automatically renumbered to increments of 10. Of course, when a high school teacher then tried to introduce us to Pascal, my brain had already been tainted. Thankfully Uni enlightened me.


Back in <cough> I only had access to a disassembler built in to the Apple][ ROM and so inserting code was a nasty issue.

I basically started out with a machine code monitor as well. In fact the first one I used didn't even have support for mnemonics, you just had a hexdump of upcodes. In fairly short order (8-9 months) I got a monitor with mnemonic support, then progressed to Commodores slow as molassees two pass file based assembler and finally on to Turbo Assembler which had everything in RAM and was lightning fast.

cheers
 
With regards to GOTO, I think it's acceptable in C but not C++. In C, it's used frequently for handling errors. There's really no other elegant solution for handling cleanup at the end of a function in the event of an error.

In C++, you should be using RAII which is a far superior solution to manual cleanup. Having objects clean up after themselves not only eliminates the need for GOTO, it also aids in staying exception-safe.

For things like nested loops, I prefer sentinel booleans to signal exit. This works just fine for doubly- and triply-nested loops. If your loops are so deep that sentinel variables become unwieldy and you think you need a GOTO, you probably need to refactor your code.
 
For things like nested loops, I prefer sentinel booleans to signal exit. This works just fine for doubly- and triply-nested loops.

"Sentinel Boolean"? I've not heard the term before. Care to elaborate because a Google search didn't return anything that was immediately enlightening.
 
Sometimes programming really drives me insane, I wasted about 4 hours today trying to figure out how to use a function in VBA. absolutely retarded. After I figured out that it had to be called via a sub routine I coded everything i needed to code in about 15 minutes... arg.
 
"Sentinel Boolean"? I've not heard the term before. Care to elaborate because a Google search didn't return anything that was immediately enlightening.

I assume something like
Code:
bool bContinue = true;
for ( int i = 0; i < 100 && bContinue; ++i )
{
   if ( ... )
   {
      ...
      bContinue = false;
   }
   else
   {
      ...
   }
}
 
That's the idea. Perhaps it would have been clearer if I had said "using a boolean variable as a sentinel".

Code:
bool timeToExit = false;
for(int i = 0; i < 10; ++i)
{
    for(int j = 0; j < 10; ++j)
    {
        if(...)
        {
            timeToExit = true;
            break;
        }
    }
    if(timeToExit)
        break;
}
 
This is quite common in C/C++, but I think it's not a very good solution, because if you modify the program to add another layer of loop, you'll have to remember to add another sentinel. This can be problematic when the loop is large and there're more than just a few people maintaining the same code.

I think it's still better to have a Java/C# style of "lable break" to be able to break from deep loops.
 
Upon starting a programming course
on the first day we had an induction, were some woman wen over the course details rules ect
"We dont tolerate sexism racism ect"

/Me puts hand up
"Does that include the french"
cue laughter from fellow students.

she looks at me rather awkwardly "yes it does" she says sharply.
"and now a quick word from the faculty head Mr Corbière"

oops....
 
I wish people still programmed in Pascal. Really elegant code to learn with, and not the horrendous hack that is C.
 
I loved pascal, started on ms quick pascal 1.0
the great thing about ms qp was the compiler error msg's were stored as a plain text file and you know how obtuse compiler error msg's can be. Thus began project plain english, where i changed all the msg's into something more understandable
eg: "unexpected end of line" was changed into " you missed out the ' you wanker"
ect, ect ect
it became a cult hit at my college.
and that is the story of my greatest contribution to programming.
 
I wish people still programmed in Pascal. Really elegant code to learn with, and not the horrendous hack that is C.

I love programming in C and assembly language but I fully agree: a person's first exposure to programming should never be C. I learned Pascal in high school and Modula-2 at university. By that time I had already spent quite a while programming the Amiga in mc68k assembler so it took me a while getting used to Modula-2. But it was well worth it.

These days I would probably recommend starting with Python. Very easy to get started with yet very powerful if you decide to dig down the rabbit hole. I always use it for rapid prototyping.
 
I wish people still programmed in Pascal. Really elegant code to learn with, and not the horrendous hack that is C.
I always thought that they're quite similar, as I found the transition from Pascal to C very easy.

I do agree with you, though. Although I didn't have an issue with it, clearly distinguishing assignment from equality with := is good for beginners to programming. I remember helping someone out with BASIC and he had some confusion with that, thinking "a = b + c" is the same as "b + c = a", and having some fundamental misconceptions how how programs work.

And mmendez, you can use inline assembly in some Pascal compilers, too. :cool:
 
In the original BASIC, assignment has to prefix with a "LET" IIRC. i.e. LET a = b + c. But when I was using my first BASIC it's already not the case anymore :p
 
I started my programming with C++. The language *almost everyone* in this country has first exposure to. And after so many years, I sorta like C. Clean, simple, minimal, insanely powerful (only if you know what you are doing) ....
 
Last edited by a moderator:
I do agree with you, though. Although I didn't have an issue with it, clearly distinguishing assignment from equality with := is good for beginners to programming. I remember helping someone out with BASIC and he had some confusion with that, thinking "a = b + c" is the same as "b + c = a", and having some fundamental misconceptions how how programs work.

I always liked Beta's (a Simula derivative) syntax for assignment:

a*10+b -> c

Chronological order is maintained reading from left to right. It is also the way a hardware engineer would think about operations.

Cheers
 
Back
Top