Old-school programming techniques you probably don't miss
computerworld.com
computerworld.com
They are useful skills, and, I think the reason that the section seems "old-school" comes from the proliferation of Java in early CS courses.
Java has most of the algorithms and structures implemented already, and there's no point in anyone redoing it once they find those implementations, so the skills fall out of use.
Yes, it definitely helps to be able to visualize how things are structured, but I think the biggest thing you learn comes from understanding the asymptotic performance of various operations on those data structures.
Without understanding these structures, the fact that one provides much faster lookup, but slower deletes seems totally arbitrary and magical.
(Not sure I'm so much disagreeing with you as elaborating here.)
Yes, that's why all general-purpose languages' standard libraries use the same implementation of the same sorting algorithm for the default sort().
Sometimes I find a really awesome javascript library that does exactly what I need it to do, but I find configuring it is a pain, or it is missing just one or two things that I need and I'm reading the source code and I really don't want to edit it...so I just write my own.
Oh while I'm ranting -- all you people that are making your ridiculous number of JQuery add-ons that do almost the same thing as tons of other add-ons, or your CSS+JQuery image slide that has been done a hundred times before just so that you can prove you have figured out how to write basic javascript and so you wrote something you've already seen a hundred times before to get some more traffic to your blog that hasn't said anything new for months now....please, stop it...stop it, stop it....your ruining the quality of my google searches. Really, you don't need to post all the time, we have readers now, we don't have to individually check back on your blog all the time, write when you have something to say, not to hit a quota. Ramble complete.
Another way to look at it is this -- how can having more knowledge, more tools in your toolbox, hurt?
You may never write one to use in a production environment, but you better damn well understand them and then some.
And no need for memory management? I don't care if you're coding in a garbage collected language you STILL better understand how computer memory works.
This article is literally below coding horror standards.
Link { Link next; Object value; }
- One of my recent tasks was to implement a B-Tree and a Binary Tree. Also, I implemented merge-sort for another project.
- Our company does create it's GUI from scratch. No drag-and-drop magic there either.
- We use GOTO (sparingly). Mostly for error handling.
- We have our own memory managers and do malloc/free (+new/delete). So manual memory management as well.
- We have our own date conversion routines as well.
- We use NULL terminated C-strings everywhere!
- We do lots of things to make our code run faster. Some of these are probably strange!
I don't know if the article is poor or I am out of date! Anyone else out there feel the same?
In any case I would miss most of the above if I didn't have to do them.
I used to screen programmers by having them code a bubble sort in 20 minutes. After about 1000 of these, I think the results were:
Pct Result
----- ---------------------------------------
50.0 Why would anyone ever want to to that?
25.0 Tried but couldn't do it
24.9 Did it in 2 loops
.1 Did it in 1 loop (Yes, I hired him.) for (int ii = 0; ii < n-1; ++ii) {
// ii+1 largest elements end up in their correct position at the end of this loop.
for (int jj = ii; jj < n-1; ++jj) {
if (arr[jj] > arr[jj+1]) {
swap(arr[jj], arr[jj+1]);
}
}
}
One loop: int ii, jj;
for (ii = 0, jj = 0; ii < n-1; ii = ((jj == (n-1)) ? (ii + 1) : ii), jj = ((jj == n-1) ? ii : (jj + 1))) {
// compare and swap as before
}
Unreadable, but it's one loop.EDIT: use code formatting, oops. EDIT 2: add proper conditional for jj update instead of jj = jj + 1.
for (set up initial conditions for both loops;
check the outer loop termination condition;
if the inner loop is done reset the inner loop and advance the outer loop,
if the inner loop is not done advance the inner loop) {
// do the inside of the loop
}I'm haven't decided whether it's a net gain, but that's something it catches especially well.
Here is the original Hungarian notation article by Charles Simonyi. http://msdn.microsoft.com/en-us/library/aa260976.aspx
But it's overbalanced by the sheer amount of effort necessary to make the compiler shut up when I do want to do that. Something like half my Ada code winds up as inane type conversions. I find myself very hesitant declare things in feet and square feet and milliwatts and meters because I know what a phenominal amount of work I am making for myself. Writing in Ada is a strange exercise in type engineering, trying to get exactly the amount of error-checking that I want out of the compiler without distracting myself too much from the actual problem I'm trying to solve. I'm rarely successful. I once recently spent four hours developing an algorithm in Perl, and then--with it understood and debugged--two days translating it into Ada. Most of that time was spent making reassuring gestures toward the compiler.
Then again, the extreme permissiveness of a language like Perl has its own drawbacks. I recently lost a whole day to a function I thought was expecting named parameters (but which wasn't). Ubiquitous default values and silent conversions are nice when you're expecting them and brutal when you aren't; to write efficiently, I must sprinkle die everywhere. And that's the catch: I'm not persuaded that truckloads of 'turn error-checking on' incantations are an improvement over truckloads of 'turn error-checking off'. It's inane code either way.
When you get right down to it, one size doesn't fit all, even within the same program. Ideally, I'd like a language that let me 'tag' variables and functions with types or units or associations, and let me decide when and what to check by default in what contexts. I'd love a language that stopped me from setting a variable in feet to one in meters, but also gave me a way to say "don't check units on this line--it's a formula--but please still check my pointer indirection". Alas, between building Perl up, quieting Ada down, templating C++, or simply building a baroque OO hierarchy in Java, nothing I've used seems really robust and flexible enough to serve this purpose well.
http://en.wikipedia.org/wiki/Hungarian_notation#Systems_vs._...
Of course that mainly only applies to OO languages which also follow the imperative and procedural paradigms. Structured programming is (mostly) irrelevant for functional languages since they don't have the same control flow constructs.