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?"

731 comments

  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 AuMatar · · Score: 3, Insightful

      Its absolutely essential to know how those work and why. If not you'll use the wrong one and send your performance right down the crapper. While you shouldn't have to code one from scratch anymore, 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.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    2. Re:Some, not all... by Anonymous Coward · · Score: 0

      They do indeed still teach this (and make you code it) in any intro to algorithms course.

    3. Re:Some, not all... by Blakey+Rat · · Score: 5, Interesting

      I did a ton of work in THINK C 5 on Mac OS 7. Programming in C on a computer with no memory protection is something I never want to experience again. Misplace a single character, and it's reboot time-- for the 13th time today.

      What's *really* weird is that at the time I didn't think that was particularly strange or difficult. It was just the way things were.

    4. Re:Some, not all... by paxswill · · Score: 1

      I took AP Computer Science AB my senior year of high school, and that was a major portion of it. We had to know why certain data structures (trees, hash tables, linked lists, arrays) were better for certain tasks, and also why some sorting algorithms were better than others. It's also part of the curriculum for CS and computer engineers at my university.

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

      Yep, very much still a part of a CS education. In fact, I'm in such a class right now. Goes fairly slow for my liking, but certainly gets the job done. http://pages.cs.wisc.edu/~cs367-1/

    6. 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!
    7. Re:Some, not all... by delsvr · · Score: 1

      Are you telling me you want us to still be quibbling over which is more efficient, "binary trees versus modified bubble sort"? Implementing hash tables?

      The complexity of our problems have grown. It's called progress.

      But of course they still teach us that stuff in school, just as aspiring physicists still go through classical, Newtonian concepts before starting their research in quantum mechanics. But by no means is this generation of physicists less capable just because they've moved past studying the nature of gravity.

    8. Re:Some, not all... by AuMatar · · Score: 2, Insightful

      Because they're dead simple, and if you don't know how they work you won't write good code. I didn't say you had to do so regularly (or ever, after college), but you need to be capable of it. If you aren't, you're not qualified to program. Period.

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

      Misplace a single character, and it's reboot time...

      If you're lucky. If you aren't, you get silent (well, sometimes not so silent) data corruption. Fun times I imagine! I'm glad I never got into it back then.

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    10. Re:Some, not all... by Anonymous Coward · · Score: 3, Insightful

      Lemme just review your *ahem* "arguments":

      Because they're dead simple

      Your first key point is that programmers must understand them because they're simple??? Um...

      and if you don't know how they work you won't write good code.

      Now you're asserting that it's impossible to write good code unless you understand these things. So all of good programming hinges on this? That's incredible! </sarcasm>

      If you aren't, you're not qualified to program. Period.

      Heehee!

      Try this one: thinking logically is critical to being qualified to program.

    11. 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.

    12. Re:Some, not all... by drolli · · Score: 1, Insightful

      mod parent up.

      if you are that uninterested in computers that these algorithms are uninteresting for you, you should leave. Moreover there can be *extremely* tricky performance things to consider about your cache/physical ram size (just write a loop which covers more and more memory.....). There are algorithms which work extremely well unless you exceed the available size of ram, but break down suddenly (i have the feeling that something of this class happens on my Nokia E61 with the bundled e-mail client. There was a day when my imap folders exceeded a certain number of e-mails, and suddenly the times to process things where growing by a factor of approx. 20-100).

    13. 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?
    14. Re:Some, not all... by Anonymous Coward · · Score: 0

      Yes, your general points are correct, but still...

      One should be well-versed in implementing custom algorithms for these basic operations, and it shouldn't take much time at all to drop one in when the situation warrants it. Some of your logic is based on the premise that "or I have to also write that algorithm in C" is a difficult proposition.

      Parent and grand-parent's point is that you should be good enough at this stuff that having to write a replacement in C is a quick no-brainer (most good higher level languages make it pretty easy to write C extensions), and therefore there isn't much of a development time or cost tradeoff to consider.

    15. 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.

    16. Re:Some, not all... by SpazmodeusG · · Score: 1

      Many of us have seen a newbie programmer trying to access elements in a linked list as if it were an array. Iterating from the start of the list to the index that they actually want. It's an incredibly stupid thing and inefficient thing to do but you'd have to know the underlying data structure to realise that.

    17. Re:Some, not all... by Toonol · · Score: 2, Insightful

      The basic fundamentals of programing will be reused in a number of different contexts and variations. Yes, a "fastsort()" api call can sort arrays, and can help you skate past the evidently difficult chore of learning something new. It won't help you realize that you could use the principles of a Quick-Sort to bear on a complicated problem.

      Another example: The computer can do exponentiation for you too, but actually understanding it will occasionally let you vastly improve the quality of your code.

    18. 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).

    19. Re:Some, not all... by idji · · Score: 1

      I had to write enterprise code 2 months ago in a vb6 dialect with no external objects and needed a sort routine - I had to implement quicksort myself. And make my own data structures. So I think a lot of these things are still going to stay with us. And I needed to implement SOAP in LotusNotes6 two years ago to call web-services. "ON ERROR GOTO" is still alive and well if you don't have try-catch

    20. Re:Some, not all... by syousef · · Score: 1

      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?

      Gone? Try writing a simple pause/delay function in Javascript without bringing the CPU to a grind.

      Any time for historical or other reasons something isn't included you end up having to do it by hand.

      --
      These posts express my own personal views, not those of my employer
    21. Re:Some, not all... by Anonymous Coward · · Score: 1, Funny

      I thought that people who understood the force were called Jedis...

    22. 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.

    23. 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...

    24. 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"
    25. Re:Some, not all... by Fulcrum+of+Evil · · Score: 2, Insightful

      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.

      Sure, it's excessive, but unless it's performance critical, I'd do the same thing - simpler and clearer usually trump faster these days.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    26. Re:Some, not all... by Anonymous Coward · · Score: 0

      Linked lists are inherently serial. Implying that you can access a linked list any other way without ancillary indexing structures is stupid.

    27. Re:Some, not all... by IntentionalStance · · Score: 1
      1978 - graduate with a degree in CS - get a job

      You're a project manager I am told and here's your team. He's called Jon and he's a 17 year old intern

      Jon could actually code believe it or not (he's now a CS Professor)

      Our task was to build - wait for it - here's the spec - the entire spec - "The complete Business System" - budget 5K GDP.

      We eventually worked out that this meant the three ledgers plus stock control - so we went and talked to some people at the customer site to try and understand what that meant. I guess we did some business analysis but we certainly didn't call it that as it hadn't come up on my degree

      Now the dangerous, off the leash, fresh CS grad really started to get stuck in:
      • Mmmm - we'll need some sort of thing to store information on disc and it can't be just a serial file. We need to be able to access specific addresses on the disc - let's mod the OS, TRIPOS. TRIPOS what quite interesting - open source with two comments in the entire thing if I recall correctly, "See the plot of Ruddygore" "Watch this bit, it's tricky". Did I mention that databases didn't come up on my degree either. There wasn't enough time left to cover this after we'd learned about augmented state transition machines and the Turing Halting Problem
      • OK - we'll need to be able to store information on disc using a LISP like paradigm. Let's build a general purpose storage thingy - what shall call it? Management now start to get excited - they're not going to get the "Complete Business System" for 5k, we've spent that already but look at all the IP these guys are generating.
      • Now let's get real - this thing's going to have deal with money and BCPL only has integers - we need to invent a library that deals with pounds and pennies. "Wow, Wow" says management "every one will buy that, can it do dollars and cents?"

      "Sorry guys" says management "the bank says we have to let you go" I got a job in London on double the money and Jon went to University. I got the arrogance slapped out of me by the old hands who explained to me that it had all been invented before

      Can you guess what happened to the company that thought it could hire a fresh CS grad as a project manager?

    28. Re:Some, not all... by Razalhague · · Score: 1

      Your first key point is that programmers must understand them because they're simple??? Um...

      If they can't understand that, how do you expect them to understand more complex problems?

      Now you're asserting that it's impossible to write good code unless you understand these things. So all of good programming hinges on this? That's incredible! </sarcasm>

      Yeah, all of good programming is based on understanding the basic structures. News at 11.

      Heehee!

      Try this one: thinking logically is critical to being qualified to program.

      Yeah, you might want to try it some time.

    29. Re:Some, not all... by Architect_sasyr · · Score: 1, Interesting

      On your nokia comment, watch the speed at which SMS' are deleted from the inbox - the larger the number, the slower it is, but it picks up speed as the number reduces (as though they are re-parsing the inbox in memory or something).

      I can squeeze (as a rule) at least a 10% performance enhancement out of any of the code that the others I program with write, purely because I bothered to learn things like the sorting algorithms, or that a for loop should be processed with >= 0 where possible (or split into a while loop) to reduce computation time. Incremental changes that make vast improvements to the performance of the code. This, incidentally, is one of the reasons I detest people learning perl or python first - ease of language or simple learning aside, the tendency is to write awful code in the long run - at least in the programmers I've seen.

      --
      Me failed English...
      FreeBSD over Linux. If my comments seem odd, this may explain...
    30. 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.
    31. Re:Some, not all... by Anonymous Coward · · Score: 0

      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').

      If you don't know and understand algorithms, then a major part of your understanding involved in good program design is left underdeveloped. I know people who can tell you all the quirks of a particular language and are subpar code monkeys who impede projects with poor design. If you understand algorithms - if you know Cormen and Skiena and Knuth and Sipser -- then you're going to have a leg up not just if you have to write your own search routine, but in designing your application. Applications are nothing but complex algorithms, after all.

      To put it in simplistic terms: Knowing the quirks of a language is like having a tech school education -- you'll know how to do a job to an adequate level, but that's about it. Knowing algorithms is like a liberal arts education -- you'll need a little time in the workforce to learn the quirks of programming in the field, but you'll have a far better understanding of higher-level concepts regarding program design.

      I'd only hire someone with a tech school mindset if I had a dead-simple job where it'd be worth the savings in salary to hire them over a better engineer.

    32. Re:Some, not all... by Korbeau · · Score: 1

      They're just a tiny minority these days?

      yeah, but a lot of.. "programmers".. make a "tiny" salary these days also :)

    33. Re:Some, not all... by Darinbob · · Score: 1, Informative

      How is that faster than: "int table[MAXINDEX+1];" ?

    34. Re:Some, not all... by RyuuzakiTetsuya · · Score: 1

      I disagree only because you cite bubble sort. I can do bubble sort if I'm given a few moments. But it's an algorithm that isn't immediately obvious.

      Stacks though is certainly an algorithm I'd expect any programmer to know. If they can't under stand what a stack is or why you'd ever use one...

      --
      Non impediti ratione cogitationus.
    35. Re:Some, not all... by Anonymous Coward · · Score: 0

      Oh, I thought of a good real life example of someone knowing the specific quirks of an API without knowing the concepts.

      Recently I was trying to figure out an API for a new device, and I found a video tutorial for it. The tutorial did helped me quite a bit, but it was obvious that this guy had a fundamental incomprehension when it came to program design: The standard for the language was to call the controller for a view "ViewbasenamehereViewController"; he created a controller following that convention. What did he call the view? "ViewbasenamehereViewControllerView", rather than "ViewbasenamehereView". It was one of those times where you don't know whether to inform someone of their stupidity, because they seem nice enough and you don't want to embarrass them or seem like a jerk.

    36. Re:Some, not all... by fractoid · · Score: 1

      Eew, that reminds me of when I first started DirectX programming. One tiny misstep in initialisation (or during runtime) and it was locked in full screen mode with no way to recover other than a hard reset. Fun times, fun times... imagine how ecstatic I was when I got a new computer and Windows XP, and could actually *gasp* run 3D apps in a window!!

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    37. Re:Some, not all... by Inthewire · · Score: 1

      Underpin. God damn it, words mean things. Or are you asserting that because I knew what you meant, what you wrote is good enough?

      --


      Writers imply. Readers infer.
    38. Re:Some, not all... by fractoid · · Score: 1

      Bitsort / bucketsort algorithms run in O(n log(log(n))) time on data with a roughly uniform distribution, so O(n*log(n)) isn't a hard lower limit. However, I'm going to have to call BS on your claim of sub-linear time, since that would not even allow you to _touch_ every index in the array. Unless you're talking about a very VERY special case like "an array of arbitrary size that's sorted except for items X to Y, with X and Y supplied to the algorithm". Which is cheating, and if that's what you were doing I'm going to blow a raspberry at you.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    39. Re:Some, not all... by Anonymous Coward · · Score: 0

      Lemme just review your *ahem* "arguments":

      Because they're dead simple

      Your first key point is that programmers must understand them because they're simple??? Um...

      and if you don't know how they work you won't write good code.

      Now you're asserting that it's impossible to write good code unless you understand these things. So all of good programming hinges on this? That's incredible! </sarcasm>

      If you aren't, you're not qualified to program. Period.

      Heehee!

      Try this one: thinking logically is critical to being qualified to program.

      You were born and raised in the Netherlands or northern Germany, right?

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

      I don't think you read my post very thoroughly, because I'm pretty sure I didn't say what you clearly think I said.

      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.

      By restating my argument from memory I have successfully completed a similar task to the one you are challenging your contemporaries with. Literally anybody could read the Wikipedia article about the Bubble Sort and write their own implementation based on it. In a similar vein, I am reiterating my previous point. Both the aforementioned hypothetical programmer and I could have accomplished the same task by copying and pasting earlier efforts.

    41. Re:Some, not all... by Anonymous Coward · · Score: 0

      You my friend, are a perfect example of what's wrong with not understanding the underlying implementation.

      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.

      You are the kind of coder that drives me nuts. Sort algorithm written in C != fastest possible sort algorithm. You need to know for example that common search alogorithms like quicksort are unstable and depending on the input can take quadratic time to finish. So when your profiler shows you are spending lots of time sorting you don't go, "Oh well, it's written in C, can't get any faster." If you understood the underlying implementation and your data set well you would possibly choose or implement a different algorithm, say mergesort or bubblesort.

      I would dare say that a bad understanding of sort algorithms would be much more important to performance than the quirks of your language. That's small beans compared to quadratic time on a set of 1 million items.

    42. Re:Some, not all... by Fulcrum+of+Evil · · Score: 2, Informative

      It isn't faster to use the map, but a map (a,b) is clearer than an array of ints with no particular typing on the contents.

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

      if you DONT look into everything including stuff considered out of date in my opinion your not a programmer.

      A true programmer in my opinion is somebody who LIKES to learn and solve problems. History of programming is a really good place to learn. ive sometimes found myself just downloading source off programs ill never use, and more times than not out of date, to look at them and learn, see what i personally would do differently, and say hmm well that could have been done better, and if the project is still being worked on ill either fix it or send it along to somebody.

      classes teach you basics, it is you who must take it further, and if its a passion, you take it as far as you can.

      --
      -Noc
    44. Re:Some, not all... by le_lotus_604 · · Score: 0

      hell I love H table :)

    45. 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.

    46. 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
    47. Re:Some, not all... by owlstead · · Score: 2, Insightful

      I would have to think about bubble sort and btree (I could do them though, but not at the drop of a hat). I would never program them myself. It's hard to write collection frameworks, and I'll gladly leave it to specialists.

      More to the point: it's important *what* these algorithms do, much more than being able to program them, at least for most programmers. It is also very important that they know how and when to use the right classes.

      I've already seen the Java "string" + "string" example, pointing out that it is slow. SO WHAT? Unless you're putting megabytes together (which you probably shouldn't), who will notice? Same with bubble sort and quick sort. Bubble sort is faster when doing small sorts? Who cares about small sorts? I've seen programmers clobber other programmers because they were using a linked list when sorting. Not very interesting if the list only grows to 10 elements.

      After 8 years in the industry, I've only written a few slightly generic collections (what they called "data structures" in the old days). They were either on a smart card (which misses all these structures) or mash-ups of other data structures (a hash map with a backing linked list is a favorite for storing multiple elements of the same type to be referenced by a key).

      All in all, there's simply no need to know how to implement these things anymore. As said, you *should* know the tools in your collections framework though. And you *should* know when to use them.

    48. Re:Some, not all... by Jesus_666 · · Score: 1, Offtopic

      Depends. Quicksort is manageable, but once you get to stuff like clever-quicksort vs. radix-exchange sort vs. quick-weak-heapsort vs. relaxed-weak-heapsort and the theory behind them things get more interesting. It's not like quicksort is adequate for everything. Or like every sorting algorithm is trivial.

      Which sorting algorithms does one need to be able to implement? With or without reference? I'm not saying that people shouldn't at least have known the theory behind some algorithms at one point but "you should know sorting algorithms if you want to be a programmer" is very vague.

      --
      USE HOT GRITS WITH STATUE OF NATALIE PORTMAN (NAKED AND PETRIFIED)
    49. Re:Some, not all... by arethuza · · Score: 1
      "Most CS majors I've talked to just blurt out "QUICKSORT!" without thought."

      Shame on any CS graduate who asserts that Quicksort is *always* best.

    50. Re:Some, not all... by SlashWombat · · Score: 1

      I think you missed the point ... You shouldn't be using quicksort ... You should in fact have used a better database type, not some flat structure.

      Have to say that I have used most of the techniques mentioned in the article, however, some of the article was a bit strange. Like where the person talks about calling into the windows API, and perhaps using undocumented API calls that broke when windows versions changed. It was fairly normal for any decent programmer to use the standard API calls to vastly speed up visual basic. How anyone even new about undocumented calls is beyond me though. More likely the windows API calls were not rolled back correctly, the result was that it might work in one version of windows, but would crash badly on another. (Windows API's are much trickier than many newby programmers think!)

    51. Re:Some, not all... by Anonymous Coward · · Score: 0

      Are you trying to cover up your ignorance and incompetence by throwing around this vague notion of "thinking logically" ? These concepts are so basic that even highschool students without any prior experience with computers are able to understand them. Why are you making up excuses for failing to grasp those concepts? To make matters worse, the only thing that stops you from knowing is your will to not know the basics. Or are you so thick and out of touch with reality that you believe you can be a competent programmer without having to learn these basic concepts?

    52. Re:Some, not all... by Anonymous Coward · · Score: 0

      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.

      Do you understand that that sort of expenses are only needed to be able to cover up poor design and the coder's incompetence? Or, to put it in other words, your boss will be forced to needlessly spend the company's cash in order to compensate for the mistake of hiring someone who doesn't even know the basics of his trade and intentionally implements bad code just to keep his neck above the water line?

    53. Re:Some, not all... by BrokenHalo · · Score: 2, Insightful

      if you are that uninterested in computers that these algorithms are uninteresting for you, you should leave.

      Yeah. TFA has relegated to its second page a couple of the techniques that used to be important to me nearly 30 years ago: self-modifying code and patching code while it was actually running. These came under the heading of "hazardous duty", since if you got it wrong you could fuck things up quite spectacularly, and EVERYONE would know about it and give you a hard time. This was the sort of thing that was guaranteed to the adrenaline going. ;-)

      I had almost forgotten about the old DEADBEEF filler in core-dumps, though. I pulled that trick out of my hat in the '80s when I was showing a new CompSci graduate a way to fix an issue with an old COBOL program. I had a hex dump of about 500 pages 11x14" fanfold, and I just flicked the edges of the paper to locate the likely culprit. She cracked up laughing when I showed her the "secret".

    54. Re:Some, not all... by Canazza · · Score: 1

      I remember in first year Uni we learned C++, basic logic, bubble sort and Bit Blitting, in second year we did multithreading (among other things), and that was only 5 years ago. Granted, it *was* Computer Games Technology, and I honestly don't have much use for *any* of those things any more (except the basic logic ofc) as I'm mainly doing Flash games now. (Although, Bit Blitting did give me a head-start on my collegues over the use of Flash's Bitmap object)

      Some of these things may no longer be relevent in languages like C# any more, what with and whatnot doing most of the legwork for dynamic arrays/linked lists and web-languages like PHP having associative arrays built in to the language (Essentially giving you an easy way to do linked lists) and Garbage collection handled invisibly in many environments (Java, Flash, C# etc) but it's good to know WHAT they do, even if you can't programme one off the bat (I've seen a fair few diagrams of how Flash's GC works, but I doubt I could sit down and write one, not without difficulty)

      I could *potentially* do many of these things, if I sat down and tried, it would take me a while, but I believe that I can still learn. You don't come out of Education knowing everything about your subject, and if you're not going to make use of something there's no real reason to learn when your time could be taken up learning something you CAN use

      --
      It pays to be obvious, especially if you have a reputation for being subtle.
    55. Re:Some, not all... by Anonymous Coward · · Score: 0

      Amiga was better in that respect. Combine no memory protection with heavily multitasking; add navigation of system structures that were mostly lists; finally put that into a machine with graphics hardware prone to do the most amazing fireworks when it crashed. Amazing.

      Well, it rebooted quite fast as well, so it was bearable. You really learned to deal with pointers in a machine like the Amiga!

    56. Re:Some, not all... by GrahamCox · · Score: 1

      I did a ton of work in THINK C 5 on Mac OS 7

      Yeah, me too. But actually, there was an advantage to the fragility of the whole darn mess - it made me very, very defensive as a programmer. Because I couldn't stand the reboots and the hard-to-debug memory errors, I would go out of my way to avoid them at all costs. I think in many ways it made me a better programmer than I would be starting out today.

    57. Re:Some, not all... by Anonymous Coward · · Score: 0

      You're wrong, and you don't understand algorithmic complexity, which is exactly why you need to learn to code these things yourself (even if you only use that knowledge to select a library later).

      It does not matter that the built-in sorting algorithm is written in C. I can out-perform an C bubble-sort with a quicksort written in Python, for sufficiently large array sizes, because of algorithmic complexity. Your statement is making a rookie mistake, and that's a severe gap in your education, which proves the OP's point.

      Also, your assumption that you can "just buy more hardware" is (a) eternally untrue in embedded or game console applications and (b) has been untrue on the PC for five years. Where is this "faster processor"? Now you need to parallelize and thread your code to take advantage of "more hardware". Congratulations on citing a myth that's at least 5 years out of date. Is that what your college professors told you? They were wrong.

      The OP's point is that you need to understand this stuff. Being able to look up quicksort on Wikipedia is no substitute for having studied it. You may as well say what's the point of going to school to study programming at all, when it's all on Wikipedia? There's a discussion there, but only if you actually read Wikipedia proactively to learn this stuff, not if you sit back and only look it up if it arises (which it never will because you don't know how to tell if your sort is slow because of the sort algorithm or just because of the data size).

      Fail.

    58. Re:Some, not all... by A+beautiful+mind · · Score: 3, Interesting

      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').

      This reminds me of a very educational example. On Perl forums sometimes the question arises: which is faster - single quotes or double quotes, the difference being that the latter interpolates variables.

      People in the know pointed it out multiple times that the single vs. double quote issue is a benchmarking mistake. See, Perl is a VM based language, with compile time optimizations. The code that people write as single or double quotes gets compiled down to the same thing. This is the kind of knowledge that is useful, knowing a bit of the theory and design of the underlying language, instead of having benchmark results, but not knowing how to interpret the results...

      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
    59. Re:Some, not all... by N3Roaster · · Score: 1

      Oddly enough, sometimes the language and library versions that are easily available (and I agree, should be the first place you look for these things) are just ever so slightly completely wrong for working with what you've already written. It wasn't that long ago (within the last couple years) that I ran into a sorting/searching problem where my options were: use a different structure for either the record or the record set (rewriting a lot of otherwise perfectly good code in the process), or write my own sorting/searching routine. Before coming to that conclusion I spent a couple days trying to coerce the appropriate library function into handling things correctly. Now, it may have been some deficiency on either my part or on the part of the documentation that prevented me from seeing the right way to do it, but I had spent enough time on it and the MIX code from Knuth Vol. 2 translates beautifully into C++ with iterators (Program B comes to 19 LOC, including single braces as a line). Now, it's not optimal for the application (it's the same algorithm as the library function I was trying to use) but it works correctly and it's fast enough to keep until I get around to writing something better.

      --
      Remember RFC 873!
    60. Re:Some, not all... by axlGrease · · Score: 2, Funny

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

      Oh, that is so *not* the way to program punch cards ...

    61. Re:Some, not all... by JustOK · · Score: 0

      or reading road signs.

      I have a GPS, so I don't need no steenkin road signs.

      --
      rewriting history since 2109
    62. Re:Some, not all... by _merlin · · Score: 3, Interesting

      You mustn't do any real-time processing with any serious volumes of data. I do market data systems for my day job. All the microseconds I can save add up. Yesterday, I knocked several seconds off the time required to do an initial load by getting rid of some redundant copying that was going on. Today I improved the response latency for certain market events by changing the data type used for a key in a map. You might not need to understand when you're doing typical desktop applications, but you'll have to be content being a hack. The real software engineers will always have to understand.

    63. Re:Some, not all... by Rockoon · · Score: 3, Insightful

      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.

      Sure, that profiler might say that you are taking n% of your time in it, but how are you going to objectively know that that n% can be reduced significantly? Is your profiler an artificial inteligence?

      That, my friend, is the problem with canned solutions. You never really know if the implementation is decent, and in some cases you don't even know what the algorithm used is. Still further, if you are a clueless canned solution leverager, you probably don't know the pitfalls associated with a given algorithm.

      Do you know what triggers quicksorts worst case behavior?

      Do you know why a boyer-moore string search performs fairly badly when either string is short?

      Do you know the worst case behavior of that hash table implementation? Do you know what the alternatives are? What is its memory overhead?

      Are any of the canned solutions you use cache oblivious?


      Now lets get into something serious. Algorithmic performance deficiencies are often used in Denial of Service attacks, and any time you use a canned solution you are setting yourself up as an easy target. Your profiler will never tell you why your customer is experiencing major problems, because the attack isn't on your development machine(s.)

      ..and finally.. being ignorant is not something to be proud of. Seriously. Your answer to discovering that the canned solution isnt acceptable is to "buy more hardware." Developers don't get to make that decision. Customers do... and thats assuming the hardware exists. If I was your boss I would fire you immediately for being a willfully ignorant bad programmer.

      --
      "His name was James Damore."
    64. Re:Some, not all... by tepples · · Score: 1

      But even then, there's a fair chance I'll leave it alone and buy more hardware

      And force a million users to buy more hardware too? Your app had better be really good if you want to use it as the starting point to launch a new hardware platform. If millions of people have a handheld device that uses a 67 MHz ARM9 CPU, but they don't have a handheld device that uses a 222 MHz MIPS CPU, then you have to target the first device.

    65. Re:Some, not all... by DarkIye · · Score: 1

      I agree 100%, but it seems actually knowing how the sorting algorithms work is usually stuff you learn in college rather than as part of a training course or the like.

    66. Re:Some, not all... by Anonymous Coward · · Score: 0

      There's nothing like memory protection units in order to follow the Printf-Coredump school of debugging. :p

      IMO, C is too easy and abstract. When I programmed in assembly for the z80 I didn't code in buffer overflows and other sloppy code. Now that I code in C I have to double and triple check all the time to make sure they haven't slipped in.
      When you are thinking at the register level, such glaring flaws are obvious.

    67. Re:Some, not all... by Restil · · Score: 3, Interesting

      I suppose it depends on what the programmer is doing. A programmer that does little more than code web scripts that interface with previously coded databases.... yeah, they can probably manage to have a career doing that and not ever need to code a sorting algorithm, or do anything equally complicated. However, if you're tasked with writing a game, or a OCR scanner, or a natural language parser, fundamental concepts of "obsolete" functions such as sorting suddenly will become extremely important. Not so much because you're going to need to suddenly learn how to program a computer to sort a bunch of integers, but you might be faced with a multidimensional structure with millions of elements and need to come up with an efficient way to organize and access it... and previously coded "sort" algorithms aren't probably going to be of much help. You're going to want to have some idea of where to start.

      -Restil

      --
      Play with my webcams and lights here
    68. 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.
    69. Re:Some, not all... by anothy · · Score: 1

      amen, brother, amen.

      --

      i speak for myself and those who like what i say.
    70. Re:Some, not all... by MadKeithV · · Score: 4, Informative

      or that a for loop should be processed with >= 0 where possible (or split into a while loop) to reduce computation time.

      This is an obfuscating micro-optimization with pitfalls (e.g. unsigned is always >= 0) and should not be a general rule. In many cases the compiler will do any optimization here automatically, and in other cases you need to profile first to make sure this is the bottleneck before obfuscating the code.

    71. Re:Some, not all... by MadKeithV · · Score: 2, Funny

      What are these newfangled "maps" or "associative arrays"? Everything is a list, isn't it?


      </Lisp_FTW>

    72. Re:Some, not all... by Zaatxe · · Score: 1

      fuck punch cards

      No, thanks. I'd prefer to fuck a 5-1/4 inch floppie, at least it has a bigger hole.

      --
      So say we all
    73. Re:Some, not all... by Anonymous Coward · · Score: 1, Insightful

      Wrong. The lowest bar is understanding the theory behind Big-O notation.

      Frankly, if you can make it through a couple semesters of college level CS & Math 300 & 400 level classes you should be able to pick up the implementation techniques pretty easily.

      I agree with you that the data structures and algorithms are important to programmers but I would suggest that you are not a real programmer unless you understand what you are implementing.

    74. Re:Some, not all... by bperkins · · Score: 1

      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.

      Please, please don't do this. I'm not going to be able to fill out the TPS reports for 90% of my co-workers.

    75. Re:Some, not all... by Ash+Vince · · Score: 1

      Why?

      To make you a better developer.

      Programmers only improve with practice and writing simply, logical code is damn good practice.

      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').

      Remember that no language is used forever. Whilst it is important that you know your specialist language inside out it also pays to have an excellent knowledge of the generic principles of coding so that when your specialist language becomes obsolete you are not left behind.

      Personally I want to choose when I retire, not have my retirement date forced on me. Programming is already a very ageist career when you have a wide variety of transferable skills, the last thing you want to do is also have an overly specialised skill set that is losing relevance.

      --
      I dont read /. to RTFA, I read /. to offend people in ignorance.
    76. 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.
    77. Re:Some, not all... by Anonymous Coward · · Score: 0

      "If you aren't, you're not qualified to program. Period."

      Hm, maybe not ... if someone is willing to pay you to write kernel code.

      But the reality is that most "programming" jobs will belong to business process analysts within the next 10 years, and knowing bubble sorts will have nothing to do with any of it. Vertical industry experience and communication skills are already what's separating the programmers from the unemployment-check collectors.

      How many mechanical engineers do we need each year to re-invent the internal combustion engine?

    78. Re:Some, not all... by sjames · · Score: 1

      Occasionally you run into a complex corner case that is just too odd for the standard library routines but no matter how many times you question it, it really is the right thing to do.

      One example I really enjoyed coding up was a setup to allow any arbitrary struct to be a member of any arbitrary list (and any number of lists) AND all of the relevant back references. That is, given a pointer to struct which contained no list pointers, I needed to be able to remove that struct from any and all lists it was in and do it quickly.

      Since it might run on embedded hardware, it needed to use as little memory and CPU as possible. Since the operations were time sensitive, I needed to know how long the somewhat baroque list operations would take.

      We're likely to see more and more of that. For decades, CPU speed and RAM sizes have been expanding faster than out ambitions for software. By that, I mean that for quite a while, there's been plenty of crunching power available for what we want to do such that many modern programmers are absolutely astonished that the computer on the lunar module could do all of the things it did with as little capability as it had AND lives depended on it.

    79. 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.

    80. Re:Some, not all... by argStyopa · · Score: 1

      "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..."

      Now we understand why Vista can make a machine that runs at 3 GIGAHertz and has 4 processor cores is now slower than my original PC AT.

      THANKS!

      --
      -Styopa
    81. Re:Some, not all... by Ash+Vince · · Score: 1

      A true programmer in my opinion is somebody who LIKES to learn and solve problems.

      This is clearly the most insightful thing anyone has said in this entire discussion.

      In fact, the only time it changes is when you solve problems all day everyday for 40+ hours per week for a few years. Then you start to use your downtime for different pursuits.

      That said, the last time I was between jobs was 4 years ago and I spent 3 months off. For the first month I did nothing work related but by the second two I was suffering withdrawal symptoms and started a few side projects to keep my mind going.

      --
      I dont read /. to RTFA, I read /. to offend people in ignorance.
    82. Re:Some, not all... by Anonymous Coward · · Score: 0

      "But even then, there's a fair chance I'll leave it alone and buy more hardware..."

      No wonder a lot of commercial software runs like a drunken horse.

    83. Re:Some, not all... by mdwh2 · · Score: 1

      Not all programmers come from a computer science background. As someone with a maths degree, maybe I should get on my high horse and claim anyone who can't quickly prove a particular theorem I cite, without looking it up should be kicked out the industry - after all, maths is a fundamental part of computing too, and in many specialised jobs (as opposed to just being a generic code monkey) it may be even more relevant.

      I do know what the aforementioned structures and algorithms are, FWIW - but I agree with the other poster in that knowing how and when to use these things is more important than being able to hand code them from scratch in exam-style conditions.

      And why on earth are you encouraging something as bad as a bubble sort in the first place?

    84. Re:Some, not all... by Anonymous Coward · · Score: 0

      Newbie programmer: How else are you supposed to work through a serial structure?

      (I agree that it's inefficient as hell)

    85. Re:Some, not all... by Anonymous Coward · · Score: 0

      Often I found that to get a doubling of speed in my C++ code I just needed to use wstring::reserve(100) or vector::reserve(oldvector.size()) at the appropriate point. Resizing stuff and deep copying can be expensive!

    86. Re:Some, not all... by mdwh2 · · Score: 1

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

      Straw man - no one has done this.

      The issue is someone claiming an arbitrary list of things that all programmers must do, else be kicked out the industry. And then you come in, misleadingly equating that as the be all and end all of programming.

      I see a lot of programmers who are bad at maths - which is equally as fundamental to computing. And yes, we should all strive to be better, but that's not an excuse to get smug about it, and call for people to be kicked out the industry. In particular, it disallows people to continue to learn in fields outside of their degree. If a fresh-out-of-university computer science graduate was starting a new job, it would be rather unfair for me to criticise him for being unable to do something under exam conditions that I could do, when it was part of my degree, and not others. As long as he's prepared to learn, that's what's important - and I should realise that there are probably things that he knows, that I don't yet know. It's commonplace for people to continue to learn outside of university.

      Unless AuMatar was expert in all fields of computing fresh out of university, he is in no position to call for others to be sacked.

    87. Re:Some, not all... by Lord+Ender · · Score: 1

      No, it is essential to know how they scale, not how/why they work. As software development becomes less of an art and more of an engineering discipline, we will realize that it is impossible to know everything about every component you use, and instead focus on the important properties of those components.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    88. Re:Some, not all... by Anonymous Coward · · Score: 0

      I'm about to graduate with my Computer Science degree and at my school they drilled sorting/searching algorithms and data structures into our heads. We had to be able to write them and explain how they worked step by step on paper.....so yeah, they are still teaching some of us those things, and I am very happy they are. Need to learn the foundations before you start adding onto them.

    89. Re:Some, not all... by EgoWumpus · · Score: 1

      I'm going to go ahead and note that most courses cover Big-O by using sorting algorithms as examples. If you don't understand the sorting algorithm, can you really be expected to understand how the Big-O is different?

      --

      [Ego]out

    90. Re:Some, not all... by Cro+Magnon · · Score: 1

      I'm not a C programmer, but I did play with it some in ancient times, and I had similar experiences on my olde DOS/Windows 3X box.

      --
      Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
    91. 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.

    92. Re:Some, not all... by Splab · · Score: 1

      I find it ironic that you use string concatinating as example for something someone should know as they rarely should take more than then length of the strings to copy to a new place (and take up some vast amounts of memory) and at the same time tell us you are more than willing to throw hardware at a problem that could very well be running in O(n^2) or worse.

      Also insightful? geez.

    93. Re:Some, not all... by mdwh2 · · Score: 1

      I probably couldn't code a particularly efficient quicksort, for example, off the top of my head - but I certainly understand how it works.

      But that's just it - according to him, you should be kicked out the industry. He stated:

      AuMatar: While you shouldn't have to code one from scratch anymore, 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.

      You can't code it at the drop of a hat, according to him, get out the industry.

      Don't be mislead by AuMatar retreating to a position of "But understanding these concepts is important". That's not the argument he presented, and indeed, that is the argument put forward by those who disagree with him. E.g., Unoriginal_Nickname stated:

      I'll agree with you for most of what you said, but I disagree that programmers should learn to implement sorting algorithms.

      You are in agreement with Unoriginal_Nickname, and others such as myself who say that understanding them is important, just that you shouldn't necessarily need to hand code one in exam room conditions at the drop of a hat. It is AuMatar who is doing the equivalent of claiming mathematicians should learn pi to 8 decimal places (actually I can do 15, but I'm not going to get smug and call for AuMatar to be kicked out the industry if he can't).

    94. Re:Some, not all... by jcochran · · Score: 1

      Precisely.

      And one of the things I've seen all too frequently is quick sort implementations that always use the 1st element in the array segment as the pivot element. Yes, it's a nice easy element to select. But it's also the worst possible element to use as well.

      The problem with picking the 1st element in the subarray as the pivot for quicksort is that it means that you have just guaranteed the O(N^2) behavior of quicksort if you pass in a presorted, or inverse sorted array. And unfortunately, that use case happens with disturbing frequency.

      Why?

      Because a lot of sort users do sorts on already sorted arrays or mostly sorted arrays.

    95. Re:Some, not all... by heri0n · · Score: 1

      Any recommended books to keep you sharp, or for those things you were sleeping in class? :P

    96. Re:Some, not all... by cervo · · Score: 1

      I call bullshit on this. In all actuality implementing these things efficiently is tough. Well not so much bubble sort/lists. But a btree is tricky. And a hash table is tricky.

      Let's look at the hash table, the hashing function is the most critical part and these are hard to design and require in depth mathematical analysis that most CS students don't learn even at the level of a MS. So sure any idiot can implement a hash function % PRIME TABLE SIZE. But to design an efficient one, that is tough. Generally it is better to use the built in library.

      Also to design an efficient quicksort is tough. small seemingly unimportant details could make huge differences in cache hit rates and the speed of the algorithm.

      Also doing these things at the drop of a hat is the problem. Many "top programmers" or "gurus" do these things at the drop of a hat and leave bugs in them that don't always show up. In general the libraries are more or less well tested and generally are good fairly efficient implementations.

      Are data structures useless? No. Basically you need to understand the library implementation of things. For example someone here was joining two lists of records together doing n^2 operations. He was also looking into a 3rd list for some weird value (in error) causing n^2 * m operations. Anyway I changed it to sort both lists and then merge them together. Each sort was nlogn and the code went from about 15 mins to about 3 (there were other issues too like trips over the network which I changed as well). But basically I didn't implement the sorts, I knew their order. In general that is what you should get from Data Structures. You should know the operations of hash tables, array lists, linked lists, trees, heaps, etc.... And be able to understand their performance and the trade offs. This also helps you when you think "can I do this faster?". Sometimes the line of thought is hmm....maybe if i used a heap...or maybe I can modify binary search to do this....

      Also there is some value to understanding the sorting algorithms, but with the libraries available to implement them for most business jobs linking databases to front end screens and maybe some calculations you won't need to use them. But some examples are:
      Merge Sort: Understanding the merge algorithm as well as divide and conquer...the merge technique is also used by SQL databases to do joins.
      Quick sort: understanding divide and conquer here and the technique of splitting the list. It is also how you can find the median or other kth value by modifying this algorithm.
      Bubble Sort: bear with me here. But the bubbling technique is awfully similar to walking up or down a heap. It's a bit of a stretch I know....It can also tell you in O(n) time if a list is sorted or not. Radix Sort: under utilized. For ASCII characters I would say that if the keys aren't too long this should be the preferred way of sorting a strings. Technically it's bucket sort but anyway....

    97. Re:Some, not all... by DunderXIII · · Score: 1

      That's true until you come up at the end of the project and find out that the bulk of the process usage comes from the 90% of "coded un-optimized" portions that people felt free to overlook during the process. If you write for any fixed hardware like a game console then the "add hardware" argument totally kills you. With that kind of problem you're pretty much screwed as you can't spend enough time going through every darn for loop in the project to optimize them so you ship with less framerate. The point about this is that knowing your algorithms or how memory works in the background will have you avoid this problem. It won't slow down development at all but will make sure you don't end-up with a resource hog. I'm not saying to optimize to death, but rather that you should strive to write optimized if you can and it's not detrimental to the readability. For instance, why use an algorithm that allocates objects dynamically when you can get away with a stack based one? Knowing this in advance will save your ass later.

    98. Re:Some, not all... by Jessta · · Score: 1

      Punch cards are an implementation detail.
      Sorting algorithms and data structures are fundamental to computer science. No matter what changes happen in the future they will be important as long as you are still programming some implementation of a turing machine.

      --
      ...and that is all I have to say about that.
      http://jessta.id.au
    99. Re:Some, not all... by ShieldW0lf · · Score: 1

      Yeah. TFA has relegated to its second page a couple of the techniques that used to be important to me nearly 30 years ago: self-modifying code and patching code while it was actually running. These came under the heading of "hazardous duty", since if you got it wrong you could fuck things up quite spectacularly, and EVERYONE would know about it and give you a hard time. This was the sort of thing that was guaranteed to the adrenaline going. ;-)

      That doesn't belong on the list. Deploying patches to servers that are coordinating the operations of thousands to millions of people in real time is par for the course these days.

      Nothing like having thousands of people getting paid to sit around playing solitaire until you fix things to make your heart explode...

      --
      -1 Uncomfortable Truth
    100. Re:Some, not all... by Moridineas · · Score: 3, 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.

      That is completely missing the point. Nobody is expecting the average programmer out there to write a superior sorting library.

      Your example of a sorting algorithm being related to decimals in pi is completely bonkers. You're really comparing learning and comprehending an ALGORITHM to memorizing digits? If you (and I don't mean you specifically) don't understand how sort algorithms work, if you don't understand linked lists, etc--and furthermore, think learning them is unnecessary rote memorization--I'd bet a years pay that you're producing shit code and probably not even realizing it.

    101. Re:Some, not all... by david_thornley · · Score: 3, Insightful

      In almost all cases, all I need to know about sorting is how to use the built-in function, and a general idea of how efficient it is. In the other cases, I can consult Knuth or Wikipedia.

      I don't happen to remember right now how Quicksort works in detail enough to write, and I don't even know what algorithm the C++ STL sort I use uses. Last time I needed to know something like that, it was heapsort, and that was years ago. I have understood quicksort in the past, and wouldn't require more than a few minutes to brush up on it, but as long as I know what it does and what its performance is like I don't need to know the details.

      Similarly, I've forgotten a lot of my parsing theory, and don't remember offhand what separates LALR(1) from a more general LR(1) parser, but I seem to be able to use compilers and come up with a usable YACC grammar.

      It's certainly worth learning this stuff at some point, and you do need to understand the implications of what you're doing, but I find that what I've forgotten about algorithms that are built into every programming language I use has never been a problem.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    102. Re:Some, not all... by kalirion · · Score: 1

      Ah, I remember how great it was when in my CS class we switched to Win 95 from DOS. Instead of Borland C++ crashing the computer on runtime errors, it only crashed the DOS Prompt! What joy!

    103. Re:Some, not all... by david_thornley · · Score: 1

      Who cares? Premature micro-optimization should have been buried with punch cards and FORTRAN IV. Make the code clear and avoid serious algorithmic inefficiencies. If you still have a performance problem, profile to see where it is. When you change code in the hot spots (and there only), test to see if you've actually improved anything.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    104. Re:Some, not all... by SQLGuru · · Score: 1

      I used to own a couple of programming books (Undocumented DOS: http://www.amazon.com/Undocumented-DOS-Programmers-Functions-Structures/dp/0201570645 and a similar Windows one). That's how I learned about hidden OS APIs Microsoft provided (and used internally even though we "normal" programmers weren't supposed to -- can't find the link, but there were lawsuits over it). I almost never used the information, but the books provided some really good insight that made be a better programmer in the long run. However, knowing that these interupts or APIs were liable to disappear with an OS upgrade, it was still sometimes necessary to use them to accomplish a task (within certain restrictions). You would just have to rewrite code when the next OS came out.

    105. Re:Some, not all... by bcrowell · · Score: 1

      I did a ton of work in THINK C 5 on Mac OS 7. Programming in C on a computer with no memory protection is something I never want to experience again. Misplace a single character, and it's reboot time-- for the 13th time today.

      Yep, I had exactly the same experience. What helped to make it particularly painful was that an error in my code could cause a null pointer to be dereferenced somewhere deep inside the Mac toolkit, but it could be really, really hard to find the place where that was happening, because the system would just crash. You got no core dump. You didn't have access to the source code for the toolkit code. You didn't have a symbol table for the toolkit code. I actually had an easier time coding in C on the really early Macs, ca. 1985, because it was closer to the metal, so if there was a crash it was usually pretty close to the bug in my code, not down seventeen layers deep in the GUI toolkit.

    106. Re:Some, not all... by hotfireball · · Score: 1

      Well, then I can say: you should also know how TCP/IP stack is working, if you're going to use socket. Then you also have to know assembler to know how your particular CPU is working, in order to write your program. Then you also have to know how to interpret Java or Python byte code, once you want to use these languages, in order to know underlying concepts. Of course, you should know how your hardware is working in a very details (Sun SPARC, for example) if you want to write some software for stocks/equities. :-) Thus, if you don't know how to push/pop stuff out of registers of your SPARC CPU or are not capable to write a driver for your specific networking card or have no idea how to implement virtual machine in order to use them, then you must be kicked from the industry right away! :-)

      Correct?

    107. Re:Some, not all... by hotfireball · · Score: 1

      Ignore it. Makes sense only in an academy or university or R&D or something very-very specific. But for a regular application developers that can do shit like a Facebook and get a millions in a cache, there will be always extreme kamikazes to oppose it, unless get married... :-) The guy will grow up eventually, then think more and then change opinion bit after a while. Especially, after he finally write finally something executable and actually usable, i.e. something other than an extreme (read: bullshit) comment on a slashdot. :-)

    108. Re:Some, not all... by MBGMorden · · Score: 1

      And why on earth are you encouraging something as bad as a bubble sort in the first place?

      I don't think he was encouraging it - rather, he was stating that one need's to understand sorting technologies to be able to effectively choose one. You need to know what a bubble sort is in order to avoid it - and you need to be generally aware that there are other ways of doing it, because without that knowledge a naive programmer is often tempted to go to a bubble or selection sort (because conceptually, they're pretty simple so without thinking it through heavily, if I had no formal CS education my first thought on how to sort something would indeed be a selection sort).

      Also, you need to know instances when one sort is appropriate. For example, for MOST things I'd probably choose a Quicksort, but in cases where I'm sorting plain integers, a Radix Sort will often be a bit more efficient.

      Also, depending on how you're storing data, a binary tree might be a lot more efficient than a linked list (and as a bonus, if you want you can pull the data back out of the tree and by it's structure it's already sorted). A hash table is also very useful as well depending on the usage. For example one of my senior year projects was to write a LISP interpreter - for user defined functions I wanted a quick way to reference and jump to those functions. There would never be any need to sort them - the primary concern was QUICKLY locating the proper function without having to go through a list to find it - so the functions ended up getting stored into a hash table based on a hash value generated by the function name. Sure I COULD have implemented it using a linked list or a binary tree, but the reality is that as the number of defined functions grew, if a user called one the program would be needlessly traversing the whole data structure to call each function, which is needless slow down. Enough stacks of inefficient programs thrown on top of each other WILL start to drag as a whole.

      The simple fact is that you can write some pretty terrible code that will indeed work, but just because it works doesn't mean that it's done *right*. That's why I still consider some Computer Science education to be critical to making a GOOD programmer.

      --
      "People who think they know everything are very annoying to those of us who do."-Mark Twain
    109. Re:Some, not all... by hotfireball · · Score: 1

      and be able to do fault isolation

      You mean, exception handling in Perl? :-)

    110. Re:Some, not all... by greed · · Score: 2, Interesting

      Too true. Some of the worst performing code I've ever seen was written by someone who "optimized" the C source first.

      Sure, it worked on the broken compiler he was coding for, but when it hit a compiler with a GOOD optimizer, it sucked: The code was unreadable, and the "naive" and "maintainable" way of writing the code was much faster.

      Your search word in the ANSI/ISO C standard is "sequence point". Follow that up with "invariant hoist", "common sub-expression", "register kills", and "non-volatile condition registers".

      (Back in the day, hand-optimizing would work for an x86 chip, because there were no registers to speak of, so nothing could be held in the CPU. But on a RISC chip, that's just not the case. By creating extra sequence points, the compiler had to ensure certain calculations were serialized.)

      Given this code:

      if(x>0) { do something without x or y; )
      if(x>0 && y) { do something without x or y; )
      if(x>0 && y && z) { ... }

      A good optimizer, especially on a target with multiple condition registers, will just keep the result of the 'x>0' comparison in a CR, 'and'ing it with the other tests. It will also start the test of 'y' long before the 'if' statement logically appears, so there's no slow-down in the pipeline.

      So don't fiddle with non-algorithmic changes to the code, until long after you've done everything else. If it makes a big difference, you need a better compiler anyway; or you need to re-think your declarations. Profile it, and only spend time impairing readability where performance really matters.

      Replacing bubble sort with quick sort is worth it. "register boolean x_positive=x>0;" isn't.

      Also, languages like C and C++ really suck if you put function calls inside tight loops. Unless the compiler "knows" the far side of the call, it has to assume memory and registers are killed (within the limits of the ABI), and so has to write variables to main storage and pull them back on either side of the function calls.

      So, what you want is to hand large chunks of work around, not single values.

      That'll be a big win for caching, too; if you're going to micro-optimize, you'd better pay attention to your cache stride and associativity.

    111. Re:Some, not all... by Olivier+Galibert · · Score: 1

      Bitsort / bucketsort algorithms run in O(n log(log(n))) time on data with a roughly uniform distribution, so O(n*log(n)) isn't a hard lower limit.

      n*log(n) is a hard limit when you don't add preconditions like a roughly uniform distribution. It's even easy to see why. There are n! possible orders for n elements and you need to find out which it is to sort them. Any test operation you do splits the sets of possibles orders m-way for a fixed (non-dependant on n) m. So k tests will sort between m**k orders at max.

      So we want the smallest k such as m**k >= n!. Which means k=log(n!)/log(m) ~= (n.log(n)-n)/log(m) (Stirling's approximation for n!).

      Since m is fixed, in O notation that gives you O(n.log(n)).

      What you *can* do, is to be faster on an interesting subset of the n! cases (partially ordered lists for instance) or to add constraints on the values so that they actually give you, more or less directly, information on the initial order (uniform distribution is such a case). That's very much a case of "knowing what your input is going to look like".

          OG.

    112. Re:Some, not all... by Bigjeff5 · · Score: 1

      Wow, you got modded Informative for reading the parent incorrectly? Quality modding there.

      The parent didn't say the C++ map was faster, he said it was clearer and easier to understand what it was doing.

      He then said that if the map is significantly slower, you've probably got other issues in your code. The obfusticating array should only be used as a last resort and if performance is critical.

      I'm not even a programmer and I got that.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    113. Re:Some, not all... by ultranova · · Score: 1

      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.

      And this demonstrates grandparent's point nicely. If your sorting algorithm is the bottleneck, it's very likely that it's because it has reached the point where exponential growth in execution time starts really kicking in. If that's the case, throwing more hardware at it won't accomplish much, since you'll get rapidly diminishing returns from faster CPUs - and if the algorithm isn't multithreaded or fully distributed, you'll also hit the wall of current technology really fast.

      For the same reason it doesn't really matter at all what language your sorting algorithm is implemented in. As soon as you feed it any significant data, the overhead from even the most overengineered monstrosity of a language is going to be diminished into utter insignificance compared to the inherent scalability of the algorithm. In modern multicore machines this is even more true, if the non-C implementation allows for multithreading and the C one won't.

      Finally, won't someone please think of Assembly ?-)

      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').

      Actually, in C, wouldn't the last example run very fast and yield a memory address ?-) As long as the answer comes fast, it doesn't matter if it's correct, is the philosophy of C and Pentium designers ;)...

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    114. Re:Some, not all... by moosesocks · · Score: 1

      And then, take a page out of Knuth's book -- throw the code away, and write it again.

      Can Knuth do us all a favor, and apply this philosophy to TeX?

      Considering that the guy is praised as the 'God' of CS, LaTeX is one of the most archaic pieces of software that I've ever had to use.

      --
      -- If you try to fail and succeed, which have you done? - Uli's moose
    115. Re:Some, not all... by ClosedSource · · Score: 1

      If you can produce code that fulfills your project's requirements, you're qualified to program it.

      In any particular case, it may require specific knowledge, but there is no universal list of necessary and sufficient skills to program.

      In my first ten years of programming in embedded systems none of the projects I worked on required sorting, searching, or sophisticated data structures.

      That's not to say that knowledge of such things is a waste of time, but it isn't always required.

    116. Re:Some, not all... by kirillian · · Score: 1
      perhaps we should re-cast most of the jobs in the current market and label them "typists"? I'm pretty darned sure that at least half of the programmers out there can't read road signs - I mean, can't read/understand the actual problem in the code in the first place.

      I remember being taught that programming was the solving of problems. Shouldn't "programmers" have basic problem solving skills?!? Seems that business people don't understand that in the first place, but then there's those teachers that just feed their students with everything instead of teaching them how to solve the stinking problems with the stuff they learned...maybe that's part of the issue...

    117. Re:Some, not all... by SQLGuru · · Score: 1

      From memory and paraphrased:

      divide your elements into equal parts, sort each part and combine

      sorting is the recursive call
      combining is a simple step because the two lists are now sorted

      Might not be exactly right, but good enough to code a simple recursive sort algorithm which should pass muster for me to retain my residence in the group named Programmers.

    118. Re:Some, not all... by Anonymous Coward · · Score: 0

      I think one of the best (and most fun to implement, especially if you're doing it in assembly) sorting algorithms is radix sort. It runs in O(n)!

    119. Re:Some, not all... by fractoid · · Score: 1

      But that's just it - according to him, you should be kicked out the industry. He stated:

      Nono - I could code one alright. It'd just be shit compared with an optimized version. I understand the algorithm fine, I just haven't bothered to learn the intricacies of implementing it optimally in my current programming environment because it's _not necessary_. And that's why I (along with everyone who has a lot of experience in programming) extoll the virtues of reusing libraries for central, very-very-oft-repeated code. Which is because if a billion people have failed for a decade to improve the algorithm, it's probably as near as makes no beans to the optimal one.

      I can code a list, a hash table, a bubble sort, a btree, and in fact have ad-hocked all of the above many times in my programming lifetime. But while I'd say all of the above are at or close to theoretical optimum just because I'm fucking awesome, I'll concede that more complicated algorithms (like quicksort) have subtleties that I haven't made a particular study of.

      I'll agree with you for most of what you said, but I disagree that programmers should learn to implement sorting algorithms.

      Eh? That was some other guy, I'm all in FAVOUR of all programmers learning basic sorting and searching, if for no other reason than that if you can't understand those then you probably shouldn't be programming.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    120. Re:Some, not all... by gladish · · Score: 1

      You mean emacs doesn't talk?

    121. Re:Some, not all... by Mr+Z · · Score: 1

      How is bubble sort not obvious? You bubble the smallest element to the front of the list, then the next smallest, and then the next smallest. How do you know what the smallest element is? Take the last one and compare it to the one previous. If the last element is smaller than the one before it, swap. Otherwise leave them as they are. Now the second-from-last element is the smallest element so far. Repeat this with the second-from-last and the one before it, until you get up to the top. Tada, you've "bubbled up" the smallest value from the unsorted part of the list.

      I actually learned bubble sort in junior high in a beginner's BASIC book.

      1000 FOR I = 1 TO N-1
      1010 FOR J = N-1 TO I STEP -1
      1020 IF A(J) < A(J+1) THEN 1040
      1030 T = A(J+1) : A(J+1) = A(J) : A(J) = T
      1040 NEXT J
      1050 NEXT I

    122. Re:Some, not all... by n00854180t · · Score: 2, Insightful

      Even if you're writing a game(and I'm a game dev), there is very little use in writing a sorting algorithm. In fact, I know my boss would give me a big "WTF!?" if I started writing one. The reason? It's going to be less efficient, and also a waste of time that I could use to be doing something that actually moved tasks forward. Now, obviously it is important to understand the various uses of different sorting algorithms, their performance implications etc. But actually knowing how, from memory, to write any particular sorting algorithm is pretty pointless IMO.

    123. Re:Some, not all... by Pollardito · · Score: 1
      The question is to what level do you have to learn? Does someone need to learn how to print a circuit board or wire an electronic circuit in order to use or program a modern computer? We can probably agree that they don't even though the fact that *someone* knows how to do those things is necessary for the higher level stuff to be done.

      This statement above is what triggered the objections:

      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

      So what does it mean to be able to do those things at a drop of a hat? To me that doesn't mean just knowing what a BTree is or where it is best used, it means being able to rattle off the code for implementing a BTree ad-hoc without refreshing your knowledge. I don't think that's something that most people can do or should have to be able to do. I think the above objections were mostly saying that knowing what it is and where it should be used are enough.

    124. Re:Some, not all... by n00854180t · · Score: 1

      Mod parent up. People above pointing out how big their optimization-e-peens are apparently haven't learned the first thing about optimization in the real world.

    125. Re:Some, not all... by Anonymous Coward · · Score: 0

      any programmer in my team who wasted time building their own sorting algorithms rather than using a library function
      Go back and reread OP. He does not say a programmer should do it, just that a programmer should be able to. Really, someone who cannot figure out how to make a binary tree is not a competent programmer.

    126. Re:Some, not all... by frank_adrian314159 · · Score: 1

      Get some chicken bones and some goat's blood and some black candles...

      For computer-related issues,you want to use iron filings, black salt, and green candles. This will summon/appease Ogun to help you in the matter, or to destroy the system entirely... you never know which. It is a computer, after all.

      --
      That is all.
    127. Re:Some, not all... by RyuuzakiTetsuya · · Score: 1

      it's not *immediately* obvious. Particularly working with other sorting algorithm options. Drop of a hat obvious.

      It took me about 10 minutes to remember the C implementation we all had to learn in highschool. Stacks, queues, linked lists, binary search trees, etc. were immediate recall though.

      The issue though isn't whether you KNOW bubble sort, imho, it's whether you're able to work out the algorithm from vague memory description.

      In my case, nested looped sorting using manipulations of an array took me a few minutes to figure out fresh.

      --
      Non impediti ratione cogitationus.
    128. Re:Some, not all... by Anonymous Coward · · Score: 0

      What a prig!

    129. Re:Some, not all... by Jack9 · · Score: 1

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

      Data Structures aren't the underpinnings of programming.

      --

      Often wrong but never in doubt.
      I am Jack9.
      Everyone knows me.
    130. Re:Some, not all... by Brandybuck · · Score: 1

      I've seen similar. I've seen maps and sets used on collections whose sole purpose was to iterate over all members. Never for searching or indexing. Lists and vectors are far more apppropriate.

      Greenhorn developers like to claim that CPUs are getting faster and RAM cheaper, so it doesn't matter. But as fast as our desktops are getting, the smaller our embedded systems are getting. You don't want to waste cycles and bytes on a cellphone, pacemaker, ignition system, etc.

      Premature optimization is bad. But so is deliberate non-optimization.

      --
      Don't blame me, I didn't vote for either of them!
    131. Re:Some, not all... by epee1221 · · Score: 1

      someone who only shows off his skills by hacking together a quick version from memory without doing any checks

      Why do so many people insist on reading this into AuMatar's argument? I don't recall seeing him say programmers should roll their own; in fact, he says a programmer generally shouldn't.

      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

      So, it seems you would toss out everyone he would, and then some.

      --
      "The use-mention distinction" is not "enforced here."
    132. Re:Some, not all... by Burkin · · Score: 1

      Which is funny since they are wagging their e-peens around claiming to be the all-knowing, world champion programmers but have apparently never learned such basic lessons.

    133. Re:Some, not all... by frank_adrian314159 · · Score: 1

      a *text editor* should do no such thing.

      Unless it's emacs, the text editor that thinks it's an OS!

      --
      That is all.
    134. Re:Some, not all... by Brandybuck · · Score: 1

      The people who bitch about having to learn the old fart skills don't really want to be programmers. They want to be operators. Hence the huge gulf between software engineering and IT. If you're the type that says "I don't have to know how to balance a btree because the language provides it", then you'll gravitate towards IT and spend your days operating computers.

      There is nothing wrong with IT, so stop flaming. But it is a very different field from engineering.

      --
      Don't blame me, I didn't vote for either of them!
    135. Re:Some, not all... by The+End+Of+Days · · Score: 2, Insightful

      That's not the case at all. The programming field is extremely large and there is room for people who don't know the underpinnings at all, and don't need to.

      Placing arbitrary bars on what constitutes a "programmer worthy of the name" is just get-off-my-lawn elitism spawned by people who are watching their craft steadily devalue under attacks from all angles.

      Sorry to let you guys in on this secret: it gets easier over time, and it will continue to do so until your arcane knowledge is as meaningless to society in general as pokemon trivia.

    136. Re:Some, not all... by Anonymous Coward · · Score: 0

      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.

      I lived thru the era the article describes, and I disagree. When the automobile was new, you had to have intimate familiarity with its inner workings. Today, not so much unless you just happen to be interested. Likewise, I welcome the fact that we can use canned software to handle much of the routine stuff and concentrate on the higher-level functionality. Sure there will be times when you need to delve into the guts of what's really going on in one of the libraries, or have to write a custom routine of your own, but that's rare nowadays, and you wait until it's necessary to become expert in the topic.

    137. Re:Some, not all... by thePowerOfGrayskull · · Score: 1

      . 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).

      I agree, but I think being able to memorize/parrot the implementation isn't the point. Instead, it's about understanding it, knowing how it works, and knowing why it's faster by comparison to other types of sorts.

      Any monkey can memorize; but if you don't have the ability to understand these algorithms at a fundamental level, then your mind is not well-suited for programming.

    138. Re:Some, not all... by david_thornley · · Score: 1

      Sure, that profiler might say that you are taking n% of your time in it, but how are you going to objectively know that that n% can be reduced significantly? Is your profiler an artificial inteligence?

      Who cares? There's a fundamental principle here: when the profiler shows a routine (including called routines) taking n% of the run time, you aren't going to reduce run time by more than n% by optimizing that. If you've got a routine that uses 80% of your run time (I had one of those once, in a financial model), then it really isn't all that worthwhile optimizing anything else.

      If the hot spots are system algorithms, then either the system algorithm is losing because it's overly general or you probably can't speed them up significantly. The people who write those typically know what they're doing and work hard on getting them fast and correct. They probably have a better idea of exactly how the cache works than I do, and how it varies from chip to chip.

      Correctness is important. Write a binary search routine yourself. Odds are it's got a bug, since that algorithm seems particularly hard for humans to get right. Since you're going for performance, a performance bug that hits now and then (such as a quicksort with a consistently bad pivot point, or a hash function with lots of collisions) is just as bad, and it's even harder to avoid those with certainty. In order to ensure that your solution is correct and consistently fast, you're going to have to do a lot of quality assurance that's already done for the canned solution.

      Only rarely are you going to be able to replace a standard solution with a hand-coded equivalent, and have it be an improvement, without a fair amount of work. If it's going to be work, there's no harm with doing a bit of research. If it's something routine like a memory allocation pool, there will be good examples on the net. If not, then you're going to spend time on it no matter what.

      You need the general ideas to proceed. You don't need the details. You can look up the Boyer-Moore search algorithm if and when it becomes important. You need to be able to understand it and its implications. You don't need to know it up front.

      As far as the DoS attack goes, if you think you can look at a large piece of software and tell at a glance how it's vulnerable via algorithmic complexity, you are overestimating your abilities in a big way, and it's going to bite you sometime. If you can tell what the DoS consists of, then you can simulate it on your own system and profile it. Odds are the hot spot isn't where you'd expect it.

      Use the standard solutions, and you're likely to wind up with more reliable and understandable source code. Try to speed it up without profiling, and you will most likely accomplish nothing worthwhile. Humans are notoriously bad at picking out hot spots, and that's with tests on humans who think they're good at it. So, run it. On a desktop, the odds are the performance is just fine. (Servers are different. On a desktop, a 10% increase in program speed usually means nothing. On a server, it can mean 10% fewer servers to maintain.) If the performance has to be improved, profile it. Find the hot spots, and prepare to spend some time on it, which can include research. When you come up with something you think is an improvement, test it. Ideally, test it on machines your customers are likely to have, to make sure your solution isn't only working better because you've got a big cache or something.

      And don't confuse ignorance of the details with ignorance of the principles.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    139. Re:Some, not all... by adisakp · · Score: 1

      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)!".

      The CS kid didn't pay attention in class when they covered O(N) sorts like counting sort and radix sort. Of course, both of those run in linear time.

      The fact that you got sub-linear time on your sort meant that your working set was structured such that you could ignore a significant amount of the data (i.e. not resorting an already sorted list). There's no way to actually step through all items in a data set in sub-linear time -- the only way it can be done is through an incomplete data iteration that ignores a portion of the working set.

    140. Re:Some, not all... by hey! · · Score: 1

      Well, with respect to sorting...

      You ought to learn how that stuff works for the same reason you ought to be able to get past the Pons Asinorum in geometry. It's important training on how to do a certain, extremely valuable kind of thinking.

      The Internet has created a new need for algorithm design. Databases of unprecedented size exist; or data distributed across the Internet forms a virtual database; or vast numbers of users create endless special cases unless novel abstractions can be discovered (if you're a Platonist, otherwise we'll say invented). A lot of that work, of course, may be graph theory-ish, but sorting teaches different kinds of intellectual lessons, about things like entropy and curious special cases to be found in certain kinds of data. If you can't cross that particular bridge, you probably aren't ready to deal with approximation algorithms. And I predict those will be the foundation many a future brilliant career: creating imperfect solutions that are, nonetheless, slightly less imperfect than the other guys have. Any company where there are vast quantities of data, or where tiny financial improvements to vast numbers of transactions are possible, in short any kind of interesting place to work needs the kind of people who aren't daunted by heapsort.

      Of course, actually coding sorting algorithms is for library developers or fools.

      For the record, my favorite sort algorithm is Shell sort. Why? Because it's interesting. Oh, Quicksort is more elegant, and more efficient provided you work around its horrible worst special case, but I like Shell sort. It is just more interesting. First of all, it take a known bad insertion algorithm (insertion sort) and improves it by the application of numerical insight. Secondly, Shell sort has a curious sequence of numeric parameters (gap size) associated with it that have no real justification other than that they work better than other equally unpromising looking sequences. That's a charming property, in my opinion.

      Heapsort is my second favorite, not because it is beautiful (it is not), or efficient (it is), but because it is the only sort algorithm (that I know of) that is ironic.

      With respect to other things in the list, I'm not entirely sure we've seen the end of self-modifying code. There are still computation constrained environments. Usually, we encounter them as the result of poor advance planning, and for better or worse the world has a plentiful supply of that. A few years ago I was asked to examine the feasibility of implementing encryption on an embedded sat tracking device that was comparable in computation power to some of the first microcomputers I ever worked on in the early 80s (eight bit instruction set, sixteen bit address, and about 6K of RAM free). Of course, if I had to really do self-modifying code like in the bad old days, it would be a lot better than that code ever was. I'd break down everything into test cases and run it in simulation on a real computer. I might even create some kind of higher level abstractions that compiled into self-modifying code. I wouldn't just rewrite pages of memory with code or mess with the stack at the end of a long day of coding and pray I understood what I just did in the morning.

      And as for Hollerith cards, we still use them around my house. They make dandy little dust-pans when you're sweeping up something extra fine, like concrete dust or flour. They're actually a hell of a lot more useful than all those old floppies AOL used to send out. Old CDs at least make reasonable coasters, or edging for flower beds. I haven't found a use for paper punch tape yet. It makes rather dreary bunting. Old hard disks can be disassembled. The platters make a workable shaving mirror.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    141. Re:Some, not all... by Sancho · · Score: 1

      There's a pretty interesting article about this here: http://savoysoftware.com/blog/?p=114

    142. Re:Some, not all... by Anonymous Coward · · Score: 0

      It's like a mathematician not memorising Pi past 8dp.

    143. Re:Some, not all... by hviniciusg · · Score: 1

      mmm, can u use a car analogy whit that?

    144. Re:Some, not all... by Harry+Coin · · Score: 1

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

      Wrong, and dangerously so.

      Understanding the basic principles = Being able to code your own.

      If you are not able to code your own, you absolutely do not understand it aside from a cursory familiarity. I'm certainly not advocating writing your own when a quality implementation is available, but pretending to understand how something like a red-black tree works without being capable of coding one is nothing but posturing.

      PS: I agree with you that higher level data flow optimization is far more important for a good application than low-level optimization.

      --
      That's pre 7-11 thinking....
    145. Re:Some, not all... by Brandybuck · · Score: 1

      Sorry, but with a name like Sancho and a low /. ID, I suspect your link is either a rickroll or a gaping horror.

      --
      Don't blame me, I didn't vote for either of them!
    146. Re:Some, not all... by InverseParadox · · Score: 1

      You are in agreement with Unoriginal_Nickname, and others such as myself who say that understanding them is important, just that you shouldn't necessarily need to hand code one in exam room conditions at the drop of a hat.

      I'm not sure he is; I know I'm not.

      Rather, I don't think that programmers should necessarily need to hand-code e.g. a sorting algorithm at the drop of a hat - but I do think that they need to be able to so code one, if the circumstance really did require it. If they don't have the skill to be able to do that, then they aren't going to have the skill to be a really good programmer.

      Putting it the other way around: if someone has acquired the skill necessary to be a really good programmer, then by and large, that person will also by that point be able to code a sorting algorithm - even if not necessarily an especially efficient implementation - at, as the fellow says, the drop of a hat. There will always be exceptions to that, of course, but not nearly enough to invalidate it as a general rule.

      By that standard, as it happens, I myself am not an especially good programmer. I could code a bubble sort with no difficulty, and linked lists (handcoded since C doesn't provide any such thing) are an integral part of every nontrivial program I write these days - but I've never even seriously understood (as in, would be able to explain it a week later without referring back to what I'd previously read) quicksort, much less been able to implement it, and I wouldn't know where to get started on implementing a hash or a B-tree.

      --
      -- The Wanderer
    147. Re:Some, not all... by julesh · · Score: 1

      I've already seen the Java "string" + "string" example, pointing out that it is slow. SO WHAT? Unless you're putting megabytes together (which you probably shouldn't), who will notice?

      It's not about the length of the strings... the problem is that creates a new StringBuffer, which creates a new char array, copies the relevant characters in, then creates a new string and returns it. New object creation is practically by definition a slow process, as it means searching for free space in the heap which almost always will not be in cache (because it isn't in active use already). Even if you're just doing "a" + "b", you're probably talking thousands of active processor cycles plus at least two or three cache misses. If this is happening in an inner loop, you're basically fucked.

      I've seen programmers clobber other programmers because they were using a linked list when sorting. Not very interesting if the list only grows to 10 elements.

      If your list has a max 10 elements, why use a linked list? An array is much simpler to work with...

    148. Re:Some, not all... by Anonymous Coward · · Score: 0

      Putz.

    149. Re:Some, not all... by julesh · · Score: 1

      The CS kid didn't pay attention in class when they covered O(N) sorts like counting sort and radix sort. Of course, both of those run in linear time.

      Neither of those were covered in any CS class I attended. Seriously; CS classes don't teach every algorithm ever invented. In fact, CS classes typically teach very few algorithms. They tend to contentrate more on the approach to take to evaluate an algorithm and see how it works. I think the only sorts we studied in any depth were bubblesort and quicksort, basically because the lecturer wanted two different examples of how to analyse complexity.

    150. Re:Some, not all... by Anonymous Coward · · Score: 0

      a *text editor* should do no such thing.

      Ed is the standard text editor. Ed is the standard text editor? Ed is the standard text editor!

    151. Re:Some, not all... by l0b0 · · Score: 1

      If size and performance really do matter, I'd say take a long, hard look at the data model and trim it until it hurts. Once you've got it replicated, cached, checksummed, indexed, normalized, de-normalized and compressed in all the right places, then we can start talking about the efficiency of libraries that have been optimized for years, probably by some really smart people. That said, using the same library for every project should ring a bell with any competent programmer - Don't Repeat Yourself.

    152. Re:Some, not all... by Fulcrum+of+Evil · · Score: 0, Flamebait

      Placing arbitrary bars on what constitutes a "programmer worthy of the name" is just get-off-my-lawn elitism spawned by people who are watching their craft steadily devalue under attacks from all angles.

      Damn skippy. In order for programmer to mean something, there must be a bar, and I've set this one pretty low. I suppose you think doctors are elitist pricks for requiring that you go to med school and get board certified before calling yourself a doctor.

      it gets easier over time, and it will continue to do so until your arcane knowledge is as meaningless to society in general as pokemon trivia.

      It isn't arcane, it's just the minimum (less than that) for you to be any good at any significant programming task.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    153. Re:Some, not all... by Anonymous Coward · · Score: 0

      you can always view it with images and JS turned off:)

    154. Re:Some, not all... by Anonymous Coward · · Score: 0

      The point of learning the algorithms is to get a feel for what the time complexity is like. I had a guy in a class make the statement, I used a linked list to solve it. To which I responded what if you give your implementation 10^7 values. If I were the professor I make the point to run his implementation with a reasonable size input for nlogn time complexity vs a n^2 time complexity, and I would tell him, if you leave before your implementation completes the sort, you FAIL!

    155. Re:Some, not all... by crowne · · Score: 1

      Listen i've been doing serious spreadsheet programming back since lotus 123, and I know that learning to sort is not that difficult, even if you haven't learnt it before. All you have to do is switch on the record macro function, and then click on the column that you want to sort, and then click on the sort button, and choose from ascending or descending.
      See that was easy, 'Knuth said ;)

      --
      RTFM is not a radio station.
    156. Re:Some, not all... by hazydave · · Score: 1

      I do hardware and software (I double-majored)... there are hardware people who only use the "black-box" model... they know a NAND or OR or FPGA or whatever, but would be challenged to know how to bias a transistor, or when you ought to use that transistor, rather than some common gate.

      They often get stuck, or turn in relatively poor design. This is the same kind of thing... it's not that everyone NEEDs to stop using off-the-shelf sorts or math op, but everyone programming should understand what it is they're using (same way the hardware guy needs to know the realities of that particular gate implementation, drive characteristics, etc), when a different sort or function might speed things up, why to chose one of the dozen-or-so built-in/library routines, and when one might need to code one's own.

      And sure, some of that takes place during optimization... when you have the luxery to optimize.

      --
      -Dave Haynie
    157. Re:Some, not all... by BeanThere · · Score: 1

      A deep understanding of sorting algorithms is usually a kind of 'proxy' measure of a proper understanding of the underlying principles of performance that a programmer must know to write decent code ... e.g. programmers who don't properly understand quicksort usually also don't understand basic things O(log n), O(n), O(n^2) etc., and end up writing crappy code as a habit. It's not about having to write sorting routines every day, but it is about having a continual understanding, in every algorithm you implement, what overall performance you'd expect to get out of it, and what other strategies would be far better.

      Writing good tight code is a habit that a good programmers gets into and just does all the time.

      Frankly I don't mind if the market is swamped with arrogant young programmers who think they don't need to know these things anymore; this is why us slightly older programmers will be able to earn far more money, because companies really do still need the skills of people who do actually know these things, even if programmers think they don't need to know them.

    158. Re:Some, not all... by michaelwv · · Score: 1

      A mathematician should not necessarily have pi memorized beyond any particular number of decimal places. However, she should be able to tell you at least 5 different ways to calculate pi and what each of the different techniques reveals about pi, transcendental numbers, series, convergence, geometry, etc.

    159. Re:Some, not all... by Darinbob · · Score: 1

      Yes, I can agree that you're not even a programmer. The array uses exactly the same syntax as a map, except for the declaration. The array declaration takes fewer characters. In no way is the map clearer or easier to use. It is easier to write the array code, and easier to use it, and easier for others to understand it. And though you don't care it will always be faster than map as it is a constant operation to do a look up.

    160. Re:Some, not all... by Darinbob · · Score: 1

      You mean no typing on the keys. The type of the contents was clear in my example, "int". The syntax to use the table is identical to a map, but vastly more efficient in time and space, with no extra typing time.

      This is absolutely not micro optimization. Just because someone doesn't immediately jump to the most inefficient implementation doesn't mean he's focused in the wrong area. It takes no extra work to use the array. In this particular example, I saw that map being used in a piece of code that required speed and may be called from an interrupt handler, and in an application that was already bloated and threatening to exceed the certain memory limits.

      Perhaps it may even be considered micro optimization to be worrying about using a vector instead of a list, or using a map instead of just using find_first_of() everywhere. Perhaps this is like the goto, in that people have been told to avoid premature optimization so often in school that they avoid all optimization like a taboo for the rest of their careers. Perhaps this explains why my Windows computers keep having to get double memory and storage every couple of years just to keep up with the applications.

    161. Re:Some, not all... by Hydrogenoid · · Score: 1

      That would be merge sort, not quicksort.
      Quicksort is (basically) :
      - choose a pivot value
      - quicksort the list of elements with a value lower than the pivot value (list 1)
      - quicksort the list of elements with a value higher than the pivot value (list 2)
      - add the pivot and list 2 to list 1

    162. Re:Some, not all... by Chabo · · Score: 2, Informative

      In any reasonable OO language, it's simple to let the language compare your new Data Types.

      Using Java as an example, just inherit the Comparable interface, then implement the compareTo() method to output whatever metric you want to compare the elements with. If you have the elements inside a standard Collection, then Collection.sort() will sort the elements by using the compareTo() method.

      --
      Convert FLACs to a portable format with FlacSquisher
    163. Re:Some, not all... by crowne · · Score: 1

      OK, I've done that too on a mainframe not the whole mainframe but a shared CICS region.
      I was debugging a CICS/DB2 program using CEDF, and I knew that the problem was that a DB2 insert statement was returning -803 (Duplicate), so I wanted to overwrite the SQLCode with 0 (OK), after carefully stepping thru and getting to the right point in the program, I go to overwrite the SQLCode storage location with zeroes and *BAM* the CICS region goes down.
      Damn now the whole team and I have to wait for the system programmers to start the CICS region up again.
      CICS is up and I start my debug session again and a little while later at the crucial point *BAM* the CICS goes down again.
      This time my phone rings ... its the sysprog ... I felt like a complete twat.

      --
      RTFM is not a radio station.
    164. Re:Some, not all... by Fulcrum+of+Evil · · Score: 1

      What makes you think that everything can be reduced to a static array? Quite a lot of things are more easily modeled as map(string,struct), and at least the map won't have a nasty buffer overflow.

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

      One could just as well claim that it has made you excessively defensive. If you spend a lot of energy avoiding errors that are no longer as costly as they were in the past (for example, because nowadays you have all the memory management that is usual in a modern language) then I would say that's a waste.

    166. Re:Some, not all... by Anonymous Coward · · Score: 0

      Perl Exception Handling:

      Programmer A: There's an error in the code; it keeps throwing this exception.

      Programmer B: Want to fix it?

      Programmer A: No. Do you?

      Programmer B: I can't even read Perl.

      Programmer A: Neither can I. Live with it?

      Programmer B: I can handle that.

    167. Re:Some, not all... by Darinbob · · Score: 1

      Yes, efficient libraries I like. However, things like STL templates aren't really the same as object libraries. STL has been optimized for years yes, but optimized for large and fast systems, not tiny resource constrained systems. The job of space efficiency (reusing object code and not just source code) was left to the compilers/linkers and they still have a long way to go. So many small systems, such as Symbian for example, use different libraries altogether.

      Then there are systems that are based on C instead of C++, but I don't want to scare the kids too much.

    168. Re:Some, not all... by Darinbob · · Score: 1

      What makes you think that everything can be reduced to a static array

      I don't. Maps are great for many things. However I had given an explicit example of only 8 possible enum values as keys (maybe it wasn't clear that they were from 0 to 7 though).

    169. Re:Some, not all... by Darinbob · · Score: 1

      And sure, some of that takes place during optimization... when you have the luxery to optimize.

      I agree. In some places, that luxury never arrives. I know that I keep TODO lists of optimization opportunities that I never get around to doing because they just aren't as important as other things. But sometimes the optimization is vital to the product and business.

      Premature optimization can be a waste of resources, but no optimization at all is also very bad. Imagine what some products would be like if no one on the team had ever bothered with optimization? Would people use FireFox if page draws were slow? Would Google exist if it took 20 seconds to get a response to queries from their page?

      Some of the optimization needs to be done during design. It's too late for most optimizations if you wait until the product is done and the boss thinks it's ready to ship, or if you try to fix performance only after the customers complain. Picking the right data structures and algorithms up front can save a lot of rewriting later on, which is why most reputable schools still teach those subjects instead of treating them like "old-school coding techniques".

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

      It's like a physicist who can't understand force, or a mathematician who doesn't understand the first fundamental theory of calculus.

      In this case, I think it's more like a carpenter who doesn't understand genetics, or botany. He doesn't know how to grow the trees, why should he be qualified to work with the wood?

      Granted, I think any decent programmer should be able to create a hash table, given the resources required. That doesn't mean they need to ever do so, or that they need the working knowledge of how to do so.

      --
      Don't thank God, thank a doctor!
    171. Re:Some, not all... by SanityInAnarchy · · Score: 1

      I doubt I would find either a bubble sort or a hash table particularly difficult.

      I would find it tedious. I wouldn't know how to do it offhand. I'd have to read Wikipedia, and it might take me a bit, since I do frequently work a few levels above it.

      being several levels above that so it is as easy as computing six times seven or reading road signs.

      How about this: Can you multiply 385*192 without a calculator? Can you do it in your head?

      Indeed, mathematicians may often make mistakes in computation. That's why we have computers. Certainly, the above mental math would be useful, but not nearly as useful as mastering a general purpose calculator.

      --
      Don't thank God, thank a doctor!
    172. Re:Some, not all... by SanityInAnarchy · · Score: 1

      Some of your logic is based on the premise that "or I have to also write that algorithm in C" is a difficult proposition.

      I write Ruby.

      It is not necessarily difficult to go to C, although it's a massive context switch for me -- I almost never touch C. But it does lose me a few of the advantages of Ruby -- for example, if I don't write a C extension, I could port my app to JRuby, and get a performance boost and access to Java libraries instead.

      Never mind that C is likely to be more code, and less maintainable. There's a reason I was using the higher-level language in the first place.

      Parent and grand-parent's point is that you should be good enough at this stuff that having to write a replacement in C is a quick no-brainer

      The fact that I haven't had to do it yet suggests that developing my C skills (and knowledge of this language's C bindings) to the point where it's a "quick no-brainer" is a waste of time.

      --
      Don't thank God, thank a doctor!
    173. Re:Some, not all... by SanityInAnarchy · · Score: 1

      And this is precisely why you'd want to go higher level, not lower level. In Ruby, I do this:

      array.each {|element|
        # do something with element
      }

      I don't have to care whether array is an actual array or a linked list. It will just do the right thing.

      --
      Don't thank God, thank a doctor!
    174. Re:Some, not all... by Anonymous Coward · · Score: 0

      The type of thinking and expertise needed for creating that higher-level functionality is more or less the same as that needed for implementing (note: implementation is not optimization) the algorithms/structures in question. Anyone who is good at the higher-level work should be able to sit down and code up a working (though not necessarily optimized) version of any of the above, just because they are fairly simple constructs. Such similarity does not exist between driving and car repair.

    175. Re:Some, not all... by Anthony · · Score: 1

      In my 28 year career I implemented a sorting algorithm once. I chose bubble sort in COBOL because n was small so the difference in performance compared to a more sophistcated algorithm was not going to be noticable.

      --
      Slashdot: Where nerds gather to pool their ignorance
    176. Re:Some, not all... by owlstead · · Score: 1

      It's not about the length of the strings... the problem is that creates a new StringBuffer, which creates a new char array, copies the relevant characters in, then creates a new string and returns it. New object creation is practically by definition a slow process, as it means searching for free space in the heap which almost always will not be in cache (because it isn't in active use already). Even if you're just doing "a" + "b", you're probably talking thousands of active processor cycles plus at least two or three cache misses. If this is happening in an inner loop, you're basically fucked.

      And how many times will a "string" + "string" be in an inner loop and add to the same string? In this case you need to create a StringBuilder sure enough. Basically, if you are doing string addition within a performance critical part of the system, you're probably already on the wrong track. Even then it is easy to remove when optimizing the application.

      Furthermore, in a loop many things get optimized by the compiler, and short lived objects are put where they belong: in the short term object storage location of the garbage collector. I wonder if that would not be in the cache.

      If your list has a max 10 elements, why use a linked list? An array is much simpler to work with...

      You use arrays when the situation requires an array. I said: a maximum of 10 elements, not 10 elements. IMHO, keeping an array that is partly filled is something you should try to avoid. To me it seems like you are thinking too much in old school optimizations, while you should be thinking about the overall design and maintainability.

      BTW, I do use StringBuilder a lot because I like working with final variables - the chances that your code is bug free is just somewhat higher with final variables (even local ones, not just fields). So I almost never use a = ""; a = a + b; a = a + c etc, because I want to assign variables only once unless they are supposed to change (offsets, counters etc etc). In a way, by using final a lot you will auto-optimize, and not just for optimalization per se.

    177. Re:Some, not all... by Jacques+Chester · · Score: 1

      "And then, take a page out of Knuth's book -- throw the code away, and write it again."

      I was pretty sure Fred Brooks is responsible for that idea, not Knuth.

      --

      Classical Liberalism: All your base are belong to you.

    178. Re:Some, not all... by JasterBobaMereel · · Score: 2, Insightful

      Number of times you have had to pick a different sorting/searching algorithm by choosing a different library or routine, I hope is many times - and how did you decide which to pick, did you try each by trial and error, or did you remember (or look up) which were likely to be the best candidates in the current situation and try just them?

      It's not what you know from memory, it's not what you can lookup, it's what you know/remember where and how to lookup the answer... learning how to use a variety of basic algorithms will help you in the future to use the most appropriate

      --
      Puteulanus fenestra mortis
    179. Re:Some, not all... by jrade · · Score: 1

      For instance, sorting/searching algorithms, data structures, etc. Don't they still make you code these things in school?

      They did at UIUC in 2005.
      --
      Wise men speak because they have something to say; Fools because they have to say something - Plato

      --

      Exception in thread "main" java.lang.NullPointerException at Sig.setCleverSig(Sig.java:42)
    180. Re:Some, not all... by Anonymous Coward · · Score: 0

      n*log(n) is a hard limit when you don't add preconditions like a roughly uniform distribution...
      ...and you limit yourself to a binary decision tree.

    181. Re:Some, not all... by badkarmadayaccount · · Score: 1

      <Nazi type="syntax">

      That is not properly formed XML in the meaning you had in mind.
      Self-closing tags indicate an empty element.
      <Nazi>

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    182. Re:Some, not all... by Anonymous Coward · · Score: 0

      I absolutely agree with bsDaemon. It is important for a developer to understand the underlying components to assure that he/she are using the best programing options. Automation won't help a developor make all the right decisions.

    183. Re:Some, not all... by richoparker · · Score: 1

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

      We wrote a lot of "efficient" code in the punch card days and it seems as though nobody really cares about efficiency anymore.

      OTOH, I hated paper tape! I guess that makes me really old!

    184. Re:Some, not all... by adisakp · · Score: 1

      Neither of those were covered in any CS class I attended. Seriously; CS classes don't teach every algorithm ever invented.

      Wow, now I'm frightened by CS programs. When I went to college in twenty years ago (at UW-Madison in 1989), I took a basic programming class in my first semester and a very elementary "introduction to algorithms" class in my second semester that used the wonderful CLR(S) book.

      Sure we spent more time analyzing bubble sort and quick sort as O(N^2) and O(N Lg N) sorts but at least we covered the concept of O(N) sorting. I can't believe that a current introductory algorithms class wouldn't even mention O(N) sorting algorithms -- especially since counting sort and radix sort are both trivially easy to implement.

      How is it that CS students are graduating now without learning concepts that were considered basic enough to teach in an introductory freshman class when I went to school? Then again, maybe our college CS programs have gone that far downhill. The kid mentioned didn't even *BELIEVE* that O(N) sorting *EXISTED* !!!

    185. Re:Some, not all... by richoparker · · Score: 1

      I did a ton of work in THINK C 5 on Mac OS 7.

      Thanks for your mention of THINK C. I wrote the "Easy Object Programming With THINK C and AppMaker" book and your comment brought back fond memories of that time. Actually, I had few problems with having to reboot...but it is something to remember. There was also a THINK Pascal version of that book because the publisher thought that Pascal was going to be more popular than C. And, BTW, THINK C was one of the first OOP languages for the Mac.

    186. Re:Some, not all... by Garridan · · Score: 1

      Can Knuth do us all a favor, and apply this philosophy to TeX?

      For the love of anything that claims, or even vaguely seems to be a god, no! Please, nobody disturb or distract Knuth until he gets volume 4 done. The man does have a limited life-span, you know. I'd rather see volume 7 than a new release of Tex.

    187. Re:Some, not all... by Garridan · · Score: 1

      However, I'm going to have to call BS on your claim of sub-linear time, since that would not even allow you to _touch_ every index in the array.

      Correct you are! The trick is to only touch the indices that need to change (or at least, minimize the ones you do). Like I said -- if you know what your data looks like, you almost always win. In this case, we were working on the innards of a partition refinement algorithm -- not only were we sorting the integers {0,1,..,n} under a weighting (a function {0,1,..,n} -> {0,1,..,k}), but we also knew that almost all of the list is already correctly sorted; and precisely where we should look for unsorted bits (not X and Y, but "everything between X and Y" where X and Y are usually very close). Wikipedia has a great article about the algorithm we used: counting sort -- and in our case, n and k are usually very small compared to the size of the list.

    188. Re:Some, not all... by DragonWriter · · Score: 1

      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.

      Given the proliferation of languages that aim to make certain tasks easier and that often offer (initially, at least) only a limited array of "good-enough-in-most-cases" basic support for sorting and datastructures, its probably not all that uncommon that someone merely basically familiar with C (or Java or whatever lower-level language is appropriate for the platform) and basic algorithms and data structures could greatly enhance a program written in one of those languages by implementing a well-understood algorithm from the literature without much difficulty. I would say that the skills to recognize such opportunities and have some idea of what is needed where they arise is a pretty important one.

    189. Re:Some, not all... by DragonWriter · · Score: 1

      Sure, that profiler might say that you are taking n% of your time in it, but how are you going to objectively know that that n% can be reduced significantly?

      I think GP isn't saying the profiler tells him that it can be improved, only that it is a waste of time to even begin thinking about whether a bit of code can be optimized until (a) it works correctly, and (b) there is a performance problem, and (b) a profiler reveals that a lot of time is spent in the particular bit of code at issue.

      Then you can analyze what your correct-but-time-consuming code is doing and see if there is a faster way of doing it that remains correct.

      If less than 1% of your time is spent in a particular bit of unoptimized code that could be made hundreds of times faster, that's less of a problem than if 99% of your time is spent in another bit of code that could be made 5% faster.

    190. Re:Some, not all... by bar-agent · · Score: 1

      And though you don't care it will always be faster than map as it is a constant operation to do a look up.

      It's a constant operation in a map, too. O(1). Isn't that the point of a map? Now, granted it will always be a faster operation with an array.

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
    191. Re:Some, not all... by bar-agent · · Score: 1

      It runs in O(n)!

      Factorial? Doesn't sound fast to me...

      --
      i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
    192. Re:Some, not all... by Rockoon · · Score: 1

      Algorithmic changes don't normally provide a 5% speed boost.. they often turn an O(n) problem into an O(log n) problem, or an O(log n) problem into an O(log log n) problem.

      The programmer used a List because his compiler has a nice List library of some kind, but no matter what a List cannot simultaneously offer both O(1) searching AND O(1) appending ..

      ..and because the ignorant programmer doesnt know how lists are implemented he doesnt know that fact.. he probably knows that appending is cheap but doesnt know why.. doesnt even know that its O(1)..

      He certainly will not know that there are structures which will trade the List's O(n) search + O(1) appending for O(log n) search + O(log n) append, and still other structures which offer O(1) search + O(n) append.

      THAT is the difference between a half-assed programmer who doesnt even want to know about these algorithms and data structures, and a great programmer who is the master of algorithms. The great programmer also uses a profiler, but often doesnt need to because he did it right the first time.

      Remember that changing data structures is often non-trivial, often prohibitive, once the project has matured.

      --
      "His name was James Damore."
    193. Re:Some, not all... by ozphx · · Score: 1

      Not at all. Its like a builder not understanding the chemical composition of concrete.

      You are incredibly naieve if you think that by being able to implement your own hashtable or parser that you should even consider implementing it yourself. It is appropriate to understand roughly how a structure/algorithm works, and the rough complexity of various interactions.

      If you really expect that you will nail a hashtable from scratch by pulling out some simple btree-and-buckets implementation, then you need a reality check. Give it a go, and then compare your nubbish attempt against the berkelydb or sqlite index implementation. Then put a naive xml parser up against a "real" one with heuristics and all that jazz.

      You'll quickly find out that memorising simple implementations of trivial algorithms is a waste of your brain-space.

      --
      3laws: No freebies, no backsies, GTFO.
    194. Re:Some, not all... by Darinbob · · Score: 1

      Map in C++ is a tree. Even if it were a hash table, it's still not strictly a constant look up though on average it's pretty close.

    195. Re:Some, not all... by Anonymous Coward · · Score: 0

      Remind me never to hire you.

    196. Re:Some, not all... by StewartBell · · Score: 1

      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.

      Heh, Seems to me like a lot of the people on here are coming from highly disparate development environments. Limited Memory and CPU's are old school to people who have jobs at new firms writing Java or .Net web applications. There are people, on the other hand who are still writing for transaction processing systems that are 20 years old. You bet your ass they need to optimize and know sorting algorithms backward and forwards. And of course, everything in between. Flame flame flame. It's like the people here can't conceive of different circumstances where the other programming paradigm works/exists. I will say that the new programmers don't know enough, but the new programs and ide's do handle a lot for them very efficiently. Great when it works. Stupid when it doesn't

    197. Re:Some, not all... by Anonymous Coward · · Score: 0

      and the holes are so small...

      oh wait...

    198. Re:Some, not all... by CPE1704TKS · · Score: 1

      I've been thinking about this problem a lot. I've come to the conclusion that in order to build the best code, and to have the best design, we need the underlying programmers as dumb as possible, and just strictly implement exactly what the architect tells them to do, in a very specific well defined way, almost like a typist that you talk about.

      Let me explain.

      I live in the Bay Area, and a few years ago, a truck crashed underneath a main thoroughfare and caused a section of a main highway to collapse. The company that fixed it, fixed it in a couple of weeks, under budget and under schedule. It was amazing, because considering how much work is involved and the amount of coordination and how risky it was, they were still able to understand exactly how long the task would take.

      I was wondering why we can't do this with software programming. Why is it so hard to estimate the creation of a piece of software?

      It's because, unlike physical engineering projects, software engineering projects leave too much of the underlying implementation to the actual implementing engineer. This causes far too much variety and subsequent bugs.

      Imagine if the construction company above left the mixing of the concrete to the person actually pouring the concrete? Of the choice of concrete? Or the choice of metal rods, etc? There would be absolute chaos. The only reason why it came on time and underschedule was because there were no underlying decisions of implementation. Everything was standardized and made in a standard way, and connected in a standard way.

      In programming, the choice of algorithm is up to the programmer. Even things like the choice of using a while loop vs for loop, etc, is up to the individual programmer. This is what causes bugs and what causes schedules to overrun. There is absolutely no predictability in software design, and the only way to get it and to create bug-free software is to take any and all decision making capabilities from the underlying programmer, and to do it in a completely standard way. This means there is less variability in how different components of software interact with each other, and the permutations of different behavior decreases.

      Believe me, I don't like the answer I came up with. I love programming, and I love the sense of creativity I feel when I'm programming. But in terms of what is a better way to develop software, I truly believe the above is the only way that as an industry we'll be able to survive. Right now programming is not "engineering" in the same sense of mechanical engineering, or civil engineering. There is far too much choice given to the left-nodes. Until we stop the leaf-nodes from making implementation decisions (turning them into little more than a bunch of typists), I just can't see this industry getting from under the stigma of buggy software, unpredictable schedules, etc.

    199. Re:Some, not all... by jgrahn · · Score: 1

      Also, languages like C and C++ really suck if you put function calls inside tight loops. Unless the compiler "knows" the far side of the call, it has to assume memory and registers are killed (within the limits of the ABI), and so has to write variables to main storage and pull them back on either side of the function calls.

      So, what you want is to hand large chunks of work around, not single values.That is, unless you make sure the compiler can inline the call

      Inline -- or know enough about the function to take a shortcut past the ABI. That's what I prefer to do too ... but be careful with phrases like "really suck". It's usually only a problem if the profiler says so.

    200. Re:Some, not all... by jgrahn · · Score: 1

      You mean no typing on the keys. The type of the contents was clear in my example, "int".

      No, it was an enum. I can see why someone would want to keep that type information for as long as possible, and using std::map is one way. It's a bit odd though ...

      I would have written my own tiny class instead, with enums in the interface and a std::vector or even a C array internally. Performance cost: none (unless I choose std::vector and these things are created and copied really often).

    201. Re:Some, not all... by bwcbwc · · Score: 1

      The key word I have trouble with here is "implement". Nowadays, with all the library routines available, if you can pseudo-code the algorithm, you have the "understanding of your craft" necessary at that level. No one is saying that a knowledge of how the algorithms work is unimportant (at least that's not how I read this thread), just that the industry has moved beyond the sorting wars to more complicated problems. An understanding of the sort algorithms is necessary to understand the more complex algorithms being developed today, but that doesn't mean you have to implement them.

      Perhaps a more modern equivalent algorithm that "everyone should be required to implement" would be to write a compression/decompression algorithm (LZH or whatever), or a media codec.

      Agree about Big(O) notation. That's still a requirement to select an appropriate algorithm from the library for your system requirements.

      --
      We are the 198 proof..
    202. Re:Some, not all... by petermgreen · · Score: 1

      The key word I have trouble with here is "implement". Nowadays, with all the library routines available, if you can pseudo-code the algorithm, you have the "understanding of your craft" necessary at that level
      Seems like a pretty minor distinction to me. If you can correctly psudo-code something but can't implement it that means you can't program.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    203. Re:Some, not all... by Alex+Belits · · Score: 1

      I don't remember a single project that had a requirement that implementation contained bugs.

      Or an implementation that didn't have them.

      --
      Contrary to the popular belief, there indeed is no God.
    204. Re:Some, not all... by 12357bd · · Score: 1

      The point isn't to memorize an algorithm, dude, the important thing is to understand the algorithm in question. Understanding not memory! There's no copy/paste for reasoning! :)

      --
      What's in a sig?
    205. Re:Some, not all... by Anonymous Coward · · Score: 0

      http://www.cs.bell-labs.com/cm/cs/pearls/cto.html

  2. Punched cards - there was a machine for that by NotQuiteReal · · Score: 2, Insightful

    Heh, I had to turn in a punched card assignment in college (probably the last year THAT was ever required)... but I was smart enough to use an interactive CRT session to debug everything first... then simply send the corrected program to the card punch.

    I was an early adopter of the "let the machine do as much work as possible" school of thought.

    --
    This issue is a bit more complicated than you think.
    1. Re:Punched cards - there was a machine for that by rnturn · · Score: 4, Interesting

      ``I had to turn in a punched card assignment in college (probably the last year THAT was ever required)... but I was smart enough to use an interactive CRT session to debug everything first... then simply send the corrected program to the card punch.''

      Jeez. You must have taken the same course that I did. (Probably not actually.) In my case it was a programming class emphasizing statistics taught by someone in the business school who actually wanted card decks turned in. (This was probably no later than, maybe, '80/'81.) I did the same thing you did. I wrote all the software at a terminal (one of those venerable bluish-green ADM 3As) and when it was working I left the code in my virtual card punch. When I sent a message to the operator asking to have the contents sent off to a physical card punch, his message back was "Seriously?

      --
      CUR ALLOC 20195.....5804M
    2. Re:Punched cards - there was a machine for that by julesh · · Score: 1

      (This was probably no later than, maybe, '80/'81.) I did the same thing you did. I wrote all the software at a terminal (one of those venerable bluish-green ADM 3As)

      Hold on... those things were "venerable" in the early 80s?! We had a bunch of old ADM3Es at my university back in '97, and I figured they were a little antiquated, but I never guessed they were _that_ old.

    3. Re:Punched cards - there was a machine for that by Ravenger · · Score: 1

      The first computer program I ever wrote was when I was at school in 1977 in mathematics class. It was a BASIC program to print out a list of numbers, and had to be transcribed onto the equivalent of punched cards, except the 'holes' weren't punched out. Instead you used a soft pencil to colour in the 'holes' to match the binary ascii code of each character in your line of code. There was one card per line of code, each with a max 80 characters that you could encode on them.

      These cards were sent off to a university somewhere, and the resulting print-outs would be sent back a week or so later. Unfortunately my program didn't work. If I had got a printout back it'd probably have said 'SYNTAX ERROR'.

      As I was a school-kid at the time I didn't really realise exactly what I was doing, but looking back now it's pretty cool to have at least attempted to write a computer program on such an ancient input device. Shows how far we've come since I was a kid.

    4. Re:Punched cards - there was a machine for that by Just+Some+Guy · · Score: 1

      Hold on... those things were "venerable" in the early 80s?

      I was playing around on a Xerox Star system in '81 or so. Even the teletypes were mostly silent by then.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Punched cards - there was a machine for that by Viadd · · Score: 2, Interesting

      Around 1980, there was a program called SPIKE, which was a virtual keypunch. It put an image of a punch card up on the screen (character graphics on a Z-100). As you typed, it wrote the characters (uppercase) at the top of the card, and blacked out the appropriate squares.

      It had a mode to do blind typing (not all keypunches printed the characters at the top of the card--that cost extra). It also had a 'dropdeck' command to shuffle the lines of your file.

    6. Re:Punched cards - there was a machine for that by frank_adrian314159 · · Score: 1

      Yeah, ADM-3A's were first out in the mid-seventies and, by the 'eighties, workstations were coming onto the market, so terminals were old(ish) technology. Since the ADM-3A was one of the better models (with it's sexy curved back), I guess venerable would be a way to describe it.

      --
      That is all.
  3. Begone, common file format loaders! by fractoid · · Score: 3, Interesting

    The one thing I don't think I'll ever, ever miss is writing loaders for some of the stupider file formats out there. Sure, it's not hard, per se, to write a .bmp loader, but once you've done it once or twice it gets old. Eventually I wrote a helper image library to do it all but it still would occasionally come across some obscure variant that it wouldn't load. Far worse were early 3D model formats, even now I tend to stick with .md2 for hobby projects just because it's simple, does what I want, and EVERYTHING exports to it.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    1. Re:Begone, common file format loaders! by pavon · · Score: 1

      Oh, man. You just made me remember that horrible mishmash of Auto-Lisp and Q-Basic I wrote in high school trying to use AutoCAD 10 as a Quake level editor, since that's what we had at school. I had moderate success, but finally broke down and bought a shareware package, only to find after months of work, that it always rotates walls around their center, so if you ever rotated a wall with an odd length, it was no longer aligned with the grid. And it didn't have a way to snap objects back to the grid, so you ended up with BSP-tree leaks galore. I had to reverse engineer it's file format so I could write more Q-Basic to snap all the coordinates back to the grid.

    2. Re:Begone, common file format loaders! by Anonymous Coward · · Score: 0

      I wish there was a better format than md2 that is just as simple and every app exports. Just something that doesn't reduce your vertices to the accuracy of one byte would make me happy.

    3. Re:Begone, common file format loaders! by robthebloke · · Score: 1

      Collada. dotXSI. fbx.

    4. Re:Begone, common file format loaders! by pjt33 · · Score: 1

      Wavefront OBJ?

    5. Re:Begone, common file format loaders! by slapout · · Score: 1

      You should check out this comment that Scott Hanselman posted about the other day:

              At this point, I'd like to take a moment to speak to you about the Adobe PSD format.
              PSD is not a good format. PSD is not even a bad format. Calling it such would be an
              insult to other bad formats, such as PCX or JPEG. No, PSD is an abysmal format. Having
              worked on this code for several weeks now, my hate for PSD has grown to a raging fire
              that burns with the fierce passion of a million suns.
              If there are two different ways of doing something, PSD will do both, in different
              places. It will then make up three more ways no sane human would think of, and do those
              too. PSD makes inconsistency an art form. Why, for instance, did it suddenly decide
              that *these* particular chunks should be aligned to four bytes, and that this alignement
              should *not* be included in the size? Other chunks in other places are either unaligned,
              or aligned with the alignment included in the size. Here, though, it is not included.
              Either one of these three behaviours would be fine. A sane format would pick one. PSD,
              of course, uses all three, and more.
              Trying to get data out of a PSD file is like trying to find something in the attic of
              your eccentric old uncle who died in a freak freshwater shark attack on his 58th
              birthday. That last detail may not be important for the purposes of the simile, but
              at this point I am spending a lot of time imagining amusing fates for the people
              responsible for this Rube Goldberg of a file format.
              Earlier, I tried to get a hold of the latest specs for the PSD file format. To do this,
              I had to apply to them for permission to apply to them to have them consider sending
              me this sacred tome. This would have involved faxing them a copy of some document or
              other, probably signed in blood. I can only imagine that they make this process so
              difficult because they are intensely ashamed of having created this abomination. I
              was naturally not gullible enough to go through with this procedure, but if I had done
              so, I would have printed out every single page of the spec, and set them all on fire.
              Were it within my power, I would gather every single copy of those specs, and launch
              them on a spaceship directly into the sun.

              PSD is not my favourite file format.

      --
      Coder's Stone: The programming language quick ref for iPad
    6. Re:Begone, common file format loaders! by fractoid · · Score: 1
      Hey, .jpg is OK. It combines actual mathematics with images of naked women and as such is a-o-kay in my book. I dunno about .pst and I'm glad of that.

      Trying to get data out of a PSD file is like trying to find something in the attic of your eccentric old uncle who died in a freak freshwater shark attack on his 58th birthday.

      This is possibly the best reason EVER for not being able to read a given file format. I am in awe, sir. Your description of this format is cross between geek humour and c'thulo-mythos-style horror.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  4. Hungarian Notation by masdog · · Score: 1, Insightful

    I don't get what the big deal is with Hungarian Notation. Why do people consider it a bad thing?

    Modern IDEs might reduce the need for it, but not everyone uses an IDE to read or write code.

    1. Re:Hungarian Notation by fractoid · · Score: 2, Interesting

      Full Hungarian notation is a bit redundant, precisely because everyone (for reasonable values of 'everyone') DOES use some form of IDE to code, and any non-epic-fail IDE will at the least tell you variable types when you mouse over them, or pop up a member list for a class/struct when you go to type them.

      However, specific notation on some things IS a good thing. Conventions like CONSTANTS, m_memberVariables, and so forth are good because they remind you that the variable in question is an exception to what you'd normally expect (that it's a number, a string, or an object). They're not strictly necessary any more (my current workplace just uses upper camel case for everything, for instance, and my last job used trailing underscores to denote member variables which was downright annoying) but IMO it's good to prevent brain fail errors. Recognising that the programmer is the source of all errors is the first step towards getting rid of them. Well, except in Borland Turbo C++. :)

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    2. Re:Hungarian Notation by ppanon · · Score: 1

      It makes sense when you use it with abbreviations for a limited set of predefined types in procedural languages. When you're dealing with object oriented programming with multiple large class libraries which need separate namespaces to avoid class name conflicts, and lots of your variables are objects that are class instantiations, it loses a lot of its effect in clarifying code. You're better off using longer more descriptive variable names.

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    3. 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
    4. Re:Hungarian Notation by AuMatar · · Score: 3, Insightful

      Three reasons.

      1)Variables change type. And then you have to rename everything. Its a pain
      2)The extra information it gives you is minimal. I want to know what data is in a variable, not the language type used to hold it. If the name of the variable is firstName, I don't need it to be called lpcstrzFirstName, I know it's a string. And the language type is rarely interesting- I want to know that the variable outsideTemp holds degrees farenheit, not that it's an integer. But Hungarian doesn't tell me that. (It also doesn't work even if I make a typedef for temperature- it'll still start with 'i').
      3)It makes searching the code for a variable that much more annoying, because they all start with freaking 'i' and 'p'.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    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. Re:Hungarian Notation by smellotron · · Score: 5, Informative

      And the language type is rarely interesting- I want to know that the variable outsideTemp holds degrees farenheit, not that it's an integer. But Hungarian doesn't tell me that

      Good Hungarian notation does exactly that, actually. Check out Apps Hungarian, which encodes the semantic type of the data, rather than the language-level data type.

      Of course stupid Hungarian notation is stupid. Stupid anything is stupid. Problem is, most people don't hear about the right approach.

    7. Re:Hungarian Notation by AuMatar · · Score: 1

      Not everyone uses an IDE. There's a hell of a lot of us who still use emacs and vi. FOr that matter unless I need a debugger I'd pull up notepad over an IDE- IDE's features tend to make it sputter on lower end computers and/or large projects, and there advantages are minimal to nill. It tends to not even be all that good at the things it can do- I can grep and find all references to a variable faster than most IDEs will find them for me.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    8. Re:Hungarian Notation by SanityInAnarchy · · Score: 1

      Not everyone uses an IDE. There's a hell of a lot of us who still use emacs and vi.

      I suppose if it's 'vi' and not 'vim', you might have a point. But emacs absolutely should be able to do something like that.

      IDE's features tend to make it sputter on lower end computers and/or large projects, and there advantages are minimal to nill.

      However, one thing they have over Notepad: Syntax highlighting.

      I hear you -- I use Kate for development these days. But even there, I've at least got syntax highlighting and code folding.

      I can grep and find all references to a variable faster than most IDEs will find them for me.

      Then for you, hungarian notation should be equally redundant.

      --
      Don't thank God, thank a doctor!
    9. Re:Hungarian Notation by Matheus · · Score: 1

      I still use a bit of Hungarian as it makes the code easier to read plus I can reuse variable names {{ especially in GUI code.. _lBLAH sits next to _tfBLAH for example }} PS I *hate* IDE generated GUI code!

      "I don't need no steenking IDE!" Gimme a file browser and a term and I'm happy as a clam. I have gotten a bit more modern now.. running gvim and mvn instead of vi and make but the only time I've used IDEs is when some employer forced me (and they still spawned vim as my editor)

      As far as finding anything in my code the parent is right: "find ./ -name "*.java" -print | grep -v "\.svn" | grep -v "target\\" | xargs grep -in " makes for a fantastic alias :)

    10. Re:Hungarian Notation by Mad+Merlin · · Score: 3, Funny

      I don't get what the big deal is with Hungarian Notation. Why do people consider it a bad thing?

      The proper name is Hungarian Line Noise, which should answer your question.

    11. Re:Hungarian Notation by hedronist · · Score: 4, Interesting

      Correct. I worked for Charles at Xerox on the BravoX project and I initially fought Hungarian. One day I had an epiphany about what it was really about and then I didn't have any problems with it. Properly done it can reduce "name choosing time" to almost zero and it makes walking into other people's code almost completely painless. The key is that you encode semantics, not machine-level details.

    12. Re:Hungarian Notation by fractoid · · Score: 1

      From your post history, I'd say you probably fall outside the 'reasonable values of everyone' I was talking about - as in, you're probably rather more technically literate than average, and (judging by your UID) probably learned to program using a text editor and command line compiler rather than with MSVC++ 6 or later (the first IDE that I used that had IntelliSense, good god it was awesome!) Also you may not be joining large projects part way through where you are unfamiliar with most of the code.

      I'd still maintain that while vi + gcc is situationally better for expert users, those of us trying not to burn too many brain cells on our daily work are almost certainly better off using a tool that can tell us what type a variable is, where it was declared, what members a struct has as we type its name, and all the other little things. They're not necessary but they most definitely speed up the arduous task of maintaining someone else's code.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    13. Re:Hungarian Notation by AuMatar · · Score: 1

      Borland Turbo C++ 3.0 (on 5 whole floppy disks!) rather than command line, but close enough- it was technically an IDE, but it was probably less capable than emacs. And I only tend to join large projects in mid-stream when I switch jobs.

      Hey, use whatever tool works for you. Different personalities work best with different methods. I just get on edge when people say "everyone uses this"- it leads to assumptions about how others work that can cause problems for their coworkers/project mates down the line.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    14. Re:Hungarian Notation by grimsweep · · Score: 1

      I completely disagree; IDEs make more sense on larger projects. Don't get me wrong; none of my IDE's can beat VI's ability to handle large files, and nothing says convenient like an inline diff. When you're working on something that starts to reach the 100+ file mark, I'd rather not rely on a simple editor and my window manager.

      A good IDE helps you to organize, track, and maintain your sanity at this scale. In Netbeans 6+, I can jump to a class's declaration, find all usages of a method (regardless of any nasty nesting), and refactor a name change across a project and everything that depends on it. I know where most of my stuff is when I write it, but I find that it can be a NIGHTMARE reviewing a huge project written by a team without sensible documentation.

      If you love regular expressions, don't let me stop you, but I think you're missing out.

    15. Re:Hungarian Notation by EnigmaticSource · · Score: 1

      Then for you, hungarian notation should be equally redundant.

      Then you don't understand Hungarian notation... or you don't understand regular expressions. Either is quite sad, if you're a (Unix) programmer

      --
      The Geek in Black
      I know my BCD's (when I'm Sober)
    16. Re:Hungarian Notation by drawfour · · Score: 2, Informative

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

      Actually, this is exactly the reason I think Hungarian is useful. If you change a variable from, say, an unsigned int to a signed int, you had better check every place you use that variable to make sure that you didn't assume something about the type that now requires a different check. For example, underflow/overflow, indexing into an array, etc... By making you do a search/replace to rename the variable, you should go over every place. The person code reviewing will also see each line that had to change as a result, and can easily check that the assumptions are still valid.

    17. Re:Hungarian Notation by amicusNYCL · · Score: 1

      Good Hungarian notation does exactly that, actually. Check out Apps Hungarian, which encodes the semantic type of the data, rather than the language-level data type.

      Good variable naming doesn't require anything extra. A variable name of "outsideTemp" does not require any other information to know what the purpose is. If it's a string, then cast it to an integer before you use it if you need to. You don't need an "unsafe" variable and a "safe" variable, or an integer version and a string version, assuming the language allows for a variable to be redefined.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    18. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      Also this is how hungarian notation was originally devised. Unfortunately some fools misread how it was done and made it a standard, thus the hungarian notation hate. Pity really because labelling your variables based on their semantic use is actually pretty useful.

    19. Re:Hungarian Notation by caerwyn · · Score: 1

      C, K or F? Hope it's obvious everywhere!

      I'm not a hungarian notation fan, but it (or similar techniques) have their place.

      --
      The ringing of the division bell has begun... -PF
    20. Re:Hungarian Notation by YttriumOxide · · Score: 1

      Full Hungarian notation is a bit redundant, precisely because everyone (for reasonable values of 'everyone') DOES use some form of IDE to code, and any non-epic-fail IDE will at the least tell you variable types when you mouse over them, or pop up a member list for a class/struct when you go to type them.

      I tend to use a "non strict, mostly my own style" form of Hungarian notation, precisely because I don't WANT to mouse over or pop up a member list or whatever - I want to be able to sit back and READ the code, not "figure it out". It's also handy for things like this (C#, because that's what I do at work mostly these days, but C++ is my background):

      private void foo() {
      //At some point, get a string from somewhere called szMoney
      //Do stuff
      int iMoney = int.Parse(szMoney);
      //Do more stuff
      }

      Now, at a glance, I know that "szMoney" is the string representation of the Money, and "iMoney" is the integer representation of it. I don't want to just call it "Money" as either, because I wouldn't know what it is without the IDE telling me (or remembering one extra thing), and, more importantly, what would I name the integer if the string was already called "Money"?

      (note: the above example is of course fictional, but in the real world, it's not uncommon that I want the same variable as different representations, and I'll be reusing both of them, so there's no way I'll call int.Parse(x) or x.ToString() each time - that'd be a waste.

      --
      My book about LSD and Self-Discovery
      Also on facebook as: DroppingAcidDaleBewan
    21. Re:Hungarian Notation by fractoid · · Score: 2, Insightful

      Yeah, I went through a phase of using Hungarian-esque notation not long after I started programming, mostly because I taught myself from Charles Petzold's excellent Programming Windows book, combined with various MS examples, all of which used Hungarian notation. Then I started realising that 90% of my variables were integers anyway, and started dropping notation where it was obvious, to the point where I now only give decoration to member/static/global variables and some pointers where it's not blatantly obvious by usage.

      I think that with a clearer coding style, Hungarian notation becomes less helpful, possibly even unnecessary. It's useful when, for instance, you have a 500-line function and you can't remember all the variables and their types, but this is far better solved by simply having non-awful code structuring in the first place rather than by any kind of variable-name decoration.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    22. Re:Hungarian Notation by syousef · · Score: 3, Insightful

      Good Hungarian notation does exactly that, actually. Check out Apps Hungarian, which encodes the semantic type of the data, rather than the language-level data type.

      Good explicitly LONG where appropriate variable names that don't conform to a complex set of rules that need to be memorized are ALWAYS a better solution.

      # rwPosition : variable represents a row ("rw");

      Awful! For one extra character you get rowPosition which is unambiguous and doesn't need to be looked up.

      # usName : variable represents an unsafe string ("us"), which needs to be "sanitized" before it is used (e.g. see code injection and cross-site scripting for examples of attacks that can be caused by using raw user input)

      unsafeName or unsafeNameString would be much better. It doesn't imply this name only applies in the U.S.A.

      --
      These posts express my own personal views, not those of my employer
    23. Re:Hungarian Notation by Dulcise · · Score: 1

      I use Hungarian notation in PHP.

      This may seem redundant in a weakly typed language like PHP. However, things get messy when you start writing Object Orientated PHP, and you can't force a user to pass you an array, or an int. You could code in checks for it, but that's simply more code that could have a bug in it.

    24. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      Three reasons.

      Okay, lets see...

      1)Variables change type. And then you have to rename everything. Its a pain.

      A type change implies a semantic change. It means you need to fix any code where the variable was being used. If you missed some, the compiler will tell you. That's a great feature, IMHO.

      2)The extra information it gives you is minimal. I want to know what data is in a variable, not the language type used to hold it. If the name of the variable is firstName, I don't need it to be called lpcstrzFirstName, I know it's a string. And the language type is rarely interesting- I want to know that the variable outsideTemp holds degrees farenheit, not that it's an integer. But Hungarian doesn't tell me that. (It also doesn't work even if I make a typedef for temperature- it'll still start with 'i').

      It gives you as much information as you want, You decide your prefixes. If what you want to know is what the data is, that's what the variable name part is for, isn't it?.

      As a side note, I would not code a temperature as an integer (or as a floating point number). It needs a proper class with information about scale, so you can safely compare temperatures and your code will be right, no matter if the user entered Celsius, Farenheid or Kelvin (or whatever). You know, space ships crash when you mix units.

      3)It makes searching the code for a variable that much more annoying, because they all start with freaking 'i' and 'p'.

      Sorry? Uh, OK. In the old days we used to remember our variable names, and when we couldn't it was a clear sign that the code was too complex and in need of splitting it in smaller, more mantainable chunks.

    25. Re:Hungarian Notation by jabjoe · · Score: 1

      I don't think anyone would argue that you can't over do Hungarian Notation. But there are things from it that I think are useful. For instance, when I look at code I want to know where a variable is defined. I don't want to keep moving the mouse over it to see where it is defined. With member and global names you can see at a glance what things are coming from where.

      It can be useful to make glance reading easier, but it must be used with a light touch or you start to loose the benefit. Like most things it's a balence, get it right and it pays.

    26. Re:Hungarian Notation by joss · · Score: 1

      > However, things get messy when you start writing Object Orientated PHP, and you can't force a user to pass you an array, or an int.

      Sorry, WHAT ?? How does Hungarian notation help there ?

      --
      http://rareformnewmedia.com/
    27. Re:Hungarian Notation by UnknownSoldier · · Score: 1

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

      _ANY_ idealogy taken to an extreme is bad. However, Hungarian notation _in balance_ is perfectly fine.

      i.e.

      p pointer
      a array
      _ member
      n number of/total
      i iterator/index
      e enum
      b bool/flag
      s static
      g global
      m matrix
      v vector
      q quaternion
      r reference

    28. Re:Hungarian Notation by DrXym · · Score: 1
      Hungarian notation is perfectly acceptable in a world where IDEs are stupid, where the language isn't typesafe (or happily lets you cast pointers / references). In the modern world, hungarian is a massive pain in the arse requiring I type m_szFoo instead of just foo when the IDE is quite capable of inferring or introspecting all the information I need about the variable.

      I recently worked on a Java project where for some completely unfathomable reason all of the code was in a Hungarian style. Java already has a well accepted and officially endorsed camelCase / UPPER_CASE notation. Even some of the tools developed by the project had to work around the hungarian when it did its own introspection. It would be very tempting to rename the code, but my experience has taught me that you don't fix what isn't broken, therefore we coded new code the correct way and left the remainder alone. Inconsistent to be sure but it was actually a useful way of telling legacy code from new.

    29. Re:Hungarian Notation by jonaskoelker · · Score: 1

      [why bad] The proper name is Hungarian Line Noise

      Why do you hate Perl? :(

    30. Re:Hungarian Notation by robthebloke · · Score: 2, Insightful

      In my experience the problem is that normally you end up seeing iCount, szName, bEnabled, fPercent, etc. None of those variable names are improved in any way by hungarian notation - you could easily drop the sz from szName and know what type it is.

    31. Re:Hungarian Notation by Dulcise · · Score: 1

      You can tell from the function definition what the inputs should be.

      The same affect can be achieved by documentation (I do also stick a bit of PHPDoc with it in too) but not every ones IDE supports PHPDoc. Most everyone's IDE supports getting the function with variables.

      This save a little bit of time faffing about figuring out what the inputs should be.

    32. Re:Hungarian Notation by iamflimflam1 · · Score: 1

      If you're really concerned about making sure people don't confuse C,K,or F then add types to represent them (in C++ you can do all sorts of things so that you can convert between them painlessly etc..)
      Using a naming convention is a waste of time as it's not enforced by the compiler.

      --
      "Some days even my lucky rocketship underpants don't help."
    33. Re:Hungarian Notation by Lord+Lode · · Score: 3, Interesting

      The only Hungarian notation I know is that of Windows MFC, and that IS stupid. The names don't even match the types anymore because they changed the names and not the types. It looks ugly, it looks LEGACY. It's a shame that the inheritance of this will remain forever in the official winapi for C++.

    34. Re:Hungarian Notation by tgd · · Score: 1

      1) Thats a good thing -- you rename where its declared and you can make damn certain code that was using it is really doing the right thing, and not something unexpected because of autoboxing or because of types implementing same-named methods that have differing behavior.
      2) Why did you assume firstName was a string? It could've been a key into a over-normalized database table of first names. It could've been an index into an array. The point is, you don't know what crap other engineers have left around for you to step in.
      3) I don't even understand what you mean. A variable name is a variable name. You search on it.

      I finally stopped using Hungarian because SO many people whined about it, but there were significant benefits to it.

      Still, using strongly declared variable with crappy names is better than the jack-assery that things like the addition of the "var" keyword in C# represent.

    35. Re:Hungarian Notation by AikonMGB · · Score: 1

      If you make an assumption about a variable, any function/method that you pass that variable to should have that assumption explicitly stated in the comments. Don't scan your code, just scan the relevant documentation.

      Aikon-

    36. Re:Hungarian Notation by anothy · · Score: 1

      i think the issue isn't really the size of the project, but the size of the environment. i have worked on projects in C, built using make (mk, but close enough), around 100 files without any issues. follow good coding standards and simple things like grep are far more powerful than what most IDEs give you. but as the environment gets more complex, things get different. i'm working with Objective C now, and while i'm enjoying the language proper, the build system and organization of frameworks is something of a nightmare to work with by hand. having an IDE there is proving very helpful, but that's because of the structure and complexity of the environment, not the code i'm working on.

      --

      i speak for myself and those who like what i say.
    37. Re:Hungarian Notation by shabble · · Score: 3, Insightful

      Full Hungarian notation is a bit redundant, precisely because everyone (for reasonable values of 'everyone') DOES use some form of IDE to code, and any non-epic-fail IDE will at the least tell you variable types when you mouse over them, or pop up a member list for a class/struct when you go to type them.

      Um - Hungarian notation is for coding what the variable represents, not the type of variable it's represented by.

      Anyone using iVariable or sVariable to indicate that the former is an int and the latter is a string is doing it wrong.

      It's this misunderstanding that's resulted in HN's 'bad' reputation.

      See http://www.joelonsoftware.com/articles/Wrong.html for an example of how HN should be used.

    38. Re:Hungarian Notation by ebh · · Score: 1

      Back in the day (early 1990's) building Unix System V, we had cscope for all of that except the actual refactoring task. We built its database as part of the regular build process, and it maintained our sanity when the environment was your favorite text editor and make and 35,000 source files.

    39. Re:Hungarian Notation by smallfries · · Score: 1

      Ah Turbo C++. That's what I learnt to cut my teeth on. And the five-disk install wasn't too bad, but my programs had a tendency to take DOS down hard, and reinstalling happened quite often.

      After using something that quick and responsive I could never get used to the noticeable latency on every operation in a "modern IDE", so I've reverted to vim and make...

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    40. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      My view on hungarian notation is that if you've forgotten the type of a variable by the time you use it, your code is too complicated.

    41. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      I don't get what the big deal is with Hungarian Notation. Why do people consider it a bad thing?

      Encoding semantic information to the variable name is all right with a type system which is not expandable. Today, most type systems are expandable and additional semantics can be enforced using OOP.

    42. Re:Hungarian Notation by Actually,+I+do+RTFA · · Score: 1

      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.

      Actually, in weakly typed languages, the only way to know what type Foo is (when writing code, not reflexivly at run time) is that is called iFoo. Why is it guaranteed to be an integer? Cause that's the rule, and if you break it, your code is wrong... whether it compiles/produces runtime errors or not. Weakly-typed languages are when you need System Hungarian.

      The rest of the time, use Apps Hungarian. Oh, that's a vector that represents a position in 2D space. Nice. Which coordinate system? Screen? Parent Window? Application? The IDE doesn't help you there.

      --
      Your ad here. Ask me how!
    43. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      And the language type is rarely interesting- I want to know that the variable outsideTemp holds degrees farenheit, not that it's an integer. But Hungarian doesn't tell me that

      Good Hungarian notation does exactly that, actually. Check out Apps Hungarian, which encodes the semantic type of the data, rather than the language-level data type.

      Except that the limited set of feasible prefixes is small enough that the annotation is now understandable only if you already know the variable type--so how does the notation add anything? The very thing which made Hungarian notation feasible was the small set of types being covered.

      I had a co-worker who loved using "semantic" Hungarian notation in MFC (C++) code. The prefixes were essentially meaningless gibberish one had to fight through to get to the variable name; there were too many classes to map each to a unique, brief prefix. Let's see, does ssbFoo mean "CStorageSetBlock", or "CSearchStringBuffer"? Gah.

      Hell, one of my primary projects even tried using Hungarian in Python code (it is standard in our C code, lamentably, using a horrid mix of system and semantic prefixes). Type-inflected naming in a language with dynamic typing. Er, no. Fortunately, was able to convince the project lead that it was a seriously bad fit.

      Hungarian notation did have a few good points, and can work well in very limited contexts, but doesn't scale worth a damn to projects of substantial size or diversity.

    44. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      Full Hungarian notation is a bit redundant, precisely because everyone (for reasonable values of 'everyone') DOES use some form of IDE to code, and any non-epic-fail IDE will at the least tell you variable types when you mouse over them, or pop up a member list for a class/struct when you go to type them.

      *snort* You kids and your fancy-pants IDEs. How much time did you waste yesterday hovering over things instead of just remembering the type of the variable?

      Modern IDEs have some real nice features--too bad using most of them slows a good coder down.

    45. Re:Hungarian Notation by iluvcapra · · Score: 1

      Actually, in weakly typed languages, the only way to know what type Foo is (when writing code, not reflexivly at run time) is that is called iFoo. Why is it guaranteed to be an integer? Cause that's the rule, and if you break it, your code is wrong....

      I run into this misconception a lot, I think it has to do with the way people from strict languages try to duck or non-typed languages in their brains. You can name a variable iFoo, but you'll never, under any circumstance, be able to guarantee, in any provable way, that it will hold an integer, because in a weak- or duck-typed language, you have no guarantee that a function or any operation will return a value of any particular type. It simply returns what it wishes, and you write your code around the presumption that the value of Foo merely provides the methods and behaviors you need. Foo may not hold an Integer, it might hold a string representation of an integer or an array, but as long as ArrayOfSize(Foo) (or whatever) returns an array of size Foo as if Foo were an integer, the code "works," and in a weakly-typed language this is the equivalent of "correct" (setting aside "maintainable" or "well-coded" or "efficient").

      Hungarian Notation to imply "type" on named variables in a weak-typed language just give you a false sense of security, because they imply a guarantee that the language is generally incapable of making. The only way you can know if iFoo is an integer is by running its "isInteger()" method against it, and in a weakly-typed language, that only guarantees that it has an isInteger method, and that it merely will behave as an integer for all intents and purposes, not that it is truly an "Integer."

      The only way you can guarantee the "type" of the value bound to a variable is by assigning it to a literal, and even then, most weak languages give you ways of redefining the methods and behaviors of literals.

      --
      Don't blame me, I voted for Baltar.
    46. Re:Hungarian Notation by spongman · · Score: 1

      correct, Hungarian doesn't give you any guarantees. that's what type systems are for.

      what it does do is help. if you see

            strFoo = 3;

      then you know that's probably an error without having to look elsewhere.

    47. Re:Hungarian Notation by spongman · · Score: 1

      Yeah, it's a shame the Windows team screwed up Hungarian and then forced their version on the world via the Windows SDK.

      I feel that many of the arguments against Systems Hungarian are valid, however most of those don't apply to Apps Hungarian. And since App Hungarian doesn't try to encode exact type information, it is easily reusable across languages.

      I code mostly in C#, Javascript, ActionScript & Java, and I use the same Apps-like Hungarian in all of them.

      some prefixes I use:

      i - index
      c - count
      str - string
      f - boolean
      b - byte
      ch - char
      rg - list/array
      set - set
      map - map/dictionary

      int cchFoo = strFoo.Length; // count of chars
      char [] rgchFoo = strFoo.ToArray (); // array of chars
      int ichFoo; // index of chars
      for (ichFoo = 0; ichFoo cchFoo; ichFoo ++)
                  setFoo.Add (rgchFoo [ichFoo]);

    48. Re:Hungarian Notation by Actually,+I+do+RTFA · · Score: 1

      you'll never, under any circumstance, be able to guarantee, in any provable way, that it will hold an integer

      If it ever doesn't, the person who wrote that line of code is in trouble.

      you have no guarantee that a function or any operation will return a value of any particular type.

      Umm... again, Hungarian to the rescue.

      Hungarian Notation to imply "type" on named variables in a weak-typed language just give you a false sense of security, because they imply a guarantee that the language is generally incapable of making

      System Hungarian was originally used to allow programmers to make guarantees to each other the compiler couldn't (technically) enforce, although it would crash the program at run time. It's not "false" security... it's just not machine verified security.

      --
      Your ad here. Ask me how!
    49. Re:Hungarian Notation by iluvcapra · · Score: 1

      correct, Hungarian doesn't give you any guarantees. that's what type systems are for.

      Weakly-typed languages don't have type systems, or if they do, they're on an advisory basis only.

      then you know that's probably an error without having to look elsewhere.

      Unless somewhere someone opened the Integer class and implemented in it all of the string methods, in which case using strFoo with methods that expect a string will work perfectly.

      --
      Don't blame me, I voted for Baltar.
    50. Re:Hungarian Notation by The+End+Of+Days · · Score: 1

      This is the basic problem with the "all I need is an editor" people. They spend so much time thinking of ways to reduce keystrokes that they solve the problem of reduced readability with Hungarian notation, rather than the obvious solution of using names that make sense in English (or whatever language they're using.)

      Hopefully those 10 minutes saved over a lifetime avoiding the additional keystrokes are worth it.

    51. Re:Hungarian Notation by amicusNYCL · · Score: 1

      C, K or F? Hope it's obvious everywhere!

      If C, K, or F matters, then that info would be part of the variable name. outsideTempC outsideTempF outsideTempK It still comes down to choosing good, descriptive variable names, regardless of whether it's an unsigned int or a null-terminated string.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    52. Re:Hungarian Notation by iluvcapra · · Score: 1

      you'll never, under any circumstance, be able to guarantee, in any provable way, that it will hold an integer

      In a weak or duck-typed language, it's impossible to write an expression that is guaranteed to evaluate a value of a particular type. Even a simple statement like "1+1" is not guaranteed to return an integer, only perhaps to return an object that has all of the methods of an integer (or a value that has all the properties thereof).

      Think about it in Scheme or Lisp. The form "+" adds two integers, but the only thing that tells you that is the documentation. This is supposed to be a good thing, since now in Scheme for instance, instead of + returning an immediate value, it can return a list using (delay x y) so that instead of receiving an instant answer, you have a value that contains all of the information to find the solution, but doesn't eval it until needed (it's "lazy"). + in this case returns a proxy value that only behaves like an integer.

      Proxy pattern is used all over the place in weak languages. A string-extraction function might not return a substring, but a trampoline object that merely consults the original string every time you try to inspect it's contents. etc. The proxy object has all the methods of a string and can be used in all the places a string can be used, but it ain't a string, it's just a shadow of the original.

      --
      Don't blame me, I voted for Baltar.
    53. Re:Hungarian Notation by Actually,+I+do+RTFA · · Score: 1

      Even a simple statement like "1+1" is not guaranteed to return an integer, only perhaps to return an object that has all of the methods of an integer (or a value that has all the properties thereof).

      We're conflating "how it works" from "the exact representation in memory". In untyped languages, I don't care if it represents it under the hood as an int, a functor needing to be executed (LISP, Scheme, Haskell) or a double (Lua). I care that I can use it as an integer. That it will be outputted with no decimal portion, that it has descreate jumps in usage, etc.

      So, you're right in that Hungarian doesn't reflect what's on the metal. But the whole point was to distinguish identical representations on the metal, like loop indicies and scalar multipliers in Lua, both of which have to be represented by a double.

      --
      Your ad here. Ask me how!
    54. Re:Hungarian Notation by julesh · · Score: 1

      Awful! For one extra character you get rowPosition which is unambiguous and doesn't need to be looked up.

      Not saying I agree with the position, but one of the basic rules of Hungarian is that the prefix should not make sense as an English word. The reasoning behind this is to make it clear what is prefix and what is part of the variable name proper.

      In this case, 'rwPosition' I can easily tell is a row, and the reason I would want to know the row is that it is the "position" (presumably of some object I'm interested in the position of). "rowPosition" is ambiguous: is it the row of a position (as in the former case), or the position of a row (the more natural interpretation of the phrase in English)?

    55. Re:Hungarian Notation by julesh · · Score: 1

      In my experience the problem is that normally you end up seeing iCount, szName, bEnabled, fPercent, etc. None of those variable names are improved in any way by hungarian notation

      I'm afraid your experience seems to be little more than a straw man, because the coders you are talking about clearly are not using hungarian as it is supposed to be used.

      First, there are three errors in your hungarian variable names:

      "iCount" does not mean "integer count", but "index count" which is nonsensical.
      "fPercent" does not mean "float percent", but "flag percent" which is similarly nonsensical.
      "bEnabled" does not mean "boolean enabled", but "byte enabled", which is unlikely to be what you intended.

      Using hungarian without actually understanding the notation is a shortcut to pointlessly obfuscated variable names.

      Secondly, even were the prefixes corrected, hungarian would not suggest using these three names (I'll come back to 'szName' in a minute). The names should be:

      cWhateverItIsYoureCounting (e.g. 'cCharacters', which may be further hungarianized to simply 'cch')
      rpctWhateverItIsAPercentageOf (e.g. 'rpctTaskComplete')
      fWhateverMayOrMayNotBeEnabled (e.g. 'fAcceptUserInput')

      the point here is that in this case, the prefix is subsuming the entirity of your variable names, leaving you free to be more specific in the actual names. 'c' is always a count of something, so specify what it's a count of. There isn't a predefined standard prefix for percentages, but the rules suggest defining a new prefix in this case; 'pct' is the obvious choice, and I prefix it with 'r' (for 'real') to ensure it isn't confused with being a 'p'ointer to a 'c'ount of something beginning with 't'. 'f' is always a flag, i.e. a variable that states whether something is enabled or not.

      you could easily drop the sz from szName and know what type it is

      First, you have to bear in mind the hungarian was developed in a group that was commonly implementing programs that used either of two different types of string -- a Pascal-style string (count of bytes followed by bytes), which was denoted by 'st', and a C-style string (bytes followed by zero terminator), which was denoted by 'sz'. In this context, the choice to use the prefix makes a lot of sense. I agree that for most people, working with only a single type of string, it is less relevant.

    56. Re:Hungarian Notation by ChaosDiscord · · Score: 1

      I'm so with you. I work on physics software, and the grad students keep giving their variables useless names like "G". What's G? I need to decode it. It would be way better if it was GravitationalConstantInMetersPerSecond. But whenever I complain about this, they yammer on about "domain specific language."

      </snark>

      Context matters. In the examples Spolsky is talking about, the context is painfully clear. If you're working on Excel, you're probably juggling piles of variables discussing rows and columns. After an hour or two of working on it, you'll see "rw" as "Row Number (integer, indexed from 1)" and "co" as "Column Number (integer, indexed from 1 where 1 is A)" and be appreciative that you are typing less, complex equations aren't multi-line monstrosities, and that you get more code visible on screen at once. Apps Hungarian is hardly a "a complex set of rules that need to be memorized", it's a relatively small set of domain specific details that you can quickly learn.

      (Now all that said, whenever I read about Apps Hungarian, I'm reminded that I'd prefer to have dedicated data types for incompatible things. If you have two classes: SafeString and UnsafeString, there isn't any risk of passing the wrong one into a function declared "void Write(SafeString output);" Clues for programmers are good. Clues for the compiler are better.)

    57. Re:Hungarian Notation by BeanThere · · Score: 1

      So you've never worked on a real programming project then, i.e. that went on for years, had at least hundreds of thousands of lines of code, involved multiple programmers, and involved a fair bit programmer turnover i.e. old programmers leaving and new programmers joining?

    58. Re:Hungarian Notation by BeanThere · · Score: 1

      "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"

      I didn't know that HN forced you to create prefixes for every type. Isn't this a straw-man?

    59. Re:Hungarian Notation by iluvcapra · · Score: 1

      So, you're right in that Hungarian doesn't reflect what's on the metal.

      You're right, but I wasn't really talking about the implementation, either (and I never mentioned in-memory rep, heaven forfend). As you started off saying, Hungarian notation is used as an ergonomic aid to the people who have to read the code. And my point is that any imputation of type or class onto a variable in a duck-typed language is a leaky abstraction. Some idiot's going to look at your line one day and to a test for (iFoo.class == Integer), and get a nasty surprise, or is going to declare a method on Integer and be shocked that iFoo doesn't have the method when he tries to use it, or is going to try to serialize iFoo when he should in fact be reading the client method to make sure it returns a value that not only acts like an Integer but is also serializeable. For integers these are sorta silly examples, but you run into this all the time when you're request a new array from something like the NSArray class in Objective-C, and it in fact hands you an instance of a private subclass of NSArray optimized for your platform, or the number of indexes it has. Or in another case you might request the selection of a table view, and the table view hands you an object that looks like the represented object of the table view's selected row, and responds to all of the methods of the object, but is in fact a proxy that refers all your relevant calls to the underlying object, using the proxy as a way of keeping the original table view notified of changes to the underlying object.

      But the whole point was to distinguish identical representations on the metal, like loop indicies and scalar multipliers in Lua, both of which have to be represented by a double.

      That's not what you said before; your original claim was HN should be used to explicate type, to wit:

      the only way to know what type Foo is (when writing code, not reflexivly at run time) is that is called iFoo. Why is it guaranteed to be an integer? Cause that's the rule, and if you break it, your code is wrong...

      Using "iFoo" to denote the role of the variable (as an accumulator in the case of a loop) is quite a different matter and I can get behind that. But I would still hasten to add that, even using reflection, you really can't tell if the value bound to iFoo is an integer. You can test to see if it responds to a certain method or protocol, that's really all you can do. You can also, in some languages, test the value of iFoo to see what class it is or what it inherits from, but this would give you false negatives in situations where a client was handing you an object that looked like an Integer and quacked like an Integer but was really something else, like in the delay/force example.

      The claim "Why is it guaranteed to be an Integer?" is based on the false premise that it's guaranteed to be anything.

      --
      Don't blame me, I voted for Baltar.
    60. Re:Hungarian Notation by zoips · · Score: 1

      Yes, because having the Hungarian notation ensures that when (not if) the user passes in the wrong type, everything is still rainbows and lollipops without the type checks...

    61. Re:Hungarian Notation by syousef · · Score: 1

      In this case, 'rwPosition' I can easily tell is a row, and the reason I would want to know the row is that it is the "position" (presumably of some object I'm interested in the position of). "rowPosition" is ambiguous: is it the row of a position (as in the former case), or the position of a row (the more natural interpretation of the phrase in English)?

      Without Hungarian notation, you need context to answer that question, which you ALWAYS need anyway if you're trying to understand a piece of code. What you don't need without Hungarian notation is training in understanding a variant of it. YOU might understand the variant, but can you guarantee that anyone working on or trying to understand your code for the next 20 years will have the same training? When you write code, you shouldn't just write it so YOU can read it. Any programmer should be able to pick it up easily. Hungarian notation was never a good idea.

      --
      These posts express my own personal views, not those of my employer
    62. Re:Hungarian Notation by Dulcise · · Score: 1

      The user is a developer, and the code will crash if they do, so that's their own fault. The point is to make sure damn well they know what they are doing if they do.

      When programming, the language should take care of the type checking, and the programmer should take care of ensuring the data that was input to the function was valid within that domain.
      This can be achieved by defining a new type if it's a new type of data (for example an class for an IP). Then the user won't be able to pass the wrong type of data. This is part of the reason why OOP is powerful, it adds type checking to the compiler.
      PHPs OOP support added the ability to restrict the type of a variable, with non freely converted types (int, string, etc), with once exception.

      It's a flaw in PHP that you can't force a user to pass an array, even though PHP doesn't automatically convert between it and primitives.

      As this is not a domain validation check, leave it to the compiler to find the flaw.

      It's a waste to add checking like that to code as it doesn't offer any benefit for the end user of the code. The person who is visiting a website or whatever doesn't care that that parameter passed is an array or an int (they do however care that the value of that array or int is within the correct domain)

    63. Re:Hungarian Notation by Anonymous Coward · · Score: 0

      I call it "Meta Data Via Namespace Mutilation".

      That accurately reflects my opinion of it.

      Coders who use Hugarian should be shot.

      Ditto for retarded naming conventions, like having all field names start with "m_" or "_", and having interfaces start with an "I" (like C# unfortunately chose...).

    64. Re:Hungarian Notation by hedronist · · Score: 1

      It is ironic that the Windoze crew screwed it up in this particular way because the original language Hungarian was used with was BCPL (predecessor of B, which was the predecessor of C). BCPL has exactly one type: int. It would have been meaningless to add "Oh, by the way, this is an int" to every name, so we didn't.

      There was, however, one machine-specific prefix, 'v'. This meant 'virtual', which not only meant it was a global but also that it might not be in memory at the moment. These were "wide body Altos" and they had 4 banks of 64K 16-bit words, but only one bank was accessible at any given moment. Whenever you wrote "vrgFoo[vifooMac]" it reminded you that those values might not be in memory unless you had specifically forced them to be. This was 30 years ago and I still feel a love/hate relationship for that architecture.

  5. Someone doesn't get data compression by SpazmodeusG · · Score: 1
    From the article

    For instance, one of my programming friends fit a 7K print driver into 5K by shifting (assembly language) execution one bit to the right.

    1. Re:Someone doesn't get data compression by pavon · · Score: 2, Interesting

      Yeah, that was odd. I could see if the final field of each assembly instruction was an address and everything was aligned to 2-word boundaries (msb-first) or you didn't use memory passed a certain boundary (lsb-first) then you could save memory by compacting all the instructions by one bit (and then packing them together). Same for registers, or if didn't use instructions with op-codes over a certain threshold. But if you were really saving one bit per instruction and you managed to compress 7k into 5k, then that means your instructions were only 3.5 bits on average to begin with, which doesn't seem very likely. Something definitely got lost in translation there.

    2. Re:Someone doesn't get data compression by EnigmaticSource · · Score: 1

      Well, writing on DEC hardware, most of the assembly instructions could be morphed by bit shifting into something else, useful, for example a Pointer Jump was just an overflow from a Jump Not Equal, so you could *cough* theoretically write an infinite looking loop that would exit when a strategically placed variable was overflowed. Thank god people don't write like that now, but when you had a 16k address space to work with, tricks like that were, well indispensable. As for the byte shifting, on a PDP, a bitwise shift (because most instructions began with a null byte) was a fast operator, rather than having to run a real decompressor.

      Thinking about this, I miss the Good Old Days(tm).

      --
      The Geek in Black
      I know my BCD's (when I'm Sober)
    3. Re:Someone doesn't get data compression by fractoid · · Score: 2, Informative

      This thread requires a reference to The Story of Mel.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    4. Re:Someone doesn't get data compression by Have+Brain+Will+Rent · · Score: 1

      16K!?!?! You had a 16K address space!?!?!?! OMG were you spoiled. Try a 7 bit address space on a PDP-8... ok, the machine could have 4K or 8K but you had to make all your code fit into 128 word pages...

      --
      The tyrant will always find a pretext for his tyranny - Aesop
    5. Re:Someone doesn't get data compression by julesh · · Score: 1

      But if you were really saving one bit per instruction and you managed to compress 7k into 5k, then that means your instructions were only 3.5 bits on average to begin with, which doesn't seem very likely. Something definitely got lost in translation there.

      I imagine she's talking about the old trick of having a routine that does one thing in its original form, but you can apply a simple transformation to it and have it do something totally different. Really, really, hard to write. Impossible to debug. But such code has been written. Microsoft's Altair BASIC had a similar trick: it has a series of routines that load a particular value into an 8-bit register (a 2 byte instruction), then at the end has the opcode of a 16-bit load to a different register (a single byte of a 3 byte instruction) before the next similar routine, with the consequence that when you execute it, the 8-bit load in the next routine is effectively ignored (its machine code is loaded into a register that is discarded at the end of the sequence), thus saving the cost of a jump over the routine. So it looks something like this (using Z80 assembly rather than the Intel 8080 it was written in, because I know Z80 but not 8080):

      Routine1:
      LD A, 1
      LD HL, [operand not specified]
      Routine 2:
      LD A, 2
      LD HL, [operand not specified]
      [...]
      Routine n:
      LD A, n
      JP somewhere_that_uses_the_value_in_A.

      So, if you call Routine 1, you see the following instructions:
      LD A, 1
      LD HL, some_random_number
      LD HL, another_random_number ...
      JP somewhere_that_uses_the_value_in_A

      But if you call Routine 2, you just see:
      LD A, 2
      LD HL, another_random_number ...

      and so on. Really nice trick, that one.

  6. Eliminate Structured Programming? by honestmonkey · · Score: 1

    I don't understand why they said that Object oriented code eliminated the need for structured programming. OO isn't any better than structured, just different. It has some good uses, but a lot of overhead and is not the best fit for all problems.

    That said, I remember spaghetti code. There was a point when FORTRAN got if/then/else statements. It was obvious in one piece of code that they told the developers to start using them. They had written

    If (a .eq. 1) then
    go to 20
    else
    go to 30
    endif
    20 continue

    My brain hurt after reading that.

    --
    Everything you know is wrong, Just forget the words and sing along.
    1. 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

    2. Re:Eliminate Structured Programming? by BikeHelmet · · Score: 1

      You're absolutely right. I've seen some methods that really would benefit from a goto statement.

      Goto lets you create loops with multiple entry points, which avoids other clutter code. It can enhance legibility when used inside a single method.

      One that I'd like to see die is:

      do {} while();

      One that I'd like to see live (but doesn't yet?) is a language like java, but with optional manual garbage collection on a per-class basis.

    3. Re:Eliminate Structured Programming? by Max+Littlemore · · Score: 2, Insightful

      The worst I saw in my ~25 years, and I include old COBOL and BASIC crap, was not spagetti in the strict sense of the word. It was a 10000 line Java method written by a VB developer. There were no gotos, but the entire thing was nested ifs switches and for loops nested to over 10 layers deep. Oh, and you did read that right, it was a method - the entire class had a solitary static method full of copy and pasted chunks. He explained that it was OO because it was Java. I might forgive him if it was gigantic nested unrolled loop that ran like stink, but it was slow and crash prone.

      A bunch of gotos and gosubs are a pleasure to debug compared to that kind of poo, seriously.

      No matter how nice a new paradigm that comes along, there is always some idiot who can make it suck far, far more than the last paradigm.

      Re wrote that as 10 classes of ~20 lines each, it ran faster and never died until it was told to.

      --
      I don't therefore I'm not.
    4. Re:Eliminate Structured Programming? by bcboy · · Score: 2, Insightful

      The one application of "goto" that I swear by is for cleaning up allocations on failure when coding in C.

      Maintaining a huge library of legacy C code, one of the most common bugs we see is leaks due to people using multiple "return" statements and failing to clean up allocations. You can fairly reliably pick such a function at random and find a memory leak: people always get it wrong.

      "goto cleanup;" however, is hard to mess up.

      I've seen any number of clever tricks to avoid the "goto". Using "break" statements in a do {} while (0) loop, for example. All of them merely obfuscate the code, and make it more likely for bugs to appear.

    5. Re:Eliminate Structured Programming? by QuantumG · · Score: 3, Interesting

      "goto cleanup;" however, is hard to mess up.

      hehe, have a look at Ian Kent's code in autofs sometime.

      His use of "goto cleanup;" is an infinite source of double free bugs.

      --
      How we know is more important than what we know.
    6. Re:Eliminate Structured Programming? by dargaud · · Score: 1

      I must say that after 20 years of successfully avoiding gotos, I'm on a project where I couldn't do other than use them: lots of different machine states with a common set of exit conditions... I don't see how I can code that simply without gotos... C:-(

      --
      Non-Linux Penguins ?
    7. Re:Eliminate Structured Programming? by locofungus · · Score: 1

      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.

      Back in the day when fortran77 was state of the art, (good) fortran programmers had developed "rules" that compensated for many of the "issues" that fortran could cause.

      One of them was "never change a function input variable" (except in the very rare case where you needed to use it as a return)

      Then, with languages like C with pass by value semantics the problem (mostly) went away. Of course, structs became a problem - they're often really too big to pass by value so we (usually) pass a pointer instead.

      Of course, that caused the same issues with accidentally changing the callers data. So C invented const. Now the compiler could protect us from those silly mistakes. C also allowed us to pass pointers so that the function could modify our data if we wanted to. But (with the exception of structs) we could see at the caller code whether our data was going to be modified by the callee code.

      Then C++ came along and introduced references. In the case of function calling parameters they add nothing that C cannot do; merely allowing the callee to omit a "(*" ")" (or replacing "->" with ".")

      But it gave us non const references. Everything that was the problem with Fortran. But, of course, C programmers are now habitually used to being able to change variables in functions. And it becomes impossible to tell whether a variable is going to change.

      I've seen code:

      i=0;
      while(i10)
          function(i);

      Clearly in C this is just wrong. But in C++ it can be made to work. It's not good code but, IMO, at least 50% of programmers consider code "good" if it gives the correct output for a given input.

      "Goto considered harmful." I'd promote "Modifiable reference function parameters considered harmful" over that any day. At least with GOTO you are able to localize your immediate problem with understanding the code. With non-const references you can need to "know" tens of thousands of lines of code before you can understand what function(i) might actually do to i from the callers perspective.

      YMMV

      Tim.

      --
      God said, "div D = rho, div B = 0, curl E = -@B/@t, curl H = J + @D/@t," and there was light.
    8. Re:Eliminate Structured Programming? by locofungus · · Score: 1

      while(i10) should have been while(i<10)

      Tim.

      --
      God said, "div D = rho, div B = 0, curl E = -@B/@t, curl H = J + @D/@t," and there was light.
    9. Re:Eliminate Structured Programming? by owlstead · · Score: 1

      Personally I was thinking about proposing that any class with a finalizer should be garbage collected by using reference counting. You would know that it got collected, and exactly when the last reference was removed. And it would allow you to close things down properly at the time the class is not used anymore.

      Proper classes nowadays don't use finalizers, so it should not make a difference in speed.

    10. Re:Eliminate Structured Programming? by Have+Brain+Will+Rent · · Score: 1

      That's the advantage of coding everything for a universal turning machine.... no goto's, no gosub's, no loops, no blocks, no....

      --
      The tyrant will always find a pretext for his tyranny - Aesop
  7. Get down to the metal by GreatDrok · · Score: 3, Interesting

    Yeah, some of these are pretty old. I do remember working on a machine where the compiler wasn't smart enough to make the code really fast so I would get the .s file out and hand edit the assembly code. This resulted in some pretty spectacular speedups (8x for instance). Mind you, more recently I was forced to do something similar when working with some SSE code written for the Intel chips which was strangely slower on AMD. Turned out it was because the Intel chips (PIII and P4) were running on a 32 bit bus and memory access in bytes was pretty cheap. The Athlons were on the 64 bit EV6 bus and so struggled more so were slower. Once I added some code to lift the data from memory in 64 bit chunks and then do the reordering it needed using SSE the AMD chips were faster than the Intel ones.

    Sometimes I think we have lost more than we have gained though with our reliance on compilers being smarter. It was great fun getting in there with lists of instruction latencies and manually overlapping memory loads and calculations. Also when it comes to squeezing the most out of machines with few resources, I remember being amazed when someone managed to code a reasonably competent Chess game into 1K on the Sinclair ZX81. Remember too that the ZX81 had to store the program, variables, and display all in that 1K. For this reason, the chess board was up at the left top of the screen. It was the funniest thing to be writing code on a 1K ZX81 and as the memory got full you could see less and less of your program until the memory was completely full and you could only see one character on screen....

    --
    "I have the attention span of a strobe lit goldfish, please get to the point quickly!"
    1. Re:Get down to the metal by jd · · Score: 1

      The reason that PGCC compiled better code for the Pentiums than EGCS did, and why EGCS compiled better code for the Athlon than PGCC did, is that optimization is still a black art.

      Similarly, if you want to compile a program "better", you run it through a source-to-source optimizer, then compile it in profile mode, then run it in typical usage, then compile it again with the profiler data. This is merely automated hand-optimizing, since you're still telling the code what is important and what isn't, overriding the compiler's built-in logic.

      And there again, if you want it really fast, you do get in there and tighten the code further. Even with the profiling data, you still know more about the context the program will be used in than the compiler can ever know. (This is especially true of parallel programming, as compilers are just not capable of parallelizing code efficiently. Which is why you have hacks like OpenMP, to manually specify all the stuff that the compiler can't do.)

      Hand-turning is fun, yes. I got all the floating-point variables crammed for a Mandelbrot generator crammed into the 80287 stack, which meant I didn't need to do painfully slow loads and saves of 80-bit data.

      --
      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)
    2. Re:Get down to the metal by owlstead · · Score: 1

      Yeah, I loved the disk copy applications that managed to copy an entire 360K floppy in just four floppy disk insertions as well. It used both the RAM and the VRAM of my MSX2 to cache the data in. Oh, the beautiful disk maps it put on the VRAM were really something. Of course sometimes they were accompanied by a curse when I saw that I was copying 00h bytes (that could have stored data, time was not as important).

      I still think 00h bytes are black :) Green patches were common too, don't know why anymore.

  8. Universal timeless programmer problem by MacColossus · · Score: 4, Funny

    Documentation!

    1. Re:Universal timeless programmer problem by Anonymous Coward · · Score: 0

      Exactly, documentation is really important, UNIX programmer's manual vol 1. keeps my stomack cool under the notebook.

    2. Re:Universal timeless programmer problem by jd · · Score: 1

      I saw some documentation for a program once. At least, I think I did. (Seriously, the only decent effort I've seen in software documentation was at Daresbury Laboratory in the UK. Since moving to the States, I've seen stuff that calls itself documentation but that is a blatant troll on the part of the author.)

      --
      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)
  9. 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.
    1. Re:What a retard! by Jack9 · · Score: 0, Troll

      Second, things like spaghetti code and Hungarian notation are not "old", they were just as stupid 20 years ago as they are now.

      Huh? Hungarian notation is now called name decoration/mangling. It's not stupid, it's par for most languages and for good reason (namespace is the most popular, but not the only use). Congrats, you're probably not a retard, but definitely a self-aggrandizing ignoramus!

      --

      Often wrong but never in doubt.
      I am Jack9.
      Everyone knows me.
    2. Re:What a retard! by martinve · · Score: 1

      Using hungarian notation for strict typed languages, e.g. Java would be redundant and moronic, but for PHP where variable types are not forced I find using it unavoidable.

    3. Re:What a retard! by Brandybuck · · Score: 1

      That's not real hungarian notation then. However, you should always be writing your code so that it's easy to know the types of variables without resorting to funky naming schemes. English is a wonderfully expressive language. Variables such as "szEmployeeName" are silly and redundant. Just call it "employeeName".

      --
      Don't blame me, I didn't vote for either of them!
    4. Re:What a retard! by julesh · · Score: 1

      Variables such as "szEmployeeName" are silly and redundant. Just call it "employeeName".

      The purpose of the "sz" prefix is to distinguish a C-style string ("s with a zero terminator") from a Pascal-style string (which would be called stEmployeeName in this case, "st" simply being an abbreviation of string and having been intended to be the more common variety). In a language where either could be used, the prefix would not be redundant as there would be no easy way of telling (prior to the incorporation of type-senstive operations in IDE editors) which it was.

      As a relevant example for a modern untyped language, consider what happens to your "employeeName" if we have a Name class (presumably with fields title, forenames and surname). Now, how do we distinguish between a variable that holds a string containing a name, and a variable that holds a reference to a Name instance? "employeeName" is no longer such a great variable name in this situation.

    5. Re:What a retard! by Alex+Belits · · Score: 1

      Name mangling is supposed to be performed by compilers, to enforce types when object files are linked into executable, and to distinguish between namespaces. Users aren't supposed to see it unless accidentally when linker reports errors that compiler did not catch (compilers helpfully demangle names in error messages).

      Any other use is pure idiocy.

      --
      Contrary to the popular belief, there indeed is no God.
    6. Re:What a retard! by Alex+Belits · · Score: 1

      If you can't remember variable type, you definitely can't remember all details of its use and purpose in your program -- what means that you shouldn't be writing that program in the first place.

      --
      Contrary to the popular belief, there indeed is no God.
  10. Dirty old Fortran by wjwlsn · · Score: 4, Interesting

    Hollerith constants
    Equivalences
    Computed Gotos
    Arithmetic Ifs
    Common blocks

    There were worse things, horrible things... dirty tricks you could play to get the most out of limited memory, or to bypass Fortran's historical lack of pointers and data structures. Fortran-90 and its successors have done away with most of that cruft while also significantly modernizing the language.

    They used to say that real men programmed in Fortran (or should I say FORTRAN). That was really before my time, but I've seen the handiwork of real men: impressive, awe-inspiring, crazy, scary. Stuff that worked, somehow, while appearing to be complete gibberish -- beautiful, compact, and disgustingly ingenious gibberish.

    Long live Fortran! ('cause you know it's never going to go away)

    --
    Getting tired of Slashdot... moving to Usenet comp.misc for a while.
    1. Re:Dirty old Fortran by hoytak · · Score: 1

      I once interned with a high-energy physics research group of about 40 people or so that had a policy that all physics related code had to be written in fortran 77. The reasoning was that it had to be fast, and that everyone could read it as everyone knew it. That was 2003. So yeah, it's not going to die.

      OTOH, that was the main reason I left physics and went into computer science -- I kept thinking "There has to be something better out there..." -- and I don't regret that decision.

      --
      Does having a witty signature really indicate normality?
    2. Re:Dirty old Fortran by techno-vampire · · Score: 3, Funny
      They used to say that real men programmed in Fortran (or should I say FORTRAN).

      Years ago I programmed with a true genius. His language of choice was PL/1, but sometimes he had to use FORTRAN to fit in with what other people were doing. Any fool could write FORTRAN code in any language they wanted, but he was the only man I ever saw write PL/1 in FORTRAN.

      --
      Good, inexpensive web hosting
    3. Re:Dirty old Fortran by X0563511 · · Score: 1

      beautiful, compact, and disgustingly ingenious gibberish.

      Sounds like perl! <hides>

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    4. Re:Dirty old Fortran by csrster · · Score: 3, Interesting

      Hollerith constants Equivalences Computed Gotos Arithmetic Ifs Common blocks

      There were worse things, horrible things... dirty tricks you could play to get the most out of limited memory, or to bypass Fortran's historical lack of pointers and data structures.

      Long live Fortran! ('cause you know it's never going to go away)

      Didn't most of the tricks just boil down to "Define one big integer array in a common block and then pack all your data, whatever its type, into that"? All my PhD research was done with code like that. It was mostly written by my supervisor years and years before even that and I never actually learned how it worked.

    5. Re:Dirty old Fortran by toby34a · · Score: 1

      There are still good scientific applications for good old Fortran. Most research weather models are still written in it (because when you need to calculate seven partial differential equations over 10-second intervals for 48-hours for a grid that's 200x200x50, you need something that runs quick) and it's still relatively easy to understand. Plus, Fortran scales to MPI work pretty well. And when you're running grids like that, you want to be able to assign 40 processors to it so that your 48-hour model run actually completes in less then 48 hours.

    6. Re:Dirty old Fortran by fractoid · · Score: 1

      Hollerith constants Equivalences Computed Gotos Arithmetic Ifs Common blocks

      And my personal all time favourite - the ComeFrom Statement.

      *delicate shudder*

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    7. Re:Dirty old Fortran by shutdown+-p+now · · Score: 1

      Computed Gotos

      Still alive. I hear it's a popular optimization technique for bytecode interpreters these days.

    8. Re:Dirty old Fortran by dzfoo · · Score: 1

      >> They used to say that real men programmed in Fortran (or should I say FORTRAN).

      Actually, the adage is more like "Real men can program FORTRAN in any language." The implications of that statement were not complementary.

              -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    9. Re:Dirty old Fortran by Anonymous Coward · · Score: 0

      A real programmer can write FORTRAN in any language.

    10. Re:Dirty old Fortran by Anonymous Coward · · Score: 0

      Oh, a former colleague of mine managed to write /370 assembly lookalike code in any language, for example C:

      struct addr /* address */
      {
              char addr0010[30]; /* street */
              char addr0020[5]; /* zip code */
              char addr0030[30]; /* town */
      }

      etc.

      Needless to say that functions had similar names...

    11. Re:Dirty old Fortran by wjwlsn · · Score: 1

      I agree, there are some problem domains where Fortran is simply the right tool for the job. (This might not win me any points on Slashdot, but I actually like Fortran a lot!) My coding style is fairly modern for Fortran, although I have yet to make use of all the things that were added in the latest approved standard (Fortran 2003). I am looking forward to the next standard, though, because it finally incorporates co-arrays for parallel programming.

      --
      Getting tired of Slashdot... moving to Usenet comp.misc for a while.
    12. Re:Dirty old Fortran by techno-vampire · · Score: 1

      Agreed. But it takes True Genius to write other languages in FORTRAN.

      --
      Good, inexpensive web hosting
    13. Re:Dirty old Fortran by Anonymous Coward · · Score: 0

      ENTRY statements... ugh.

  11. One word by keithmo · · Score: 1

    CFront

  12. Hardware not working as promised by bradbury · · Score: 1

    I can think of at least two instances on entirely different hardware (an IBM 370 and a Motorola 68000) where I had to discover that it was not working as promised. This involved a test-and-set instruction which was essential for Oracle (in the early 1980's days) to function reliably. Now of course with the multi-core CPUs they have to get these things right -- but back in the "old" days the hardware engineers could be more careless.

    A test-and-set instruction, for those uninformed, is an instruction which locks the memory to prevent other CPUs from changing it when one needs an exclusive lock on it.

    It is interesting, though infuriating, from a software standpoint when one is using it to diagnose hardware problems.

    1. Re:Hardware not working as promised by Animats · · Score: 1

      Now of course with the multi-core CPUs they have to get these things right -- but back in the "old" days the hardware engineers could be more careless.

      Multi-processor arbiter theory wasn't properly understood until the mid-1970s. Some early shared memory processors had race conditions with access to shared memory. There's a famous Intel patent on this. See Arbiter on Wikipedia for details. Ir turns out that you cannot resolve a race condition of that type in constant time. Sometimes you have to allow extra time for the arbiter to settle in one state or the other. Support to detect the need for that additional delay has to be designed in.

      Engineers still get this wrong occasionally in I/O hardware. The people who design CPUs know all about it, but the lower-level people who design bus interfaces sometimes don't.

    2. Re:Hardware not working as promised by Brett+Buck · · Score: 1

      Most of the processors I have written embedded code for have multiple pages of errata, mostly instructions that don't work correctly in a few situations.

                  Brett

    3. Re:Hardware not working as promised by anothy · · Score: 1

      you think the problem of hardware not working as promised is gone? wow, i want to come live in your world. fun survey: check the correctness of the MP table on a motherboard with ACPI support. get a decent sample size and i'm betting you'll score about 60%, and that number's dropping.

      --

      i speak for myself and those who like what i say.
  13. Intellisense and Debuggers by ArcadeNut · · Score: 0

    Are probably the greatest things (productivity wise) they ever added to an IDE.

    No more :

    ...code...

    PRINT "Got to this point!"

    ...code...

    ...code...

    PRINT "Now I'm here!"

    --
    Visit the Arcade Restoration Workshop @ http://www.arcaderestoration.com
    1. Re:Intellisense and Debuggers by AuMatar · · Score: 1

      Ewww. Intellisense is evil. It's just freaking annoying. I refuse to use IDEs just because of the existence of intellisense- I don't want the slowdown it brings, and I want exactly what I type and only what I type to appear. I'd rather have a computer wth clippy than intellisense.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    2. Re:Intellisense and Debuggers by Tacvek · · Score: 1

      working Intellisense should not cause any slowdown, because it should be running only in the background, using idle cycles. When it works well, it lets you avoid having to stop to check the manual or header file to determine the correct order of the the parameters to a function, since the prototype would appear as a tooltip when you typed the open paren. Or when you remember that a class has a member function that does what y6ou want, but it had an odd name, which you know you would recognize if you saw. Just type the '.' and press the command completion key (or chord) and skim the list.

      If you are actually getting text that you did not type being added to the document, and it is not because you explicitly pushed a command completion key (or chord) then something is wrong.

      --
      Stylish sheet to fix many problems in Slashdot's D3: https://gist.github.com/801524
    3. Re:Intellisense and Debuggers by AuMatar · · Score: 1

      I'd rather just not have the feature- if I want to type something, I'll type it. Typing isn't exactly the slow part of programming as it is- for every minute I spend typing I spend several of design and debugging. You don't need to defend the feature- for the way I like to work it's just broken. I'd rather use freaking notepad without intellisense than an IDE with it.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    4. Re:Intellisense and Debuggers by mark-t · · Score: 3, Insightful

      A feature like intellisense isn't a feature to save typing time... its primary benefit is to save looking things up in a manual if one happens to not remember the exact spelling of some class member or function. If one knows exactly what ones wants to type in the first place, it doesn't stop you, nor should it even slow you down, unless it's implemented poorly.

    5. Re:Intellisense and Debuggers by AuMatar · · Score: 1

      It slows me down by annoying me- I find text appearing underneath what I'm typing annoying. Which doesn't stop you from using it- just add a feature to turn the damn thing off. And while maybe it "shouldn't" slow things down, I've never seen an implementation that didn't, significantly. Maybe recent releases of Eclipse and Visual Studio have improved it, but on VS it used to be a multisecond slowdown at times.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    6. Re:Intellisense and Debuggers by Anonymous Coward · · Score: 0

      Charles Petzold, an author of several well-known books on Windows programming, dislikes the CASE (computer-aided software engineering) features provided by modern IDE's such as Visual Studio. He gave a speech criticizing parts of the Visual Studio, in particular IntelliSense, the code generation wizards, and drag-and-drop GUI builders, and other convenience features of the IDE.

      Petzold's article reminded me of Edward Tufte's famous critique of PowerPoint.

      During the '90s, Microsoft (like many large companies) had several slogans, but one that they seemed to take to heart was "Making it easier". That perhaps should be kept in mind while reading the Petzold and Tufte articles.

    7. Re:Intellisense and Debuggers by HeronBlademaster · · Score: 1

      Try debugging code that modifies the stack pointer and get back to me. (For the curious, we implemented a simple kernel entirely in userspace; it supported multitasking via timers and setjmp/longjmp. I never did get gdb to work with it at all. Print statements were all I had, most of the time.)

    8. Re:Intellisense and Debuggers by fractoid · · Score: 1

      Working with a fairly large (several hundred source files, probably 20-30mb of C++ code all up plus a much larger amount of Python scripting) project, MSVC++ 2005 on a 2-year-old Core2 Duo system still has a sub-1-second pause at worst, and is usually pretty much instant. Once you get used to it, it really does make coding much quicker and easier, although if it distracts/bugs you enough to frequently knock you out of flow then it might be easier just to stick with what you're used to. Eclipse is still shite (in my experience).

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    9. Re:Intellisense and Debuggers by Anonymous Coward · · Score: 0

      You've just outed yourself as someone that uses Microsoft development tools - no one else in the world calls code completion "Intellisense".

      Particularly since it took a long time for Microsoft's code completion to reach anything resembling "intelligence" or "sense".

    10. Re:Intellisense and Debuggers by locofungus · · Score: 1

      I've been forced to use an IDE with this recently. I regularly find it screwing up my code (worse is the fact that the editor doesn't understand vim keystrokes):

      obj.callFunction();

      and I want to change callFunction() to doitFunction()

      (In a real editor: /call<ret>Rdoit<esc>
      or, commonly, something like /call<ret>Rdoit<esc>n.n.nn.n.)

      So I move the cursor to after call; delete four letters; type "doit" and then start cursoring up or down to move to another line of code. But that causes me to scroll through a dropdown box of methods.

      Or I type the do then hit "return" because the dropdown has highlighted the one I want and I get "doitFunctionFunction()"

      I suspect it's a bit like remembering telephone numbers. I don't have a "phone book" set up because I can type the number faster than I can look it up in any "phone book" on any phone I've used. And I find that I remember all the important numbers as a result. (And, equally usefully, I find that I can remember telephone numbers for long enough to read them and then type them into the phone for the numerous cases where it's never going to be ready in a "phone book". And that means I'm not constantly switching my gaze between the written number and the screen of my phone)

      I'd guess that people who use intellisense all the time never learn their method names so would be lost without it. The rest of us see nothing wrong with having a second screen open with header files/documentation etc - and you need the documentation anyway to be able to tell what a function does.

      Tim.

      --
      God said, "div D = rho, div B = 0, curl E = -@B/@t, curl H = J + @D/@t," and there was light.
    11. Re:Intellisense and Debuggers by anothy · · Score: 1
      gah! bad geek!

      The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.

      Brian Kernighan, true as it ever was, and always will be.

      --

      i speak for myself and those who like what i say.
    12. Re:Intellisense and Debuggers by hesaigo999ca · · Score: 1

      I believe you can actually configure to not use intellisense and other features in the GUI of VS, this making it even more robust as the better you are and the less help you need the faster your environment becomes...disable intellisense and refactoring from VS, you will see a big jump in performance!

    13. Re:Intellisense and Debuggers by plalonde2 · · Score: 1
      You need to learn to use a command-line debugger. IDE debuggers "work" for simple bug and code flow tracing, but they are useless for anything subtle.

      There's nothing I hate more than the IDE deciding to display the new value of a variable by overwriting the old one, making it impossible to track the history of a variable without a piece of paper. Try debugging tricky races without that history.

      Real debuggers give you a log, in your window, of all your actions and of the previous state you examined. No IDE I know of gives you that.

    14. Re:Intellisense and Debuggers by NeoSkandranon · · Score: 1

      You might be surprised. I've taken over several apps where just this thing was done.

      Why? So when the generic and totally unhandled exception got thrown, it was apparent where the program stopped of course!

      --
      If you can't see the value in jet powered ants you should turn in your nerd card. - Dunbal (464142)
    15. Re:Intellisense and Debuggers by mhelander · · Score: 1

      What? reading docs!? You should always guess what a function does from its name alone, and whenever your guess is wrong you should rant about the the developer having chosen a poor name for his function!

  14. Patching binaries by spaceyhackerlady · · Score: 1

    Yikes!

    About the only one I never used was self-modifying code. Does patching binaries with a hex editor count?

    I always thought hungarian notation was a crock. It alway seemed to be preoccupied with low-level data types, when what you were supposed to to was define data types that said what your data did, and leave it at that. I actually rather liked the way Pascal defined numeric types, leaving it up to the compiler to select an appropriate representation while you go on with your work.

    ...laura, who has programmed in APL and who has used punched cards

  15. Fortran implicit integers by belmolis · · Score: 4, Informative

    For some reason the article says that only variables beginning with I,J,and K were implicitly integers in Fortran. Actually, it was I-N.

    1. Re:Fortran implicit integers by techno-vampire · · Score: 3, Informative

      Yes, and the reason for that was that I and N were the first two characters of the word integer.

      --
      Good, inexpensive web hosting
    2. Re:Fortran implicit integers by Geirzinho · · Score: 5, Informative

      Nonsense, it's simply because i - n commonly is used to denote integer variables (sum x_i from 1 to n) i mathematical notation. This is a practice dating back at least to Gauss.

    3. Re:Fortran implicit integers by Anonymous Coward · · Score: 0

      It also says:

      Newer object-oriented languages, starting with C++ in the early '90s

      Nevermind that Smalltalk predates that by a decade or so.

      It's hard to take an article like this seriously when it gets basic facts like these so wrong.

    4. Re:Fortran implicit integers by Anonymous Coward · · Score: 0

      For some reason the article says that only variables beginning with I,J,and K were implicitly integers in Fortran. Actually, it was I-N.

      Haha! Go home, old timer :)

    5. Re:Fortran implicit integers by Anonymous Coward · · Score: 0

      Sure, but m is also a common letter to use for integer variables, and there are many letters that have become more usual to use for integers than for other things in the alphabet. The reason they went with the subset i-n was, of course, mostly because that fit best with mathematical convention, but GP is also right in that it made a nice mnemonic - "I-N-teger".

    6. Re:Fortran implicit integers by Anonymous Coward · · Score: 0

      You're a base idiot and a poltroon. Learn your alphabet or remove yourself from the gene pool.

    7. Re:Fortran implicit integers by frogzilla · · Score: 1

      Fortran was written for and by scientists and mathematicians. In physics, matrix notations use i,j,k to indicate the dimensions of a matrix that are related to the x,y,z spatial coordinates. You often need another set of three counters for a different set of matrices that you are carrying (think about transformations between different representations of space) so l,m,n are convenient. There are more rules to Fortran's implicit typing than that though. All of this makes perfect sense if you have training in physics. For those whose training overlapped in physics and computer science the "implicit none" expression is a common sight at the top of every Fortran routine.

    8. Re:Fortran implicit integers by techno-vampire · · Score: 1
      For those whose training overlapped in physics and computer science the "implicit none" expression is a common sight at the top of every Fortran routine.

      Interesting you should say that. My friend's degree was in Mathematical Astronomy and he kind of wandered into programming back in the '60s.

      --
      Good, inexpensive web hosting
  16. Duff's Device by Bruce+Perens · · Score: 4, Interesting

    Duff's Device. Pre-ANSI C-language means of unrolling an arbitrary-length loop. We had an Evans and Sutherland Picture System II at the NYIT Computer Graphics Lab, and Tom wrote this to feed it IO as quickly as possible.

    1. Re:Duff's Device by Bruce+Perens · · Score: 1

      Oops, it says he wrote it at Lucasfilm.

    2. Re:Duff's Device by Anonymous Coward · · Score: 0

      Duffs device can still be useful, I used it recently in some js code to improve performance on a tight loop.

    3. Re:Duff's Device by iluvcapra · · Score: 1

      The part of Lucasfilm now called Pixar, it might be added.

      I always thought that Duff's device wasn't an example so much of optimization as much as it was an example of how strange C's switch statement semantics were. That you can have switch cases both inside and outside a do loop strikes most people as being very strange. That the compiler takes this and actually interprets it into optimized assembly is even more confounding and interesting.

      --
      Don't blame me, I voted for Baltar.
    4. Re:Duff's Device by Bruce+Perens · · Score: 1

      Yes. Somewhere in my attic I have the keyboard from Pixar's Picture System III. It had LED labels over the function keys, although I've never figured out how to use it without the Picture System. I have the front panel from the Lucasfilm (and later Pixar) VAX in my office. It was used to make the "Genesis Effect" in Star Trek: The Wrath of Kahn" and perhaps some stuff in Star Wars.

    5. Re:Duff's Device by Anonymous Coward · · Score: 0

      Pre-ANSI C? I've used it this year in ISO14882-2003 C++.

  17. Some of those are just wrong by AuMatar · · Score: 4, Informative

    First off, most of the things on the list haven't gone away, they've just moved to libraries. It's not that we don't need to understand them, it's just that not everyone needs to implement them (especially the data structures one- having a pre-written one i good, but if you don't understand them thoroughly you're going to have really bad code)..

    On top of that, some of their items

    *Memory management- still needs to be considered about in C and C++, which are still top 5 languages. You can't even totally ignore it in Java- you get far better results from the garbage collector if you null out your references properly, which does matter if your app needs to scale.

    I'd even go so far as to say ignoring memory management is not a good thing. When you think about memory management, you end up with better designs. If you see that memory ownership isn't clearcut, it's usually the first sign that your architecture isn't correct. And it really doesn't cause that many errors with decent programmers(if any- memory errors are pretty damn rare even in C code). As for those coders who just don't get it- I really don't want them on my project even if the language doesn't need it. If you can't understand the request/use/release paradigm you aren't fit to program.

    *C style strings

    While I won't argue that it would be a good choice for a language today (heck even in C if it wasn't for compatibility I'd use a library with a separate pointer and length), its used in hundreds o thousands of existing C and C++ library and programs. The need to understand it isn't going to go away anytime soon. And anyone doing file parsing or network IO needs to understand the idea of terminated data fields.

    --
    I still have more fans than freaks. WTF is wrong with you people?
    1. Re:Some of those are just wrong by shutdown+-p+now · · Score: 3, Insightful

      you get far better results from the garbage collector if you null out your references properly, which does matter if your app needs to scale.

      You don't get any difference at all if you null out local variables. In fact, you may even confuse the JIT into thinking that the variable lifetime is larger than it actually has to be (normally, it is determined by actual usage, not by lexical scope).

    2. Re:Some of those are just wrong by julesh · · Score: 1

      You don't get any difference at all if you null out local variables. In fact, you may even confuse the JIT into thinking that the variable lifetime is larger than it actually has to be (normally, it is determined by actual usage, not by lexical scope).

      Yes. But nulling fields is still critical. See, even more that you need to understand about how the memory allocation system you're using works...

    3. Re:Some of those are just wrong by Anonymous Coward · · Score: 0

      I think he meant long term variables, not temporary objects created inside short-lived code blocks.

      But even if you do null out references to temp objects inside short-lived code blocks, it won't "confuse the JIT"; the VM doesn't keep track of how often an object is accessed, it only keeps track of reference counts. The reference count is decremented the same whether you explicitly null out the reference or just let the } handle it. (Well, I suppose the explicit null assignment might be wasting a single CPU cycle zeroing out a word on the stack...)

    4. Re:Some of those are just wrong by shutdown+-p+now · · Score: 1

      the VM doesn't keep track of how often an object is accessed, it only keeps track of reference counts.

      It does not. Java does not use a reference-counting garbage collector, it uses a tracing one (which is why there are no problems with cyclic data structures in Java). So there are no counts incremented or decremented as you assign to reference variables.

      When GC time comes, the collector has to check all reference variables to determine which objects are unreferenced. For static and member fields, this is trivial. For local variables on the stack, not quite, because a local may actually be mapped onto the register (and, in fact, the same register can be reused for different locals), and because all locals are allocated at the top of the stack frame for the call, regardless of how deeply nested they are lexically within the method body. On the other hand, for locals, GC has the liberty of performing GC as soon as the variable is no longer used, even if it's still in scope (per the language specification) - so it doesn't really matter if the local is null or not, since, after the last point in code when it was used, GC will simply not consider that local as a GC root. When you assign a null, you actually "use" the variable one extra time, thus prolonging its lifetime (note that this is an observable effect in the presence of user-defined finalizers, so the compiler cannot optimize away that null assignment).

    5. Re:Some of those are just wrong by angel'o'sphere · · Score: 1


      *Memory management- still needs to be considered about in C and C++, which are still top 5 languages. You can't even totally ignore it in Java- you get far better results from the garbage collector if you null out your references properly, which does matter if your app needs to scale.

      That is wrong. In fact you make your program slower by nulling out stuff because you have the var = null; assignments in addition to the GC running later anyway.

      People setting vars to null often do that on the stack anyway which is complete nonsense.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  18. 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.
    1. Re:Yes, I'm old by Spit · · Score: 1

      Yeah self-modifying is a satisfying trick. Left off the list though is cycle-counting and padding, required for juggling processor and display.

      --
      POKE 36879,8
    2. Re:Yes, I'm old by isBandGeek() · · Score: 0, Redundant

      It's what real programmers do to make 64 gig of RAM enough for anyone.

      I would really love 64gig of RAM in my PC. Surely you mean 64MB?

    3. Re:Yes, I'm old by QuantumG · · Score: 1

      Hehe, no I don't. Server machines with 16 processors and 64 gig of ram and the app still runs out of memory. This is what you get for trying to scale a multi-threaded app by throwing hardware at it.

      --
      How we know is more important than what we know.
    4. Re:Yes, I'm old by SanityInAnarchy · · Score: 1

      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.

      If you're shipping more library code than application code, that's a good thing. It means you're not reinventing the wheel.

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

      Nah, I'd rather use eventmachine if I'm going for cooperative multithreading, and I'd like to be able to use Erlang-style processes for pre-emptive.

      plus he mentions "modifying the code while it's running"

      Yeah, that was the one that made me go "wtf"? The examples given certainly aren't needed often anymore. However, modern scripting languages do this almost by definition. Sufficiently high-level metaprogramming can be very good. (It can also be very bad, but so can anything.)

      I've written my own implementations of malloc/free/realloc and gotten better memory performance.

      Great! Put em in the GC library, so the rest of us don't have to think about it.

      * Math and date conversions

      Really? This should be in the standard library for just about anything. In Rails, the example given would be calculated as: 3.weeks.from_now

      * Hungarian notation

      Ew.

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

      Or Ruby. PHP sucks for reasons other than slowness and its potential to attract noobs.

      However, "making code run faster" is what you do after the code runs, and does what it's supposed to do, and is modular, flexible, and maintainable. And even then, you're often faced with a very clear question of programmer time vs CPU time. Sometimes it's worth it (games, embedded systems) -- often times, you do the simplest performance hacks you can, and throw hardware at the rest.

      "Sure, it'll take me about 120 hours to get to it with a debug build."

      Yeah... I don't have this problem. Ever. But then, I'm a web developer, so I probably have things a bit easier...

      Just what is it you do?

      --
      Don't thank God, thank a doctor!
    5. Re:Yes, I'm old by QuantumG · · Score: 2, Informative

      However, "making code run faster" is what you do after the code runs, and does what it's supposed to do, and is modular, flexible, and maintainable.

      Yeah, and you say this like you've never experienced it. Honestly, if you're writing new code you're in the vast minority of programmers.. or you're just playing around. Most of us are working on code that was written years ago and has to keep doing what it does or the company will lose money.

      I'm a web developer

      Ahh, I see.

      I'm.. not.

      --
      How we know is more important than what we know.
    6. Re:Yes, I'm old by Amazing+Quantum+Man · · Score: 1

      * Sorting algorithms

      Agree with parent.

      * Creating your own GUIs

      Actually was required in a graphics class.

      * GO TO and spaghetti code

      Goto is still useful in one case that I know of: Bailing out of nested loops in C (not C++ -- you'd throw an exception).

      for (i = 0 ; i < N ; ++i)
      {
        for (j = 0 ; j < N; ++j)
        {
          if (disaster) goto bailout;
      /* yada yada yada */
        }
      }
      bailout:
      /* recover here */

      * Manual multithreading

      Agree with parent -- select is useful. State machines are also useful. I had to code at the bare metal level (no OS), and needed something that at least sort-of worked in a semi-multitasking manner. Used an eventloop and a state machine.

      * Self-modifying code
      Never did this abomination, though I did do the patch thing.

      * Memory management

      Wrote a handle-based memory manager. It didn't actually do cleanup, but would compact memory when it got too fragmented.

      * Working with punch cards

      The fun part was waiting 12 hours for the result of your 15 line program.

      * Math and date conversions

      Needed to do trig, in mils (1 mil = 9/160 degree). On a 4MHz Z80. In 14-bit scaled fixed point arithmetic.
      Not fun.

      * Hungarian notation

      Evil.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    7. Re:Yes, I'm old by syousef · · Score: 1

      I'm old too but...

      * 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.

      No, you're just focusing on the application instead of reinventing the wheel.

      * 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.

      Did you just imply that harming yourself is useful????

      GOTO is only good for getting around problems in the language. If you use it for anything else you're mad. If you're coding in anything modern this won't be an issue (but I'm not an advocate of throwing away working code because it's not fashionable so if you're maintaining an app you MIGHT have some use for GOTO).

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

      This one really depends on the application. I'm not in favour of automagic.

      * 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.

      Self modifying code is an abomination. Only useful if you've got less memory than a modern calculator.

      Learning to use a debugger and modify running code that way is on the other hand a prime skill.

      * 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.

      Memory leaks are a pain. It's not always your mistake either. The library. Someone else on your team. But yes even you coding otherwise brilliantly can overlook a memory leak.

      * 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.

      THAT I don't miss.

      * Math and date conversions
      Every day.

      Agreed, unless there's a function in the standard library you'll end up doing it yourself unfortunately. Java is AWFUL for date conversion. (Since setLenient doesn't work the best solution I've seen is to convert and convert back to check, which is an awful kludge). What gets my goat is everyone doing 6 different ways instead of creating a library for your team to use.

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

      Another abomination. With today's editors that's just not necessary!

      * 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.

      No. You should never write code that runs like a dog in the first place.

      * 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."

      This has never happpened in my career. Usually they want it debugged, fixed, and documented yesterday.

      --
      These posts express my own personal views, not those of my employer
    8. Re:Yes, I'm old by twostix · · Score: 0, Redundant

      "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."

      Perhaps you should take a course on exception handling and logging.

      And before you ask, I work on a system that takes weeks to analyse data and create reports too.

    9. Re:Yes, I'm old by Anonymous Coward · · Score: 0

      I'm a web developer

      Ahh, I see.

      I'm.. not.

      I... wish I weren't.

    10. Re:Yes, I'm old by bennomatic · · Score: 2, Interesting

      Another former c64 user here. I remember typing in lots of those ML programs, wiling away my summer vacation... But I also cut my programming teeth there; no sooner had I learned BASIC that it seemed too slow and limiting to me, so I picked up a book on 6510 assembler, another book on the C64 architecture, and started writing self-modifying code--how else could you do what you needed in 38k of available RAM?

      I still remember little dribs and drabs, like "032 210 255" was the assembled code for JSR $FFD2, the kernel jump table's address for "print a character to the screen.

      Those were the days.

      --
      The CB App. What's your 20?
    11. Re:Yes, I'm old by smash · · Score: 2, Informative

      No. You should never write code that runs like a dog in the first place.

      Being initially correct is far more important for nailing down what you are trying to do than being FAST.

      Premature optimisation is a sure fire way to shoot yourself in the foot. Who cares if a function that is called on a rather minimal basis is slow but understandable and easily verifiable as CORRECT?

      Write a prototype, *profile it*, THEN put on your optimisation hat.

      I don't care how fast your code gives me incorrect output.

      --
      I run: Windows, OS X, Linux, FreeBSD. Just because you have a hammer, doesn't mean everything is a nail.
    12. Re:Yes, I'm old by Fulcrum+of+Evil · · Score: 1

      "Sure, it'll take me about 120 hours to get to it with a debug build."

      Whatever happened to loading up a crash dump + symbols and looking for something obvious?

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    13. Re:Yes, I'm old by Fulcrum+of+Evil · · Score: 1

      Then the code stores into an instruction in the neighborhood of execution. The retirement unit detects a memory modification at the same address as a pre-fetched instruction. This triggers an event which looks much like an interrupt and has comparable overhead. The CPU stops loading new instructions.

      Seems obvious. My company is a largish online travel site and it doesn't have what you'd call a shopping cart. It's so weird...

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    14. Re:Yes, I'm old by QuantumG · · Score: 1

      Yes, that is sensible. Unfortunately, sensible isn't an option around these parts :)

      --
      How we know is more important than what we know.
    15. Re:Yes, I'm old by 91degrees · · Score: 1
      "Hey, we had a crash 42 hours into the run, can you take a look?"

      Yeah. I've had that.

      "Do you have a save?"

      "No."

      "Do you have a crash dump?"

      "No."

      "Does this happen consistently?"

      "No."

      Bug report: Can't reproduce"

    16. Re:Yes, I'm old by Anonymous Coward · · Score: 0

      I don't think he's talking about premature optimization. Or even talking optimization at all.

      You might get 10% with a profiler and optimization. Premature optimization could possibly give you 1%, but will usually just be wasted time.

      But the real speed improvements come from designing the system right from the beginning. And we're not talking percentages here, but 10x or 100x improvements.

      Sure you can speed up sorting your comma-separated text files by rewriting your bubble sort in assembly. You're doing it wrong. You should have designed your application around a real database instead.

    17. Re:Yes, I'm old by dkf · · Score: 1

      * 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.

      You spend clients' money writing sorting algorithms rather than just using the well-implemented ones that already exist for every production language I've ever heard of? (The algorithms you need to be aware of here for the in-memory cases are quicksort, mergesort, and insertion sort. If it doesn't fit in memory, it's probably better to let a database engine take care of the details.)

      * Creating your own GUIs

      Umm.. well actually..

      I did RTFA and the point is about doing the low-level pixel bashing. It's much easier to use a toolkit library to handle those bits, and it's doubly easier to use one developed by other people. (Not everyone has to reinvent GTK...)

      * 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.

      Did you know that you can use OO techniques to spread the spaghetti across thousands of classes? Thousands of methods, all called doit(). Grrr!

      * Manual multithreading

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

      You're better off encapsulating all the tricky bits in one spot/file and then just using them everywhere else. Less efficient, sure, but so much easier to make work.

      * 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.

      SMC is terrible for performance. Avoid if possible, use a tool to do it (correctly!) for you otherwise. That's how things like debuggers work.

      * 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.

      If you can use GC, do so. With much experience, it saves a lot of hair-tearing...

      * Math and date conversions

      Every day.

      This is another one where using a library is a good idea. Date processing is stupidly difficult to get right.

      * 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.

      Faster by smarter algorithms and cache management? Great. Faster by dicking around with instruction ordering? Leave that to the freaking compiler

      * 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."

      I feel your pain. "Did you save a crash dump for me?" is a useful question there...

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    18. Re:Yes, I'm old by Have+Brain+Will+Rent · · Score: 1

      No, optimization should start long before you write the first piece of code. IMO the most significant optimizations are done in the design stage. Then yes, by all means, after the code is shown to be working correctly, profile it and tweak the hot spots.

      --
      The tyrant will always find a pretext for his tyranny - Aesop
    19. Re:Yes, I'm old by Anonymous Coward · · Score: 0

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

      Because every php developper is a moron and can't code?

      I've had to build massive web applications on limited hardware. It wasn't any easier than trying to squeeze a couple more cycles from a x86 asm routine (yeah, been there too).

      you're likely shipping more library code than application code.

      Welcome to 2009. In most cases, if you're writing your own libraries when "good enough" already exists, you're wasting time and money on an ego-trip.

    20. Re:Yes, I'm old by Anonymous Coward · · Score: 0

      "Those were the days"

      Oh yes, when "G.R.O. La Sour and Grape" was popular.
      Hit that high note!

      Post AC because of the awfulness of the pun I couldn't resist.

    21. Re:Yes, I'm old by natoochtoniket · · Score: 1

      Nonsense. You get about 90% of your efficiency on the day you choose your algorithm and data structure. Choose those well, then code them clearly and correctly, and you will rarely need to use a profile tool. The profile tools can be useful for finding the slow parts of the program, of course, after it is written. It usually turns out the the slow parts are those that were written by the fresh-out who didn't pay attention in the "algorithms and data structures" course.

      You are right that "peephole" optimizations are best ignored until late in the process. But, if you choose your algorithms well, you shouldn't ever need to do that sort of "optimization". A straightforward quick-sort, with no "optimizations" at all, is faster than the most highly "optimized" bubble sort on all but the smallest data sets.

      The beauty of libraries is that the library classes implement most of the good "standard" algorithms. I haven't needed to code a sorting algorithm for at least ten years. Any more, I only need to decide when to use one, versus using a map (hash or tree) class or a database table. Unfortunately, the fresh-outs who didn't pay attention in class still manage to make bad choices, and they still manage write code that is both slow and incorrect.

    22. Re:Yes, I'm old by Shinobi · · Score: 1

      "If you're shipping more library code than application code, that's a good thing. It means you're not reinventing the wheel."

      If you never reinvent the wheel, you do not get any better wheels. Now, we do have better wheels, and our vehicles are far more efficient, because some engineer somewhere said "To hell with all the conservative and/or lazy retards who thinks this is ok because it works, I'll make a better wheel"

      "Great! Put em in the GC library, so the rest of us don't have to think about it."

      Rather, remove non-thinking academically trained compiler monkeys from the loop, makes for far more efficient and reliable software.

      "However, "making code run faster" is what you do after the code runs, and does what it's supposed to do, and is modular, flexible, and maintainable. And even then, you're often faced with a very clear question of programmer time vs CPU time. Sometimes it's worth it (games, embedded systems) -- often times, you do the simplest performance hacks you can, and throw hardware at the rest."

      No, making code run faster is something any serious developer does already in the design stage. Modularity and flexibility is evaluated for necessity at this stage too. Not all software needs to be either of those. As for throwing more hardware at it, that's just a crutch. I've already seen some competitors of mine collapse because they ran into situations where a doubling of the hardware only lead to 10% improved performance. Two weeks extra programmer time yielded 30%, without requiring hardware upgrades, and the associated costs of additional space, power and cooling requirements(Anyone who doesn't factor that in is extremely stupid)

      Overall, laziness has turned the computing world into an incredibly resource wasting field. I'd actually go so far as to say that most companies have a waste approaching 50% when you actually analyze how much flooring space is used, how much power, how much cooling, how much unnecessary cabling. In fact, long-term thinking has, just like in economy, been told to "go to hell", for short-term comfort.

    23. Re:Yes, I'm old by syousef · · Score: 1

      Being initially correct is far more important for nailing down what you are trying to do than being FAST.

      If the algorithm runs too slowly to be practical, it is not "correct" in terms of fitness for purpose, even if it eventually returns the right results.

      Premature optimisation is a sure fire way to shoot yourself in the foot. Who cares if a function that is called on a rather minimal basis is slow but understandable and easily verifiable as CORRECT?

      "Premature" optimization? I'm not talking about optimising every loop here, but if your algorithm is designed using bubble sort and linked lists when what is needed is quicksort and btrees, it's a complete waste of time writing it one way then rewriting the other when you know the initial method will give you an unusuable system. What's more in the case of some algorithms a complete rewrite of the code is needed so you might end up recycling none of the code (If you're lucky you'll have learnt something relevant from the initial "unoptimized" attempt.

      Write a prototype, *profile it*, THEN put on your optimisation hat.

      Sure if a prototype is appropriate go for it, but even your prototype should be using the right general algorithms and ideally you should be able to reuse some of the code from your prototype (if possible).

      I don't care how fast your code gives me incorrect output. ...and I don't care how correct your code is if I'll be long dead before it completes it's execution.

      --
      These posts express my own personal views, not those of my employer
    24. Re:Yes, I'm old by Lord+Ender · · Score: 3, Interesting

      I write web apps. I never have to sort anything, except when I ask the database to give me data in a certain order. Why would it be useful for me to implement and be intimately familiar with sorting algorithms? I haven't used them since college.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    25. Re:Yes, I'm old by Anonymous Coward · · Score: 0

      My language is better than your language.

    26. Re:Yes, I'm old by n00854180t · · Score: 1

      I have to disagree. Writing things right the first time almost never happens in the real world (and just leads to wasted time trying to think of the perfect method of designing a system). Typically you get 10x-100x improvements by rewriting the correct but slow parts of your code, or redesigning the system to work around the parts that are slow.

    27. Re:Yes, I'm old by gwjgwj · · Score: 2, Informative

      Every day. How about we throw in some reverse polish notation too.. get a Polka going.
      Actually, Polka is a Czech dance.

    28. Re:Yes, I'm old by BeanThere · · Score: 1

      Surely you do at least need to understand the theoretical lower bound performance that your database software will be able to return your requested sorted data? And also what you need to do (what it needs) to allow it to be able to give the best performance? And also when you would need to restructure your data in other ways when the lower bound theoretical performance will not be fast enough? And also how to approach tracking down the source of the bottlenecks when your major database application is slow?

      In order to be able to do any of these things even half effectively, you need to be "intimately familiar" with sorting algorithms to the point that you can grasp these things quickly as pure *intuition*.

      Unless you've only ever written small database apps that don't deal with large datasets.

    29. Re:Yes, I'm old by GodfatherofSoul · · Score: 1

      You left off being humble. Oh, right...

      --
      I swear to God...I swear to God! That is NOT how you treat your human!
    30. Re:Yes, I'm old by Lord+Ender · · Score: 1

      Actually, I disagree with your assertion that knowing which database indexing structures scale in which ways is the same as being intimately familiar. You don't have to know how to implement an algorithm to know its properties.

      Further, in some companies it is the job of the DBA, not the app developer, to decide how the database should index some value.

      With web apps, it is obvious when the bottleneck is with the DB, and if your datastructures are at all sane, it's dead simple to pick the right DB index by trial and error without even needing to google for the properties of the sorting methods.

      So I'm not saying it's worthless to have refined sort-fu but it's not nearly as useful as it was in the old days. Its another one of those "solved" problems that, for the most part, rarely even requires consideration.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    31. Re:Yes, I'm old by syousef · · Score: 1

      I have to disagree. Writing things right the first time almost never happens in the real world (and just leads to wasted time trying to think of the perfect method of designing a system). Typically you get 10x-100x improvements by rewriting the correct but slow parts of your code, or redesigning the system to work around the parts that are slow.

      Get the design "right" in the first place. I've worked in the real world at major organizations. I've seen a lot of poorly implemented systems, and I've seen some excellent ones that did get it right first time.

      If with every system you work on you have to redesign and recode and it gives you 10x-100x improvement, you're probably doing it badly.

      --
      These posts express my own personal views, not those of my employer
    32. Re:Yes, I'm old by ronabop · · Score: 1

      * 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.

      Your php comparison is broken. I specialize in writing (or, more often, re-writing) PHP, Perl, Python, Java, and Ruby web-application 'code' for scalability. The language used isn't the problem, people who don't care to write fast code is the problem. They will write shit code, regardless of the language.
      In short, your comparison is also true for the following statements: "you're a dweeb who might as well be coding in C++", or "you're a dweeb who might as well be coding in Java", as both are equally true, but equally meaningless.

    33. Re:Yes, I'm old by SanityInAnarchy · · Score: 1

      If you never reinvent the wheel, you do not get any better wheels.

      Very true. The question is whether it's worth the investment at a given time, and whether the guy who's designing the navigation system needs to know about it.

      Rather, remove non-thinking academically trained compiler monkeys from the loop,

      I think you missed the point widely here.

      The point is not that I don't want to have to think. It's that I don't want to have to think about such inane, minute, insignificant details as memory allocation, when I should instead be thinking about things which are actually important to my application. Like, oh, business logic.

      As for throwing more hardware at it, that's just a crutch. I've already seen some competitors of mine collapse because they ran into situations where a doubling of the hardware only lead to 10% improved performance.

      Guessing they didn't design for horizontal scalability.

      You're right, performance must be considered at the beginning. However, the details we're talking about -- again, memory allocation -- are a vertical scalability problem. Not wholly unimportant, but secondary to horizontal scalability -- mostly because you can always buy more hardware (and space, power, and cooling), even on demand, while you cannot always count on Moore's Law to provide you with a faster CPU, and when you can, it gets progressively more expensive for the performance you get.

      Yes, tweaking malloc and free, and tuning for performance, all helps with vertical scalability, which means fewer servers to buy. That is a good thing, and I am not disputing it.

      However, this eventually runs into the physical limitations -- if there is a theoretically most efficient algorithm, there is also a theoretical maximum for how much load any one server can handle.

      And having things be modular, flexible, maintainable, even stable and portable, are all things that can help with horizontal scalability.

      The time to consider vertical scalability, and that two weeks of extra programmer time, and squeezing out even 20 or 30%, is once you already have a product, and some traffic, and you're looking to cut down on operating costs. Because done right, that's all you'll be doing -- spending a little less on hosting.

      I'd actually go so far as to say that most companies have a waste approaching 50% when you actually analyze how much flooring space is used, how much power, how much cooling, how much unnecessary cabling.

      Now, compare the expense there with a typical programmer salary. Sometimes it's worth it, sometimes it's not.

      long-term thinking has, just like in economy, been told to "go to hell", for short-term comfort.

      What happened to this, then?

      Modularity and flexibility is evaluated for necessity at this stage too. Not all software needs to be either of those.

      In the long term, all sufficiently complex software needs to either be both of those, or be eventually replaced with something which is.

      We've read recently about Twitter looking at replacing some things with Scala -- being able to replace part of your software with something written in an entirely different language is pretty damned flexible.

      In the short term, deliver or die. And I'll deliver a hell of a lot faster with Ruby than you will with C. And Twitter again illustrates this -- call them lazy, call them unreliable, but you can't call them unsuccessful, and they now have the cash to do something about the other two.

      --
      Don't thank God, thank a doctor!
    34. Re:Yes, I'm old by smash · · Score: 1
      Agree, algorithm choice is important. This is not what I was referring to. I was referring to the CODING (never write "code" that runs slow in the first place) statement. Code and algorithm selection are different aspects of programming....

      Pick the correct algorithm, write it in an easily understood manner in a high level language, and THEN get tricky with optimisation tricks...

      --
      I run: Windows, OS X, Linux, FreeBSD. Just because you have a hammer, doesn't mean everything is a nail.
  19. Linux kernel? by hoytak · · Score: 1

    Given that half the stuff people supposedly don't have to worry about are just things taken over by the kernel, I'm guessing she didn't poll many of them...

    --
    Does having a witty signature really indicate normality?
  20. As someone who works in the gaming industry... by Anonymous Coward · · Score: 0

    I can attest that we still do a fair bit of this stuff. We implement our own sorts/searches, data-structures, GUIs, low to high level threading primitives, and memory management. We aren't afraid of pointers, we do strange things to make stuff run fast, and use self-modifying code in some cases (in-game dynamic scripting, for example.)

    Most of us don't use gotos or hungarian notation anymore, although occasionally you'll find some brain dead game studios who still do.

    Also, the article was written by someone who isn't a hardcore developer. I can smell a casual from a 32 hops away.

  21. Memory Management by Rob+Riepel · · Score: 3, Insightful

    Try overlays...

    Back in the day we had do all the memory management by hand. Programs (FORTRAN) had a basic main "kernel" that controlled the overall flow and we grouped subprograms (subroutines and functions) into "overlays" that were swapped in as needed. I spent hours grouping subprograms into roughly equal sized chunks just to fit into core, all the while trying to minimize the number of swaps necessary. All the data was stored in huge COMMON blocks so it was available to the subprograms in every overlay. You'd be fired if you produced such code today.

    Virtual memory is more valuable than full screen editors and garbage collection is just icing on a very tall layer cake...

    1. Re:Memory Management by Thornburg · · Score: 1

      Virtual memory is more valuable than full screen editors and garbage collection is just icing on a very tall layer cake...

      MMmmmm... Garabage Collection Cake, yum yum.

      Is your name Oscar, per chance?

    2. Re:Memory Management by EnigmaticSource · · Score: 1

      I see we have a RSTS/E (or RSX) programmer in the house. I hated doing the memory management, but those database routines were, well awe inspiring.

      --
      The Geek in Black
      I know my BCD's (when I'm Sober)
    3. Re:Memory Management by MadKeithV · · Score: 1

      That reminds me of how much "fun" it was to access 256kb of video memory through a 64kb window.
      I had a huge bible on my desk describing the register calls on all common video hardware of the day, just to get things to work across multiple machines.
      Some things *have* improved since then.

    4. Re:Memory Management by frank_adrian314159 · · Score: 1

      Reminds me of the time I had to port a FORTRAN program from an IBM 360 that used ~360KB of memory to a PDP-11 running RSX-11M (and only 32KB of memory). I ended up doing my own disk caching for a rather large bitmap and the overlays flew in and out! It ran, but it took about ten times as long. Of course time on the 11 was free, while we had to pay for time on the 360, so the cost savings were worth it. Plus, I had an onion tied to my belt...

      --
      That is all.
  22. Up hill both ways by oljanx · · Score: 1

    Yeah yeah, I've heard this story before. Hey what about 64K memory segments? I'm at least old enough to have had a headache or two with that...

  23. I Like Hungarian Notation by Greyfox · · Score: 1

    It's a pretty good indicator that the programmer was inept and trying to hide that fact with an obnoxious coding convention. I don't recall ever seeing a piece of production code using it where this wasn't the case.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    1. Re:I Like Hungarian Notation by NeoSkandranon · · Score: 1

      "I don't recall ever seeing a piece of production code using it where this wasn't the case."

      Now that you mention it...

      Well, "Systems" Hungarian at least, in my short programming experience.

      --
      If you can't see the value in jet powered ants you should turn in your nerd card. - Dunbal (464142)
  24. radio in the computer case by bcrowell · · Score: 5, Interesting

    Circa 1984, when I did summer programming jobs at Digital Research (purveyors of CP/M), one of the programmers there showed me how you could put a transistor radio inside the case of your computer. You could tell what the computer was doing by listing to the sounds it picked up via the RF emissions from the computer. For instance, it would go into a certain loop, and you could tell because the radio would buzz like a fly.

    Documentation was a lot harder to come by. If you wanted the documentation for X11, you could go to a big bookstore like Cody's in Berkeley, and they would have it in multiple hardcover volumes. Each volume was very expensive. The BSD documentation was available in the computer labs at UC Berkeley in the form of 6-foot-wide trays of printouts. (Unix man pages existed too, but since you were using an ADM3A terminal, it was often more convenient to walk over to the hardcopy.)

    On the early microcomputers, there was no toolchain for programming other than MS BASIC in ROM. Assemblers and compilers didn't exist. Since BASIC was slow, if you wanted to write a fast program, you had to code it on paper in assembler and translate it by hand into machine code. But then in order to run your machine code, you were stuck because there was no actual operating system that would allow you to load it into memory from a peripheral such as a cassette tape drive. So you would first convert the machine code to a string of bytes expressed in decimal, and then write a BASIC program that would do a dummy assignment into a string variable like 10 A$="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx". Then you would write self-modifying code in BASIC that would find the location where the string literal "xxx...." was stored, and overwrite it with your machine code. So now if you gave the LIST command, it would display the program on the screen, with the string literal displayed as goofy unprintable characters. Then you would code the program so it would execute the machine code stored at the address of the variable A$. Finally you'd save the program onto cassette.

    1. Re:radio in the computer case by Aardpig · · Score: 1

      One of the great strengths of BBC BASIC was that you could put assembly language in-line. You didn't have to muck around with hand-assembly, like you did on other platforms.

      --
      Tubal-Cain smokes the white owl.
    2. Re:radio in the computer case by tchi.keufte · · Score: 1

      Amstrad CPC 464 ? 6128 maybe ?

    3. Re:radio in the computer case by Anonymous Coward · · Score: 0

      Care to name such micros that didn't have assemblers? MS BASIC was a late comer. Assemblers were always available at a cost, as were compilers of various sorts. Early micros were big on Forth to avoid the pathetic BASICs in ROM. But then most people just went to assembler to get the job done. Programs were simple and trivial back them, hitting the metal was far easier than today.

    4. Re:radio in the computer case by julesh · · Score: 1

      MS BASIC was a late comer

      WTF? MS BASIC was first released for the MITS Altair, arguably the first commercial microcomputer, and IIRC launched within a month of the hardware it ran on.

    5. Re:radio in the computer case by Anonymous Coward · · Score: 0

      Actually I have a habit of listening to AM on a crappy old transistor radio, and I can tell what my laptop is doing pretty well from the interference I get.

      As to assembly in basic: the trick I learnt was to make use REM (remark) followed by a bunch of filler, usually 12345678... to make it easy to count. Then poke your assembly code to the point in memory where the REMark began (fixed code locations - fun). Then used USR (user call) to execute assembler from that address - job done ;)

      And speaking of self-modifying code: when I was a kid I actually wrote some BASIC code on my microbee that worked thusly: it would get you to enter an equation (INPUT A1$) in BASIC compatible format. It would then tokenise this (BASIC was tokenised, so for example COS would be stored in memory using a hexadecimal token) and then POKE it over the top of some stategically cased code in memory (early in the code so it didn't move around). Then it could GOTO the (newly minted) line to evaluate the equation and voila... a self-modifying equation plotting program was born.

    6. Re:radio in the computer case by schamarty · · Score: 1

      We had an ancient printer (line printer, actually more precisely a band printer I guess). From outside the computer room, listening to the sound pattern of the printer, you could tell what job was printing -- the checks for customer X's brokerage house, the statements for some other customer bank Y's customers, the bills for utility Z, etc (outsourcing during those days meant the computer as well, not just the people!).

      Another funny one. The Burroughs B-1200 had hard disks the size of washing machines. When the job went into the sort phase, the entire disk would start shaking like any top loading washing machine doing the spin cycle, from the rapid and almost random head seeks or something I guess.

      Someone asked my boss why it did that, and he said: oh this is how we sort -- we shake the disk and all the heavy records fall to the bottom.

  25. No programming language... by Nakoruru · · Score: 3, Insightful

    You will never find a programming language that frees you from the burden of clarifying your thoughts.

    http://www.xkcd.com/568/

    1. Re:No programming language... by bencollier · · Score: 1

      But learning a new language can often alter the way you clarify your thoughts. I'm learning Haskell at the moment and it's a bit of a sidestep mentally.

  26. Wasnt that old by gmuslera · · Score: 0, Offtopic

    I tought that Schindler's List was from the 40's, but this one seems a bit more recent.

  27. it's even really by ILuvRamen · · Score: 0, Offtopic

    And old people have powered wheel chairs so it's even. Not that I'm implying a 35 year old programmer would need one lol. In fact, they'll have robolegs or their brain in a robot body when they're old :P

    --
    Google's Super Secret Search Algorithm: SELECT @search_results FROM internet WHERE @search_results = 'good'
  28. The Story of Mel by NixieBunny · · Score: 4, Informative

    If you're going to talk about old school, you gotta mention Mel.

    --
    The determined Real Programmer can write Fortran programs in any language.
    1. Re:The Story of Mel by dargaud · · Score: 2, Funny

      Now whatever happened to this guy ? Did he carry on to write Perl or something ?

      --
      Non-Linux Penguins ?
    2. Re:The Story of Mel by Tablizer · · Score: 1

      He opened a diner and hired some bimb0s

    3. Re:The Story of Mel by Anonymous Coward · · Score: 0

      THANK YOU!

      I have been looking for this for YEARS since I first ran into it nearly 7-8 years ago!!

    4. Re:The Story of Mel by richoparker · · Score: 1

      If you're going to talk about old school, you gotta mention Mel.

      What a good story. I remember the LGP-30 very well, all 16 instructions in the set...and the ever familiar H-E-M-A combination to compute numeric values from hex digits. I wrote a lot of LGP-30 machine code in those days. It too had a Jump address in each instruction, for optimizing the location of the next instruction on the drum. As I recall, the "Royal McBee" (i.e., Librascope) LGP-30 had only 4K 32-bit words of drum memory, and lots of very sophisticated programs were written with that little bit of memory. Brings back both fond and ugly memories of loading in a big roll of paper tape, only to find at the end that the program didn't load properly, and to have to try again and again. It was my first computer. That was in circa 1959.

  29. One page version by Anonymous Coward · · Score: 0

    http://www.computerworld.com/action/article.do?command=printArticleBasic&taxonomyName=Development&articleId=9132061&taxonomyId=11

  30. Self-modifying code has been a lose for a decade. by Animats · · Score: 4, Informative

    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.

    Code that generates code is occasionally necessary, but code that actually modifies itself locally, to "improve performance", has been obsolete for a decade.

    IA-32 CPUs still support self-modifying code for backwards compatibility. (On most RISC machines, it's disallowed, and code is read-only, to simplify cache operations.) Superscalar IA-32 CPUs still support self-modifying code. But the performance is awful. Here's what self-modifying code looks like on a modern CPU:

    Execution is going along, with maybe 10-20 instructions pre-fetched and a few operations running concurrently in the integer, floating point, and jump units. Alternate executions paths may be executing simultaneously, until the jump unit decides which path is being taken and cancels the speculative execution. The retirement unit looks at what's coming out of the various execution pipelines and commits the results back to memory, checking for conflicts.

    Then the code stores into an instruction in the neighborhood of execution. The retirement unit detects a memory modification at the same address as a pre-fetched instruction. This triggers an event which looks much like an interrupt and has comparable overhead. The CPU stops loading new instructions. The pipelines are allowed to finish what they're doing, but the results are discarded. The execution units all go idle. The prefetched code registers are cleared. Only then is the store into the code is allowed to take place.

    Then the CPU starts up, as if returning from an interrupt. Code is re-fetched. The pipelines refill. The execution units become busy again. Normal execution resumes.

    Self-modifying code hasn't been a win for performance since the Intel 286 (PC-AT era, 1985) or so. It might not have hurt on a 386. Anything later, it's a lose.

  31. In a word, DOS by Anonymous Coward · · Score: 0

    It started with "640K ought to be enough for anybody". That led to an incredible series of hacks (terminate-and-stay-resident, upper memory address space overcommit, small-frame expanded memory, large-frame expanded memory, the "extra" 64K segment, VCPI, DPMI) that promised to maintain backwards compatibility with existing DOS software while allowing slick new applications to use multiples of the 640K limit. Sometimes they did, until the customer installed some new package which used other undocumented tricks that didn't play well with the first vendor's. Then the customer support lines would light up, and everyone would point fingers at everyone else.

    Meanwhile, Intel came up with a 16-bit chip that allowed apps to use as much as 16M (considered a huge amount of memory in those days), but only in "protected mode", which wasn't meant to be compatible with DOS. It turned out that compatibility was something that customers cared about. So startups including Phar Lap and Rational (no relation to the later ClearCase vendor) came up with system software to allow DOS applications to leverage 16-bit protected mode (not too hard), in a graceful and robust manner in the presence of other DOS-extended apps (hard). Microsoft wrote its own DOS extender for Windows 3; customers could run Windows in 16-bit real mode, in 80286 protected mode, or in 80386 protected mode. Marketers were apparently convinced that there was a huge base of installed 80286 machines; while this was undoubtedly the case, most of those users had no intention of upgrading to Windows 3 or the GUI spreadsheets and word processing packages that ran atop it. But engineers at the time spent absurd amounts of time trying to get their programs working in the "brain dead" 80286 protected mode environment, with signs like "SS != DS" posted in cubicles as reminders of pitfalls to avoid.

    And that was just memory management aspect of DOS and Windows 3 (which was really just an graphical DOS extender, as Andrew Schulman pointed out in his book "Undocumented Windows").

  32. Remember "inside out" coding? by roc97007 · · Score: 2, Informative

    "Top-down" coding produced readable but horribly inefficient code. Doesn't do any good for the code to work if it doesn't fit in the e-prom.

    "Bottom up" code produced reasonably efficient spaghetti. Good luck remembering how it worked in 6 months.

    "Inside-out" coding was the way to go.

    You wrote your inside loops first, then the loop around that, then the loop around that. Assuming the problem was small enough that you could hold the whole thing in your head at one time, the "inside-out" technique guaranteed the most efficient code, and was moderately readable.

    At least, that's the way I remember it. 'S been a long time...

    Now, these new-fangled tools do all the optimizing for you. 'S taken all the fun outta coding.

    --
    Oliver's law of assumed responsibility: If you're seen fixing it, you will be blamed for breaking it.
    1. Re:Remember "inside out" coding? by Max+Littlemore · · Score: 1

      I've always done that and never new it was called inside out..... Thanks.

      --
      I don't therefore I'm not.
  33. Re:Self-modifying code has been a lose for a decad by QuantumG · · Score: 1

    Hehe.. dude, the purpose of self-modifying code these days is mostly as an anti-debugging trick.. although sometimes its as a replacement for this code:

    static bool flag = true;
    if (flag) { /* do something once only */
          flag = false;
    }

    but I've not seen any compilers that do it automatically. When I worked at VMWare there was actually a bit of code that did self modification specifically to *cause* a cache clear of the current page.

    --
    How we know is more important than what we know.
  34. swapping two values without a temporary variable by domulys · · Score: 5, Interesting

    x = x xor y
    y = x xor y
    x = x xor y

    Now you know!

  35. Spagetti code by G3ckoG33k · · Score: 1

    Have you ever wondered why procedural spagetti code is hard to read? Me too. Maybe it is because the code is full of references to a myriad places which makes it hard to follow. However, that may be applied to object oriented programming too. Have you ever looked at at class and wondered which and what the...

    1. Re:Spagetti code by bratwiz · · Score: 1

      >> Have you ever wondered why procedural spagetti code is hard to read?

      Oh, I just thought it was because of the meatball.

  36. Old school coding problems... by greenguy · · Score: 2, Funny

    1. Writing on a slate. Man, did that compile slow!
    2. When you heard "stack," it meant firewood.
    3. The error message was a ruler across the knuckles.
    4. Memory overloads. My own memory, I mean.
    5. If you wanted to change your resolution, you had to wait until New Years.
    6. Try coding when you're drinking the original mountain dew.
    7. The rantings of code guru SFBM, the inventor of open Morse code.

    --
    What if I do the same thing, and I do get different results?
  37. I can't believe that anyone has mentioned... by Anonymous Coward · · Score: 0

    programming without a decent source control system. Too many programmed without any source control system. And for a long time the ones that existed generally used exclusive locking to avoid conflicts. Ugh.

    Can you imagine trying to synchronize software without having the patch utility? It is just how things were until Larry Wall got tired of people doing it by hand and breaking rn horribly. And even once diff and patch existed, it took a while for people to accept that you could use it as a basis for an effective source control system. Kids today have no idea what an advance CVS was in its heyday.

    Another item that should be there is programming without having unit testing, but far too many people still don't do that. However unit testing is not particularly new. The first version of Perl in 1987 came with a set of unit tests, and the test suite is one of the reasons that Perl managed to be ported to so many systems.

    I am still waiting in vain for other mainstream programming groups to learn what has been standard in Perl since CPAN started - every library you get should come with a set of unit tests, and those unit tests should run successfully before you install the library. Some almost get it. For example lots of Ruby folks write unit tests, but unfortunately by default rubygems does not run them before installation.

  38. Programming IOCPs has got to count for something by HockeyPuck · · Score: 1

    Ah, the good old days...

    CHPID PATH=(F9,FD),SHARED, *
              PARTITION=((OSPX,OSP1,OSP2,OSP3,OSP4),(OSPX,OSP1,OSP2,OS*
              P3,OSP4)),SWITCH=97,TYPE=FC
    *
        CNTLUNIT CUNUMBR=1097,PATH=(F9,FD),UNITADD=((00,001)), *
              LINK=(FE,FE),UNIT=2032
            CNTLUNIT CUNUMBR=B700,PATH=(F9,FD),UNITADD=((00,256)), *
              LINK=(**,05,09,0B),CUADD=7,UNIT=2105

    Wait, this was yesterday.

  39. Overlay trees by pesc · · Score: 1

    I developed a program on a PDP-11. It was a 16-bit computer and had 64kB memory. It didn't have virtual memory so in order to fit a large program you had to build an overlay tree.

    Consider if function a() called b0() and b1(). And b0() called c0() and c1().

    By knowing the call tree in your program and some other stuff about the dynamics of your program you could arrange so that b0() and b1() shared the same space in memory. Likewise for c0() and c1().

    By studying linker maps you could create an overlay description file to make your program fit into 64kB. The OS would use this to automatically bring pieces of code in and out.

    You can only imagine the consequences when you start to change the program and the pieces grow in size or new calls are added (b1() now calls c0()). You'd often have to manually do a new overlay tree.

    No wonder VAX/VMS was such a hit in the late seventies with 32-bit computing and virtual memory support.

    --

    )9TSS
  40. Hungarian Notation by Anonymous Coward · · Score: 0

    Regardless if the Hungarian Notation is considered an old skool trick (which I wasn't aware of), I'd still find it useful because it kind of gives your code a certain amount of self-documentation just by glancing at it.

    Example:

    m_pSomeStruct

    We can instantly tell ourselves by the Hungarian Notation that this is a pointer to some kind of structure, which is also a member variable of a class or structure.

    Look how much we can instantly figure out merely by glancing at it without sifting through comments or other documentation!

    Regardless if it is considered old skool or not, I'd recommend every coder adopt, or continue, this practice.

  41. The stack is just taller by schickb · · Score: 1

    The main thing that has changed over the years is that the software stack has grown deeper, and today there are many more people working at higher abstraction levels where a lot is handled for them.

    But under the covers, little has changed. Someone must write and understand code all the way down to the hardware. You can bet that people writing kernels and drivers think a lot about space and speed. Or write some code for one of the low cost micro-controllers that are in virtually all electronic devices and you won't have the luxury of a large software stack.

    There are very likely *more* people writing low level code today than 20 years ago. Only the percentage of programmers writing low level code is declining because there are many orders of magnitude more programmers writing higher level code.

  42. How about working with EPROM burners and erasers by shoor · · Score: 1

    I worked for a time in what are now called 'embedded systems'. Our prototype equipment had eprom (eraseable programmable read only memory). The burner was roughly square, covered with sockets for different kinds of eproms. You had to find the socket that matched your eprom. You erased the roms by putting them in a box with a strong ultraviolet light. You could tell the eraseables because they had a little window to let in the UV.

    Do people still use those old fashioned hardware debuggers with the adapter that had pins for the socket on the board where the CPU would go, so it could capture the signals on all the pins?

    --
    In theory, theory and practice are the same; in practice they're different. (Yogi Berra & A. Einstein)
  43. They're still here! by Wintee · · Score: 1

    These historical artifacts of programming haven't gone away, they're still here. Runtime libraries and OO languages hide a lot of the complexity from users. There's still plenty of lists, and memory management code hanging around in the C++ runtime libraries. As a Compiler developer for DSPs we still encounter a lot of these problems. Memory is sparse, and applications need to have a minimal footprint. On some processors we need to do pointer math to calculate pointers. And while we do provide C++ support and an abridged C++ runtime library, you would be amazed at the number of users who stick to assembler and C. They are insistent that C++ is slower (which it can be if you get lost in certain parts of the language) and far more memory hungry (which is certainly is if you pull in large sections of the runtime library. But it can drastically reduce time to market. DSP's are the little brothers to your desktop CPUs that most people will be programming for. Because they're smaller with more constraining power requirements the processors are still playing catch-up to your PC. Multi-core processors are in some ways still an emerging technology. And the languages and tools used on them are steps behind too. Not to mention the conditioning of a lot of DSP developers (One of our senior chip designers (just retired) always designed his chips for assembler - "no one programs a DSP in C".)..

    1. Re:They're still here! by AuMatar · · Score: 3, Informative

      The reason people say C++ is slower and uses more memory is because it is. Not due to the language itself (except for one case), but due to how people use it and the mistakes they make

      1)RTTI and exceptions- very slow. If you use them you will be slower than C. Of course most embedded systems avoid them like the plague. (This is the one case where it's a language fault)

      2)Passing objects. Its a frequent mistake that people forget to pass const object& rather thn the object itself, causing extra constructors and destructors to be called. Honest but costly mistake.

      3)The object oriented model and memory. In an object oriented model you tend to do a lot more memory copying. In C, if you have an OS function that returns a string (a char*), you'll use generally save that pointer somewhere, use it directly a few times, then free it. In C++ you'll take it, insert it into a string object (which will cause a copy), pass that object around (and even by reference thats less efficient than using a char* directly), probably call c_str() on it if you need to pass it back to the OS, then finally let the destructor free it. More time.

      4)The object oriented model and hiding complexity- it can be very easy in an object oriented system to forget the true cost of an operation. Programmers think of x=y as a cheap operation, like it is with ints. With objects, it may be very expensive. Same with other operations that happen "automatically" like string concatenation using +. It can be easy to write code that doesn't look too bad, but really takes thousands of cycles.

      5)Constructors, copy constructors, and operator =- some of these can be called in very unusual places, especially when they're being passed to and/or returned from a function. Read Scott Meyers for a list of all of them. If you had a function that was passed in two Foo objects, mainpulated them, created a new Foo object, set it equal to one of the two passed in, and returned that Foo object I doubt 1 in 10 programmers would correctly guess all of the times these would be called (and I'm not that 1- it's been way too long since I studied the issue). In C these would be at worst 4 memcpys (two for pass in, 1 for assignment, 1 for return). So C++ object quirks can eat up a lot of time in these situations.

      All that doesn't mean you shouldn't use C++. But due to it you won't get the sheer execution speed you would in C.

      --
      I still have more fans than freaks. WTF is wrong with you people?
  44. But it teaches you to be careful by _merlin · · Score: 1

    I got my start on System 7, and I'm grateful for it. You see, with a fixed size heap and no memory protection, you learned to be very, very careful about memory leaks and corruption, because your program could do very bad things if you weren't. I'm a better developer for it.

  45. The real olden days by Is0m0rph · · Score: 1

    Back in my day we didn't even have computers we programmed on stone tablets with a chisel and hammer and we liked it!

    1. Re:The real olden days by bratwiz · · Score: 1

      TABLETS !?!?! You had Tablets !?!??!!

      Sheesh, in my day, we used a sharp stick and drew figures in the mud.

      We were doing binary before the zero was even invented.

      All we had were ones, no zeros.

    2. Re:The real olden days by Is0m0rph · · Score: 1

      Man you are old!

  46. They missed the Apple ][ (6502) 16 bit index by mykepredko · · Score: 2, Interesting

    Back around 1980, the most common piece of self modifying code was to implement a 16 bit index read/write/goto instruction in the Apple ]['s (and Atari and C64) 6502 processor.

    The processor has an 8 bit index register but to allow it to access more than 256 byte addresses, you could either create 256 versions of the operation (each one accessing a different 256 byte address block in memory) or put the function in RAM and modify the instruction that selected the 256 byte address block.

    Sorry, I know longer have the code and my 6502 manuals are packed away, but I'm sure somebody out there remembers and has an example.

    myke

    1. Re:They missed the Apple ][ (6502) 16 bit index by Two9A · · Score: 2, Informative

      I had a similar problem when I was writing an "extended text-mode" (80x25) software driver for the C64, recently. Since each character is encoded into 8 bytes, and there are 256 possible characters, the character definitions span over a wider space than the 8-bit index register can fetch.

      Simple to fix: just self-modify the instructions that handle the font buffer, changing the base pointer as you enter a new page. Since the C64 has a 6510 chip, you'll probably understand the code quite well.

      I wrote an article on the code a few months back, might be an interesting read.

      --
      xkcdsw: the unofficial archive of Making xkcd Slightly Worse
    2. Re:They missed the Apple ][ (6502) 16 bit index by UnknownSoldier · · Score: 2, Informative

      > the most common piece of self modifying code was to implement a 16 bit index read/write/goto instruction in the Apple ]['s (and Atari and C64) 6502 processor.

      Yeah, there were 2 common paradigms...

      a) self modifying code...
      300: A2 00      LDY #00
      302: BD rr ss   LDA $ssrr,X
      305: 9D tt uu   STA $uutt,X
      308: E8         INX
      309: D0 FA      BNE $302
      30B: EE 03 03   INC $303
      30E: EE 07 03   INC $307

      b) using the Zero-Page
      300:B1 00  LDA ($00),Y
      302:91 00  STA ($00),Y

    3. Re:They missed the Apple ][ (6502) 16 bit index by tepples · · Score: 2, Informative

      b) using the Zero-Page

      I program for a 6502-based platform, and I use that method too. But on the Apple II family, assembly language was often used to write subroutines for programs written in Applesoft BASIC to call, and Applesoft BASIC used about 90 percent of zero page for itself, so it was more difficult to find "holes" in BASIC's usage for you to stick your addresses. But then that was no problem if you're writing pure-assembly programs; in that case, you only had to stay out of the way of the Monitor and DOS. Nor is it a problem on some 6502-based platforms such as the NES, which has no built-in BASIC.

  47. One technique that missed the list... by Sooner+Boomer · · Score: 1

    ...magic numbers. I did a lot of coding in assembly and machine code for old CPUs like the 6502 where miniscule available memory made these a necessity. You young whippersnappers whine about having only 4 Gig in your computer, try doing work with only 4 Kilobytes! And that was expanded from the original 1K. now get off my lawn!

    --
    Chaos maximizes locally around me.
  48. One thing I don't miss from ye olden days by rmd6502 · · Score: 1

    Regular employment.

  49. True story by Moraelin · · Score: 5, Interesting

    Let me tell you a true story to illustrate why I think people should still learn that stuff.

    ACT I

    So at one point I'm in a room with what looks like two particularly unproductive Wallys. Though it's probably unfair to call both Wally, since at least one looks like the hard working kind... he just makes as much progress as a courier on a treadmill.

    So Wally 1 keeps clicking and staring at the screen all week and spewing things like "Unbelievable!" every 5 minutes. My curiosity gets the better of me and I ask what's happening.

    "Look at this," goes Wally 1, and I indeed move over to see him toiling in the debugger through a Hashtable with String keys. He's looking at its bucket array, to be precise. "Java is broken! I added a new value with the same hash value for the key, and it just replaced my old one! Look, my old value was here, and now it's the new one!"

    "Oh yes, we had that bug too at the former company I worked for," chimes in Wally 2. "We had to set the capacity manually to avoid it."

    I clench my teeth to stop myself from screaming.

    "Hmm," I play along, "expand that 'next' node, please."

    "No, you don't understand, my value was here and now there's this other key there."

    "Yes, but I want to see what's in that 'next' node, please."

    So he clicks on it and goes, "Oh... There it is..."

    Turns out that neither of them had the faintest fucking clue what a hash table is, or for that matter what a linked list is. They looked at its hash bucket and expected nothing deeper than that. And, I'm told, at least one of them had been in a project where they actually coded workarounds (that can't possibly do any difference, too!) for its normal operation.

    ACT II

    So I'm consulting at another project and essentially they use a HashMap with string keys too. Except they created their own key objects, nothing more than wrappers around a String, and with their own convoluted and IMHO suboptimal hash value calculation too. Hmm, they must have had a good reason, but I ask someone.

    "Oh," he goes, "we ran into a Java bug. You can see it in the debugger. You'd add a new value whose key has the same hash value and it replaces yours in the array. So Ted came up with an own hash value, so it doesn't happen any more."

    Ted was their architect, btw. There were easily over 20 of them merry retards in that project, including an architect, and neither of them understood:

    A) that that's the way a hash table works, and more importantly

    B) that it still worked that way even with Ted's idiotic workaround. It's mathematically impossible to code a hash there which doesn't cause the same collisions anyway, and sure enough Ted's produced them too.

    ACT III

    I'm talking to yet another project's architect, this time a framework, and, sure enough...

    "Oh yeah, that's the workaround for a bug they found in project XYZ. See, Java's HashMap has a bug. It replaces your old value when you have a hash collision in the key."

    AAARGH!

    So I'm guessing it would still be useful if more people understood these things. We're not just talking abstract complaints about cargo-cult programming without understanding it. We're talking people and sometimes whole teams who ended up debugging into it when they had some completely unrelated bug, and spent time on it. And then spent more time coding "workarounds" which can't possibly even make any difference. And then spent more time fixing the actual bug they had in the first place.

    --
    A polar bear is a cartesian bear after a coordinate transform.
    1. Re:True story by wilsoniya · · Score: 1

      Thats... terrible. I would like to hear these people's description of how a hashtable is 'supposed' to work. Even more puzzling to me is how someone could decide to use a data structure without understanding its behavior (and without at least checking the Java APIs or simply Googling).

      --
      I can't remember the last time I forgot anything.
    2. Re:True story by Fulcrum+of+Evil · · Score: 1

      It's mathematically impossible to code a hash there which doesn't cause the same collisions anyway,

      If you know the set of values your string can take, you can compute a perfect hash (if you want). There's even a tool to do it. Sorry about the 'tards, though

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    3. 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.
    4. Re:True story by arotenbe · · Score: 2, Insightful

      Even more puzzling to me is how someone could decide to use a data structure without understanding its behavior (and without at least checking the Java APIs or simply Googling).

      Easy. They learned that they should use *insert class here* in Intro to Programming 1 or 2 and never thought about it again since then. Horrendous overuse of StringBuilders is probably the most common example of this, but it can apply to just about anything.

      --
      Tomato wedge sperm darts that are Republican.
    5. Re:True story by noidentity · · Score: 4, Informative

      Turns out that neither of them had the faintest fucking clue what a hash table is, or for that matter what a linked list is. They looked at its hash bucket and expected nothing deeper than that. And, I'm told, at least one of them had been in a project where they actually coded workarounds (that can't possibly do any difference, too!) for its normal operation.

      It's all too-often that people get the wrong view of a program using the debugger, either because it's not showing what's really there, or they're not interpreting it right. If you think something's wrong based on what you see in the debugger, write a test program first. More often than not, the test program will pass. After all, the compiler's job is to output code which meets the language specification regarding side-effects, not to make things look right in the debugger. In this case, the developer should have written a simple test which inserted two different values that had the same hash code, and verified that he really could only access one of them in the container. He would have found that they were both still there.

    6. Re:True story by Moraelin · · Score: 1

      Fair point, but in these guys' case invariably that wasn't thr case.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    7. Re:True story by julesh · · Score: 3, Funny

      So Wally 1 keeps clicking and staring at the screen all week and spewing things like "Unbelievable!" every 5 minutes. My curiosity gets the better of me and I ask what's happening.

      Is it just me who would be_much_ more tempted to say, "You keep using that word. I don't think it means what you think it means."

      (Yes, I know it's a slight misquote, but it's close enough to be really tempting...)

    8. Re:True story by rve · · Score: 4, Interesting

      Though it's probably unfair to call both Wally, since at least one looks like the hard working kind... he just makes as much progress as a courier on a treadmill.

      The hard working kind is the worst, because a manager can't really see why such a team member isn't working out.

      I used to work with one of those. This Wally was very smart, a genius in fact; extremely articulate and fluent in several world languages, a PhD, a decade of experience as an architect and developer for various high profile customers. A fantastic work ethic: worked 10 hours a day, meticulously tested everything they checked in so that the countless bugs this person checked in never showed up in normal user testing. Race conditions, memory leaks, thread safety, thousands upon thousands of lines of unreachable code, countless more lines of workarounds for supposed bugs in 3rd party tools that were actually the proper results to their improper input.

    9. Re:True story by owlstead · · Score: 1

      "Funny" situations. But none of them would happen if the people knew how to use the collections available to them. You need to know how and when to use them, not so much how to program them. And don't say that's easy enough, there are plenty badly implemented frameworks (especially within companies) that beg to differ.

    10. Re:True story by dkf · · Score: 1

      If you know the set of values your string can take, you can compute a perfect hash (if you want). There's even a tool to do it.

      You can, just as you can pre-size the array of hash buckets, but it's probably a mistake to do so. The costs of using a generic algorithm are really quite small unless your hash function is stupidly expensive, and then when some wiseguy decides to expand the problem-space you don't need to do anything special.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    11. 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. =)

    12. Re:True story by dgriff · · Score: 3, Interesting

      Interesting. I wonder if part of the problem is that modern GUI debuggers just make it too easy for people to poke around in the internals of an object? Without the debugger they are restricted to using the API as intended and would never have gone down that rabbit hole.

    13. 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.
    14. Re:True story by Moraelin · · Score: 1

      Hmm. That's an interesting idea indeed.

      Still, I fancy that a determined soul could always find _some_ way to poke around an object. Worst case scenario, you serialize it to a file and look in it that way. At least for Java there are libraries which serialize to XML too, so there's no need for hex-fu or anything.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    15. Re:True story by Lonewolf666 · · Score: 1

      I can confirm that for the debugger in Delphi 6. It is quite convenient and correct most of the time, but on occasion it will simply give you wrong values. Then you need to (temporarily) code in a message dialog that displays the values. This will give you the correct numbers at the expense of a bit more work.

      --
      C - the footgun of programming languages
    16. Re:True story by pjt33 · · Score: 1

      Most of the time I think I've found a bug in a compiler it's because the compiler crashes. In that case, I'm right.

    17. 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
    18. Re:True story by xquark · · Score: 1

      B) that it still worked that way even with Ted's idiotic workaround. It's mathematically impossible to code a hash there which doesn't cause the same collisions anyway, and sure enough Ted's produced them too.

      ever heard of perfect hash functions for specific sets of data? - not practical in most cases but definitely mathematically possible.

      --
      Arash Partow's Philosophy: Be a person who knows what they don't know, and not a person who doesn't know.
    19. Re:True story by Anonymous Coward · · Score: 0

      As a simple example, I run into people who think that to rewrite:
      [buttock clenching example]
      ... is some clever optimization, and it speeds things up because Java doesn't have to check the extra bounds on i any more.

      I would have to kill them. Oh and their pets, for good measure.

    20. Re:True story by _merlin · · Score: 3, Insightful

      LOL, I used to believe that, but I can now reliably make SunPRO, GCC and MSVC miscompile things. SunPRO has a bug where it always considers children of friends to be friends. SunPRO occasionally constructs locals when an exception should have caused flow control to leave the block earlier. GCC insists on copying temporaries passed by const reference. SunPRO outright crashes when you try templating on a member function pointer type. MSVC incorrectly mangles names of symbols in anonymous namespaces contained within other namespaces. GCC won't find global operators inside a namespace that contains operators, even for completely unrelated types. Giving GCC the same specific register constraint for an input and output of an inline assembly block will cause miscompilation - you need to use numeric constraints. People say that I only find this stuff because I'm digging around in the dark corners of the language where no-one else goes. It still sucks to be tearing my hair out over it, though.

    21. Re:True story by YourExperiment · · Score: 1

      EPILOGUE

      Well, they sure made a hash out of that!

      Entire cast laughs loudly
      Cast freezes in place, credits roll

    22. Re:True story by Anonymous Coward · · Score: 0

      Here's some rough pseudo-Java I have to work with in my Job:


      class Record extends Listable
      {
          private HashMap map = new HashMap();

          private Field field = null;

          public void addField(Field f)
          {
              map = null;
              if(field == null)
                    field = f;
              else
              {
                  Field tmp = field;
                  while(tmp.next() != null)
                  {
                      tmp = (Field)tmp.next();
                  }

                  tmp.addNext(f);
              }

              buildFieldLookup();
          }

          private void buildFieldLookup()
          {
              if(map != null)
                  return;

              map = new HashMap();

              Field tmp = field;
              while(tmp != null)
              {
                  map.put(tmp.getName(), tmp);
                  tmp = (Field)tmp.next();
              }
          }

          public void addRecord(Record rec)
          {
              if(!checkDependants)
                  throw new UnrelatedRecordException("...");

              Record tmp = this;
              while(tmp.next() != null)
              {
                  tmp = (Record)tmp.next();
              }

              tmp.addNext(rec);
          }
      }

      Insane. Absolutely insane. I tried to add 10,000 (or was it 100,000? Not an insane amount anyway) Fields to a Record once. It took *80 seconds*. This is actual goddamn production code. Been around for years, and I'm not the one who wrote it.

      I'm not actually at work right now, so I can't remember if that's the right code or not, but that's close enough to show you exactly how stupid it is. I especially like how we iterate through the list of fields not once, but *twice*!

      Note that both Record and Field extend off Listable, which is another in-house class that wants to be a List, but really just isn't. At all.

      Note the particulars of the addRecord() function above. Now look at the following class:


      class DynaRecord extends Record
      {
          public void addRecord(Record rec)
          {
              try
              {
                  super.addRecord(rec);
              }
              catch(UnrelatedRecordException())
              {
                  addRelatedRecord(rec);
                  super.addRecord(rec);
              }
          }
      }

      Isn't that just wonderful? Violates every good programming practice you can think of, really.

      And it's absurdly slow to boot. I also like how we don't actually adhere to little things like Java Beans standards anywhere in the code, except for stuff I've written (note how it's called next()?)

    23. Re:True story by anothy · · Score: 1
      i think we're mostly in agreement, but i take issue with how you're formulating this "ideal case" argument:

      In theory, people shouldn't know more than what collection to use...

      i think the theory and practice in your statement are exactly backwards. in theory, people shouldn't use tools they don't understand the implications of. if you don't know how some library is going to behave in all cases your program could conceivably encounter (and many it couldn't), you shouldn't be using it. in practice, we all end up doing so, if only because of the volume and scope of what we're dealing with, and the fact that what we're doing shifts over time. still, i think we'd want that gap to be as small as possible.

      --

      i speak for myself and those who like what i say.
    24. Re:True story by MadKeithV · · Score: 2, Funny

      I think C++ templates are a compiler bug.

    25. Re:True story by Moraelin · · Score: 1

      Which is largely why the "there" was in that statement. In their case, the data set was pretty much random String objects. I very much doubt that you can write a hash method that will never ever produce collisions on that case.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    26. Re:True story by banana+fiend · · Score: 2, Insightful

      You may not be wrong, but you should exhaust all other possibilities first. I was working in a company where we found a bug in the floating-point calculation on the intel chip. http://en.wikipedia.org/wiki/Pentium_FDIV_bug

      Lots of people also found it. You can't even assume that your hardware is right :)

      (Oh, btw, damn your sig! I'm singing that song now!)

      --
      Johns: Well, how does it look now? Riddick: Looks clear.
    27. Re:True story by krupicka · · Score: 1

      Hmm. I've found many bugs in compilers, operating systems, and commonly used libraries. I've also found bugs in a handful of different microprocessors. One simply needs to be able to cleanly identify and prove the root cause. Unfortunately, that is not so simple.

      btw Programming languages don't really have bugs. Their implementations can.

    28. Re:True story by Punto · · Score: 1

      I don't get it.. how did they even find out that the value gets replaced? don't you just do "hash[key]" and the value "magically" reappears again? why would they even go into the debugger after that?

      --

      --
      Stay tuned for some shock and awe coming right up after this messages!

    29. Re:True story by sjames · · Score: 1

      Hmm. I've found many bugs in compilers, operating systems, and commonly used libraries. I've also found bugs in a handful of different microprocessors. One simply needs to be able to cleanly identify and prove the root cause. Unfortunately, that is not so simple.

      And typically, the sort of person who can actually do that is one who actually understands all of the fundamentals. The type of person who understands why at one time i++; i++; was faster than i+=2 in C.

    30. Re:True story by Sax+Maniac · · Score: 1

      Oh. My. God.

      You know, I've interviewed people who were very high-level programmers and ran into this. Someone would say "oh, we used std::map to implement this", and I'd ask "so how do you think that's implemented?" looking for a two-word answer, you know, like "hash table".

      Blank stares. "It's, uh, like an SQL database, you say the key and get-um the value back"...

      Right.

      You are too kind when you say "guessing it would still be useful". Those people are fucking idiots and should not be programming when they obviously have no clue about the basics of a freaking 201-level college CS course.

      I'm going to remember your anecdote next time I need to justify why people need to actually know how computers work instead of being API gluebots.

      --
      I can explanate how to administrate your network. You must configurate and segmentate it, so it can computate.
    31. Re:True story by SirGeek · · Score: 1

      You are too kind when you say "guessing it would still be useful". Those people are fucking idiots and should not be programming when they obviously have no clue about the basics of a freaking 201-level college CS course. I'm going to remember your anecdote next time I need to justify why people need to actually know how computers work instead of being API gluebots.

      I know your pain. I used to program embedded systems in ASM langauges (I actually have programmed in 5 different dialects for a multitude of processors - including ones with NO STACK). When you tell people about that they shudder. I actually found it quite fun. Learning how to optimize code by HAND, you learn how to efficiently code loops, etc. So that you can make efficient use of things (knowing when the registers were zero, etc.).

      To do that type of programming you needed to know how to design and code efficient data structures. As well as how to implement an algorithm efficiently.

      I've always been amazed at the IDE Junkies who insist that they need them to do their job. I've been programming for around 20 years now, and I STILL don't use an IDE. Granted my job is less programming now (but I still have an opensource project or two that I work on). I always feel that the IDE is too restrictive.

    32. Re:True story by Rary · · Score: 1

      Your story describes another problem that I have seen all too frequently: the problem of "I can't be doing something wrong, it must be a bug in the system".

      The problem basically boils down to programmers blaming the language/library/framework/tool/operating system/environment/anything-but-themselves when they can't figure out what's wrong. After all, it couldn't possibly be that there's a bug in their own code that they just can't seem to find, or — as is the case in your story — a lack of understanding of the library on their part.

      The simple rule is this: if you find yourself saying "I've found a bug in X" where "X" is anything other than your own code, stop. You haven't. What you've found is a problem with your own code, or your own understanding of your own code, or your own understanding of X. The bug is not in X.

      (Yes, sometimes the bug really is in X, but this is very, very, very infrequently the case.)

      --

      "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    33. Re:True story by ebuck · · Score: 1

      I once worked for a company that had a key person who didn't understand hashing and the hash tables built from them, so I'll add my story

      I run into a performance problem, so I implement a hash table, later I get called into Wally's office. Wally tells me that the company doesn't use hash tables. It seems that they tried hashtables, but that eventually pulled out all of the hashtable code because it was benchmarked as slower than linked lists.

      This Wally was deeply involved in the code way back when, so in the discussion that followed I found that he was concerned that the hash values could be lost by the system. To make sure that they were not lost he implemented an array to hold them. That the array would sometimes overflow when there were too many hashes to store, so he basically implemented a Vector on top of a singly-linked list of arrays.

      At the end of the day, he calculated the hash, then performed a lookup of the hash in the linked list, as an error checking measure to prevent access a non-stored hash. Then he jumped from the list to the array address via pointer, because that was a "good" optimization of the previous attempt (I didn't want to ask). Finally, to reduce the complexity of handling a possible out of memory error, they allocated the linked list nodes and hashtable array ahead of time. Then they tried to add a binary tree search of the linked list of hashes, to speed it up, meaning that the linked list needed to be ordered. For one reason or another, the binary search code never worked properly due to the, so they eventually did sequential access of a sorted list. To add icing to the cake, their solution didn't handle key collisions.

      I think of that Wally fondly, because he is a smart guy and very personable. It's just that he never learned what makes a hashtable work, and in his position now he'll never need to learn it. To his credit, he did benchmark before and after and correctly decided to pull out his code.

    34. Re:True story by lordtrickster · · Score: 1

      ... is some clever optimization

      You hit the real problem right there. The people who do that crap decide that their theoretical clever trick is better than the design on the system they're working within. Even if such "clever" ideas were actually an optimization at some time, they're bad design, and they conflict with future improvements to the underlying platform.

      It's really just arrogance. Few of the people who do such things (such as in the parent post or the Wallys) really have the background knowledge to know whether it's a good idea. They just assume they're better than whoever built the platform they're on.

      To go back to the original point, knowing data structures is great, but the problem is often the people who "don't know what they don't know" and don't acknowledge the fact.

    35. Re:True story by BotnetZombie · · Score: 3, Insightful

      Horrendous overuse of StringBuilders is probably the most common example of this

      If you have a more efficient way to concat large strings of unknown length, I'd like to hear about it.

    36. Re:True story by Anonymous Coward · · Score: 0

      Argh, yes. I remember sitting in school and the professor gives us a handout of bugs to watch out for and workaround in the C++ compiler and/or library relating to absolutely basic template functionality.

      I was stunned (and pissed) that something people apparently used every day in production environments had such tremendous problems that we would encounter them in an entry level educational setting.

    37. Re:True story by krupicka · · Score: 1

      Or the one who can tell you why --i; was faster than i--;

    38. Re:True story by mvdwege · · Score: 1

      Well, see the comments that started off this subthread. Apparently you don't need to know basic algorithms if you just use the provided libraries/classes.

      Mart

      --
      "I know I will be modded down for this": where's the option '-1, Asking for it'?
    39. Re:True story by UnknownSoldier · · Score: 2, 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.

      So when MSVC prints "Internal Compiler Error" and stops compiling my code, I'm wrong? :)

      Five years ago, it was easy to cause MSVC to crash & burn - lately their back-end compiler has gotten much better dealing with C/C++ code.

    40. Re:True story by Anonymous Coward · · Score: 0

      I'm not seeing the WTF. You're describing a situation where adding a new key with the same hash value will override the old key's hash mapping, like this:

      set hash{'foo'} <= one # set to 'one'
      set hash{'bar'} <= one # also set to 'one'
      set hash{'bar'} <= five # set the new key's hash value to 'five'
      print hash{'foo'}; # outputs 'five' for the old key's hash value

      I call that a broken hash algorithm and I don't give a damn how it is supposed to be implemented, I would find a replacement or write my own if none existed.

    41. Re:True story by maxume · · Score: 1

      I'm not real sure that it comes from one concept/area illuminating the other, I think the interest and drive to understand what is going on, regardless of the context, is probably at work.

      I guess magical thinking might make it quite a lot more difficult to understand things at the lower level though than at the higher level (because part of being higher level is not worrying about each detail).

      --
      Nerd rage is the funniest rage.
    42. Re:True story by ahsile · · Score: 1

      ... No. No. No. If two keys resolve to the same hash it should chain the key/value pairs together. Take a look at the picture here:

      http://en.wikipedia.org/wiki/Hash_table#Collision_resolution

    43. Re:True story by flablader · · Score: 1

      Add to that the fact that most "modern" IDE's will automatically suggest member functions for an object and nobody even has to look at the API or any other type of documentation to really screw things up anymore!

      The sad part is that I know I'm guilty of doing exactly this.

      At least now I'm protected from myself; if vi has that capability I don't know how to use it...

    44. Re:True story by owlstead · · Score: 1

      Great example of bad code, but that does not at all have anything to do with the argument I'm making. Yes, you need a bit of a backgrounder (and the more the better), but do you need to be able to implement algorithms to make successful use of them?

      Gosh, I could post the method that incorrectly tried to implement a modulus operation (easily replaced by "%" in this case) as well. Will I get modded up as well? Currently I'm just hoping that my colleagues try and know the language and the API well. Knowing to implement algorithms is something that is on the wish list, but it's somewhere way down there.

      Not turning off checkstyle is higher on my list, for example.

    45. Re:True story by 1729 · · Score: 1

      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.

      Well, I'm a compiler writer, so I've found a bug in a compiler or two. Perhaps added some, as well, though I hope I've weeded most of those out before the public releases.

      But, in general, you're right. Some advanced users can reliably find bugs in compilers, operating systems, and libraries, but in my experience, when a newbie finds a "bug" in such a system, they're almost always wrong.

    46. Re:True story by ultranova · · Score: 1

      If you know the set of values your string can take, you can compute a perfect hash (if you want).

      Not if the hash is limited in length - it's a 32-bit integer, in Java's case. Since there's only a limited number of unique hashes, there's only a limited number of strings they can map to before a collision occurs. Not that that makes any difference to the function of a hash map, but still.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    47. Re:True story by ultranova · · Score: 1

      So... Why was it faster?

      I really wish people would explain when they mention these things. Some of us are just hobbyist programmers, and far from professionals, but we still want to know :).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    48. Re:True story by fractoid · · Score: 1

      See, even *I* know that one. It's because pre-increment stored the old value on the stack and post-increment didn't. At least in the compiler/assembler that I used... >.>

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    49. Re:True story by fractoid · · Score: 1

      Do-what-you-want-cuz-a-Pirate-is-freee
      YOU ARE A PIRATE! :)

      And wow, there can't be THAT many people around who actually genuinely struggled with the FDIV bug at work. O.o

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    50. Re:True story by fractoid · · Score: 1

      So when MSVC prints "Internal Compiler Error" and stops compiling my code, I'm wrong? :)

      Yes. 100% your fault. The MSVC compiler cannot be wrong. All hail Big Bro~(erm)MSVC!!

      And yah it's been a long time since I properly confused MSVC++. And even then it was mainly because the dependency system broke on our code and we ended up with mixed release and debug mode librarires. :/

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    51. Re:True story by david_thornley · · Score: 1

      You do realize that stl::map does not use hash tables, right? It uses a tree structure. The Committee didn't manage to get hash tables into the Standard in time. The draft proposal I saw for the next Standard uses stl::unordered_map for hash tables.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    52. Re:True story by Satanicolas · · Score: 1

      use a sane language you masoschist

    53. Re:True story by fractoid · · Score: 1

      No, I didn't. I was kind of hoping that people would see it as implied that we're talking about a stable, non-broken interface here. But still, good point - 10 years ago most 'publicly released' libraries were FUBAR and no-one thought to tell me (us?) that this wasn't to be expected.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    54. Re:True story by Alpha830RulZ · · Score: 1

      In their defense, back in the day, hashing referred to a commonly used indexing approach that allows multiple records/items with the same key. The hashing algorithm managed these as collisions, and specified some routine for collision management. The items should always be inserted into the list. Anyone with that background could justifiably complain that Java's HashMap is misleadingly named. Of course we can chide them for not reading the class docs, but that's a side issue.

      Hashing was sensible back in the day when disk accesses as you might need to run down a b-tree were more expensive than calculating the index with a hash function.

      [tongue in cheek] As anyone with a Real Computer Science background would know. [/TIC]

      --
      I was taught to respect my elders. The trouble is, it's getting harder and harder to find some.
    55. Re:True story by Dragoness+Eclectic · · Score: 1

      Every time I get attracted to an IDE, my next job doesn't have it available. Currently my IDE is gvim!!
      Last job, I think I was using xemacs. I'm happy if I have syntax coloring and mouse-driven text selection, so gvim or xemacs works.

      Stuff like Eclipse is shiny and really nice, but if it takes 6 months - 1 year to get new software packages approved for use, IF you can make a case for them, and you've already got gvim on the computer.... you edit with gvim. Or vim. And build with make. I prefer using a Makefile anyway--I can see what steps are being used to generate my code, and control what's linked in easily. (unlike MS Visual Studio, which by default linked in the entire kitchen, complete with sink).

      Oh, and will people please stop with the bubble sorts? That's one of the least efficient simple sorts around, but it's the algorithm everyone remembers when they have to pull a sort out of their ass on the fly. Why can't people remember insertion sort or selection sort instead? They're just as simple and more efficient!

      --
      ---dragoness
    56. Re:True story by krupicka · · Score: 1

      On some architectures (e.g. 68k), there were pre-decrement and post-increment addressing modes. So things like *a-- = *b-- would be slower than *--a = *--b

    57. Re:True story by sjames · · Score: 1

      Back in the bad ol' days, compilers didn't optimize, they just translated. i++ translated into a single asm instruction to increment a register and it would generally run in one instruction cycle. So that's 2 cycles for i++; i++; Further, on several CPUs, any register could be the target of an INC instruction.

      OTOH, the +=2 form would load 2 into the accumulator register (load immediate) for one cycle, add in the register holding i for 1 cycle (or 2), then move the result back to the register holding i (yet another cycle).

      Considering this was on CPUs running at under 1 MIPS, that could run into some real time differences for code inside a loop. These days, the compiler will see the +=2 and do the right thing.

      This was around the time that the register keyword for auto variables could actually speed things up by telling the compiler to keep that variable's value in a machine register as much as possible. Commonly used with i for a loop/array index.

    58. Re:True story by Sax+Maniac · · Score: 1

      You have a good point. I have to be honest, I've never looked at the implementation myself to know for sure, and only have passing familiarly with the STL stuff.

      The point of my interview question, however, was not a trivia test, but to generate some discussion on a certain topic. She brought up this container, and I like to make sure people have passing familiarity with data structures and Big O notation. Rather than ask a point-blank question, I wait for an "in" and then ask them a question to get me to that topic, while they are still are talking about their chosen topic. It's an old technique I've used for years.

      What I wanted a discussion of how such a container "might be" built under the hood - not specific info on how that particular one was. They could even say "well, it might be a linked list, but I suspect that would be slow this case...". Even if it was totally wrong and it was implemented differently, it's not the point of the question, and would way be better than the "duh, it's a black box" answer.

      --
      I can explanate how to administrate your network. You must configurate and segmentate it, so it can computate.
    59. Re:True story by Fulcrum+of+Evil · · Score: 1

      Since there's only a limited number of unique hashes, there's only a limited number of strings they can map to

      The point is that when you have a known set of values, it's hardly ever more than 4 billion.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    60. Re:True story by BeanThere · · Score: 1

      Yeah, I've found many too.

    61. Re:True story by juletre · · Score: 1

      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.

      I always use StringBuffer for String concatenation.. So I tested it, java 1.5.0_10.
      Loop1:
      String one = "";
      for(some limit) {
      one += createString();
      }


      Loop2:
      StringBuffer buf = new StringBuffer();
      for(some limit){
      buf.append(createString);
      }
      ;
      For 50.000 iterations I get (in ms)
      + : 397131
      buf: 51


      So.. Anything I missed?

      createString: return String.valueOf((int)(Math.random()*100000));

      --
      "he, who has quotes in his signature, is a douche" - unknown.
    62. Re:True story by Anonymous Coward · · Score: 0

      LMAO
      http://forums.sun.com/thread.jspa?threadID=668244&tstart=17026

    63. Re:True story by Moraelin · · Score: 1

      Well, you're missing the fact that you're using it right. The people I'm complaining about are those who'd write some version of stuff like:

      String one = "";
      for(some limit) {
          StringBuffer buf = new StringBuffer();
          buf.append(one);
          buf.append(createString());
          one = buf.toString();
      }

      And insist that it's faster because they use a StringBuffer. Some tips and tricks page told them so.

      Ok, so maybe if it were like that, they (or the compiler) would figure out that the "new StringBuffer()" can be moved out of the loop. A more realistic scenario is when the code looks more like this;

      StringBuffer buf = new StringBuffer();
      for(int i = 0; i < names.length; i++) {
          buf.append(names[i].toString());
      }

      but the toString() method in that class is something like 'return firstName + " " + lastName;"

      The average lemming trying to optimize it, won't even look at the imperial arseload of temporary StringBuffer objects created in that loop, one for each iteration. They optimized the big loop, that's it. Wonder why it doesn't actually run much faster.

      But those aren't the cargo cultists yet.

      The cargo cultists are the ones who then proceed to optimize the toString() method above like this:

      public String toString() {
          StringBuffer buf = new StringBuffer();
          buf.append(firstName);
          buf.append(" ");
          buf.append(lastName);
          return buf.toString();
      }

      It doesn't actually produce any improvement whatsoever, since it's exactly what the compiler generates for 'return firstName + " " + lastName;' anyway. And in that loop we used as an example, it still results in a temporary StringBuffer being instantiated and thrown away per iteration.

      And again, I don't even mind seeing something like this just because someone is used to using StringBuffer. It's a good habit. I'm just somewhat amused when I see someone present such a rewrite as an optimization. Because some site told him that StringBuffer is faster than +. Heh.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    64. Re:True story by juletre · · Score: 1

      Yes, after i calmed down I guessed that was what you meant, but too late. Already posted.
      I tried the scenarios above as well after my initial tests. Not much difference there.
      For what it's worth, i didnt know java used stringbuffer internally for concatenation, so I did learn something today. (which makes it a good day). But i do want credit for actually writing my own tests and investigating the matter :)

      --
      "he, who has quotes in his signature, is a douche" - unknown.
    65. Re:True story by Anonymous Coward · · Score: 0

      What about your chances of finding a difference between documentation and code?

    66. Re:True story by SanityInAnarchy · · Score: 1

      I would like to hear these people's description of how a hashtable is 'supposed' to work.

      Store the keys with the values. Then, every lookup, do direct comparisons between keys. That way, you only have the value overridden when the keys are actually equal, not just when there's a collision.

      --
      Don't thank God, thank a doctor!
    67. Re:True story by petermgreen · · Score: 1

      Someone determined and knowlagable enough can almost certainly poke there nose where it doesn't belong. In java for example you can use reflection with access control turned off.

      but an idiot with a debugger can do so far more easilly than an idiot without a debugger.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    68. Re:True story by RAMMS+EIN · · Score: 1

      ``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. ''

      Sadly, I've wasted a lot of time because that is what I used to think.

      ``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. ''

      That's the key. I'm used to GNU/Linux and the free BSDs, and those actually work well. Then I had to use various fashionable Java frameworks, Sun's Java, and MySQL, and I ran into bugs with most of them. And, of course, being unfamiliar with the technology, I assumed that I was doing something wrong, until lots of time spent reading documentation and testing things convinced me that, really, the bugs were not in my code but, indeed, in the code it was built on.

      --
      Please correct me if I got my facts wrong.
    69. Re:True story by RAMMS+EIN · · Score: 1

      Exactly. It makes me wonder what they were even doing in the debugger in the first place. Clearly not debugging an actual problem with the hash tables...

      --
      Please correct me if I got my facts wrong.
    70. Re:True story by DragonWriter · · Score: 1

      I don't get it.. how did they even find out that the value gets replaced? don't you just do "hash[key]" and the value "magically" reappears again? why would they even go into the debugger after that?

      Probably they ran into some other, unrelated, problem, had no idea where it came from, dropped into the debugger and set a bunch of watches and looked for something that didn't look right to them, and instantly focussed like a laser on the first "odd" (to them) thing that cropped up.

    71. Re:True story by petermgreen · · Score: 1

      Such stuff happens precisely to people who don't understand the underlying machine, virtual or not.
      True, otoh as you post shows misunderstanding the underlying machine can be worse than not understanding it at all.

      And how many people really have the time and inclination to properly study something like the pentium 4 or a modern JIT? And the machines (whether virtual or physical) don't sit still either. So the knowlage has a short shelf life.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  50. 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)
    1. Re:OO isn't even different. by caerwyn · · Score: 1

      If I had mod points, you would get them.

      The author of the article seemed like either a non-programmer, a complete novice programmer, or, frankly, a completely incompetent programmer. I was going to write something like the above, but was too annoyed by the idiocies to be coherent.

      --
      The ringing of the division bell has begun... -PF
    2. Re:OO isn't even different. by fractoid · · Score: 4, Informative

      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.

      Erm, why the hell not? Good programmers, even the best programmers (in fact especially the best programmers), will just use qsort() (or the equivalent for the language they're using). Then, IF performance on their lowest-spec target hardware is unacceptable, they will profile their code and find out what's taking the time. And then, IF it's the sorting algorithm that's the bottleneck, only THEN will they implement a more specific version. Anything else is a waste of time and an additional risk of introducing unnecessary bugs.

      Unless we're really pushing the boundaries (and those boundaries are so far away with modern computers that 99% of applications can't even SEE them from their cosy seat in the middle of userland) the stock sorting algorithm your language provides will be plenty fast enough. If you're using a high-level interpreted language, you'll never beat it in efficiency.

      What you're saying may have been true 15, or even 10 years ago, but it's certainly not true now.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    3. Re:OO isn't even different. by jd · · Score: 1

      Mostly because downloading a library, reading through the non-existent docs, examining code in order to write own docs coz nothing worth reading was supplied, fixing the inevitable off-by-one bug that only affects the case you're concerned with, realizing the implementation was never properly tested and has chronic robustness/security/performance issues, and then downloading another library where you will discover exactly the same problems, rinse, repeat, is always going to be slower than writing your own.

      Hell, half the places I've worked get so stroppy over licenses that the meetings on whether it's acceptable to the politics of the project to use a given library take far longer than just writing my own sort, linked-list, stack, queue or whatever.

      It used to be that, for DOS, there were more shareware change directory programs than anything else. This wasn't because people needed more change directory programs or that there was even a demand for change directory programs. It was precisely because there was NO demand that there was a glut, a paradox in the supply-and-demand model.

      --
      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)
    4. Re:OO isn't even different. by Shinobi · · Score: 1

      "Erm, why the hell not? Good programmers, even the best programmers (in fact especially the best programmers), will just use qsort() (or the equivalent for the language they're using). Then, IF performance on their lowest-spec target hardware is unacceptable, they will profile their code and find out what's taking the time. And then, IF it's the sorting algorithm that's the bottleneck, only THEN will they implement a more specific version. Anything else is a waste of time and an additional risk of introducing unnecessary bugs."

      Wrong. Mediocre(at best) programmers who think they are good will do that. GOOD programmers, especially the best ones, will look at what the app requires in the design stage, before even the first line of code is written.

    5. Re:OO isn't even different. by jandrese · · Score: 1

      IMHO, the real advantage of OO is that you can declare your state outside of the functional code. In old structured code you were forced to either keep your state global (and then you were stuck with exactly one copy of that state), or pass it in on every function call (and if you have a lot of state this can get messy).

      I've never really bought into the "but now you're thinking with objects!" stuff that they teach in school. It's mostly a convenient way to trim down the function call complexity that doesn't result in people getting on your case for defining "global" variables (even though in C all of that would have been safely tucked away in its own file anyway, just as C programmers had been doing for years). Worse, sometimes you get the braindamage where people want to define everything as an object, and suddenly all of the complexity you were saving by going to OO is returned through the declaration of dozens of unnecessary objects (with their associated startup and shutdown complexities) that would have been much better handled as a single simple function.

      --

      I read the internet for the articles.
    6. Re:OO isn't even different. by adisakp · · Score: 1

      Erm, why the hell not? Good programmers, even the best programmers (in fact especially the best programmers), will just use qsort()

      Remind me to never let you use a linked-list that needs to be sorted if qsort() is the only hammer you know how to use.

    7. Re:OO isn't even different. by fractoid · · Score: 1

      Wrong. Mediocre(at best) programmers who think they are good will do that. GOOD programmers, especially the best ones, will look at what the app requires in the design stage, before even the first line of code is written.

      GOOD programmers use butterflies. >.>

      Maybe I didn't make this quite blatantly obvious enough, but I was talking about the general case where you have an array of whatsits and you want it to be sorted. Of course you'll take a squint at it and go "hmm, I'm sorting a list, I'll use bubblesort" (thanks adisakp for pointing out that obvious case) or "hmm, the data is often presented in reverse order (or whatever pathological case your particular quicksort implementation suffers from), maybe I should use something other than quicksort". If you just have 100 strings/ints/floats/whatever in an array and you want them rearranged to go from smallest to biggest, then you're wasting time puddling around with search algorithms instead of just using the library functions.

      I bet you're the type that hand-codes everything in assembler "because it's faster".

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    8. Re:OO isn't even different. by Shinobi · · Score: 1

      "I bet you're the type that hand-codes everything in assembler "because it's faster"."

      Only if the situation requires it. Then again, I get well-paid for when I actually have to do so, and the compiler monkeys from academia are unable to deal with it. What you can bet on, however, is that I map out exactly what needs to be achieved, what problems I will encounter, and what solutions are appropriate, before I even consider writing the first line of code.

      As for "faster", in quite a few cases, it still is, because compilers are still only as smart as the programmer who wrote it. But mostly, I use assembler in embedded apps nowadays, and more for exact control and issues with fitting it all into memory, like when there's only 10kiB available for use at BEST.

      Other than that, I use C++, Java, Fortran and Erlang. Looking into ADA also.

    9. Re:OO isn't even different. by Anonymous Coward · · Score: 0

      Also the generic sort will do one thing the average programmer will neglect to do - analyze the data to be sorted.

      VMS did this more than 25 years ago.

  51. Re:swapping two values without a temporary variabl by Imagix · · Score: 1

    x = x xor y y = x xor y x = x xor y Now you know!

    Hmm (let's assume C++, or something close to it): int x = 4; int & y = x; x = x xor y; y = x xor y; x = x xor y;

    Oops. x starts at 4, and ends up with 0. Bad swap algorithm.

  52. And more cargo-cultism by Moraelin · · Score: 5, Funny

    And a few more examples of cargo-cultism, from people who were untrained to understand what they're doing, but someone thought it was ok because the Java standard library does it for them anyway.

    1. The same Wally 1 from the previous story had written basically this method:

    public static void nuller(String x) {
        x = null;
    }

    Then he called it like this, to try to get around an immutable field in an object. Let's say we have an object called Name, which has an immutable String. So you create it with that string and can't change it afterwards. You have a getName() but not a setName() on it. So he tried to do essentially:

    Name name = new Name("John Doe");
    nuller(name.getName());

    I understand that he worked a week on trying to debug into why it doesn't work, until he asked for help.

    2. From Ted's aforementioned project:

    So they used the wrapper classes like Integer or Character all over the place instead of int or char. This was back in Java 1.3 times too, so there was no automatic boxing and unboxing. The whole code was a mess of getting the values boxed as parameters, unboxing them, doing some maths, boxing the result. Lather, rinse, repeat.

    I ask what that's all about.

    "Oh, that's a clever optimization Ted came up with. See, if you have the normal int as a parameter, Java copies the whole integer on the stack. But if you use Integer it only copies a pointer to it."

    AAARGH!

    --
    A polar bear is a cartesian bear after a coordinate transform.
    1. Re:And more cargo-cultism by julesh · · Score: 1

      "Oh, that's a clever optimization Ted came up with. See, if you have the normal int as a parameter, Java copies the whole integer on the stack. But if you use Integer it only copies a pointer to it."

      AAARGH!

      The icing on the cake would be if they were running on a 64 bit system, so the pointer was actually _more_ data than the int itself...

    2. Re:And more cargo-cultism by Anonymous Coward · · Score: 0

      oh my flying spaghetti monster

      you've made me appreciate my programming colleagues

    3. Re:And more cargo-cultism by andy.ruddock · · Score: 1

      How big's an int then?

      --
      God: An invisible friend for grown-ups.
    4. Re:And more cargo-cultism by Moraelin · · Score: 1

      An int in Java is always, by VM definition, 32 bits. I.e., 4 bytes. A reference (pointer) can be 32 bits on a 32 bit machine, or 64 bit on a 64 bit machine with a 64 bit VM. And that's not even counting the overhead of the wrapper object itself, which is IIRC 8 bytes itself, though it depends on VM too. That is, on top of the actual int in it. (Though, to be fair, that's on the heap and they were talking about optimizing copying to the stack;) Plus the GC overhead when dealing with the gazillions of extra wrapper objects. If you've ever seen a GC run into 2 billion small objects, well, you'll know what I mean.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    5. Re:And more cargo-cultism by robthebloke · · Score: 1

      the same size or smaller than long.

    6. Re:And more cargo-cultism by julesh · · Score: 1

      And that's not even counting the overhead of the wrapper object itself, which is IIRC 8 bytes itself, though it depends on VM too.

      It's likely to be at least 12 bytes, I think:

      * Memory allocation information, needs to store size of allocation along with scratch space for the garbage collector. I would be surprised if this came to less than 4 bytes overhead.
      * Pointer to the object's class, 4 bytes on a 32-bit VM.
      * Pointer to a monitor object (for use with synchronized() blocks, wait() and notify() method calls, presumably initialized to null unless any of these are used). 4 bytes on a 32-bit VM.

      As this comes to a total of 16 bytes when the actual size of the object is included, I doubt there'll be anything wasted on alignment fragmentation, although if the allocation overhead is less than the 4 bytes I've guessed at, the allocator will likely align allocations to 16-byte boundaries thus negating any savings made there.

    7. Re:And more cargo-cultism by NeoSkandranon · · Score: 1

      My colleagues now seem a slight bit less retarded programming wise (and I'm sure I'm no whiz myself)

      So you cruelly burst their bubble, right?

      --
      If you can't see the value in jet powered ants you should turn in your nerd card. - Dunbal (464142)
    8. Re:And more cargo-cultism by blueg3 · · Score: 1

      As far as I know, people run 32-bit JVMs even on 64-bit OSes. But, even if the JVM was 64-bit, it's the same amount of data either way -- one word. :-)

    9. Re:And more cargo-cultism by kalirion · · Score: 1

      Have you ever considered submitting to The Daily WTF?

    10. Re:And more cargo-cultism by mortonda · · Score: 1

      "Oh, that's a clever optimization Ted came up with. See, if you have the normal int as a parameter, Java copies the whole integer on the stack. But if you use Integer it only copies a pointer to it."

      AAARGH!

      Priceless and worthless at the same time... awesome!

    11. Re:And more cargo-cultism by slapout · · Score: 1

      I think Alex at thedailywtf.com would probably like to talk to you.

      --
      Coder's Stone: The programming language quick ref for iPad
    12. Re:And more cargo-cultism by ultranova · · Score: 1

      And a few more examples of cargo-cultism, from people who were untrained to understand what they're doing, but someone thought it was ok because the Java standard library does it for them anyway.

      I'm untrained (self-learned) too and I have no trouble understanding why these things are wrong. Someone willing to hire me?

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    13. Re:And more cargo-cultism by Moraelin · · Score: 1

      Self trained counts too, I should think.

      --
      A polar bear is a cartesian bear after a coordinate transform.
    14. Re:And more cargo-cultism by SanityInAnarchy · · Score: 1

      I think this actually vindicates what I was trying to say. Had Ted bothered to test it empirically, he would've found what the rest of us already know -- that it doesn't save you anything.

      --
      Don't thank God, thank a doctor!
    15. Re:And more cargo-cultism by julesh · · Score: 1

      As far as I know, people run 32-bit JVMs even on 64-bit OSes.

      Depends. For memory intensive stuff (e.g. application servers) most people are on 64-bit VMs these days. For desktop use, 32-bit is the most common.

      But, even if the JVM was 64-bit, it's the same amount of data either way -- one word. :-)

      Except, even in a 64-bit VM, an int is only 32 bits. While the stack will presumably be padded to 64-bit alignment, the VM should be passing two ints in each 64 bit word (assuming there are enough available).

  53. New Headaches by Tablizer · · Score: 3, Insightful

    The biggest "new" headache that will probably end up in such an article 20 years from now is web "GUIs", A.K.A. HTML-based interfaces. Just when I was starting to perfect the art of GUI design in the late 90's, the web came along and changed all the rules and added arbitrary limits. Things easy and natural in desktop GUI's are now awkward and backassward in a browser-based equivalent.

    Yes, there are proprietary solutions, but the problem is that they are proprietary solutions and require users to keep Flash or Active-X-net-silver-fuckwhat or Crashlets or hacky JimiHavaScript up-to-date, making custom desktop app installs almost seem pleasant in comparison, even with the ol' DLL hell.

    On a side note, I also came into the industry at the tail end of punched cards (at slower shops). Once the card copy machine punched the holes about 1/3 mm off, making them not read properly, but on *different* cards each pass thru. It's like including 0.5 with binary numbers, or 0.4999 and 0.5001 with a quantum jiggle.

    Good Times
       

  54. Re:swapping two values without a temporary variabl by Duvzo · · Score: 1

    Oops. Someone can't XOR. Bad post.

  55. Re:Self-modifying code has been a lose for a decad by Darinbob · · Score: 2, Informative

    A lot of RISC machines do support it, it's required and mandatory if only to load new exception handler routines, boot loaders, program loaders, etc. Even for debuggers you've got to drop a trap instruction at the breakpoints. Of course, if you never leave user mode then you may not ever have to worry about it.

    I don't expect the average programmer to have to deal with this, cache flushing, pipeline synchronization, etc. But definately a lot of embedded programmers need to know it, and operating system writers.

    Even in a debugger I've modified assembler code in place. It's a handy trick if your re-link and re-download can take 15-30 minutes.

  56. BCPL/TRIPOS and pain by IntentionalStance · · Score: 1

    Coding in BCPL (http://en.wikipedia.org/wiki/BCPL)on 64k TRIPOS (http://en.wikipedia.org/wiki/TRIPOS) machines with no memory protection was probably the worst experience for me.

    BCPL effectively had no types and memory management was very c like.

    If memory got tight, which it always did, you needed to needed to split your application into pieces and get the code to page sections of itself in and out of memory.

    If you didn't initialise a variable it was probably equal to zero. If you used it as a pointer then your were probably smashing all over the bottom of memory.

    The stand alone debugger was loaded at the bottom of memory so you'd now smashed that to pieces and you were probably left to debug by walking through memory by pushing buttons of the front of the machine, reading the hex of memory locations and trying to de-assemble and decompile the memory one word at a time

    Now I use Eclipse - luxury - don't miss those days at all.

  57. Re:swapping two values without a temporary variabl by Pinckney · · Score: 2, Insightful

    You're missing the point---it breaks when one of the variables is a reference to the other.

    It's a neat algorithm, but the case in which it fails just goes to show that these skills aren't irrelevant. Yes, you should know what a reference is. Using your compiler and libraries as a crutch for your lack of understanding leads to unpleasant bugs.

  58. I miss a lot by byrtolet · · Score: 1

    Althought I will not miss some of the mentioned techniques, the rest made the programming fun for me. And I miss them a lot.

  59. 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.

    1. Re:Ya I would compare it to long division by rolfwind · · Score: 1

      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.

      Well, strictly not if that calculator gives you decimals instead of a remainder besides the whole number and that number has to be carried over elsewhere.

    2. Re:Ya I would compare it to long division by Have+Brain+Will+Rent · · Score: 3, Insightful

      Division by hand? Don't you just do it in your head?

      --
      The tyrant will always find a pretext for his tyranny - Aesop
    3. Re:Ya I would compare it to long division by javaxjb · · Score: 2, Insightful

      If you really want to understand how division works, iterative subtraction would be better -- literally count the number of times the divisor gets used. Then, to optimize (vs iterative subtraction) and improve accuracy (over long division) learn double division. Long division belongs in the same category as these old school coding techniques -- I'm tempted to hedge a bit on that point since long division is faster, but I can't even remember the last time I used it (probably best measured in decades).

      --
      Programmers in mirror are brighter than they appear
    4. Re:Ya I would compare it to long division by CrashandDie · · Score: 5, Funny

      I'd rather do it by hand. I'd love to see you divide a pizza in 6 using only your head.

    5. Re:Ya I would compare it to long division by ZyBex · · Score: 1

      Right... please divide sqrt(2) over Pi, with 4 decimals, in your head. Quickly please, I haven't got all day.

    6. Re:Ya I would compare it to long division by necro81 · · Score: 1

      I'm still waiting for my implanted math co-processor.

    7. Re:Ya I would compare it to long division by RobBebop · · Score: 1

      I have binary figures. Each finger can either be up or down. Therefore, I can count to 2^5 on each hand or 2^10 if I combine them. Dividing with the number 6 shouldn't be a problem, however representing the number "4" becomes somewhat of an issue when I'm holding up my hand at the ice cream store telling the clerk that I want four scoops on my cone.

      --
      Support the 30 Hour Work Week!!!
    8. Re:Ya I would compare it to long division by Geoffrey.landis · · Score: 1

      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.

      No, I will disagree with that particular example. I do know how do to long division, but I don't think that the mechanics of long division give you any particular insight into mathematics, or even into arithmetic. Long division is simply a symbol-manipulation process; there's no real content to it.

      Now, Newton's method-- that's something that's worth learning. In fact, why can't we teach students to do long division by Newton's method? Then they'd learn something useful!

      --
      http://www.geoffreylandis.com
    9. Re:Ya I would compare it to long division by thechao · · Score: 1

      I've got the pencil in my left ear to stay. Do I roll up the paper, or what? Should I cut a hole in it and hang it on my nose?

    10. Re:Ya I would compare it to long division by nabsltd · · Score: 1

      ...and you're never going to be able to get 84 of anything.

    11. Re:Ya I would compare it to long division by Bigjeff5 · · Score: 1

      I don't know if you've used a calculator recently, but most calculators that cost more than $20 or so can give you a remainder instead of a decimal. I've got two that do it - one is my good TI graphing calculator, and one was a cheapo depo calculator I got for a non-calc physics class because I thought I lost my graphing calculator. The first was around $100, the second around $20, or less I can't remember for sure.

      Plus, if you're regularly doing long division and carrying the remainder, chances are you're doing those calculations on a computer where the calculators are much more robust.

      Cheers!

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    12. Re:Ya I would compare it to long division by Dimitrii · · Score: 1

      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.

      Well, strictly not if that calculator gives you decimals instead of a remainder besides the whole number and that number has to be carried over elsewhere.

      Or you need a better calculator or learn to better use the one you have. Even the MS Calculator has an Int function and a memory.

      big/little = big / little MS = - Int = * MR =

      The superior RPN is left to others.

    13. Re:Ya I would compare it to long division by Cormacus · · Score: 1

      I don't always have a calculator on hand. But I usually have a pencil and a scrap of paper. Failing that, I can follow the algorithm for long division in my head.

      --
      Mon chien, il n'a pas du nez. Comment scent-il? TrÃs mauvais!
    14. Re:Ya I would compare it to long division by Anonymous Coward · · Score: 0

      Simple just ask you to divide that pizza into 6 pieces, now that's using your head!

    15. Re:Ya I would compare it to long division by Anonymous Coward · · Score: 0

      dividing it into 6 pieces with my head would be easy. Its dividing it into 6 EVEN pieces with my head that might be tricky. Plus who wants hair in their pizza.

    16. Re:Ya I would compare it to long division by kackle · · Score: 1
    17. Re:Ya I would compare it to long division by Stratocastr · · Score: 0

      I'd rather do it by hand. I'd love to see you divide a pizza in 6 using only your head.

      Only jedis and physicists can do that.. Since they both understand force, that is.

      --
      Slashdot - I went there to fix their grammar that they're so bad at.
    18. Re:Ya I would compare it to long division by Anonymous Coward · · Score: 0

      Easy 3 intersecting chords

    19. Re:Ya I would compare it to long division by Old+Wolf · · Score: 1

      No, no it isn't. Knowing how to do a long division by hand adds nothing whatsoever to your understanding or foundations.

      As an analogy, can you do a cube root by hand? I can't. I'm sure I could figure out an algorithm if I really wanted to . But I don't. Does it stop me understanding higher level math? Absolutely not.

      Back to the original topic, it is absurd to say that you need to know how to implement X in order to use X. Who among us could implement MS Windows?

    20. Re:Ya I would compare it to long division by Anonymous Coward · · Score: 0

      Actually, iterative subtraction was exactly how I was introduced to division back in 3rd grade. That was long ago - these days it's probably all taught using "new math" and a TI-83.

      This is the part of the post where I yell about getting off my lawn.

      - T

    21. Re:Ya I would compare it to long division by scamper_22 · · Score: 1

      Actually, your example is the perfect example of what NOT to do.

      95% of people have no idea how long division work, yet they can do it. It's just a process they follow. I taught high school... trust me when I say, they have NO IDEA of the math behind long division... neither do most adults. Multiplication by hand is a bit more intuitive, but even there... not everyone knows the math behind it.

      Similarly, I know quite a few programmers who know how to regurgitate a sort algorithm, yet they don't quite understand how things work.

    22. Re:Ya I would compare it to long division by Anonymous Coward · · Score: 0

      You also have binary (or even ternary) palms: 0 palm up, 1 palm down [, 2 palm vertical].

      Thus, you should be able to manage 2^12 with your hands, without anything more complicated than binary (it helps to use hand rotation as the most significant two bits).

  60. Re:swapping two values without a temporary variabl by Curate · · Score: 1

    x |= y |= x |= y

  61. And another one by csrster · · Score: 1

    Back in the day ... I did my PhD work on a university-wide mainframe which cam equipped with a seriously dubious scheduling algorithm and a whole lot of quota restrictions on job queues, job output queues, cpu usage etc. The critical parameter was the five-minutes-cpu per job limit. The only way to get around this was the self-resubmitting job which, when it got to 4:30 minutes cpu, would write its state to disc and resubmit itself using the written state as input. The fun, of course, was avoiding creating a rabbit job which would reproduce itself uncontrollably bringing the entire university's theoretical research program to a grinding halt. Oh happy days.

    1. Re:And another one by bratwiz · · Score: 1

      I did something a little similar to that for submitting print jobs to the lab's shared hard-copy terminal.... worked well until a couple of days later the computer dept manager was frantically searching around for whomever was running that job that had the mini-mainframe computer crabbing across the floor of the computer room....

      (it was moving the heads of the 14-inch disk drive back and forth very rhythmically)

  62. GOTO slashdot by DrugCheese · · Score: 1

    it's hardcoded into my brain

    --
    *DrugCheese rants*
  63. re by redGiraffe · · Score: 1

    Do you remember releasing your application and the best way to solve a bug was to restart the entire frikin machine? ..oh, we still do that?

  64. Re:swapping two values without a temporary variabl by Psychotria · · Score: 1

    Yeah, except that's not XOR it's plain OR

  65. Premature optimizations by IntentionalStance · · Score: 5, Informative

    This is one of my favourite quotes:

    "The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet." - Michael A. Jackson

    That being said, when I hit the experts only situation I can usually get 2 orders of magnitude improvement in speed. I just then have to spend the time to document the hell out of it so that the next poor bastard who maintains the code can understand what on earth I've done. Especially given that all too often I am this poor bastard.

    1. Re:Premature optimizations by TaoPhoenix · · Score: 1

      That explains Vista --> 7.

      --
      My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
    2. Re:Premature optimizations by djnewman · · Score: 2, Interesting

      I fully agree on the "don't optimise" part, but that only works when the library is decent. As we are talking about the bad old days, there was a time when bubble sort was the C library standard and quick sort was not even in the library. Knowing that quick sort is faster in most cases was an optimization. If a program was later recompiled against a library that had an optimized quick sort then the users quick sort "optimization" now becomes a liability. It's a lesson that it may always premature to optimize. A smarter approach may be to use an analyzer instead.

  66. IDE issues? by TiggertheMad · · Score: 1

    1)Variables change type. And then you have to rename everything. Its a pain

    Visual studio -> Right click on any variable -> rename -> type new name -> click ok

    eta .3 seconds

    You might not use VS, but really, any good IDE should have this feature. Don't get down on tha' hung' because you are using a shoddy IDE.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
    1. Re:IDE issues? by robthebloke · · Score: 1

      Visual studio -> Right click on any variable -> rename -> type new name -> click ok

      Only for managed languages - doesn't work for C++ (though you can buy plug-ins that will do it - i.e. visual assist). I've not yet seen any C++ refactoring tools that work reliably enough trust in a commercial environment.

    2. Re:IDE issues? by spongman · · Score: 1

      even better:
      - edit variable name
      - Ctrl-Alt-F10, Enter

    3. Re:IDE issues? by The+End+Of+Days · · Score: 1

      And if you're using VS, then you have all the information about the type available at a click (or even a hover) and don't need to encode it in the name.

  67. Re:swapping two values without a temporary variabl by Alistair+Hutton · · Score: 2, Interesting

    As a python user I've always been confused by this one
    x,y = y,x
    Is the easiest way to do it surely?

    --
    Puzzle Daze is now my job
  68. Re:How about working with EPROM burners and eraser by honkycat · · Score: 1

    Do people still use those old fashioned hardware debuggers with the adapter that had pins for the socket on the board where the CPU would go, so it could capture the signals on all the pins?

    As of... crap, I guess it's 8 years ago now... these were still in use, but phasing out, at least in my experience. Modern processors supported a JTAG test interface that allowed in-circuit debugging via a serial connection directly into the CPU itself. Not sure what the current state is; I recall being able to do some things with the 68k ICE that were not supported on the JTAG interface -- mostly related to detailed state of registers in the CPU. I don't recall whether this was an inherent limitation of the interface or a quirk of a cheap implementation of the interface.

  69. Goto by Spike15 · · Score: 1

    Don't miss this.

  70. Obviously not an embedded programmer by gnalre · · Score: 1

    In the embedded world many of those items are still required skills, however I will admit they are not as important as they once were.

    On the other hand I often worry how little my windows programming colleagues understand about the mechanics of computers especially when it comes to such things as parallel programming and network stacks.

    --
    Choose your allies carefully, it is highly unlikely you will be held accountable for the actions of your enemies
  71. Writing out code by hand by dredwerker · · Score: 1

    When I learnt Cobol we had to write out the code onto coding sheets for someone else to type it in. You had to get your characters in the right place in the 80 columns otherwise it wouldnt compile for the next day argggggggh.

    --
    On a long enough timeline. The survival rate for everyone drops to zero. Chuck Palahniuk, Fight Club, 1996
  72. RSX Memories by andrewbaldwin · · Score: 1

    Ahh RSX11M -- happy days :-)

    I wouldn't want to go back to the days of trying to cram everything into a 16 bit address space with no virtual memory support but.... having to create trees and manually specify which parts of a program could swap when was an interesting and useful education.

    Going back a few years (OK 25+ -- ouch that makes me feel my age!) I remember working on a system which had a tool to manipulate key data files and effectively had one module per screen. To fit it in we had to capture data and store it in a root node and then allow the module to swap out and let the next screen's one swap in. (There was a bit more to it than that, but I'm simplifying for brevity)

    It could be a right pain, trying to work out why something wasn't picking up the right values, only to discover an execution scenario where a vital chunk was swapped out when least expected.

    Having multiple trees in the same program -- now that was 'fun' -- lost art nowadays with big address spaces, loads of memory, automated virtual memory management as a "don't worry about it - it just works" feature.

    (Cue IT version of Monty Python's four Yorkshire men sketch....)

  73. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    It should be noted that the performance is considerably worse for that particular variable swap on the majority of architectures.

    XOR is a rarely used operation outside of encryption and compression, so most architectures aren't designed to execute the XOR operation very quickly. The performance is focused elsewhere.

    However, if your target architecture does have optimized XOR operations, go for it.

  74. For any fans of Hungarian notation.... by waimate · · Score: 1

    ... I have one word : wParam.

    I rest my case.

    In Win32, wParam went from 16-bit to 32-bit, but still stayed as wParam. Now in Win64, wParam is a 64-bit quantity.

    wParam my foot.

    1. Re:For any fans of Hungarian notation.... by dzfoo · · Score: 1

      Uh, could it be because the "w" refers to the machine's Word Size; you know, either 16, 32, or 64 bit address space?

              -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    2. Re:For any fans of Hungarian notation.... by julesh · · Score: 1

      ... I have one word : wParam.

      I rest my case.

      In Win32, wParam went from 16-bit to 32-bit, but still stayed as wParam. Now in Win64, wParam is a 64-bit quantity.

      A bad, inappropriate use of hungarian that should not have been allowed to stand. From the original documentation of hungarian:

      "w - a word (typically 16 bits). For most purposes, this is an incorrect usage"

      A word was only "typically" 16 bits, but not strictly defined to be that length. With the move to 32 bit machines, 32 bit words became de rigeur. On 64 bit machines, 64 bits is also an acceptable interpretation. But the caution that the usage is likely to be incorrect is also relevant. It points out that in this case the prefix is, basically, useless.

      "l - a long (typically 32 bits). The same warnings apply to this as to w."

      As is "lParam" a vague specification that means almost nothing.

      In this case, the prefixes can only be interpreted as names that do not provide any useful meaning. Which given that they are being used in names of variables _whose meaning changes depending on context_ this is probably about as good as it can get.

  75. Duff's Device by shutdown+-p+now · · Score: 1

    What, no mention of the Duff's Device, possibly the neatest and at the same time the ugliest C hack ever? Here's the (modernized) code for those too lazy to click on the links - What's really scary is that it's perfectly ANSI/ISO C compliant:

    void dsend(char *to, char *from, int count)
    {
            int n = (count + 7) / 8;
            switch (count % 8) {
            case 0: do { *to = *from++;
            case 7: *to = *from++;
            case 6: *to = *from++;
            case 5: *to = *from++;
            case 4: *to = *from++;
            case 3: *to = *from++;
            case 2: *to = *from++;
            case 1: *to = *from++;
                                  } while (--n > 0);
            }
    }

    This works because of the way switch statement is defined in C - the case labels inside are really just labels (even though they cannot be targets of a goto statement), and so constructs can flow around and between them almost freely, with only the same limitations as for normal goto labels.

    Unfortunately (or fortunately?), this has survived in C++, but not in any other language from the curly-braces family that I know of.

  76. Re:Self-modifying code has been a lose for a decad by Anonymous Coward · · Score: 0

    Code that generates code is occasionally necessary, but code that actually modifies itself locally, to "improve performance", has been obsolete for a decade.

    WTF? One of the most used technology in the Real-World [TM] uses exactly this technique to achieve outstanding speed, often surpassing static compilation.

    Java's JIT compiler modifies, rearranges, at runtime, the bytecode, so that, amongst other, the most often visited paths are executed faster. You may say "oh but it's bytecode, not native" but anyway the set of supported instruction on, say, a Core 2 Duo is just "faked" on top of non-accessible instructions.

    Java's JIT compiler does modify code at runtime and it's not anywhere near obsolete. It's a technology that pretty much powers the Real World [TM]. Think about modifying bytecode the next time you do a non-cash money transaction.

    The problem is your narrow view on were self-modifying code can take place. You're not forced to modify the very next (or previous) instructions to qualify for self-modifying code. Sure, modifying code may imply *one* cache miss, but what if it's done to then later on avoid thousands of branches?

    That's what the JIT does. Think about it next time you make a non-cash payment. Because I can guarantee you at some point there's Java JIT involved in the process.

  77. Michael Schumacher is NOT a car mechanic by SmallFurryCreature · · Score: 2, Insightful

    It is well known that Michael Schumacher is NOT much of a car nut when it comes to the mechanics. How many world championships did he win? Oh, more then ANYONE ELSE?

    You need to know about the network stack if it is your job to know about the network stack. If it isn't, you don't need to know about it. What good is it for someone who writes an music codec to know about the network? Parallell programming notepad?

    --

    MMO Quests are like orgasms:

    You may solo them, I prefer them in a group.

  78. Re:swapping two values without a temporary variabl by dkf · · Score: 1

    As a python user I've always been confused by this one

    x,y = y,x

    Is the easiest way to do it surely?

    Yes, but you should be aware that the system is creating (at least) one temporary behind the scenes to hold those values while they're being swapped over. Which isn't to say don't write that! The method you use has the strong advantage of being really easy to get right, as opposed to that idiotic xor "idiom"...

    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  79. Re:swapping two values without a temporary variabl by dkf · · Score: 2, Interesting

    x = x xor y
    y = x xor y
    x = x xor y

    Now you know!

    That's a terrible way of doing it! It guarantees that the compiler and processor can't do anything smart with reordering variable accesses since the values are now officially dependent on each other, despite not really being.

    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  80. Reference counting and memory allocation by DrXym · · Score: 1
    I used to program COM a lot. I actually like COM (strip away legacy OLE and its actually pretty elegant) but the one I thing I hated was reference counting. When you CoCreate an object you set its count to 1, whenever somebody wants to use an interface on the object they AddRef to increment the count and then they Release to decrement it again. Interfaces are essentially "checked out" while in use. When the final reference to the object is released the object is responsible for destroying itself.

    Problem was this never worked out perfectly. Somebody would AddRef too many times or Release too many times meaning the object leaked or died while still in use. Releasing early meant a crash occured somewhere else since other consumers had an invalid pointer. Even with smart C++ pointers you always got some situation with inout parameters or thrown exceptions or two objects referencing each other or some unsafe cast or even third party code where things got screwed up. Sometimes it could take hours and hours to find leaks.

    While C# and Java don't alleviate all of these issues (objects can still hold strong references), they do basically scrape all of this crap from the developer's plate meaning less and more readable code. Reference counting and garbage collection is automatic and just works. There are even weak reference classes for cases where two classes might need to reference each other.

    Of course garbage collection is its own issue but IMO far, far, far better than what preceded it. The biggest issue with GC is it needs tuning, and some novice programmers make stupid mistakes such as creating objects in a loop rather than reusing them - the kind of thing that means 10,000 transient objects suddenly leap into and out of existence giving the GC a hernia. IMO it wouldn't be a bad thing for Java and .NET devs to learn C++ just to understand some of the underlying issues their language is mostly protecting them from.

    1. Re:Reference counting and memory allocation by petermgreen · · Score: 1

      The biggest issue with GC is it needs tuning, and some novice programmers make stupid mistakes such as creating objects in a loop rather than reusing them - the kind of thing that means 10,000 transient objects suddenly leap into and out of existence giving the GC a hernia.
      The bigger issue is that in java (in many ways the poster-boy language for gc) you have to go out of your way to avoid creating lots of garbage.

      Consider method a contains a loop which calls method b which in turn calls method c.

      Now method c wants to return more than one double/long to method b. What are the options? In a conventional language b would just declare variables and pass them as pointers or references to c but that isn't an option in java.

      1: create an object in c and return it, this is the most obvious thing to do but will create a storm of objects.
      2: create an object in b and pass it to c, this would be a fine idea if b contained the loop but in this case it has no advantage over the first option.
      3: create an object in a and pass it to b and then onto c. This avoids the object storm but exposes a to implementation details of b.
      4: use some existing object or even a static field to carry the return values. This avoids the problems of the previous options but introduces a whole load of it's own (thread safety for example).

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  81. The CORAL programming language. by ciderVisor · · Score: 1

    CORAL allows you to declare and use variables with whitespace within them. This arguably makes for more pleasant-looking code than when you use underscores or CamelCase (and is a real help for dyslexic programmers).

    What's not so cool is that the compiler ignores whitespace so that

    Variable number 1
    Variable number1
    Variablenumber 1
    and
    Var iablenum ber1

    are all equivalent. All it takes is some inconsistent naming and you become unable to use search functions which don't ignore whitespace (I couldn't even tell you if grep has a switch for that - the system I programmed with CORAL didn't run Unix and its search command was brain-dead).

    Oh, and bitwise operations were allowed, but bits were numbered from the most significant downwards !

    One of the most horrible jobs I ever did was porting a system written in CORAL into C. If it hadn't been for modern IDE's and debuggers, I reckon I'd still be doing it !

    Begone foul beast !

    --
    Squirrel!
  82. Fixed-point arithmetics. by Ihlosi · · Score: 1

    Or integer arithmetics in general. Ever written a function to compute a square root or a binary logarithm using only integer? Fun stuff.

  83. Re:Self-modifying code has been a lose for a decad by eulernet · · Score: 1

    You forgot to mention that the code section on Windows is now read-only.
    When you change it to read/write, there is a factor 2 penalty (the code runs 2 times slower), even when not using self-modifying code.

  84. video coding by Teunis · · Score: 1

    A lot of this still comes up in video coding and working with complex rendering environments. ... even cards. *cough* (although more in a "this object has to be X size sense rather than 80-column limits) ... but then I've only been coding since the 80s so what do I know ;)

  85. Teach *style* by ChienAndalu · · Score: 1

    Event if you teach them what hash tables and linked lists are, many developers still write functions that are 500 lines long that could be 20 lines. Some people I have worked with don't even grasp the concept of a subroutine.

    But of course they now know about patterns and javadoc, so they put a

    /**
        * This is a FooBar singleton factory (See the Design Patterns book)
        */

    On top of their stinking mess and feel smart.

  86. I wrote a macro assembler in Apple][ basic by slashbart · · Score: 1

    When I got my Apple][ clone (ca. 1980) it came with basic and that's it. I knew assembly language programming, and the computer manual came with the processor instruction set (or I got that some other way). Anyway, I wrote a macro assembler in basic, so that I could write applications that were faster than possible with the basic interpreter. That was good fun :-)

  87. Re:Self-modifying code has been a lose for a decad by Anonymous Coward · · Score: 0

    A JIT compiler is a compiler, self-modifying code is usually not.

  88. Re:Self-modifying code has been a lose for a decad by Anonymous Coward · · Score: 0

    although sometimes its as a replacement for this code:

    static bool flag = true;
    if (flag) { /* do something once only */
                flag = false;
    }

    Could you explain the motivation for this part?

  89. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    First good answer.

  90. One she missed... by julesh · · Score: 1

    Calling arbitrary locations in the system ROM to call utility functions (which were usually designed to be called to implement BASIC commands, the most commonly-used one being "LOAD").

    The idea that there might be a new version of the machine produced in future that _had different software in its ROM_ just never occurred. Thus leaving machine vendors with the annoying situation that they were unable to upgrade their systems, because half the software out there had dependencies on the precise implementation of their ROM-loaded software.

  91. Re:swapping two values without a temporary variabl by Have+Brain+Will+Rent · · Score: 1

    or just SWAB x,y

    --
    The tyrant will always find a pretext for his tyranny - Aesop
  92. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  93. Roll your own virtual memory by mbone · · Score: 1

    In the 1970's, on IBM 370's, you could have virtual memory if you created your own swap tables. This required a lot of thinking about program structure and execution order. You had to figure out if a routine was in use or not, and swap it in and out of memory. If someone added a call to a routine while it was swapped out, the program would dump core.

    Worse, sloppy programmers would assume that the contents of non global variables would be there from one call of a routine to the next. That would be true - as long as the routine wasn't swapped out. So, changing the swap tables was likely to cause subtle bugs, as counters or indices suddenly got reset to random numbers. Since the swapping would generally depend on what the program was doing, it might pass simple check cases, but go weird some of the time on extended runs.

    I can remember literally spending weeks debugging such problems in previously working code.

  94. String Packing by psbrogna · · Score: 2, Interesting

    On TRS-80's Mod I & III's this technique was used to emulate the sprite functionality available at the time on the Commodore. You'd predefine arrays of strings (limited to 255 chars- max string length in BASIC) that contained combinations of Extended ASCII (>127) characters which corresponded to the desired 5x3 pixel mappings and control codes to reposition the cursor while outputting the string. This way you could use the BASIC PRINT statement instead of the graphics SET() & RESET() statements. This resulted in enough of a peformance boost that you could write playable games in BASIC rather than Assembly.

    1. Re:String Packing by psbrogna · · Score: 1
      Footnote: Don't quote me on this but I believe it was Ride of the Valkyrie by a Mr. Christopherson (sp?) that first used this technique. RotV was available on tape casette and loaded at either 300 or 1,200 baud depending on what model you had.

      I also don't miss tape drives.

  95. Isolation is bad by nurb432 · · Score: 1

    As people become less and less knowledgeable about the basics, we will end up with more and more bloated and unstable code.

    How many people today even know what microcode is? Let alone used it to push bits around registers directly? Understanding at that level gives you an appreciation of what is going on that is lost when you see the computer as a black box you toss prepackaged widgets at.

    --
    ---- Booth was a patriot ----
    1. Re:Isolation is bad by bratwiz · · Score: 1

      Are you referring to _machine code_, utilizing the processor's published low-level programming instructions and interface, or _microcode_ used in the firmware to implement the machine code?

    2. Re:Isolation is bad by nurb432 · · Score: 1

      Yes, i really said microcode. One really should understand how things works at their lowest level to be truly effective. Im not saying they have to be an expert and delve into how holes move across the gates on the die, but a general understanding of bit movement at the gate level is a good thing.

      Losing that knowledge is sad.

      --
      ---- Booth was a patriot ----
    3. Re:Isolation is bad by bratwiz · · Score: 1

      I agree with you. Most people don't even know what microcode is or what it does or why it would be useful to be able to manipulate it. Heck, most CPU's these days don't even give you access to the microcode level anymore anyway.

    4. Re:Isolation is bad by julesh · · Score: 1

      Heck, most CPU's these days don't even give you access to the microcode level anymore anyway.

      Probably because most CPUs these days don't _use_ microcode any more. Almost all instructions are implemented in fixed functions in a pipeline rather than being microcoded. Microcode went out of style with the 486.

  96. We've passed the high point of productivity by Invisible+Now · · Score: 1
    I write production code without a net and on tight deadlines.

    Given my druthers I'd step back five to ten years and keep each component to a single page.

    Many of the articles points are cute, valid and bring back happy memories of making hard problems go on the old day's slow boxes, but they don't compare to the overhead of writing current code in today's production environments. (How about Vista being more bloated and slow than XP?)

    Think of the chain of single point failures when you are dependent on thousand's of other programmer's commercial objects performing EXACTLY as documented.

    These chain breaks are common... what can you do if you trust and are betrayed by someone else's slow or buggy object? And the verbosity of declaring hundreds of properties to display, say, a simple web page are preposterous.

    What if you have a demanding app, or just don't need the overhead of every marketing guy's punch list of features slowing down your code?

    Perhaps we were better off, and more productive somewhere between manual memory management and pointers in C... and today.

    --

    "Knowing everything doesn't help..."

  97. undefined symbol 'select' by tepples · · Score: 1

    Manual multithreading

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

    Unless the embedded platform you're working with doesn't even have select() or WaitForMultipleObjects(), and you have to write your own version.

    "Hey, we had a crash 42 hours into the run, can you take a look?"

    Any computing task expected to run more than about an hour will need to have some sort of checkpointing.

  98. Re:swapping two values without a temporary variabl by DamageLabs · · Score: 2, Informative

    x = x + y
    y = x - y
    x - x - y

    Much less CPU intensive.

  99. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    x, y = y, x

  100. Hell by Dunbal · · Score: 1

    I must be pretty old. I remember when you could only multiply by using a loop and adding to the register the necessary amount of times.

    --
    Seven puppies were harmed during the making of this post.
    1. Re:Hell by Anonymous Coward · · Score: 0

      Which processor was that that you could not do a binary multiplication using shifts and tests? It must have been pretty braindead (or you were multiplying by very small numbers).

  101. template calls by tepples · · Score: 1

    any non-epic-fail IDE will at the least tell you variable types when you mouse over them

    But with the template calls that pervade the C++ standard library, it's harder to make a C++ IDE non-epic-fail. What does std::stlp_string <std::w_char, std::char_traits> mean to a programmer in a hurry?

  102. Re:swapping two values without a temporary variabl by Piquan · · Score: 2, Interesting

    Several years ago, I disassembled the output of gcc -O2 (on an RS/6000) for swaps through a temp variable, and swaps using xors. Turns out that the peephole optimizer recognized both patterns and replaced them with the same machine-specific fastest way.

  103. Re:Self-modifying code has been a lose for a decad by terryducks · · Score: 1

    here's an easier one ... You have a wheelbarrow full of mulch and "Jackass" comes by in his shopping cart and dumps the load. You now have to pick up everything and continue. Till he does it again. It really slows down work.

  104. Re:swapping two values without a temporary variabl by Zebedeu · · Score: 1

    That's a neat little trick.

    Not that I'd ever use it because it's not very readable, but I'll try to remember it next time I need to impress someone :-)

  105. Re:swapping two values without a temporary variabl by bziman · · Score: 3, Insightful

    This might be okay if you are SO constrained you can't afford one register's worth of temp space, but if you're into performance, this is 4-8x slower than using a temp variable, in every language I've tried it on. Run your own benchmarks, see what I mean. Also, don't obfuscate your code, just to be "clever".

  106. Inheriting Software by ImdatS · · Score: 1

    Back in 1988/89, while I was working for a small HW/SW company in Berlin, I inherited code from four different "groups" of people:

    1. From one external developer who was supposed to write some embedded stuff in C:

    He delivered the code and went on holidays to the caribbean (I am not exaggerating). Imagine, this was the time without email and mobile phones. Actually, I didn't inherit it directly but a colleague. And someone else had given the contract to that external person without asking us.

    Anyway, we had to install it on a mission-critical power amplifying thingy (I don't know what it was, I'm a software guy). It just didn't work... Then my colleague, who didn't know C, asked me if I could have a look at the code because he didn't really understand it (he was an assembler coder only). The code looked like this: ...
    #define BEGIN {
    #define END }
    #define THEN {
    #define IF if
    #define WHILE while
    #define FOR for
    #define FUNCTION
    #define PROCEDURE void
    #define REAL float ... (you get the picture here) ... ...
    FUNCTION DOSOMETHING (REAL in, INT out)
    BEGIN ...
          FOR (...) BEGIN
          END ...
          IF (...) THEN
          ELSE
          END
    END

    --- I started crying

    2. It was from a physicist who worked there as programmer for a while and left. He developed in Turbo Pascal.

    The code was really nicely structured, he had written a really nice guide how to structure and write code. It was readably without any comment - perfect.

    The one thing... it was the most inefficient code I had ever seen and it used some tricks of Turbo Pascal 3, which drove me really crazy when I tried to bring it forward to TP4/TP5 (was it OVLs? I dunno anymore)

    3. Two external guys developed another piece of software as a new module for (2) above. They insisted that they should use Turbo-C. I don't know who said "yes", but after a while I received their code to integrate it as a separate module (actually separate exe) to our package.

    Integration was no problem, it worked, everything was fine. Except when a client asked for some changes. I had to dive into the code and try doing some changes... Well, ... it was object-oriented C - no, it was NOT C++, it was their own flavour of object-oriented C they had developed...

    --- I started crying again.

    4. The last example was actually an operating system we developed for a small self-developed computer based on C-64 (it was for QS-systems for car manufacturers; this piece of hardware had built-in analogue and digital measurement-device inputs and so on). The code was beautiful, it was fast, efficient and ... readable. It did everything we wanted and I understood everything. It was faster than a C64 and so on...

    I really loved that "OS"... the drawback?? He was such a genius that he became an alcoholic and had to leave the company and we couldn't continue developing the stuff anymore...

    Throughout my 27 years of computing, the worst thing that happened to me was inheriting software from various different sources at the same time. But other than that, all the other stuff I can only say: "Been there, done that" (yes, even punch-cards, PDP/11s, Vixens... ahm, VAXens, etc. -- no, no magnetic cylinders)

  107. I still get a kick out of instant compilers! by TheMonkeyhouse · · Score: 2, Interesting

    my first enterprise application was HAND WRITTEN on coding sheets and handed to a data entry operator who typed it in and i had to wait 3-5 days for a compilation report and code listing printouts. Needless to say the first report was mostly syntax errors (bad handwriting, smudges and data entry errors). Then i had to hand in modifications to be made on new sheets - these would only take a day or 2 to come back!

    a few years later i worked on a PRIME mini and had to submit all C applications into a queue for compilation - sometimes 30 minutes but on high load days, it could take 8 hours - just to compile the damn code! again i pick up the results in the form of a printout.

    but now, even to this day, i still get a huge kick out of compiling, building, linking (including generating and optimizing) 1 million+ lines of code right on my desktop in seconds.

  108. So what.... by hesaigo999ca · · Score: 1

    Let's talk assembler for a minute, many of the young whipper snappers, don't know that a GUI like visual studio that creates its own language (CLR) to then be recoded into assembler then into binary, is like all languages, really, at the core.

    Yet how many can code in assembler, even I have trouble keeping any resemblance of the code, and
    need to brush up every now and then, so if 20 years go by, no one will even know what assembler is, which is sad, because we still have to know it essentially, as it is pre-binary, and the only thing
    to stop us from needing to recognize 0 and 1 patterns to communicate with our computer.

  109. Used to be pretty bad by Drakkenmensch · · Score: 1

    How about that total absence of respect back in the days where programmers were seen as interchangeable faceless drones (aka Code Monkeys) in a "fad industry" that everyone just assumed would go away with the hula-hoop and the Rubik Cube?

    1. Re:Used to be pretty bad by bratwiz · · Score: 1

      >> How about that total absence of respect back in the days where programmers were seen as interchangeable faceless drones

      Don't worry, its still absent.

  110. Intelligence by QuietLagoon · · Score: 1

    "You and I learned C when it was programmers, not compilers, which had to be intelligent." --- Terry Lambert

  111. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    You're missing the point---it breaks when one of the variables is a reference to the other.

    It's a neat algorithm, but the case in which it fails just goes to show that these skills aren't irrelevant. Yes, you should know what a reference is. Using your compiler and libraries as a crutch for your lack of understanding leads to unpleasant bugs.

    If "one of the variables is a reference to the other", you don't have two variables, you have ONE.

    Tell us, bright boy, how to swap two values in one variable. There's a Nobel Prize in Mathematics riding on your answer.

    Geez, you went all the way around the circle from smartass to dumbass.

  112. Re:Quicksort by gr8_phk · · Score: 1

    Is quicksort still all the rage? For my time critical stuff I use heap-sort because it's execution time is O(n*log(n)) whereas quicksort is worst case O(n*n) but typically O(n*log(n)). I've always wondered about this because most quicksorts are usually faster in practice than heapsort, but that's an average. Can anyone clarify this for me?

  113. 6502 Multiplication by carkb · · Score: 1

    One old school programming thing was learning how to multiply in 6502 (C64 and others) machine language which didn't have a multiply instruction available. It involved doing bitwise math instead of costly addition loops.

  114. Re:radio in the computer case: the music of... by pruneau · · Score: 1
    I did this with my first "programming" love, a Texas Instrument Ti-57.

    Since I was doing "undercover" programming (i.e. programming at night when I was supposed to sleep ;-), I discovered pretty quickly that the beast was making noise, a lot of different ones. I quickly learned the sound of a running program, the noise of an error, and the sound of a few number being displayed as well.

    I then kept this habit since, learning the sound of a properly running computer, and being able to tell when the beast is trashing, and so on.

    Of course, with all those new-fangled virtual hosts, I'm missing a lot of cue about the system I'm working with. This is sad, my friend, really sad.

    --
    [Pruneau /\o^O/\ warranty void if this .sig is removed]
  115. Exemplary Problems Demonstrate Useful Solutions by EgoWumpus · · Score: 1

    Parroting quicksort is useless. But learning to write a sorting algorithm is a gateway to very fundamentally useful topics, such as recursion. It's not so much that the particular example (sort) is useful, it's that it teaches tricky but fundamentally useful ways of thinking.

    --

    [Ego]out

  116. BACK IN MY DAY by Anonymous Coward · · Score: 0

    We had to walk FIFTEEN MILES to get to our compiler, uphill both ways, in the snow!

  117. Programming is buisness/web programming syndrome by Anonymous Coward · · Score: 0

    You just keep seeing it, programmers who only deal with high-latency and/or low bandwidth applications on modern PCs writing op-eds about how "old school" programming techniques which involve actually understanding how computers work have become obsolete. The article makes a handful of valid points, but taken as a whole is completely off base.

    For perspective I'm a 29 year old software engineer working in the aerospace industry. In the embedded world, many of these techniques, and especially the need to understand them is not going away any time soon, and I'd wager it is the same anywhere that hardware capacity is not much greater than the load imposed by the problem.

    The biggest problems I've seen in my current project are inexperienced developers cramming "modern" programming idiom like multithreading into a program where a much simpler idiom like a state machine with select() would get the job done. Oh, and function pointers, they might have their place in some instances, but imo they are the modern equivalent of goto, potentially useful but used improperly they can have horrible effects on the readability of code.

    For a second opinion, I'll put on my amateur hardware hacker hat and laugh in the author's face. I'm assembling a BCD clock project running on a 16MHz microcontroller and I'm coding everything in bare C. OS? Libraries? What are those?

    Final note to the author. If you explicitly limit the domain of your claims to the sub-set of the industry that you actually work with, you'd have a heck of a lot less people heckling you about over-generalization. Then again you might just not care.

  118. The pitfalls and fun of threading, sans threads by clintp · · Score: 1

    My introduction to "multithreaded" code was on the Atari 6502 platform. I know it wasn't threads, but 25 years later it still feels like them.

    The vertical blank interrupt (as the television monitor scanning beam moved back into position) happened 60 times per second. In that brief amount of time, the 6502's normal instruction flow was interrupted and you could execute just a few instructions.

    This is where you read the joystick, played music, and did housekeeping. Of course, you didn't have time to do all of these in a single VBI so you'd develop a chain or round-robin of routines to run in the VBI.

    Lots of registers were off-limits in the VBI, taking too long could cause all kinds of weird effects, many memory addresses were overwritten without warning, side effects everywhere, and if you failed to return properly the game was over -- time to reset.

    Simpler times...

    --
    Get off my lawn.
    1. Re:The pitfalls and fun of threading, sans threads by nsaspook · · Score: 1

      I had the same "fun" with the Atari ST long ago.
      http://cd.textfiles.com/806atari/501-600/577/AMULTI13.FLD/AMULTI.DOC

      --
      In GOD we trust, all others we monitor.
  119. Re:swapping two values without a temporary variabl by scipero · · Score: 1

    Nice, though the last line should doubtless read:

    x = x - y

    No?

  120. 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.
  121. Lotus 1-2-3 Macros by FishBike · · Score: 1

    I'll tell one coding "technique" I certainly don't miss at all: the Lotus 1-2-3 macro. My first job after college was to finish development of such a macro, which had been started by the (non-programmer) owner of the consulting company that hired me. This multi-thousand line macro was the production scheduling system for a major transformer manufacturing plant. Back then a macro was simply a recorded collection of keystrokes with some control structures around it to do loops and branches and so on, nothing like the relatively well-structure VB macros of today.

    Amazingly, this thing actually worked. When the guy who hired our company to write it got a job with a competing manufacturer, he even hired us again to do the same thing all over again. We were determined to learn from the past and figure out how to write more structured and maintainable code the second time again. Unfortunately we were also determined to do it as a Lotus 1-2-3 macro again. I am so glad I quit that job before having to finish V2.0 of the Mother of all Macros.

  122. Made me feel old by Anonymous Coward · · Score: 0

    Hand sorting algorithms - check
    Custom linked lists - check
    Custom GUI interfaces - check
    Spaghetti code (w/ GOTOs) - check
    Manual threading/TSR apps - check
    Self modifying code - check
    Custom memory management - check
    Punch cards - nope (phew!)
    Text only dev tools - check
    Custom math and date logic - check
    Hungarian notation - check (Grrrrr!)
    Strange optimization techniques - check
    Forced patience - check

    I guess 12 out of 13 isn't too bad. Still, reading that article started to make me feel old. Thankfully, I got a small boost from having never had to use punch cards!

    1. Re:Made me feel old by bratwiz · · Score: 1

      TEXT !?!?! You had TEXT !?!?!?! Sheesh, all we had were blinking lights and toggle switches...

      I remember when the hot new feature was "address auto-advance"...

  123. Re:How about working with EPROM burners and eraser by hierofalcon · · Score: 1

    Yes. Although I tend to do most debugging on a Linux based hardware emulator I wrote, at times when debugging hardware issues, we still dig out our old Arium and plug it into the boards.

  124. Re:swapping two values without a temporary variabl by Pinckney · · Score: 1

    Note that STL swap(T&,T&) handles this case just fine, even if you try to use it on the same variable. Claim you'd never be so stupid if you'd like, but if anyone else uses your code, they will likely be annoyed if your custom swap(T&,T&) function fails so badly without warning.

  125. Re:swapping two values without a temporary variabl by Lord+Ender · · Score: 1

    And if you use that today, the maintenance programmers will kick your ass.

    --
    A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
  126. Age-old Question... by Anonymous Coward · · Score: 0

    This is really an age-old question that has effected other fields long before it has effected programming. The question I refer to is, of course, what is worth learning when training in the field (a.k.a. what are the essentials for an undergraduate degree)? If you look at mathematics curricula today, for instance you'll find the regular gambit of calculus courses along with a smattering of higher-level courses such as numerical analysis, abstract algebra, and (at some undergraduate universities) topology. These topics were not decided upon overnight... but over many years of teaching this material, it was determined that these formed the most valuable basis for other material that may interest the student.

    Today, most professional mathematicians specialize in a very specific topic for their graduate degrees and only have a "cursory" understanding of higher mathematics outside of their field of expertise. I think this is the direction computer science is heading. There are far too many languages, specializations, and paradigms already and that number is only growing by the day.

    This isn't an entirely bad thing - it means accelerated development of given topics - but it also leads to narrow-mindedness and an inability to connect concepts from different but related fields of study with concepts from one's own field. Pick your poison folks...

  127. Re:swapping two values without a temporary variabl by Asgerix · · Score: 1

    Ok, now do it with strings!

    --
    Life is wet, then you dry.
  128. Angular Integers by ciderVisor · · Score: 1

    This isn't always a bad thing. The one situation where integer representations really win is in angular calculations. If you represent the angles 0-360 degrees as 0 to 2^n bits, you can forget about overflows and just use the integer operators to perform addition and subtraction and throw away the carry flag. Finding the shortest distance between two angles is also an easy thing to calculate. If you use 32 bits to represent an angle, you can achieve accuracies to around 1/1,000,000th of a degree. Hell, even 16 bits lets you work down to around 1/200th of a degree.

    Be wary of 'upgrading' angular-integer code to utilise hardware floating-point units - the extra bounds checking required might negate potential speed increases.

    --
    Squirrel!
  129. I respectfully disagree by Weaselmancer · · Score: 1

    But by and large, the article is right -- there's a vast majority of places where these just don't matter anymore.

    IMHO, they are still relevant for a number of reasons:

    1) Not everything is coded in Java. I do a lot of embedded programming, bootloader code, and the like. You have to be able to knock out a ring buffer manually or you simply can't do this kind of work. It's great when I get to do Java/C# and all this stuff is already there, but more often than not I'm fiddling around in the bootloader or in driver source and it's all C to the wire. I know that colors my experiences though. But without the drivers and the bootloader, Java has nowhere to live in the first place.

    2) Even when you do have them premade, somebody had to put those functions in the libraries for you to use. From a certain point of view, the tiny minority of asm guys you mention are the vast majority - their code is copied over and over and over, every time you link to their work.

    3) Knowing what's under the hood makes you a better driver. There's your obligatory car analogy since we're doing it old school in this thread.

    --
    Weaselmancer
    rediculous.
  130. Punch Cards for input into MCNP5 by Chruisan · · Score: 1

    The input file for MCNP5 (http://en.wikipedia.org/wiki/Monte_Carlo_N-Particle_Transport_Code)used for nuclear engineering uses a punch card format. Each line in the input file is refered to as a card, and the file is called the input deck. The lines are limited to the same restrictions as a regular punch card, and the program will spit out errors if you do not create the input file properly.

  131. m_MemberVariable by Anonymous Coward · · Score: 0

    Please stop using "m_" as a prefix to a member variable of a class.

    Jeez, we all know it's a member variable.

    This falls under the same category as Hungarian notation. Stupid and useless.

  132. I've found plenty of bugs too by Myria · · Score: 2, Insightful

    Although it's generally true that what I initially think is a compiler bug is almost always my fault, I definitely run into actual compiler or library bugs on occasion.

    - I was working on some low-level boot loader assembly code, and found that "call esp" was not working as documented. It turns out that most modern Intel CPUs have a bug they haven't bothered fixing where it jumps to the value of ESP *after* pushing the return address. AMD processors don't do that, which is why it worked for me >_<

    - I found that a memcpy() in our Win32 "vectored exception handler" was corrupting memory. The code that caused the exception was a memmove() that had decided to go in reverse to ensure a proper copy. It turns out that Win32's exception handler stub wasn't clearing the x86 direction flag before calling exception handlers, a violation of the Win32 calling convention. Compilers assume that the direction flag is clear at the start of a function, so a constant-sized memcpy() will frequently get inlined as simply "rep movsd".

    - We found an extremely obscure bug in Visual C++'s compiler where it incorrectly zero-extended a pointer to 64 bits when it should have sign-extended as per the C standard. A global declaration like this was being used:

    int var;
    long long extended = (long long) &var;

    If the base address of a 32-bit program is >= 0x80000000, as occurs in NT device drivers, the extension to 64-bit will be zero-extended instead of sign-extended. This differs from what happens in local variables.

    In fact, getting this right is impossible with the relocations available to Win32 images and object files. The compiler should've thrown an error because it can't do the requested operation. (In C++ it could, but would have to make it a constructor.)

    --
    "Screw Sun, cross-platform will never work. Let's move on and steal the Java language." - Visual J++ Product Manager
  133. Punch cards and a a TTY. by Jaywalk · · Score: 1

    I was smart enough to use an interactive CRT session to debug everything first

    I had a punch card assignment as well (circa 1979 because "in the real world, everybody uses punch cards") but my preferred machine was a TTY. Part of it was because none of the engineering students knew the thing existed. It was in the basement of the dorm and it was mostly a commuter school. But it also meant I could get printouts any time I wanted. The tubes only had line editors anyway, so the teletype machine wasn't a big step backward anyway.

    --
    ===== Murphy's Law is recursive. =====
  134. Wrench, crescent wrench, crescent hammer. by SEWilco · · Score: 1

    He's right. At least the simple methods should be taught along with examples of when those fail, skim over some more advanced tools, and teach how to find the right tool for the job. Otherwise you'll encounter pinball machines that don't accept coins for a while because they're doing a bubble sort of all the games ever played (stored on a 500GB disk) so they can show the top score.

  135. Sometimes it's forced upon them by Moraelin · · Score: 1

    Well, I'll agree that often there is hubris involved. But sometimes they do have to optimize, though. Like, they hit deadline, and their code runs slower than a sleepy snail on sandpaper. With Slow cast on it.

    The client says, "this has to run at least 5 times faster or else."

    And nobody involved has more clue than building a cargo-cult program. In many cases nobody involved even understands the O notation.

    Enter desperately googling for ideas that they aren't even qualified to understand why they're bad ideas, or why the VM doesn't work that way.

    The "for an int Java copies the whole value on the stack, but for Integer it copies only a pointer" mis-optimization I mentioned in the other message, was born out of such an emergency. Their code ran like a 3-legged pig on greased ice, the client was unsatisfied, and they just had to try something before they bring in the consultants. Of course, the real bottleneck was how they used the database. But they hadn't figured that out.

    So they scratch their head and go, "let's use a cache." Which they promptly invalidate when they write something, and they're doing a read-compute-update loop there, so it really brings nothing except more complexity and more overhead.

    So their architect comes up with that... great idea ;) Let's replace every single int with an Integer, and every char with a Character at that, 'cause his half-knowledge made him infer that it would be somehow faster. They actually spent two weeks doing that change to their heap of code. Of course, it still doesn't run any faster. Luckily, not measurably slower either, because that's not the bottleneck anyway.

    Now what?

    Someone googles some more and comes upon such a "clever trick". The page is from the 90's, though, and that trick stopped working after Java 1.0.

    Lather, rinse, repeat.

    --
    A polar bear is a cartesian bear after a coordinate transform.
    1. Re:Sometimes it's forced upon them by lordtrickster · · Score: 1

      That's so depressing, heh.

      I guess my optimistic side would have expected the "architect" to know better. You'd think that by the point a person has managed to gain that title, they'd have enough overall experience that they don't just grab random idea A off of random page B and spend two weeks trying it without actually validating the idea. You've described an entire team that was doomed regardless of their knowledge of any one concept. Sounds like a group of people that went in for the money, not because they actually care to learn about what they do.

      ...a sleepy snail on sandpaper. With Slow cast on it

      Mad giggles

  136. Garbage Collection by kilodelta · · Score: 1

    The big problem with Windows applications today isn't so much garbage collection as it is bloated applications.

    Those advanced coding platforms might wipe the snot from your nose, but they still can't build tight code.

    E.g. Firefox with a number of add-ons consumes 123K of memory. Google Chrome - 19K. And lets not talk about the top RAM consumer on my system, iTunes.

  137. Manual multithreading and multitasking by T.E.D. · · Score: 1

    I once came across some code that consisted of many unrelated branches of nested loops spread across several source files. Everything was done in a loop, including calls to other routines (also implemented in loops).

    After puzzling over this for quite a while, I finally realised that this was an old Fortran programmer's way of implementing threads. The termination condition for these loops was typically seme kind of flag-signaled event, or a time expiring, whereupon the program would bubble back out of all the loops, then descend down some other path into some other inner loop to service the event.

    It was really beautiful Fortran code, very clean and organized. Sadly, he wasn't using Fortran anymore, but Ada, which supports threads in the language...

  138. Not quite that old, but wow by bryan1945 · · Score: 1

    My dad has told me stories of punch cards. I'm obviously a bit newer than that. I'm not a programmer, never was (except for Basic on my Apple II), but had to take some programming classes in college. Fortran, Cobol, and oh my, machine & assembly. What a mess that was. One project was to write a clock in machine. At one point my clock was running backwards because I misaddresed two registers, or some such. 2 years ago I had to take a Java class for my masters, Even though I read /. and vaguely know what's going on, wow I was blown away with all the crap that libraries hold now. You know that decimal to roman notation that all newbies have to write? After doing that, I contemplated how I would have done that in basic 25 years ago. No way I could have made it pretty.

    Feel free to make fun of me- I've never been a good programmer, which is why I went into engineering!

    --
    Vote monkeys into Congress. They are cheaper and more trustworthy.
  139. Re:Self-modifying code has been a lose for a decad by bcrowell · · Score: 1

    Self-modifying code hasn't been a win for performance since the Intel 286 (PC-AT era, 1985) or so. It might not have hurt on a 386. Anything later, it's a lose.

    Performance isn't the only reason for writing self-modifying code. For instance, the Motorola 68k had instructions for doing I/O to special hardware ports numbered 0-255. I had to write OS-level routines in C to do in(port) and out(port,byte). Because of the way the addressing modes worked, there was actually no possible way to implement this without writing self-modifying code. My boss didn't like it when he first saw it, but once he studied the addressing modes, he agreed that it was necessary. One worry was that the code would already be in cache before you modified it, so IIRC we did some jumps back and forth to make sure that the cache would get refreshed.

  140. Punched Card trick by Frequency+Domain · · Score: 1

    The author of the article mentioned that boxes of punched cards inevitably got dropped, and had to be restored to their proper order. Since many programmers ignored the sequence numbers in cols 72-80, or forgot them, a simple quick-fix trick was to draw a diagonal stripe across the top of the deck with a magic marker.

  141. Mel Kaye - not just an urban legend. :) by argent · · Score: 1

    Mel Kaye was a real person, and here's his signature to prove it.

  142. Interesting trend by Rorschach1 · · Score: 1

    In the embedded world, of course, you still get to use most of these tricks. Not to mention all sorts of low-level hardware hacks. I've written about that here before, but what I find really interesting is that despite the general trend toward ever-faster and more powerful embedded processors, there's at least one new core out there that's SMALLER than its 1970s predecessors.

    Freescale's (relatively) new RS08 core is absolutely Spartan. IIRC, the directly addressable memory is 256 bytes. Everything beyond that requires paging. No index register, but it's emulated with a couple of RAM locations. Some single-byte instructions act on only a 4 or 5 bit address space. The advantage of all this minimalism is that the parts can cost under 50 cents each.

    So not only is there still some need for all of the old tricks, but there are opportunities to learn NEW ugly hacks! I'm sure someone can come up with something suitably mind-blowing with an addressable index register and a processor architecture that supports self-modifying code.

  143. I'm being pedantic but by ClosedSource · · Score: 2, Informative

    just because you're trying to optimize the performance of your system doesn't make it a real-time one. If it were a real-time system, missing a timing window would result in your data being incorrect, not just tardy.

    1. Re:I'm being pedantic but by _merlin · · Score: 1

      It's real-time in that the data has to be processed and passed on within a reasonable time window, otherwise automated trading systems screw up. It's not like, say Photoshop, where it doesn't really matter how long it takes as long as it isn't so long that the user gets really pissed off.

    2. Re:I'm being pedantic but by ClosedSource · · Score: 1

      The difference is that in a real-time system time windows aren't vague but known precisely and the software is designed and tested accordingly.

      In general, if you make an existing real-time system run faster, it will probably fail. It's a bit like batting in baseball - swinging early is no better than swinging late.

  144. Re:Quicksort by Anonymous Coward · · Score: 0

    Ah, the missing piece of O().....it talks about the driving factors, but not the actual forumla as it relates to performance....

    n*log(n) + 15
    n*log(n) + 4000000

    That's how two algorithms can be seemingly different in performance......and for that matter, why Bubble Sort can still be somewhat relevant. Depending on your value of n, the most performant algorithm can change....and as you describe, border cases matter, too.

  145. Hungarian Notation Fail... by argent · · Score: 1

    The thing that pisses me off most about people who mindlessly follow Hungarian notation, even more than the ones who use hungarian notation in typeless languages, and that's the ones who don't realize that "sz" means "zero-terminated string" and tag all their strings in languages where the string is a first class opaque data type with "sz".

  146. Multi-threaded Code by bratwiz · · Score: 1

    Didn't Jacquard invent multi-threaded code???

  147. Re:Quicksort by Mr+Z · · Score: 1

    Quicksort can be made to avoid the O(n*n) pretty easily (randomly selected pivot goes a long, long way very cheaply), and in my experience it tended to be around 2x as fast for typical data. Of course, I haven't measured in a while.

    On deeply pipelined yet highly parallel machines, if you're sorting lots of small things, a modified merge sort combined with loopless sorting networks for the "leaves" (ie. subdivide only down to, say 16 elements and use a sorting network for the rest) can actually work better because of the inherent parallelism across the bushy parts of the tree.

  148. Re:Quicksort by not-my-real-name · · Score: 1

    This is true. There are certain pathological cases where Quicksort is O(n*n). Some tweaks have been done to the basic algorithm to remove as many as possible of these, but they are still there.

    If you know that your data is, or is close to, one of these pathological cases, then you will want to use another algorithm.

    I think that more important than knowing how to bang out various sorts on demand is knowing the characteristics of each one and when to use them.

    For example, if I only have 10 items to sort you might be better off using a simple O(n*n) sort rather than a complex O(n*log(n)) sort. If you know that your data is very nearly sorted, then a pass or two of a bubble sort may be all you need (this is one of the pathological cases for quicksort). If you know nothing about your data, then quicksort is probably a good start. And learn about your data.

    --
    un-ALTERED reproduction and dissimination of this IMPORTANT information is ENCOURAGED
  149. Re:Quicksort by fractoid · · Score: 1

    I remember a case study I read when I was a young'un about a particular data set, where the person writing the article settled on bubblesort, because a fast machine-language implementation of bubblesort was quicker than the quickest implementation of quicksort that the author was able to come up with.

    In the end, the fastest algorithm _in practice_ *is* the fastest algorithm, and should be used.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  150. Re:Quicksort by Mr+Z · · Score: 1

    Oh, and I forgot... heap sorts do have one place where they truly shine: Priority queues. The incremental O(log(n)) update to rectify the heap after an insert makes it a perfect candidate for priority queues.

    Of course, if you didn't take data structures and basic algorithms, how would you know this? :-)

    I guess if someone gave you a bag of higher level algorithms (STL and Boost come to mind in the C++ world) documented with big-Oh on all the pieces, you could still get by quite well without knowing the lower level details. Somebody implemented STL and Boost though.

  151. I still kinda like it by TrekkieGod · · Score: 1

    I'm one of the few people who actually likes a simple form of hungarian notiation. I understand the arguments against, and I understand the "apps hungarian" was the original intent, as a poster below notes, but I would still rather also see the type information. There's nothing wrong with additional information, as long as you still get all the other information you need, and as long as it's not confusing. Allow me to explain:

    1)Variables change type. And then you have to rename everything. Its a pain

    This was never an issue for me. The vast majority of the time a variable is constrained to a single file, for the rest of the times, I still have multiple-file replace tools.

    2)The extra information it gives you is minimal. I want to know what data is in a variable, not the language type used to hold it.

    Ah, yes. The information might be minimal, but it still saves me the pain in the ass to go look at the declaration if I need to. Yes, I know IDEs will give you that information automatically these days, but often I just ssh into a machine and do less on the source file (for this reason, I also limit my source lines to 80 characters).

    I agree that what data is in the variable is much more important, and I also include that in the variable name.

    If the name of the variable is firstName, I don't need it to be called lpcstrzFirstName, I know it's a string.

    True, and lpcstrz is more information than I would need to know with just a glance, so I wouldn't use it. If I really need to know if it's a long pointer or some other type of string, that happens so infrequently that it's not too bad to go look at the definition. However, is it a member variable for the class or a local variable within the function only? sFirstName would instantly tell me the string is local m_sFirstName would tell me it's a member of the class, without me having to go check.

    And the language type is rarely interesting- I want to know that the variable outsideTemp holds degrees farenheit, not that it's an integer

    Yes, but why are you so resistant to knowing both? I don't know if outsideTemp holds F, C, or K. I also don't know if it's an integer or a float, or for that matter, I don't know if it's a string representation of the temperature. I don't know if it's local or a member of the class. But if I name it, m_fOutsideCelsiusTemp, you get everything.

    3)It makes searching the code for a variable that much more annoying, because they all start with freaking 'i' and 'p'.

    Yes, but who cares what it starts with? If you're looking for the variable that holds outside temperature, you're not going to guess at the type or whether it's in F or C. You're just going to type grep -inH "temp" *.c, and vary the query depending on what comes up.

    --

    Warning: Opinions known to be heavily biased.

  152. Re:Quicksort by fractoid · · Score: 1

    And as N -> infinity, they are roughly equivalent. That's what big-O notation is about (not big O's, as you probably guessed...). It's about how the algorithm _scales_ as input sizes increase.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  153. Good and bad, but that's progress by ^_^x · · Score: 1

    I'm not a programmer, though I've enjoyed coding in various languages for hobby and as a student...

    Pointers can burn in helllllll... other than that, I'm kind of torn - I always enjoyed coding things as small and efficient as I was able, and even reusing variables for something else once I was done with them to avoid taking up ONE MORE BYTE of precious RAM, haha... on the other hand, when I first played with VB.NET I was enamoured with IntelliSense and the way I could just think up and idea for a program and then bang it out like I had an assistant handing me the right tools from my toolbox instead of wasting time chasing forgotten semicolons, or trying to make sure I was always using the right operators to refer to memory pointers, or in some cases, just trying to kludge a method to get some data passed to a function and back.

    So there are things to be said for both program efficiency and programmer efficiency, and it really depends on the project. I still think it would be fun to go into firmware or PLC programming some time to take advantage of small, efficient, reliable code on a limited set of resources though. There is a certain beauty to an elegant solution that can be more easily understood and appreciated by others on a smaller project.

  154. I Owe My Life's Work to Spaghetti Code by GMFTatsujin · · Score: 1

    I started programming on my C64 when I was seven years old. Commodore Magazine had reams of printed code to type in every month, and I was fascinated to learn how it all hung together to make a working program.

    In high school, I noticed a BASIC programming class offered, and I took it knowing I was in for an easy A. (I was a bored D student with an A+ brain, so that class appealed to me.) The first program was the usual HELLO WORLD deal with a few extras thrown in for interest. I coded it in the way I'd learned how. It was fast and easy.

    The next day, I found my printed program hanging up on the door with the words "NEVER DO THIS" in red ink blazing at the top. I brought it to my teacher and demanded an explanation. The code worked, it ran, it gave the desired output. What gave?

    Turns out the class was in *Structured* BASIC, which I'd never encountered before.

    My Teacher, Mister Maier, told me that it was obvious that I knew what I was doing with BASIC programming concepts, but learning how to structure my code wouldn't be significant work for me. I was already learning PASCAL and other structured languages anyway; it was easy to apply those ideas to BASIC, which I'd always thought of in terms of line numbers and GOTOs.

    Mr Maier offered to make me his aide: I wouldn't have to do all the boring programs and I would have unfettered access to the computer lab. In return, I would help him in class by assisting students debug their code and get ideas about how to tackle problems.

    His was a brilliant solution. He elevated the challenge level of the class to meet my skills. He showed insight and trust in *me*, which was something teachers didn't generally feel inspired to do around me previously. He gave me the opportunity to TEACH, and that kept my investment in the class surprisingly high. Suddenly my expertise in this esoteric arena began to pay off.

    Because of that, I became more invested in my own formal education, my confidence skyrocketed, I went on to college (which surprised everyone), graduated with honors, and pursued a Masters in Education.

    Mr Maier literally changed my life, and I have spaghetti coding practices to thank for opening that door.

    That, and a damn fine teacher.

  155. Whippersrnappers unaware of old-school techniques? by try_anything · · Score: 1

    Hell, we seem to be obsessed by them. We romanticize them. We justify using crappy obsolete technology by the fact that it caters to old-school techniques. We seem to think that if it weren't for the old-school techniques, there wouldn't be any opportunity to improve our software using hard work and ingenuity.

    "Our software sucks because we use Python, which doesn't offer any scope for hard work and ingenuity. Man, if we wrote in assembler or Perl, we could rock out with some wicked cool code and give our software the hard, nasty edge we need to kick ass!"

    No, no, the opportunities for hard work and ingenuity are sitting right in front of us while we daydream about how awesome we would be if the world hadn't gone all soft and candy-assed on us.

  156. My gawd by sbeckstead · · Score: 1

    Haven't seen old school programmers have this much fun arguing since the days of rec.arts.programming and rec.arts.software.engineering.

  157. Hungarian Notation by Dracorat · · Score: 1

    While TFA accurately points out that in most modern IDEs, you can point at a variable and see what data type it is, thus making Hungarian notation not needed, I disagree that Hungarian is deprecated.

    Few points:
    If I am reading code, I don't want to stop and point at variables to see what types they are.

    If I am doing a code review of printed out code or emailed code, I don't even have an IDE.

    And perhaps the most important: If I see something named pSomeValue but it holds data values itself instead of a pointer value (something you can usually see fairly easily in code when being misused) then I question it immediately and often find bugs right away. If on the other hand it was named "SomeValue" that wouldn't be the case. I may actually think it's being used correctly.

    Hungarian notation is as much as it ever was, one of the signatures of a programmer who knows what he's doing. (Or she!)

  158. Professionalism! by Anonymous Coward · · Score: 0

    Most working programmers don't have the balls to get their heads down and learn about the tools they use every day. They start and then go "gosh, that's hard", which soon translates into "hey, I don't need this academic bullshit to write a program!" and goes downhill from there as they struggle and squirm once they run into a real problem.

    It's rather pathetic, and sad. They like to look down at "college" programmers, and rightly, because many "college" programmers are so inept with actual tools that they can't get the connection between implementation and getting an "A" in their Data Structures class. But, the fact is that there are indeed "college" programmers who /also/ know what they're doing-- and, generally speaking, smoke amateurs for lunch.

    For real professionals, there's just no excuse.

    This article is amusing, but it also encourages the mediocre. Not understand sorting algorithms, some of the most insightful things you can do with a computer, simply because we know a couple of them are faster in most cases? Don't make me laugh. Ditto not being able to understand the actual "goto debate", etc.. Basically, there /ARE/ some things for which actual understanding is not optional and will make a big difference in how you program. If it doesn't matter for you, and you think typing "sort()" is good enough, then you take a big piss off a cliff and be content with your own pig snot.

    If anything, use this article for suggestions during your next interview: you'll separate wheat from chaff in a hurry.

    (Note: I certainly don't miss writing TSRs, though. ;-P)

  159. Because most people do it in an insulting way by weston · · Score: 3, Insightful

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

    Because you're essentially attacking them.

    What if I responded to you by saying: "I'm sorry, but if you don't understand how flatly attacking people's qualifications for their job is insulting and threatening, you shouldn't be having this discussion. You simply don't have the interpersonal skills to articulate this kind of thing in a manner that would be productive, let alone persuasive."

    Get your dander up at all?

    And please don't hide behind the "I was just stating a fact, if the shoe fits, wear it." There are lots of good ways to say what you're trying to get at that are probably even closer to the truth.

    Which is that really don't have to learn *everything* about computers in order to be good at computers. It is certainly an underlying truth that the more you know, the better you are as a developer. But it's entirely possible to be a reasonably productive developer without knowing everything... as long as your abilities are matched to what you need to accomplish. And there's more or less a curve of task difficulty to go along with a curve of developer abilities.

    I don't know very much about building compilers. Some people would say that makes me a mere dilettante of a software developer. That's a rash overstatement. It's absolutely true I would be a *better* developer if I knew more about these things, and certain problem domains would be more open to me, but there's a huge problem space that really doesn't require this knowledge. This works the other way, too: I probably know more about Linear Algebra and Discrete Mathematics than many developers and even some CS majors (studied Math in school) and I'm familiar with the Logic Programming paradigm (written full programs in Prolog). These things make me a better developer, particularly for some problem domains, but it certainly doesn't mean anyone who doesn't know these things is a simple hack.

    I think implementing hashes and other primitives that are now part of libraries/languages falls in this category. Being able to implement them is certainly a *demonstration* that you've mastered certain skills. The contrapositive doesn't necessarily follow. Not ever having implemented them -- in particular because you've never had to -- doesn't necessarily imply that you lack the ability to solve that class of problem.

    And in fact, it might demonstrate a certain stripe of wisdom: there's a limited amount of time and a pretty much infinite supply of problems. What do you spend time learning how to do?

    1. Re:Because most people do it in an insulting way by Count+Fenring · · Score: 1

      Well done! Also, your signature fills me with ineffable joy.

  160. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    Thanks for the trivia, but how do we actually know you can ship code on time, and within budget?

  161. Re:swapping two values without a temporary variabl by NewWorldDan · · Score: 1

    Dude, you're totally harshing the buzz here. You don't obfuscate your code to be "clever". You obfuscate your code because you can. Also, have you ever worked on an 8-bit embedded controller? Sometimes you don't have an extra byte for that temp variable. On the other hand, they've gotten so cheap and low power that those problems are a thing of the past.

  162. Re:Self-modifying code has been a lose for a decad by Anonymous Coward · · Score: 0

    hmpf hmpf, indeed code self modification without explicit synchronisation has never been supported in a backward compatible way on the x86 familly. It is even a way to distinguish between 8086 and 80286 (or is it between 80286 and 80386 ?)

    You also makes a lot of assumptions on conditions in which the code will self-modify ; it can indeed be interresting even on modern architectures if the code does not change very often, for example to enable / disable traces in a kernel.

    And it _is_ also possible on common RISC machines (you also have to use explicit synchronisation like on x86)

  163. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 1, Interesting

    y = x + y - (x = y)

  164. Re:Quicksort by gr8_phk · · Score: 1

    When you're aiming for realtime photon mapping, you start with a ray tracer that's already fairly optimised. Then you make the photons work. Then you optimise some more.

  165. Re:Quicksort by fractoid · · Score: 1

    Someone pays you to implement realtime photon mapping? Are they hiring? O.o

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  166. Re:swapping two values without a temporary variabl by Anonymous Coward · · Score: 0

    x = x + y
    y = x - y
    x - x - y

    The XOR implementation is not subject to overflow problems. (And the typo has already been noted by scipero.)

    Much less CPU intensive.

    That depends on the CPU. For example, on old x86 CPUs, XOR AX,AX was faster than MOV AX,0; generally, XOR was faster than MOV, ADD, and SUB.

    - T

  167. Over-Judging (Re:True story) by Tablizer · · Score: 1

    I generally agree. Most of us have at least some part of us that likes to learn by digging around in stuff rather than just reading the dry docs (no pun intended). Sometimes poking around will lead us to make mistakes, and sometimes it improves our knowledge. A worse-case outcome, like the hash example, is perhaps not representative of the net advantages of poking around. Sometimes you have to take a step back to move 2 steps forward.

  168. Interesting, but wrong on oh so many counts... by EightBitBanger · · Score: 1

    One of the things this article ignores completely is the area of embedded programming -- and there is still a LOT of it going on. There are still a ton of NEW projects being done based on 8051 and 6800 series derivatives -- and those are just two of the major architectures.

    Even if you are not specifically doing embedded programming per se, the more you know about the basic architecture of your system the more you can help the compiler take advantage of it.

    For instance, on the vast majority of processors comparing a register to zero is typically a VERY low cost operation. Furthermore, many processors have hard coded instructions that both decrement a register, compare it to zero, and branch if it is not. If you enable the most aggressive optimizations on some compilers they will attempt to do loop re-ordering (often with disastrous results) and do sometimes succeed. HOWEVER, more often than not there are chunks of code inside the loops that prevent effective re-ordering from occurring. If you are aware of your processors underlying architecture and try to intentionally write most of your loops as count down to zero in the first place, you make life much easier for the compiler and allow it to make more efficient code as a result. This is just one small case.

    Also, as far as hand optimizations go, I still do it quite often -- even at the raw assembly level. With visual inspection and manual adjustment I have proved time and time again that I can do a MUCH better optimizing job than the Keil compiler can. I can also typically get some gains on ColdFire/Freescale stuff as well, just not quite as drastic.

    I have worked on many projects over the years and seen more bad programmers than I care to admit -- and the most recent/youngest batch has both some of the best and worst I've ever seen (with far more of the later than the former). This is not their fault, it is the fault of what the university's are teaching them. At one company I used to work for (and this was a BIG company with over a hundred thousand of employees worldwide) our local HR department had a standing policy to NOT hire Computer Science graduates for permanent programming positions unless they had interned with us first. Basically, all the CS grads had far to many theoretical and inefficient/unreliable programming ideas to unlearn to be useful.

    Also, there are many cases where even hand manipulation at the raw binary code level is still needed and useful. Although most projects I deal with now, thankfully, use flash for code space, a few still do use OTP (one time programmable) parts. It has not been that many years ago that I had to spend the better part of 2 months figuring out a way to "overburn" a set of parts by finding a safe location where I could turn existing instructions into NOP's followed by a branch to a new chunk of code at the end of our programmed space (when re-programming/overburning an OTP you can still turn a 1 to a 0 but not the other way around -- thankfully, the architecture we were using considered 00 as a NOP and we had left all the unprogrammed space as FF's). And yes, this is a very extreme example, but it allowed me to find a fix that allowed us to use over 35 THOUSAND mis-programmed parts that otherwise would have had to be tossed (and these parts cost in the $12 range EACH).

    Similarly, on some large volume consumer products, manual code optimizations, low level coding, and hand tweaking is still the norm -- for a very simple reason: it saves money. In almost every case, it is still almost always cheaper to use the micros with less onboard flash and hand optimizing the code often allows us to keep code just below the threshold of the next size part. Similarly, on one project I was on we had 3 engineers spend 6 months hand writing a custom DSP algorithm that allowed us to remove a filter circuit whose component cost was on the order of $0.15 USD (yes, 15 cents). The management team was utterly thrilled over this as the volume for the circuit in question was way over 1 million units (you do t

  169. Re:Quicksort by pjt33 · · Score: 1

    Arrays.sort in Java uses mergesort rather than quicksort for objects because quicksort has one big downside: it's not stable. For primitives this doesn't matter, but for objects which might already be sorted on one field it could do in some use cases.

  170. Re:Quicksort by JasterBobaMereel · · Score: 1

    If you knew about sorting and had actually learnt it you would know that Quicksort is the default because is is usually the quickest and most efficient method, but on some datasets it can be slow or inefficient, and there are "better" sorting methods for that data ...

    You do not need to optimise quicksort (the version you are using is probably already more optimised than you can make it...), you need to optimise your use of it ... i.e. use it where it is appropriate, and use something else where it is not!

    --
    Puteulanus fenestra mortis
  171. Re:Quicksort by fractoid · · Score: 1

    If you knew about sorting and had actually learnt it

    Because obviously from my statement that "most library implementations of 'sort' are quicksort based", I know nothing about sorting. Yeah. >.>

    All rules of programming (without exception) can be replaced (for a sufficiently intelligent entity) with a simple rule of "don't be fucking retarded and do something suboptimal" - but that doesn't work so well as a directive to humans.

    --
    Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
  172. Re:Quicksort by Anonymous Coward · · Score: 0

    Yes, I've worked with the "optimise later" sort. Try this out: Phase I of the project sets up Hardware and Memory requirements, based on average memory usage for similar projects. Phase II sets up the infrastructure with whatever crap is easiest to through together, no optimization. Phase III get to write the program with 50% less memory than normal, and faster response. With less money, usually, and less people.

  173. sorting algorithms, hashtables, and trees (oh my) by ifeelswine · · Score: 0

    a few people have mentioned that you tend to not write sorting algorithms and data structures in this day and age. but it's still critical that they be understood so a developer can understand the trade-offs for selecting a particular library and also the requirements needed to interface effectively with the chosen algorithm. C++'s STL library does a very good job about being somewhat "in your face" about time complexity. Java's collection api, which is also a well designed library, is much less in your face about time complexity and the various trade-offs. Since I sling java code for a living, i'll whine about Java collections. #1. I have solved performance problems with large datasets simply by re-implementing the hashcode method on objects. When explaining that a hashtable (or hashmap in java parlance) degrades to linear time if the hash distribution isn't sufficiently sparse, i'm reminded that these concepts are new to the folks implementing systems on which multibillion dollar businesses are run. #2. explaining to folks why you have to override both hashcode and equals if you want to expect your stuff to work is equally as evasive as well as the following: #3. pointing out that you should re-put a stored object into a hashtable after you mutate because the hashcode may no longer be accurate. #4. explaining why when you iterate over a keyset for a hashmap things aren't in order, but when you use a treemap you are. #5. choosing a linkedlist for queue-like operations, choosing a treemap for natural-ordering, choosing a hashmap for good average performance. it would be nice if when these problems are encountered and unwound a lightbulb would go off and they said "oh! i remember this from CS-xxx class" but instead it's like.. "oh you're such a geek i bet you don't get laid much." i think we get in trouble when we attempt to make hard things easy. most un-zen-like.

  174. The list is inaccurate by drew_eckhardt · · Score: 1

    >Honorable mention: Implementing a linked list or hash table yourself

    In a lot of languages, you're going to implement your own linked lists if you want to have efficient in-order (LIFO or FIFO) and out-of-order removal.

    With the C++ STL list template you can stash an iterator in each object and it isn't a problem. WIth Java, Perl, and probably C# that's not an option.

    There are fewer situations where an off-the-shelf hash table implementation won't do the trick although they exist.

    >Manual multithreading and multitasking

    Most programmers can't make systems with multiple interacting locks work right. Thorough testing with contemporary tools is not possible, so customers are often the ones to find problems. For instance, I regularly crashed a SPARC running Solaris to the ROM monitor when doing a simple user space pthreads.

    Modeling tools like spin/promela exist to prove locking schemes are correct although locking is often a leaky abstraction and you can't guarantee the implementation tracks the model.

    Pre-emptively scheduled kernel threads don't perform and scale well enough for many applications. The C10K paper would be the first popular reference here. Non-premptive user space threads are a partial solution but still have a large cache and TLB footprint.

    Consequently, most smart people building reliable and performant systems software end up with message based concurrency control systems. With popular language support (Java, C++, perl, not Erlang or Haskell) lacking appropriate functionality and popular libraries (libevent) being incomplete and not working well in multi-core environments this is usually home brew (Google's kilim might be a good contemporary example). That's manual multi-threading and multi-tasking.

    A contemporary definition of "performant" should be on the order of 1M operations per second per node.

    >Honorable mention: Non-WYSIWYG editing platforms. Some of us remain comfortable with vi/emacs, command-line compile options or .nroff for documentation formatting, but initially we programmers didn't have a choice.

    I'll take vi and a text markup language over WYSIWYG editor any day. Multiple cut buffers make re-arranging text much faster. All of the meta-data is visible with the markup language and can be manipulated with the standard QWERTY keyboard while the WYSIWYG editor doesn't make all of it visible and requires traversing a maze of menus to make sense of it.

    With my roff and html resumes I've never had a problem getting bullets at the right indentation level on the first try. With Microsoft Word or Open Office I've had to do little dances with paragraph deletions because traversing the menu structure didn't always do the trick.

    This disregards productivity loss due to the temptation to play around with the layout instead of trusting the macro package to do the right thing.

    > Honorable mention: Writing your own utilities to search for where you'd used functions or procedures and where you'd called them.

    A coding standard makes that painless. Search for ^function( for the definition. Search for white space function( for use. Within a file an editor like vi will jump to the next reference with one key.