Slashdot Mirror


Dr. Dobb's Calls BS On Obsession With Simple Code

theodp writes "Over at Dr. Dobb's, Editor-in-Chief Andrew Binstock has a nice rant on The Misplaced Obsession with Simplicity. 'Any idiot can write complex code,' goes the old maxim, 'the true art is writing simple code.' Right, Andrew? Wrong (mostly). Binstock explains, 'It's not true that any idiot can write complex code. Complex code is difficult, often very difficult, to write. It's entirely true that it's more difficult to maintain, too. But that's the nature of complexity. Some things are intensely difficult to express in code and they require complexity, simply because they're not inherently simple.' After citing the complex-but-necessarily-so code of Al Aho and sometimes-misguided reverence for cyclomatic complexity limits to help make his point, Binstock concludes, 'My view of simplicity is unemotional and free of idolatry because I define it with respect to complexity, rather than the other way around: Simplicity is the quality of code that is no more complex than required to express the underlying complexity. In this way, simple code can be intensely complex. There is no inherent good/bad dichotomy.'"

58 of 381 comments (clear)

  1. To quote Einstein by BenSchuarmer · · Score: 5, Insightful

    Everything should be made as simple as possible, but not simpler.

    1. Re:To quote Einstein by girlintraining · · Score: 5, Funny

      That quote is attributed to Einstein, but you should know by now a great many quotes are attributed to him, but very few can be proven to have been from him. -_-

      "There's no such thing as a correct quote citation on the internet." -- Abraham Lincoln

      --
      #fuckbeta #iamslashdot #dicemustdie
    2. Re:To quote Einstein by Spy+Handler · · Score: 5, Informative

      It's paraphrase of Einstein who said something like that at various times in his life, but not those exact words.

      Here's an exact quote from Einstein:

      "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience." - From "On the Method of Theoretical Physics", Oxford, June 10, 1933.

    3. Re:To quote Einstein by lgw · · Score: 4, Insightful

      Arguing against stupid "complexity metrics" is fair. A programmers job is to game the system. Give him a metric other than making the customer happy, and it will not end well.

      But I've seen far too much code that was simply far more complex than it needed to be. Stop tripling the size of your code for use-cases that no one has asked for, people!

      If you can make assumptions that significantly simplify your code, and those assumptions fit within the actual, stated requirements of the work (ignoring requirements that exist only in your head), for goodness sake make those assumptions.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    4. Re:To quote Einstein by 93+Escort+Wagon · · Score: 3, Funny

      In the words of Albert Einstein: "I never said most of the things I said."

      --
      #DeleteChrome
    5. Re:To quote Einstein by internerdj · · Score: 4, Insightful

      Not all customers are smart enough to know to ask for everything. Even a smart customer may not be able to give you a real answer for what happens in X cornercase. Presumably you (or someone like you) are being paid to hash out all the hidden requirements and assumptions to achieve the customer-stated requirements.

    6. Re:To quote Einstein by djdanlib · · Score: 2, Interesting

      Stop tripling the size of your code for use-cases that no one has asked for, people!

      Yeah, just let it throw a bugcheck when something happens outside of the design parameters and let the user sort it out with your support department. /sarcasm

      Security risks. Data corruption. Performance edge cases. Productivity loss. Unexpected bluescreens. Actual damage to physical hardware controlled by the software. You know all that bad stuff could have been easily prevented if the programmer anticipated those situations, and the people hiring that programmer probably expected the software to be well-made... It's much less expensive to do it ahead of time than to fix it when it breaks. Change in development = cheap, change in production = expensive.

    7. Re:To quote Einstein by Zalbik · · Score: 4, Insightful

      Presumably you (or someone like you) are being paid to hash out all the hidden requirements and assumptions to achieve the customer-stated requirements.

      Yes, but this should be done prior to code writing.

      Far too often I've seen extremely complicated code designed to handle "what-if" scenarios that never happen.

      i.e.
      Developer: "I wrote that configuration module in case they ever need to change the parameters of X"

      Me: "Did you ask if X would ever need to be reconfigured?"

      Developer: "Of course! And the client said that sure, if I could make it configurable, go ahead and do so"

      Me: "And did you ask how likely it would be that X would need reconfiguration? Or under what circumstances X would need to be reconfigured? Or what types of 'reconfigurations' they think they would need? We're looking at 2 man-months of code, plus testing, plus implementation time here....was any kind of cost-benefit analysis done to see whether it was worth it to write this?"

      Developer: [blank stare]

    8. Re:To quote Einstein by Honclfibr · · Score: 5, Funny

      Clearly, not taking his own advice here...

    9. Re:To quote Einstein by gstoddart · · Score: 3, Insightful

      Stop tripling the size of your code for use-cases that no one has asked for, people!

      So, we should stop doing any bounds and input checking if the client didn't ask for it explicitly?

      Is this part of Agile Programming or something? Write the most incomplete code you can get away with because it isn't in the spec?

      I once had a co-worker bitch and complain I was checking the result of every single function, including strprintf() -- he said it was unnecessary. Not long thereafter, we spent some time tracking down a problem which turned out to be in his code, because he wasn't checking anything (again, because it was 'unnecessary').

      If you write shitty, incomplete code up front, it's much harder to make it less shitty and incomplete later. If I know from experience there's a bunch of things that can go wrong, I'm going to try to account for as many of those things as possible when I write it.

      Those use-cases nobody asked for can sometimes be the difference between code which collapses at the first unusual inputs, and stuff which can at least tell you WTF went wrong. Because sometimes, even the simplest of things can fail.

      --
      Lost at C:>. Found at C.
    10. Re:To quote Einstein by lgw · · Score: 4, Interesting

      Those things aren't part of the formal requirements in your world?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    11. Re:To quote Einstein by Anonymous Coward · · Score: 3, Insightful

      Clearly, not taking his own advice here...

      Dude, the man ushered in a revolution in physics. His idea of simple would melt most people's brains.

    12. Re:To quote Einstein by lgw · · Score: 2

      Very well put. So much needless code comes from trying to support actions that the customer will never actually care about.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    13. Re:To quote Einstein by gstoddart · · Score: 4, Interesting

      Those things aren't part of the formal requirements in your world?

      I've never seen formal requirements which detail every edge case I need to account for.

      There's an assumption we'll be writing robust code, and as it gets created we build in as much error checking and handling as we can think of, and over time you usually end up adding more.

      If coders had to be told in writing every error condition to check for, there wouldn't be any -- because the client wouldn't know (especially true when you have to create a library to do some of the work), and the developers would just say "not in the spec".

      Come to think of it, I've never seen formal requirements for much more than the really high-level systems stuff. From my perspective, a system which has been fully designed and spec'd out before anybody writes code is a myth.

      --
      Lost at C:>. Found at C.
    14. Re:To quote Einstein by ZahrGnosis · · Score: 5, Insightful

      I think you're confusing feature-creep with a comment that was meant to be about edge-scenarios. Allowing someone to configure parameters that were never spec'ed to be configured is feature-creep (gold plating, extra coding, call it what you will), and I agree should be avoided and adds unnecessary (or not obviously necessary) "complexity".

      Handling an edge criteria that was implied but not explicit in a specification is what is typically meant of "corner case", and is not the same thing you described. Recognizing that the customer asked for something logically impossible (they want two data sets to reconcile, but they are at unexpectedly incompatible cardinalities), or something that, upon investigation while building an app, wasn't precise enough (they asked for this to be their standard green, but their standard list only includes red and blue).

      It's nearly impossible to specify all of those prior to coding, which is why the typical "waterfall" development techniques have fallen out of vogue. You're always going to learn things while coding, and this is one of the main contributors towards apparently unnecessary complexity. If I design version 1 of a program perfectly, and customers have new requirements for version 2, it's unlikely that the "simplest" implementation of version 1 will be the one that is most conducive to an upgrade. You end up with a choice between refactoring completely or sacrificing some efficiency and simplicity to graft the new features onto an otherwise good version 1.

      I think Dr. Dobbs is nitpicking, though. There are definitely many ways to address, measure, or understand simplicity, and I agree that it should not be THE goal in and of itself. But the idea of making code easy to read, easy to understand both in the micro and macro sense, and just generally "simpler", has many merits.

    15. Re:To quote Einstein by Anonymous Coward · · Score: 3, Funny

      I've seen extremely complicated code designed to handle "what-if" scenarios that never happen.

      As is usually the case, XKCD covered this well. The image title is particularly good:

      I find that when someone's taking time to do something right in the present, they're a perfectionist with no ability to prioritize, whereas when someone took time to do something right in the past, they're a master artisan of great foresight.

    16. Re:To quote Einstein by plover · · Score: 3, Insightful

      The efficiency of a system can not simply be measured by CPU cycles. It all depends on where your costs are. Efficiency has to be measured by money.

      If your highest costs are in runtime efficiency, then yes, you need efficient code. But if your highest costs are in end-user time spent entering data, usability beats efficiency. If your highest costs are driven by software engineering practices, such as testability, reliability, supportability, frequent deployments, etc., then readability becomes far more important than efficiency.

      The usability argument works like this: if I have to pay a barrista $10 an hour to touch 20 buttons just to place an order for coffee, and the user time per button press is 3 seconds while the system time per button is 8 milliseconds or less, the efficiency of the code is almost irrelevant. My development investment is best spent in reducing the number of button presses. If a fancy GUI and a magical "do what I want" button reduces the 20 button touches to 10, I can save 30 seconds of labor per cup of coffee. If adding that fancy GUI increases the system time from 8 milliseconds to 30 milliseconds per button press, I haven't actually incurred any additional labor costs because the system is still faster than an average human's response time (maybe not in a highly caffeinated coffee shop, but it's still far less important than saving even a single button press.)

      I've found that in most business applications user time is the largest expense, by a very wide margin.

      If libraries of tested proven code are cheaper than hand written assembler, I don't want to pay a developer to replicate that work, even if it would be theoretically more efficient - unless the program that they're working on has efficiency as the most important goal. If I was developing an algorithm for slinging polygons at a graphics card, you better believe I'd squeeze every cycle out of the GPU. But if I'm figuring tax on a cup of coffee, or the total of a chart on a web site, efficiency isn't nearly as important as provable correctness.

      Lest you think I'm trying to defend the stupid walled gardens of iOS and their ilk's practices of constraining UIs and simpleton features, I'm not. I do think that there needs to be a mix, however. To use your iPhone rant, first remember that the iPhone is sold to completely average people, therefore, a simple UI is the primary requirement. (In other words the "dumbwagon" must be the default.) Furthermore, it should be restricted so that Joe Average can't accidentally screw it up to the point where it's impossible for him to recover to the dumbwagon state. Beyond that, however, everything else should be possible - there should be advanced configurations, user scripting, compilers, all that stuff that makes a computer do what I want. (And that's why I hate Apple.)

      --
      John
    17. Re:To quote Einstein by Ash-Fox · · Score: 2

      Yes, but this should be done prior to code writing.

      Considering how often clients will sign off on something and then double back on what they signed off on, and ask for changes and sign off on those new changes which then invalidate some requirements that were previously implemented but because they were signed off, it's a requirement... I think expecting these situations to be completely resolved beforehand is wishful thinking.

      Me: "Did you ask if X would ever need to be reconfigured?"

      Developer: "Of course! And the client said that sure, if I could make it configurable, go ahead and do so"

      Why is the developer handling requirements and not someone dedicated to dealing with business logic? Your developer should be talking to your project's business analyst about these things, not the client. Your projects don't sound very well setup, you're clearly missing vital controls. No wonder why you have problems with developers.

      --
      Change is certain; progress is not obligatory.
    18. Re:To quote Einstein by KingMotley · · Score: 2

      Is this part of Agile Programming or something? Write the most incomplete code you can get away with because it isn't in the spec?

      Yes. It's part of TDD, where the coder is supposed to write the absolutely smallest set of code that passes said test.

    19. Re:To quote Einstein by aztracker1 · · Score: 2

      I find that this is most often the case when people will use "Enterprise Design Patterns" for small projects that do not inherently need them. Much of the time this makes things more complex with no real benefit.

      --
      Michael J. Ryan - tracker1.info
    20. Re:To quote Einstein by Belial6 · · Score: 2

      That is only if you look at the problem from strictly a developer's point of view. In many environments, new applications mean greater accountability, and often increased workload generated by the software preventing work tasks from getting 'lost'. From a manager's point of view, the greater accountability is good thing, and the employees should have been doing all of the tasks all along. After all, it is hard to argue with a manager that "If we use this software, we will have to do our jobs completely.". The argument that "We have not been doing our jobs completely because we do not have the staff to do the job completely." gets heard and acted on as if it is only "We have not been doing our jobs completely.".

      Thus, the users who are now being put in, quite frequently, the role of completing impossible tasks are going to be hostile to the introduction of the software. Whether the company is run well or badly, they likely have some of the more trusted users assigned to acceptance testing. These users can have a vested interest in exploiting even the slightest ambiguity in the spec. If they can find anything that could be construed as being incorrect, they will happily send you back for another round of updates. This can be dragged out for months before management decides to pull the plug on the project completely.

      If you are an in house developer, you have just wasted a huge amount of time, and your project has been a drain on the company. If you are an outside developer, you now have to take a loss on payment, or call in the lawyers. None of these options are good.

      Conversely, a few configurable items can nip this behavior in the bud. There are only so many times that a hostile user can declare an application unusable due to a button name preference, or icon color when each declaration is responded to with a "No problem. You are just looking at the default. It is a customer configurable feature. Just click on settings and there is a field to set it to whatever you want.". After the 3rd or 4th time this happens, the ploy starts to wear thin. Eventually management steps in to put an end to it.

      Just as both simplicity and complexity can be taken too far, so can configuration. Counting on customers to always know or understand when configurability makes sense is a recipe for disaster.

  2. Meh by Anrego · · Score: 5, Insightful

    Interesting article, but this seems an issue of a very pedantic interpretation of a common idiom.

    When I (or I suspect most) whine about pointlessly complex code, it's just that. Code that is more complex than is reasonable for the problem. No one expects a simple solution for a challanging problem. It's an overly complex solution to a simple problem which we complain about...

    1. Re:Meh by Anonymous Coward · · Score: 2, Insightful

      I think Dr. Dobb's stopped being relevant oh like 10 years ago. Its like a total kids magazine now, nothing like it was years ago. Most articles in it are unreadable.

    2. Re:Meh by spiffmastercow · · Score: 2

      One of the programmers I work with complains when you use more than 1 function to do a job. Even if it means writing a 20 page function. His code is unmaintainable because you can't change even a tiny part of it without breaking something 3 pages down. He cries that my code is too complex because I break things down into small simple functions and multiple files and build complex behaviors out of them so he has to swap between files.

      He used to work on IE at Microsoft, so that might tell you something.

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point.

    3. Re:Meh by rwv · · Score: 2

      It wasn't until the mention of Cyclomatic Complexity that I understood what the summary was saying. It boils down to writing individual functions logically with as many if/else/while/for/switch branches as you need. Oftentimes, breaking up code into multiple functions to satisfy some arbitrary Cyclomatic "Complexity" coding standard makes it MORE COMPLEX. On the other hand, Cyclomatic Complexity can be used to find spaghetti code that would make a good project for refactoring. At the end of the day... human analysis figures out what is simple vs. complex. It's impossible to know how complex a piece of software is with code metrics alone.

    4. Re:Meh by ewibble · · Score: 2

      Reuse, and breaking a problem in simpler logical blocks are both valid reasons to use functions, the latter helps in understandability and limits scope since you can more clearly determine what the inputs and outputs , and intent of a function is (as long as you name it right). You can also read the main function easier.
      ...
      int id = findIndex(name,table);
      ...

      reads much easier than:
      ...
      int id = -1;
      for (int i = 0; i < table.size; i++) {
            if (strcmp(name,table.data[i].name) == 0) {
                    id = i;
                    break;
            }
      }

      ...

    5. Re:Meh by T.E.D. · · Score: 4, Insightful

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point

      I disagree, strongly. Breaking a large routine into smaller ones abstracts away what those smaller routines are doing. It puts a boundry around their interaction with the rest of the code, and puts their code away somewhere that I don't have to worry about, unless there's some reason I want/need to know the details of how that routine accomplishes what it does.

      If you put it all flat into one big routine, I have to read and grok everything in that routine, if only to reassure myself that none of it has interactions with the one area I care about.

      We actually have terms for this stuff: Cohesion and Coupling. Cohesion in particular is an important concept here.

      I find it amusing that the author's big example is Aho's parsers. Parsers are one of those special cases, as lexical analysis is a problem that is generally best solved by state-machines. I've tried for years, and really there aren't a lot of good ways to code lexer state machines that aren't either way slower than the typcial implementations, or a web of control flow that looks like a huge mess to those of us reared on structured programming. It isn't talked about much, but lexers (and some parsers) unashamedly make use of goto statements as their core braching mechanisim. Using Aho's awk parsing code as an example of why "clean" code isn't always desirable is like using the US Marines as an example of why killing people is often a good option for solving disputes. Perhaps its true in a technical sense, but its really crappy advice to be giving the general public.

    6. Re:Meh by spiffmastercow · · Score: 2

      Reuse, and breaking a problem in simpler logical blocks are both valid reasons to use functions, the latter helps in understandability and limits scope since you can more clearly determine what the inputs and outputs , and intent of a function is (as long as you name it right). You can also read the main function easier. ... int id = findIndex(name,table); ... reads much easier than: ... int id = -1; for (int i = 0; i < table.size; i++) { if (strcmp(name,table.data[i].name) == 0) { id = i; break; } }

      ...

      My guess is you're going to use findIndex more than once in your programming career though, making it a prime candidate for function from code reuse standpoint. I consider this a poor example. It's hard to find a good counter-example, because there have been very, very few times in my career where I've written code that I couldn't reuse. In my experience moving code off to a separate function for no other reason than to clarify the code only helps clarify the code for the initial author, not for those who have to dig through all of his nested one-use functions to figure out what's actually going on.

      I will concede that separation of concerns is a good reason to break apart single-use operations. But not arbitrarily based on code size.

    7. Re:Meh by ebno-10db · · Score: 2

      Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

      I miss nested functions - they were very useful for just that sort of thing. It also clarifies that nested function g() exists only to implement something in enclosing function f(), which is often the case when breaking thinks up for clarity rather than trying to write reusable functions. Since a nested function can access the locals of its enclosing function, it also often avoids having to pass very long argument lists.

      Nested functions were a standard feature of Algol family languages, but unfortunately died w/ C (though gcc supports nested functions as an extension). These days many people seem unaware that there even is such a thing as nested functions.

    8. Re:Meh by spiffmastercow · · Score: 2

      Breaking even a single operation into smaller blocks it a good thing, if it spans hundreds of lines.

      I miss nested functions - they were very useful for just that sort of thing. It also clarifies that nested function g() exists only to implement something in enclosing function f(), which is often the case when breaking thinks up for clarity rather than trying to write reusable functions. Since a nested function can access the locals of its enclosing function, it also often avoids having to pass very long argument lists.

      Nested functions were a standard feature of Algol family languages, but unfortunately died w/ C (though gcc supports nested functions as an extension). These days many people seem unaware that there even is such a thing as nested functions.

      Nested functions are quite nice, and are actually supported by most higher level languages in common use these days. It's a much more appropriate way to break up code than putting bits and pieces all over the place just to reduce the size of a single code block.

    9. Re:Meh by spiffmastercow · · Score: 2

      Most higher level languages in common use? C, C++, Java don't have them. What other language is in "common use" these days? PHP?

      Actually, the latest C++ and Java implementations do support it, as do C#, VB, Lisp variants, Python, and Scala, and most any pure functional language. Anything that supports closures supports this to some degree (the readability of the solution varies, however).

    10. Re:Meh by MrChips · · Score: 2

      Do you re-use your functions, or do they only exist to break apart a single operation into smaller blocks? If it's the latter, then he may have a good point

      I disagree, strongly. Breaking a large routine into smaller ones abstracts away what those smaller routines are doing. It puts a boundry around their interaction with the rest of the code, and puts their code away somewhere that I don't have to worry about, unless there's some reason I want/need to know the details of how that routine accomplishes what it does.

      Both approaches have merit and should be used where it makes sense. When abstracting away some lower level detail, a separate method may be best, but when breaking a higher level method into it's higher level steps (if that makes sense), keeping it all in one method keeps it linear which can help with reading/review.

      It matters though how a method is broken up. Use whitespace to separate logical sections. Have a short comment at the top of each section to indicate what that section does. Write the comments first as an outline of the method. Declare variables where they are first used. Declare them in a limited scope where possible. Declare them const where possible (especially if method-global) to limit later misuse. In some languages you can introduce a nested scope for no other reason than to isolate local variables if you like.

      And note that breaking the method into separate sub-methods doesn't necessarily solve the problem of changes near the beginning breaking things later on. It just makes it harder to know where the "beginning" and the "later on" are.

  3. Einstein quote by olsmeister · · Score: 2

    The way I heard it was "Everything should be made as simple as possible, but no simpler." However I have since learned that me be a paraphrase of the actual quote, "It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience."

  4. Agree, but not completely by parallel_prankster · · Score: 5, Insightful

    I have often noticed that complexity is added to code when it grows over time. Typically, a project starts off very well. We have requirements and we use the best possible design with limited future expansion capabilities and come up with simple code that works well. However, over time, things change and we come across situations that the original code cannot handle. But instead of writing from scratch, we hack it and that is how complexity and subsequently bugs get added. In my experience, the base infrastructure code for any system always looks simplistic and beautiful. The ugly part is often how it has been used over the years.

  5. Carpetbombing Philosophy by Anonymous Coward · · Score: 2, Insightful

    You know what's bad?
    An object with a single 2200 line method that takes 70 parameters

    You know what's also bad?
    300 tightly coupled classes that have no individual use.

    Striking the balance is what is really important and there's no one size fits all metric for that beyond peer review.

    I find myself cringing every time someone comes in and makes a grand sweeping statement about simplicity or density or whatever else because it ignores problems by carpet bombing a philosophy.

    Cyclomatic complexity doesn't mean much without analysis.

  6. Premise is wrong. by Anonymous Coward · · Score: 2, Insightful

    Any idiot can write complex code.

    Bzzt, wrong. It's:

    Any idiot can write complicated code.

  7. "rant" is a nice way of putting it by girlintraining · · Score: 5, Insightful

    "Simplicity is the ultimate sophistication."
    -- Leonardo da Vinci

    "Plurality should not be assumed without necessity."
    -- William of Ockham, often referred to as Ockham's Razor -- the simplest explanation is usually the right one.

    "Everything should be made as simple as possible, but not simpler."
    -- Attributed to Einstein

    "If you can't explain it to a six year old, you don't understand it yourself."
    -- Albert Einstein (attributed)

    "Truth is ever to be found in the simplicity, and not in the multiplicity and confusion of things." -- Issac Newton

    "Beauty of style and harmony and grace and good rhythm depend on simplicity."
    -- Plato

    "The greatest ideas are the simplest."
    -- William Golding, Lord of the Flies

    "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage to move in the opposite direction."
    -- E.F. Schumacher

    "Those guys are all wrong."
    -- Andrew Binstock, Editor in Chief, Dr. Dobbs

    Choose well, reader...

    --
    #fuckbeta #iamslashdot #dicemustdie
    1. Re:"rant" is a nice way of putting it by chthon · · Score: 2

      In anything at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away.

      Antoine de Saint-Exupery (1900 - 1944)

  8. interesting topic, disappointing article by dirtyhippie · · Score: 2

    Frankly, I was a little disappointed in this article. His arguments seems a bit - for lack of a better term: simple.

    Is there anyone out there who is arguing that simple solutions to inherently complex problems exist and are a good thing?

    1. Re:interesting topic, disappointing article by Hentes · · Score: 3, Insightful

      Complex problems are defined as problems with no simple solution. The article is not just simple, it's a tautology.

    2. Re:interesting topic, disappointing article by fahrbot-bot · · Score: 2

      Frankly, I was a little disappointed in this article. His arguments seems a bit - for lack of a better term: simple.

      Well... Any idiot can make a complex argument. :-)

      --
      It must have been something you assimilated. . . .
  9. PEP20 by RobbieCrash · · Score: 3, Interesting

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.

    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.

    --
    Keep on knockin'
    https://robbiecrash.me
  10. Good design is simpler than no design by joeaguy · · Score: 2

    Simplicity is word that gets batted around a lot. When it used to mean "the shortest distance to a solution to the immediate problem", you are often trading immediate simplicity for longer term inflexibility.

    I've found the simplest solutions are those which are well designed, which take into account not just the immediate problem at hand, but reasonable future variations of that problem. The up front investment in thought and design and pay off in a big way down the road when new problems can be solved more elegantly, quickly, and be more maintainable.

    Its like someone who collects books. You could just stack them up on the floor, but finding one or adding more is going to increase the chance that they all fall over. If you take the time to get some bookshelves and think of a cataloging system, your book collecting is going to scale much better.

    Good design and good structure benefit simplicity. If you ignore it, you are just pushing complexity into the future.

  11. Re:So the news is... by SirGeek · · Score: 2

    The people who I think need to be berated are the folks who write the obfuscated code or do things like overload operators not because they need to, but because they can.

    I think you mean beheaded. And their heads mounted on the wall above the server room :)

  12. Clever code by Teckla · · Score: 2

    Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

    -Brian Kernighan

  13. He just redifined everything. Its a strawman. by Karmashock · · Score: 4, Interesting

    When you redefine your opposition's argument and then knock it down with your own argument it is called a strawman. That's what he just did there.

    No one is saying in regards to simplicity that all programs should be two line bits of nothing.

    What people are instead saying is that code should be efficient, tight, and achieve the end goal as simply and directly as possible.

    What we are and have always been talking about is efficiency. It goes back to the first computers that had very limited memory. They required VERY efficient code because they simply didn't have the storage or memory to run anything that took up more space. As a result, code for those machines tended to be very very efficient. It was a requirement.

    When we complain about complexity, we are not complaining that the task of the program is too complex. Rather, we're complaining that the program is badly coded. We are complaining that it is inefficient and disorganized.

    So nice try. Try again.

    --
    I've decided to stop wasting my time responding to AC trolls/sockpuppets... so if you want a response from me... login.
  14. Once again reinventing Fred Brooks by dkleinsc · · Score: 3, Insightful

    Brooks made a big point in "No Silver Bullet" about the difference between what he called accidental complexity (introduced by the developers) and essential complexity (introduced by the reality of the problem). And the key thing is that the accidental complexity needs to be avoided or fixed with tools, but the essential complexity can't be avoided.

    --
    I am officially gone from /. Long live http://www.soylentnews.com/
  15. The truth revealed by sl4shd0rk · · Score: 2

    "I had incorporated some sophisticated regular expression pattern-matching.."

    So many simple projects turn the corner of complexity, and never look back, right about at that statement.

    --
    Join the Slashcott! Feb 10 thru Feb 17!
  16. How Long Is A Man's Arm? by guttentag · · Score: 2

    In journalism school I had a professor who had personally interviewed the Dalai Lama and as a result he often had a very practical outlook on things. When he gave us our first writing assignment (an obituary for a famous person of our choice who was still alive... I decided William Safire had died of a heart attack upon learning that genetic testing proved Hillary Clinton was not, in fact, a congenital liar), someone immediately asked how many column inches he wanted. He replied with a question: "How long is a man's arm?" People started trying to measure their arms against things or guesstimate the average length of a man's arm, asking if that meant he wanted 30 column inches. Finally he quieted everyone and said, "A man's arm is long enough to get the job done. No more. No less." Likewise, the articles we were to write were to be long enough to get the job done. No important things left out, no filler added in. It was an important lesson in judgment.

    I think the same applies to code. It should be just complex enough to get the job done. No more, no less. Sometimes that means you're going to have complex code, but it shouldn't be any more complex than it needs to be.

  17. His only source contradicts him by Hentes · · Score: 2

    "I had incorporated some sophisticated regular expression pattern-matching technology into AWK Brian Kernighan once took a look at the pattern-matching module that I had written and his only addition was putting a comment, 'Abandon all hope, ye who enter here.' As a consequence, neither Kernighan nor Weinberger would touch that part of the code. I was the one who always had to make the bug fixes to that module"

    Even the source he cites admits that complex code is a bitch to maintain.

  18. he'd still be wrong, see machine code by raymorris · · Score: 4, Insightful

    Compare .NET code to the compiled machine code.
    Which is easier to understand and work on? The .net runtime is nothing but a set of functions in a separate file. using simple functions means main()can be an outline of the program, for example .

    By any measure, Linus Torvalds is an incredibly successful programmer. His guideline is 6-8 lines per function or so.

    Consider these two example programs:
    Stand
    Turn left
    Walk four steps
    Turn right
    Walk two steps
    Turn right ... 1000 more lines

    Vs:
    heatlunch()
    readslashdot()

    Even if the function heatlunch() is used nowhere else, using it makes the program far more understandable than inlining the walking code to get to the microwave.

    1. Re:he'd still be wrong, see machine code by spiffmastercow · · Score: 2, Insightful

      Compare .NET code to the compiled machine code. Which is easier to understand and work on? The .net runtime is nothing but a set of functions in a separate file. using simple functions means main()can be an outline of the program, for example . By any measure, Linus Torvalds is an incredibly successful programmer. His guideline is 6-8 lines per function or so. Consider these two example programs: Stand Turn left Walk four steps Turn right Walk two steps Turn right ... 1000 more lines Vs: heatlunch() readslashdot() Even if the function heatlunch() is used nowhere else, using it makes the program far more understandable than inlining the walking code to get to the microwave.

      But you forget you also have to walk back to your desk.. At that point, you have two usages of a pathing algorithm.. Which means you're repeating code, which means that using a function to enable code re-use instead makes sense. I'm hardly an advocate for complex functions (most of my code are 1 or 2 liners), but there are times when you simply cannot express something concisely in a short function, and the answer to that is *not* to artificially reduce it into code that does nothing but resides in a different location.

    2. Re:he'd still be wrong, see machine code by DahGhostfacedFiddlah · · Score: 5, Insightful

      On the other hand, even if code isn't used in more than one place, that doesn't mean it's not "expressing something concisely".

      Additionally:
      1) Methods are great ways of naming orthogonal snippets of code, rather than using a comment that may become obsolete.
      2) Breaking large methods into smaller ones increases maintainability by enforcing certain constraints such as not reusing variables declared 100 lines up just because they happen to serve similar purposes.

      I agree that you don't want to just arbitrarily break your method up for the sake of smaller methods, but I don't think reuse is necessarily the best way to judge whether methods should be refactored.

  19. tame complexity with useful abstractions by dickens · · Score: 2

    Even very complex problems can be made to look simple at various levels of abstraction. Hiding complexity inside objects that represent real-world objects is a good way to make the code that uses those objects simpler.

    In development, plan to do at least one major refactoring after the project is feature-complete to move complicatons in and out of abstractions, add new abstractions or collapse old old ones as needed to make things "feel good".

  20. Re:Hello World! by fatphil · · Score: 2

    A separate class - are you mad? Just template them on , sheesh!

    --
    Also FatPhil on SoylentNews, id 863
  21. Garbage Can Coding by DahGhostfacedFiddlah · · Score: 2

    I liken this to an overflowing garbage can. Every subsequent coder delicately places his code on top of the steaming pile, praying that it all holds together.

    Then someone makes one too many changes. The pile topples, and the poor sod who touched it last is the one who has to take the garbage out (rewrite it).

  22. need to spec appropriate level of robustness by Chirs · · Score: 2

    I work on highly-available systems (telecom equipment, core network stuff). Even there, some parts of the system can be less robust and some parts need to be as robust as possible.

    The design for a given component needs to take into account how robust that component needs to be. Do you check EVERY POSSIBLE error condition and figure out intelligent ways to handle them (can be quite difficult and very time-consuming) or can you just panic the system if you detect something has gone wrong and you don't know how to handle it?

    In some cases, you need to trade off between reliability and performance. In other cases you need to ship a product so it goes out with known corner cases that aren't handled because in the real world that condition should never happen.

  23. Elegant by Zaphod+The+42nd · · Score: 2

    There already exists a word for "no more complex than required", and that term is ELEGANT.

    Its been around since the beginning of programming. Get with the program. This is a non-story.

    --
    GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-