« Sodom and Sarcasm | Main | We don't need no thought control »

November 21, 2019

Comments

Interesting.

I am pleased that my adviser in the math dept at the University of Nebraska many years ago became chair and pushed really hard to increase the number of women faculty members and graduate students. More importantly, successful women graduate students: the department has earned notice and awards from the AMS for the mentoring program for women PhD students. They do a lot of interesting support for undergraduate women as well.

Goto took an ungodly long time to die. In 1977 I was doing a masters thesis on large-scale network optimization problems. As part of that I got a copy of what was then the world's fastest code for that class of problems from the Naval Postgraduate School. It was Fortran and was full of every goto variant the language supported, with comments suggesting they were all there to make the code faster. I spent a month rewriting with normal control structures. The result had 20% fewer lines of code and was 40% faster. Mostly because with reasonable structure (and indenting) it was possible to recognize some obvious inefficiencies in how the data was organized.

About the most GOTO riddled code I ever worked on was software to monitor and control oil and gas pipeline pumping stations. Luckily, at the time - 1992, there was software that could restructure and pretty print FORTRAN and point out the places it couldn't be fixed by the software. That made the original code easier to understand even if it didn't get replaced.

(and indenting)

OMG.

I've only skimmed the Liskov interview so far. It brings up a lot of difficult issues for me, which maybe I'll touch on later, or maybe not.

But indenting? I spent a significant chunk of my working life taking over existing code from other people and maintaining/expanding it for new versions and enhancements and fixes, or helping to translate old code as replacement systems were being written in more modern environments.

For a lot of that work, the first thing I did was to reformat everything to make the structure clear.

I don't understand how anyone can write/read/debug code that is not just not sensibly indented to reflect the logic, but indented all over the place without any regard to the logic whatsoever.

Circling back to the OP's link, for most of the almost 40 years I worked as a technical person, I was the only woman doing that kind of work in my company (i.e. taking over existing code, interpreting old code, etc.). I was the only one willing (able?) to read other people's code and take it on as my responsibility. It was beneath my colleagues' dignity, apparently, to try to decipher stuff other people had written in languages they didn't know.

.....Biting my metaphorical tongue on a much longer rant.

Goto took an ungodly long time to die

oh, i assure you it's not dead.

int foo()
{
   int ok = doSomething();
   if (!ok) goto end;
   ok = doSomethingElse();
   if (!ok) goto end;   
end:
   cleanup();
   return ok;
}

that is the approved standard at the rather large software company where i work, for C.

nested ifs are considered gauche because so many of us still use vi in 80-char-wide terminal windows and horizontal scrolling is bad.

At least, in your example, the GOTOs are contained within the subroutine.

C only lets GOTO within the function. thankfully.

(there's always the terrifying setjmp / longjmp, though!)

I don't understand how anyone can write/read/debug code that is not just not sensibly indented to reflect the logic, but indented all over the place without any regard to the logic whatsoever.

My first assignment at Bell Labs was to take over a piece of PL/I code. The guy who wrote it wrote in paragraphs. Statement, semicolon, a blank space, start the next statement. When the editor line was nearly full, newline at a point where it didn't break the syntax -- in practice, anywhere that didn't split a keyword or variable name -- and continue. Not unusual to see the last line in a paragraph that finished with:

END; END; END; END; END; END; END;

The equivalent of 5,000 lines of that stuff. It actually ran and produced correct results. I never figured out how he did it. I couldn't find an existing pretty printer for PL/I at the Labs, so I had to write one.

job security.

I don't understand how anyone can write/read/debug code that is not just not sensibly indented to reflect the logic, but indented all over the place without any regard to the logic whatsoever.

Amen, sister, amen.

But then, I've never understood why people don't comment their code either. It not only makes life enormously easier for someone else who has to come along and try to maintain it later. I find that it also makes it easier for ME to remember what I was doing months or years ago when I wrote it.

(there's always the terrifying setjmp / longjmp, though!)

I have a piece of antique interactive C code that implements the main program loop with setjmp/longjmp. Given the overall purpose and structure of the program and data, bailing out of the C stack from an arbitrary depth is not an unreasonable way to handle things.

The C style you showed is also not unreasonable in its place. Absent the syntactic sugar, it's basically Python's

try:
   doSomething()
   doSomethingElse()
except Exception as e:
   cleanup()

CLU looks like an interesting language.

https://en.wikipedia.org/wiki/CLU_(programming_language)

a long lost cousin of C++.

Absent the syntactic sugar, it's basically Python's...

that's what i keep telling myself.

i should do it like this:

#define TRY
#define THROW goto voidend
#define CATCH voidend:

and then just write it:


TRY {
ok = doSomething();
if (!ok) THROW;
...
}
CATCH;
cleanup();

then i could pretend i was using a proper language.

unexpected bonus newlines keep on-line life fresh.

10 PRINT "HAIRSHIRTHEDONIST IS AWESOME!"
20 GOTO 10
30 END

See. I know all about this stuff.

But then, I've never understood why people don't comment their code either. It not only makes life enormously easier for someone else who has to come along and try to maintain it later. I find that it also makes it easier for ME to remember what I was doing months or years ago when I wrote it.

Absolutely, esp. the last bit.

*****

See. I know all about this stuff.

That went without saying. ;-)

At a facility I once worked at, the mini-computer we were using would come to a near-complete stall about noon every day. Turned out that one of the engineers was using a bit of code he had written to display the time on his terminal when he went to lunch. The code was using a hard loop without any pause between each update of the time.

bet it kept that CPU nice and warm, too.

See. I know all about this stuff.

Well, you've definitely got the infinite loop down.

I write most of my comments before I write the code, to tell myself what to do.

Well, you've definitely got the infinite loop down.

At least since 1985, and I was a late starter.

The introduction to the interview says:

The language, CLU (short for “cluster”), relied on an approach she invented — data abstraction — that organized code into modules. Every important programming language used today, including Java, C++ and C#, is a descendant of CLU.

Other people were definitely thinking about abstract data types at that time, with encapsulation. (For example, James H. Morris Jr.'s papers from that time, such as "Types are Not Sets".) I think of CLU (the language Liskov and her students designed) as having abstract data types with parametric polymorphism (which was new and perhaps unique, although Jim Morris's 1969 PhD thesis laid some groundwork).

I don't see how C++ can be considered a descendant of CLU, since its designer explicitly based it on the classes and inheritance of the much earlier Simula-67.

i think Stroustrup has said the idea for C++ templates and were inspired by CLU and Ada. exceptions, too.

A blatant bit of commercialism. A book was written by an Internet buddy.

"Learn C++ the quick, easy, and “lazy” way. This book is an introductory programming text that uses humor and fun to make you actually willing to read, and eager to do the projects -- with the popular C++ language."
C++ for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners

Spent an hour or two yesterday running C++ constexpr examples through various compilers on the Godbolt website, to see what it would actually do at the machine level.

I've spent about half of my fabulous 35 year and counting tech career working in C++. It's weird to work in a language where what you write might... not be what you get. Sometimes in consequential ways.

That was always kind of so, but with the language enhancements since the C++11 standard, even more so.

"Hints to the compiler" are my bete noire.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name is required. Email address will not be displayed with the comment.)

Blog powered by Typepad