Slashdot Mirror


Old-School Coding Techniques You May Not Miss

CWmike writes "Despite its complexity, the software development process has gotten better over the years. 'Mature' programmers remember manual intervention and hand-tuning. Today's dev tools automatically perform complex functions that once had to be written explicitly. And most developers are glad of it. Yet, young whippersnappers may not even be aware that we old fogies had to do these things manually. Esther Schindler asked several longtime developers for their top old-school programming headaches and added many of her own to boot. Working with punch cards? Hungarian notation?"

28 of 731 comments (clear)

  1. Some, not all... by bsDaemon · · Score: 5, Insightful

    Some of those are obnoxious and good to see them gone. Others, not so much. For instance, sorting/searching algorithms, data structures, etc. Don't they still make you code these things in school? Isn't it good to know how they work and why?

    On the other hand, yeah... fuck punch cards.

    1. Re:Some, not all... by SanityInAnarchy · · Score: 5, Insightful

      any programmer who can't do a list, hash table, bubble sort, or btree at the drop of a hat ought to be kicked out of the industry.

      Why?

      Lists, hash tables, and sorting is already built in to many languages, including my language of choice. The rest, I can easily find in a library.

      When performance starts to matter, and my profiling tool indicates that the sorting algorithm is to blame, then I'll consider using an alternate algorithm. But even then, there's a fair chance I'll leave it alone and buy more hardware -- see, the built-in sorting algorithm is in C. Therefore, to beat it, it has to be really inappropriate, or I have to also write that algorithm in C.

      It's far more important that I know the performance quirks of my language of choice -- for instance, string interpolation is faster than any sort of string concatenator, which is faster than straight-up string concatenation ('foo' + 'bar').

      And it's far more important that I know when to optimize.

      Now, any programmer who couldn't do these at all should be kicked out of the industry. I could very likely code one quickly from the Wikipedia article on the subject. But by and large, the article is right -- there's a vast majority of places where these just don't matter anymore.

      Not that there's nowhere they matter at all -- there are still places where asm is required. They're just a tiny minority these days.

      --
      Don't thank God, thank a doctor!
    2. Re:Some, not all... by Ruie · · Score: 5, Insightful

      any programmer who can't do a list, hash table, bubble sort, or btree at the drop of a hat ought to be kicked out of the industry.

      Why?

      Because if these well known tasks are difficult for them their job title is really typist, not programmer. The challenge is not to write bubble sort day in and day out, but being several levels above that so it is as easy as computing six times seven or reading road signs.

    3. Re:Some, not all... by AuMatar · · Score: 4, Insightful

      I'm thinking perfectly logically. If you don't understand and can't replicate the concepts that underpine your craft, you aren't qualified to practice it. It's like a physicist who can't understand force, or a mathematician who doesn't understand the first fundamental theory of calculus. They aren't capable of doing their job. Apparently this includes you.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    4. Re:Some, not all... by Darinbob · · Score: 4, Insightful

      One problem I've seen with some programmers, is they use the built in libraries to solve all problems. I've seen C++ maps (ie, red-black trees) be used to implement something a trivial array could do (ie, they keys were an 8 value enumeration). They've got a hammer, and all problems look like nails.

      It's not difficult to whip up data structures or algorithms that can beat the one-size-fits-all versions in language libraries. Of course, some people say "don't reinvent the wheel", but then there are applications where size and performance really do matter. Or maybe limited memory and limited CPU systems are considered too old school for some.

    5. Re:Some, not all... by Unoriginal_Nickname · · Score: 5, Insightful

      I'll agree with you for most of what you said, but I disagree that programmers should learn to implement sorting algorithms. Unless they're doing serious research on the subject it's doubtful that Joe Programmer is going to be whipping up a sorting algorithm that's better than the one provided.

      What you're suggesting here isn't like a mathematician not understanding calculus. It's more like a mathematician only having pi memorized to the 8th decimal. I see zero value in learning to parrot quicksort, especially since the information is easily obtained and the implementation you use is almost certainly as fast as is possible (assuming you aren't Abrash).

    6. Re:Some, not all... by Garridan · · Score: 5, Insightful

      Recently, I had a colleague ask me what sorting algorithm he should use in the inner loop of some algorithm he was implementing. Most CS majors I've talked to just blurt out "QUICKSORT!" without thought. Ok, that's got an average runtime of nlg(n). After about an hour of discussion and analysis, we came up with an algorithm that ran in sub-linear time. Now's the time for the CS kids to blurt, "ZOMG, but you can't sort in less than O(nlg(n)!" Ah, but you can, if you know what your input is going to look like.

      When a function gets executed billions or trillions of times, it's worth optimizing. Often times, doubling the speed of a deep internal function does nothing -- other times, it can cut the runtime of your program in half. I come from a mathematical background, and I do lots of computation. Often times, it can take a year or more to solve a problem with a quick implementation. Spend a few weeks optimizing it, and you might be able to solve the problem in a few hours.

      There is no substitute for analyzing your code. And I do mean, sitting down with a writing implement and a blank surface, and tracing through the algorithm. Then, profiling the code and hammering down hotspots. And then, take a page out of Knuth's book -- throw the code away, and write it again.

    7. Re:Some, not all... by Anonymous Coward · · Score: 5, Insightful

      *different* AC

      Why, why, why do people get SO offended when you tell them they have to learn computers to be good at computers?

      People expect to learn engineering to be a mechanic. To study biology if they want to be a surgeon. Hell, to read a cookbook just to learn how to cook.

      But answer "How do I program?" with "Well, there's this manual, see..." and you get "Elitist! Elitist! Hey everybody, come see the arrogant condescending elitist who's persecuting me! Come and see the violence inherent in the sys-teeeem!"

      Fine then, let's start telling everybody it's magic. Get some chicken bones and some goat's blood and some black candles...

    8. Re:Some, not all... by Fulcrum+of+Evil · · Score: 4, Insightful

      but I disagree that programmers should learn to implement sorting algorithms.

      Dead wrong. Every programmer worthy of the name must be able to implement the basic data structures and algorithms, understand Big-O notation, and be able to do fault isolation (this last one is tricky). This is the lowest bar.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    9. Re:Some, not all... by fractoid · · Score: 4, Insightful

      If you don't understand and can't replicate the concepts that underpin your craft, you aren't qualified to practice it.

      Well put. Saying that sorting algorithms are readily available in libraries for virtually all platforms, and thus that modern programmers need not learn them, is just wrong. It's like saying that an engineer need not know about moments of inertia when designing a beam, because he can click a button on his design software to tell him the rigidity. Or like a mechanic not knowing how to use a spanner because he has an air gun available.

      I probably couldn't code a particularly efficient quicksort, for example, off the top of my head - but I certainly understand how it works. Contrary to what Unoriginal_Nickname says below, it's not like a mathematician not memorising Pi past 8dp, it's more like a mathematician not ever learning what Pi is because he has a computer program that he can use to calculate the circumference of a circle.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    10. Re:Some, not all... by Aceticon · · Score: 4, Insightful

      Maybe you guys are frozen in time - or maybe you're some kind of elitist-coder types.

      From where I stand, the most relevant optimizations have to do optimizing the data flows between systems - the most typical of which are appServer-database and GUI-appServer and between storage and memory. We're talking about shaving hundreds of miliseconds, maybe even seconds per-operation: not nanoseconds.

      Even if you work in standalone, small size applications, were knowing the basic principles of algorithms can be more important, hand-coding your own is not only useless (there are plenty of libraries out there with good implementations) it's actually counter productive (it introduces a complex piece of code which is often not properly tested and might be even slower than the library ones)

      Understanding the basic principles = important.
      Being able to code your own = only important for those who never evolved beyond just-a-coder.

    11. Re:Some, not all... by sgbett · · Score: 4, Insightful

      while we are being pedantic...

      From TFA: "most text editors instantly tell you the variable type"

      a *text editor* should do no such thing.

      --
      Invaders must die
    12. Re:Some, not all... by anothy · · Score: 4, Insightful
      you're missing the point, which is understandable since this thread has gone totally stupid. but hey, i'm up early.

      My argument is that learning to implement a sorting algorithm will not impart special knowledge beyond the experience that can be attained by completing virtually any other task. Like I said above, I see absolutely zero value in the ability to recite a particular solution from memory.

      the problem is that you're conflating two different things. the "ability to recite a particular solution from memory" is largely, i'd agree, useless in most cases. but that's not really what this is about. the process of learning imparts special knowledge beyond what is learned. you begin to understand the "whys" of things in ways that you simply cannot if you've never learned the thing.

      in most ways, statements of the form "you must know X" are really proxies for statements of the form "you must have learned X" (even current retention is less important), mostly because they're so much easier to verify.

      --

      i speak for myself and those who like what i say.
    13. Re:Some, not all... by gerglion · · Score: 4, Insightful

      You are mixing up 'programmer' and 'computer scientist'. They aren't necessarily one and the same. Computer science is largely the mathematics of computing, it just so happens that to physically show it often one has to write code to do it. This doesn't mean that everyone who writes code automatically is a CS major/graduate.

      As an aside, you could also argue that programmers should have a good grasp on design patterns, requirements, planning, etc... Which seems to fall under the title of software engineer now. My CS department to date has required me to take a single SE course since I've been here and it'll be the only one I'll take.

      'Programmer' is too vague a description, as it is just one who programs, regardless of how they learned, why they are programming, what they are programming, etc... It could be someone writing Lisp for their Masters/PhD research, some web designer writing javascript for their new website, or a CE/EE writing assembler for a new driver/BIOS for hardware.

      --
      I know you have come to kill me.
      Shoot, coward. You are only going to kill a man.
    14. Re:Some, not all... by 16Chapel · · Score: 5, Insightful

      Number of times I had to implement sorting algorithms for my degree: 3

      Number of times I've had to implement sorting algorithms in my 10 year career: 0

      They make good teaching exercises, but any programmer in my team who wasted time building their own sorting algorithms rather than using a library function, would get a few sharp words about efficiency.

    15. Re:Some, not all... by mdwh2 · · Score: 4, Insightful

      I'm a mathematician who works as a programmer. My apologies for not fitting into your simplistic argument.

      (My job requires plenty of mathematical knowledge, and a maths background was more appropriate for my job than computer science, despite being a programmer.)

      Perhaps we should take it further - surely by your reasoning, only a Bubble Sortist needs to know how to hand code a Bubble Sort under exam conditions, but other kind of programmers don't? After all, it's surely not possible that different fields may cross over, and that different people have different experiences.

      What I would value far more is not someone who can regurtitate his college days where he memorised line by line an algorithm that you shouldn't be using anyway, rather, someone who can hand code any given algorithm as and when he needs to, when he hasn't previously memorised it - that could be a bubble sort if he hasn't previously learnt it, but it's even better to test that with other things.

      Furthermore, for standard algorithms I would value someone who reads up about the algorithm, and preferably uses a standard version, to ensure optimised usage, no bugs, and to know about it's flaws (as is obviously the case with bubble sort), or whether they should be using it at all. Far better than that then someone who only shows off his skills by hacking together a quick version from memory without doing any checks.

  2. What a retard! by Alex+Belits · · Score: 4, Insightful

    First of all, most actual practices mentioned are well alive today -- it's just most programmers don't have to care about them because someone else already did it. And some (systems and libraries developers) actually specialize on doing just those things. Just recently I had a project that almost entirely consisted of x86 assembly (though at least 80% of it was in assembly because it was based on very old code -- similar projects started now would be mostly in C).

    Second, things like spaghetti code and Hungarian notation are not "old", they were just as stupid 20 years ago as they are now. There never was a shortage of stupidity, and I don't expect it any soon.

    --
    Contrary to the popular belief, there indeed is no God.
  3. Re:Eliminate Structured Programming? by Brett+Buck · · Score: 4, Insightful

    Actually, the worst spaghetti code I have ever seen (in 30+ years most of it in life-critical systems) is OO C++. It doesn't have to be that way, but I have seen examples that would embarrass the most hackish FORTRAN programmers.

              I am alarmed at the religious fervor and non-functional dogma associated with modern programming practices. Even GOTOs have good applications - yes, you can always come up with some other way of doing it, by why and with how much extra futzing? But it's heresy.

            Brett

  4. Re:Hungarian Notation by Dunx · · Score: 4, Insightful

    Hungarian notation is bad because you are encoding type and scope information into the name, which makes it harder to change things later.

    The fact that it is also one of the ugliest naming conventions is merely a secondary issue.

    --
    Dunx
    Converting caffeine into code since 1982
  5. Re:Hungarian Notation by snookums · · Score: 4, Insightful

    Really it has nothing to do with IDEs, but more compilers, good coding practice and OO principles. A few cons:

    • The code should be simple enough that you can easily track a variable from declaration through use, or imply the type from the context and name.
    • Since most (all?) compilers and interpreters ignore the Hungarian prefix, there's no way of knowing that iFoo is really an integer. This is particularly true of weakly typed languages that are popular in a lot of modern programming environments.
    • In a large OO project you might have hundreds of types. Creating meaningful prefixes for all of them is going to be next to impossible, and having obj at the front of everything is redundant.

    For a succinct summary: Hungarian Notation Considered Harmful

    --
    Be careful. People in masks cannot be trusted.
  6. Yes, I'm old by QuantumG · · Score: 5, Insightful

    * Sorting algorithms

    If you don't know them, you're not a programmer. If you don't ever implement them, you're likely shipping more library code than application code.

    * Creating your own GUIs

    Umm.. well actually..

    * GO TO and spaghetti code

    goto is considered harmful, but it doesn't mean it isn't useful. Spaghetti code, yeah, that's the norm.

    * Manual multithreading

    All the time. select() is your friend, learn it.

    * Self-modifying code

    Yup, I actually write asm code.. plus he mentions "modifying the code while it's running".. if you can't do that, you shouldn't be wielding a debugger, edit and continue, my ass.

    * Memory management

    Yeah, garbage collection is cheap and ubiquitous, and I'm one of the few people that has used C++ garbage collection libraries in serious projects.. that said, I've written my own implementations of malloc/free/realloc and gotten better memory performance. It's what real programmers do to make 64 gig of RAM enough for anyone.

    * Working with punch cards

    Meh, I'm not that old. But when I was a kid I wrote a lot of:

    100 DATA 96,72,34,87,232,37,49,82,35,47,236,71,231,234,207,102,37,85,43,78,45,26,58,35,3
    110 DATA 32,154,136,72,131,134,207,102,37,185,43,78,45,26,58,35,3,82,207,34,78,23,68,127

    on the C64.

    * Math and date conversions

    Every day.

    * Hungarian notation

    Every day. How about we throw in some reverse polish notation too.. get a Polka going.

    * Making code run faster

    Every fucking day. If you don't do this then you're a dweeb who might as well be coding in php.

    * Being patient

    "Hey, we had a crash 42 hours into the run, can you take a look?"
    "Sure, it'll take me about 120 hours to get to it with a debug build."

    --
    How we know is more important than what we know.
  7. OO isn't even different. by jd · · Score: 5, Insightful

    There is no practical difference between OO code and structured code. The article assumed structured code means goto and gosub, but any Real Programmer knows that procedures (which are just gosubs by name rather than address) are still structured programming.

    So what's OO? Each class is just a bunch of functions and procedures, with one entry point and one exit point for each - your standard structured programming methodology. The fact that there are different classes makes no difference. Calls between classes don't change the nature of a class any more than pipes between programs change the nature of programs.

    I wasn't impressed by other claims, either. Garbage collection is still a major headache in coding, which is why there are so many debugging mallocs and so many re-implementations of malloc() for specialist purposes. Memory leaks are still far, far too common - indeed they're probably the number 1 cause of crashes these days.

    Pointer arithmetic? Still very very common. If you want to access data in an internal database quickly, you don't use SQL. You use a hash lookup and offset your pointer.

    Sorts? Who the hell uses a sort library? Sort libraries are necessarily generic, but applications often need to be efficient. Particularly if they're real-time or HPC. Even mundane programmers would not dream of using a generic library that includes sorts they'll never refer to in, say, an e-mail client or a game. They'll write their own.

    One of the reasons people will choose a malloc() like hoard, or an accelerated library like liboil is that the standard stuff is crappy for anything but doing standard stuff. This isn't the fault of the glibc folks, it's the fault of computers for not being infinitely fast and the fault of code not being absolutely identical between tasks.

    The reason a lot of these rules were developed was that you needed to be able to write reusable code that also had a high degree of correctness. Today, you STILL need to be able to write reusable code that also has a high degree of correctness. If anything, the need for correctness has increased as security flaws become all the more easily exploited, and the need for reusability has increased as code bases are often just too large to be refactored on every version. (Reusability is just as important between versions as it is between programs - a thing coders often forget, forcing horrible API and ABI breakages.)

    The reason that software today is really no better, stability-wise, than it was 15-30 years ago is that new coders think they can ignore the old lessons because they're "doing something different", only to learn later on that really they aren't.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  8. Ya I would compare it to long division by Sycraft-fu · · Score: 4, Insightful

    You don't need long division in normal life. Regardless of if you are in a math heavy career or not, you aren't going to waste your time doing it by hand, you'll use a calculator which is faster and more accurate. However, you need to learn it. You need to understand how division works, how it's done. Once you learn it, you can leave it behind and automate it, but it is still important to learn. An understand of higher level math will likely be flawed if basic concepts aren't learned properly.

  9. Re:True story by fractoid · · Score: 5, Insightful

    My mother, who was programming before a fair few of us (including me) were born, once told me this: If you think you've found a bug in a compiler, or an operating system, or a programming language, or a well-known commonly used library... you're wrong.

    Of course, this doesn't hold true 100% of the time, especially when you're pushing the limits of new versions of large 3rd party libraries, but when one is just starting to program (and hence using very well known, well tested libraries and code) it's true 99.99% of the time.

    (Oh, btw, I love your sig. Makes me laugh every time. :)

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  10. Re:True story by ShakaUVM · · Score: 4, Insightful

    >>If you think you've found a bug in a compiler, or an operating system, or a programming language, or a well-known commonly used library... you're wrong.

    You apparently never tried doing template coding in C++ ten years ago. =)

  11. Re:True story by Moraelin · · Score: 4, Insightful

    Well, obviously all 3 above knew how to use a Hashtable or HashMap, but neither knew what they really do and all ended up trying to fix what's not broken.

    But the real answer I'm tempted to give is more along the lines of the old wisecrack: In theory there's no difference between theory and practice. In practice there is.

    In theory, people shouldn't know more than what collection to use, and they'll be perfectly productive without more than a Java For Dummies course. In practice I find that the people who understand the underlying machine produce better code. Basically that you don't need to actually program anything in ASM nowadays, but if you did once, you'll produce better code ever after. You don't need to chase your own pointers in Java any more, but you _can_ tell the difference between people who once understood them in C++ and those who still struggle with when "x=y" is a copy and when it holds only a reference to the actual object. You theoretically don't need to really know the code that javac generates for string concatenation, but in practice you can tell the difference in the code of those who know that "string1=string2+string3" spawns a StringBuffer too and those who think that spawning their own a StringBuffer is some magical optimization. Etc.

    And then there are those who are living proof that just a little knowledge is a dangerous thing. I see people all the time who still run into something that was true in Java 1.0 times, but they don't understand why or why that isn't so any more.

    As a simple example, I run into people who think that to rewrite:

    for (int i = 0; i < someArray.length; i++) {
        doSomething(someArray[i]);
    }

    as

    try {
        for (int i = 0; ; i++) {
            doSomething(someArray[i]);
        }
    }
    catch (ArrayIndexOutOfBoundsException e) {
    // do nothing
    }

    ... is some clever optimization, and it speeds things up because Java doesn't have to check the extra bounds on i any more.

    In reality it's dumb and actually slower, instead of being an optimization. Any modern JIT (meaning since at least Java 1.2) will see that the bound was already checked, and optimize out the checking in the array indexing. So you have exactly one bounds check per iteration, not two. But in the "optimized" version, it doesn't detect an existing check, so it leaves in the one at the array indexing. So you _still_ have one bounds check per iteration. It didn't actually save anything. But this time the exit is done via an exception, which is a much more expensive thing.

    For bonus points, it introduces the potential for another bug: what if at some point in the future the doSomething() method throws its own ArrayIndexOutOfBoundsException? Well, they'll get a clean exit out of the loop without processing all values, and without any indication that an exception has occured.

    Such stuff happens precisely to people who don't understand the underlying machine, virtual or not.

    --
    A polar bear is a cartesian bear after a coordinate transform.
  12. Re:True story by Have+Brain+Will+Rent · · Score: 4, Insightful

    I think you've got the bar a little high there. I'd settle for not continuing to run into bugs that result because people wrote code that copies a string into a buffer without knowing if the buffer was big enough to hold the string. Or, not quite a bug, people who place arbitrary, and small, limits on the size of strings (or numbers) - cause god forbid that anyone have a name longer than 12 characters, or a feedback comment longer than 40 characters, or ...

    --
    The tyrant will always find a pretext for his tyranny - Aesop
  13. Re:Quicksort by fractoid · · Score: 4, Insightful

    Um, I'm pretty sure quicksort is still the go-to sort simply because it's the implementation that's built into almost every single programming environment. Then again honestly, I'd say that from the point of view of a pragmatic programmer... it doesn't matter. There's a built-in fuction (whether it's qsort() in the C standard library, or Arrays.Sort() in Java, or whatever) that will take your array and return it, sorted. If your app runs too slow and you profile it and it turns out the speed problem is in the sorting AND you can't find a better algorithm that doesn't depend so much on sorting... THEN you look at optimising it. Never forget the two cardinal rules of optimising:

    1) Don't optimise.
    2) (Experts only:) Optimise later.

    Or as I once read it eloquently expressed:
    1) Make it work.
    2) Make it work right.
    3) Make it work fast.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.