Slashdot Mirror


Literate Programming and Leo

jko9 writes "First proposed almost 20 years ago by Donald Knuth, the idea of Literate Programming is basically that of making program documentation primary, and embedding code in the documentation, rather than vice versa. Despite some obvious advantages apparent to anyone who has struggled to understand a poorly documented program, literate programming never really caught on. That all could change, however, with the release of a new program called Leo, written by Edward K. Ream. Leo supports standard literate programming languages like noweb and CWEB, but with a crucial difference - Leo adds outlines. The effect is striking: overall organization of a program is always visible and explicit. Much of the narrative of the documentation gets placed in the outline, making documentation simpler, and allowing viewers to approach the code at various levels of detail. Screenshots and tutorials for Leo are here - if that site gets slashdotted, you can download the visual tutorials in .chm form or html form from Leo's Sourceforge site. Leo is an open source program written in Python. Any current practioners of Literate Programming techniques out there? People who have tried it and given it up? Can the addition of outlines to Literate Programming make it more powerful / popular?"

358 comments

  1. no thanks... by Anonymous Coward · · Score: 0

    i'll stick to JavaDoc

  2. Finally by maf212 · · Score: 0, Interesting

    its nice to see people trying to help out slashdotting.
    Maybe we can get other posters to get a few backup links in their posts to try to alleviate the load on these poor sites.

    --
    --Note to self. Add witty sig here, someday...
  3. Literate Programming by bigjocker · · Score: 4, Interesting

    My previous employer had a strict rule concerning code: you first write the JavaDoc for all the project, then implement it. It's useful as hell ... and if you mix that with UML design before the documentation, its a killer technique.

    --
    Life isn't like a box of chocolates. It's more like a jar of jalapenos. What you do today, might burn your ass tomorrow.
    1. Re:Literate Programming by Anonymous Coward · · Score: 0

      That seems a little too 'waterfall'-y for me.

      If you follow the RUP-ish approach of Object modelling, sequence diagramming, and documenting in a java-doc form, you'll find its the nicest approach you've ever used...

    2. Re:Literate Programming by Anonymous Coward · · Score: 0

      In that scenario (and in my school's freshman CS classes, which is where I got the idea), what would be useful would be a utility that parses valid JavaDocs, and outputs a subsequent Java class with all of the data members declared, and the methods stubbed out, like reversing the javadoc util.

    3. Re:Literate Programming by bigjocker · · Score: 3, Interesting

      In that scenario (and in my school's freshman CS classes, which is where I got the idea), what would be useful would be a utility that parses valid JavaDocs, and outputs a subsequent Java class with all of the data members declared, and the methods stubbed out, like reversing the javadoc util.


      Try XDoclet for that. Its still in beta, but a lot of people (including me) use it for production.

      --
      Life isn't like a box of chocolates. It's more like a jar of jalapenos. What you do today, might burn your ass tomorrow.
    4. Re:Literate Programming by ipjohnson · · Score: 1

      Oh my god ... you mean an actual process? What a crazy concept "think before you code."

      Its called engineering.

    5. Re:Literate Programming by smagoun · · Score: 2
      In a similar vein, take a look at the Sandboss project . It's an open-source implementation of something called "Structs and Nodes Development"; it makes heavy use of javadoc + code generators to drastically simplify programming large distributed systems.

      While the implementation isn't complete (yet), the concept works amazingly well (I used a previous iteration at my last job) and saves literally man-years of development on large projects. Very cool stuff...

    6. Re:Literate Programming by rot26 · · Score: 1

      Its called engineering.

      "Engineering" requires measurability and repeatability, something that (as I understand it) Göedels implied can't be done. And in any case, if it IS possible it won't be a language-only based solution. I think. Probably.

      --



      To ensure perfect aim, shoot first and call whatever you hit the target
    7. Re:Literate Programming by Raiford · · Score: 1
      Funny you should point this out since object modelling and integrated circuit design have such similarities. How many chip designers would go right to fabrication before pencil/paper -> simulator -> hardware ? Many (if not most) programmers don't seem to think this way though.

      --
      "player 4 hit player 1 with 0 stroms"
    8. Re:Literate Programming by ctrimble · · Score: 3, Informative

      Actually, it was completeness and consistency that Godel tackled, and he proved it (rather than implied it). Complete = all true statements have a proof. Consistent = p & ~p is not a theorem of the system. This is for all systems strong enough to support the Peano axioms (and some weaker systems, I believe). However, 1st order logic is both complete and consistent.

    9. Re:Literate Programming by SerpentMage · · Score: 4, Insightful

      Being a professional engineer this is not how you approach the problem whatsoever. No engineer in their right mind writes the documentation ahead of time. Actually there are engineers that do that, but they work for the government.

      Real engineering is tinkering and logging what you did. In engineering there are three phases, which involve tinkering and experimenting and doing simulation. The second phase is coming up with a game plane. With the last phase being the implementation.

      And engineers do just jump in and do something when they know what they are doing. An engineer is an engineer because they know how to guess-estimate. That is why an engineer goes to school for 4-5 years to learn what engineering is. They when you need to tinker and when to jump in!

      The problem in IT is that you have people who do not have enough engineering education to know what they are doing. And by education I do not simply mean school education, but training or simply good mentoring.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    10. Re:Literate Programming by iabervon · · Score: 2

      The problem, of course, is that you don't know what features your code will need to have until you write the code that uses it. If you do too much design in advance, you'll have a wonderfully designed project which is impossible to implement (and now I use some information which I haven't been provided access to...) or which has lots of methods which aren't actually useful.

      The only reasonable way to write code is to document it at the same time as you're implementing it: afterward, you've forgotten how it works, and before you don't yet know how it works. Of course, you'll want to do higher-level design beforehand, but be aware that your design must be flexible, in case it turns out not to work that way.

    11. Re:Literate Programming by Anonymous Coward · · Score: 1, Funny

      I think we're talking about real engineers, not Sanitation Engineers, such as yourself.

    12. Re:Literate Programming by ipjohnson · · Score: 1

      God help me if I have to use anything you design ....

      Its not so much documentation as thinking through a design before diving in. For some small things you can just do documentation and code at the same time but for very large chunks of code that need to work with other you need to lay the design down first before implementation. Its just the way things work. You need to be able to explain you ideas to co-workers/system engineers who ever needs to know.

      Coding and engineering are 2 different animals and not enough programmers do the later. If your car failed as much as software does would it be tolerated? Its because of people with a mind set like yourself that throws stuff together and say "there it works" ...

      And don't even get me started on software testing ....

    13. Re:Literate Programming by ipjohnson · · Score: 2, Insightful

      Actually there are many ... many different ways to measure software one of the ones we use is "McCabe Complexity" along side a handful of other metrics. Hell CMU came up with a rating system for software engineering groups called CMM that evaluates your process as well as your process to change your process (defect reduction and what not).

      I'm not saying I agree with them but they are out there. I personally feel coding is a craft and not a science ... but management doesn't like to hear that because it means results are less reproducable. Thats a whole other can of worms.

    14. Re:Literate Programming by ipjohnson · · Score: 2, Insightful

      The trick is to have the requirements laid out. I know thats not possible some of the time but for the most part you should not be writting production code until most everything is nailed down. That said pathfinding (i.e. writting code to test theory) should be done before sitting down to write the real code.

    15. Re:Literate Programming by Raiford · · Score: 1
      Hmm, I am an engineer with a PhD and I worked for the federal government for 12 years (NASA). We did some tinkering with stuff but that rarely led to much of anything useful. The process I learned and practiced was get your idea on paper in the form of a conceptual design. Run the numbers, iterate on that and then finally go build something. That is about the only way to do it a far a large development projects like spacecraft and aircraft are concerned.

      --
      "player 4 hit player 1 with 0 stroms"
    16. Re:Literate Programming by Anonymous Coward · · Score: 0

      Programmers don't create physical "things." The home builder/circuit design analogy is flawed. If a programmer screws something down you don't have to tear down a house to fix it: you hit the delete key. That's not to say that you shouldn't have an amount of upfront design. I just qiestion 2 facets: 1. how deep it needs to go 2. do the people that try to compare software dreation to building physical things think before they analogize

    17. Re:Literate Programming by Raiford · · Score: 1
      Programmers don't create physical "things." The home builder/circuit design analogy is flawed. If a programmer screws something down you don't have to tear down a house to fix it: you hit the delete key.

      Speaking of flawed logic: Both equate to manpower and dollars wasted for ill-planned effort ! The only distinction that exists between the two is that a computer program doesn't involve material costs (which often times, especially now in the electronics industry, is the minimal expense). Every other aspect of the model fits.

      --
      "player 4 hit player 1 with 0 stroms"
    18. Re:Literate Programming by ipjohnson · · Score: 1

      I'm sorry but if a programmer screws something up it can be just as deadly as building a house with 87 degree joints ....

      Just because you can hit the delete key doesn't mean it solves the problem ...

    19. Re:Literate Programming by Bush+Pig · · Score: 0

      This is pretty much what my uncle (a retired civil engineer) did. He always says that a good engineer is a bloke who can design a building that almost falls over.

      --
      What a long, strange trip it's been.
    20. Re:Literate Programming by Kiwi · · Score: 2
      The only reasonable way to write code is to document it at the same time as you're implementing it

      I find that I write better code when I first put out a basic sketch of the design. Basically, the data structures used, the names and arguments for the functions, and what the functions do. Once this is sketched out, I go about actually writing the code in question. I will generally actually making up more functions than what I sketeched out, and will change some of the arguments that the functions receive.

      I find that the code I write while designing the strucutre is more bug-prone and difficult to maintain; "play it by ear" is not a good way of working for projects of any significant complexity.

      Since Slashdot has zapped signatures (in the defulat config), I will referer people to my main software project. This project is my most ambitous project to date; it currently has over 24,000 lines of code (including comments).

      My experience with looking at the source code for projects is that the main problem is not how people comment the code, but that people generally do not comment their code at all.

      - Sam

      --

      The secret to enjoying Slashdot is to realize that it should not be taken too seriously.

    21. Re:Literate Programming by jaoswald · · Score: 2

      To expand on your point:

      Programmer's create mental "things" which are just as expensive, in terms of mental effort, to tear down and rebuild as it is expensive, in a material sense, to tear down and rebuild a house.

      If a programmer screws something down, someone else may have read it and written other code that depends on it. Any changes need to be broadcast to the other developers who might have used it, causing them to have to relearn what they have done and rewrite their code. That's potentially a huge cost in developer effort and frustration.

      Why else is "backward compatibility" is such a byword?

    22. Re:Literate Programming by Elanor · · Score: 1

      "It's useful as hell"
      "its a killer technique"

      Excuse me, but I don't know if you're saying they're good things or not. AFAIK, hell isn't p'tcularly useful, except maybe for toasting marshmallows. Is "killer" a positive adjective?

    23. Re:Literate Programming by ebbe11 · · Score: 2
      Real engineering is tinkering and logging what you did. In engineering there are three phases, which involve tinkering and experimenting and doing simulation. The second phase is coming up with a game plane. With the last phase being the implementation.

      Thank God bridges aren't built that way!

      --

      My opinion? See above.
    24. Re:Literate Programming by SerpentMage · · Score: 2

      I think you were not reading my post or you read the first line and not the rest. There are 3 phases

      1) Tinkering, experimenting and get an idea of what is going on.
      2) Putting together a game plan
      3) Implementing the game plan

      In fact my approach works better because it gives you an idea before you know what is going on. Then when you have an idea what is going on then you implement. When I said a game plan I mean formal definition, which could be documentation, models, etc.

      Those that document ahead of time actually waste time because you are going to change your mind anyways until you actually know what you are going to do.

      Nowhere did I say just do it and then say there it works.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    25. Re:Literate Programming by SerpentMage · · Score: 2

      Excuse me, but they are... Nobody in their right mind is going to let you build a bridge without having built a small model ahead of time. Models, simulations, tinkering are the heart and sole of engineering. Civil engineers will go out and plop down some concrete to test some ideas to see if they work. If you design a bridge solely by paper you get the same error that occured with the Tacoma bridge and the harmonics.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    26. Re:Literate Programming by iabervon · · Score: 2

      I like to just start writing code, but what I'm actually doing is a sketch of the design; it's just that I'm using a programming language rather than something less formal and more ambiguous. Generally, my first version won't remotely compile; it's not to actually be run, but rather to show data structures and flow control. I actually sometimes write it in a different language (Scheme is good for designing some things; Java is great for deciding where you need function pointers). If I've written it in the language I'm going to use, I avoid mistakes in translation.

      I think the code you write while designing the structure should be either thrown away and replaced with code written after the structure is designed or should be essentially pseudocode (but in the language you're using: it should have comments or function calls instead of any non-trivial operations, and only idiomatic control structures).

    27. Re:Literate Programming by Anonymous Coward · · Score: 0

      Hello, my full name is David Speed Ream. I am known as Speed to friends and enemies alike, but I gladly answer to David or most any other handle. I am an unabashed and biased fan of Leo, the fact that it was written by my brother Edward only slightly coloring my already colored glasses. I have been testing and using LEO in software production for over 4 years. My company currently has over 50,000 lines of code in over 100 source files that are written using LEO. My comments are from two points of view, the first being software project manager for a complicated, multi-module software product, and the second being as a production line coder. For me, LEO's greatest and only real drawback is the learning curve. This learning curve can be shallow is if all that is required is that someone code using LEO. However, in our company we allocate 40 to 80 hours ON TOP of the normal coding load for someone to come up to speed on LEO. The ROI (return on investment) is calculated by me to be on the order of 3 months. So if I hire a consultant for less than 3 months, I don't teach him LEO, even though all source code in our company must reside in LEO files for the reasons I won't go into now. I consider that my coders are 15 to 30 percent more efficient in their daily operations than my competition's people. This indefensible claim of mine is based on the changes in my productivity as LEO grew from a test document production tool to the primary production method for all our assembly, c and cpp source code. Personally, I hate to deal with documentation when I write code, except: 1) When I am first sitting down to solve a new problem. Then the documentation becomes quite long-winded and pontificatory, as if I were the only one on earth smart enough to solve the problem - or 2) When I come back to code I or someone else has written and find the documentation insufficient to understand the code without study (seems to be most of the time). So I do not require my engineers or myself to do a great job of documentation, nor do I use LEO for that purpose. Rather, it is LEO's outlining and organizing ability, and LEO's ability to create source files from within the outline that give me what I think is a tremendous competitive advantage. Each of my company's products run on all versions of windows from Win 3.1 to XP. In our flagship software piece, there are ten main modules, and each module is maintained by one single LEO file. In the CODEC module, one LEO file named compress.leo organizes and creates seven .asm files, forty-four .c files, twenty .h files, two .def files, four .mak files, etc. etc. etc. This one file can be checked out from source code control and given to an engineer for the addition of a new feature. In it are contained all the known issues for the CODEC, each issue arranged in its own clone section. One clone section groups together every routine, variable or type definition that must change between different versions of Windows. These sections could be from six different c source files, two assembly files, and eight .h files. Another clone section groups together those sections relating to memory problems, which change according to the memory configuration and TSR configuration (or lack thereof) on the target machine. Another clone section groups sections that fail (or don't fail) if the routine in question was accidentally run during the dreaded 'interrupt time'. Another clone section is a section containing clones, each of which is named after the major bug that was fixed when the engineer who fixed the bug grouped a bunch of routines, definitions, etc. together to fix the bug. None of the above clone sections was 'designed' into the document. Just the opposite happens. When the codec was first written, there was just a single LEO file with a bunch of sections for each c routine or assembly module. As the product grew and was tested on various platforms, each failure of the module was organized into clones each time a failure was fixed. This is what I call "SELF DOCUMENTING CODE". This has nothing to do with me sitting and documenting anything. Its just that the STRUCTURE of a bug fix (or product enhancement) lives on long after the coding is done, as long as no one is foolish enough to delete the cloned sections that 'DOCUMENT' what happened. In actual practice, this organizational 'history' is so powerful that I can't begin to describe it. A 'REVERSE LEARNING CURVE' happens when an engineer gets a LEO file that already has the 'interrupt time sensitive' routines grouped together by the last unfortunate soul who had to work on them. There may not be any more written documentation, but the knowledge contained in the structure can be breathtaking. It is certainly timesaving. I find this particularly true in my own case. Often I'll look at some code that seems totally unfamiliar and think 'what idiot wrote this crap'. Then I'll look at the version control comments and realize that I wrote the crap. Then for sure I know the documentation is non-existent, but the clones I used to develop it are still there, and they always serve to refresh my memory in an indescribable way. Enough of this commentary, I just looked at the clock. Best wishes to anyone willing to try LEO for a week. I hope you will be glad you did.

    28. Re:Literate Programming by ebbe11 · · Score: 2
      Civil engineers will go out and plop down some concrete to test some ideas to see if they work.

      That's right - but they won't call it the real bridge afterwards. They call it a test, an experiment and throws it away when they're done with it.

      No so in SW-development where the kluged-up prototype often becomes the Application 1.0 because management don't think there is time to do it right.

      --

      My opinion? See above.
    29. Re:Literate Programming by Anonymous Coward · · Score: 0

      This model my be the only way around the "plan to throw the first one away" problem, but it may just be a way to shorten the time it takes to get the first one out.

  4. Programs as flat text files - why? by Animats · · Score: 4, Interesting
    It's wierd, when you think about it, that programming is still done in flat text files. Almost nothing else is still done that way. One could argue for programs in HTML, with the code bracketed in XML so that the compiler could find it.

    Few systems even allow multiple fonts in program text, although the original Bravo editor for the Xerox Alto did.

    1. Re:Programs as flat text files - why? by Hard_Code · · Score: 2

      "One could argue for programs in HTML"

      HTML is still fat text files.

      A more novel idea would be to keep a "live" database of code modules at the method-level, and programs would be an aggregation of such modules.

      --

      It's 10 PM. Do you know if you're un-American?
    2. Re:Programs as flat text files - why? by Shaleh · · Score: 1

      ther reason is doing that basically forces a special programming editor on you. Most UNIX people have long known that editors are very, very personal and would thus fight this to the death.

      In my experience there has always been more code than docs so I have never seen the use of the literate technique or your suggestion of ?ml.

    3. Re:Programs as flat text files - why? by GusherJizmac · · Score: 3, Interesting

      Because it works. It is a logical and physical way to break up your code. Why else would it be in use for almost the entire existence of programming? Also, you say "Almost nothing else is still done that way". HTML is done in flat files. You just break it up according to however you want. XML files are just "flat text files" when you get down to it. The few things that aren't "flat text files", are binary proprietary formats to the detriment of everyone. MS-Word isn't a flat text file, and as such, it's very difficult to read.

      And furthermore, what does putting code in XML give you that you can't do now? Why do you need different fonts? Fonts are for layout and presentation, not for communicating instructions to the computer. Most editors support syntax highlighting, which is all you need.

      --
      http://www.naildrivin5.com/davec
    4. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      It's called Lisp.

    5. Re:Programs as flat text files - why? by mystik · · Score: 3, Funny

      program in html/xml? Lisp/scheme lends itself nicely to this, witness:

      (display (+ 4 (+ 3 4)))

      becomes

      <display> <+>4 <+>3 4</+></+></display>

      --
      Why aren't you encrypting your e-mail?
    6. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0
      I guess you've never used VB.


      Actually, though, ProjectBuilder on Next allowed you to connect objects to do most of the GUI programming. You still needed to write the objects yourself (as "flat" files).


      Why is a "flat text file" bad? Modern editors/ides do stuff like syntax coloring, show what parameters a function takes, and auto-complete functions.

    7. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 1, Informative

      Userland Frontier/ Radio is exactly that.

      It has an object database with script objects, outlines, and other bits that mimics a file system. The scripts are presented as outlines, one method per window.

      Since scripts are outlines, you can expand and collapse bits to show what you're working on. I find it painful to go back to a flat file text editor, even a good one.

    8. Re:Programs as flat text files - why? by joto · · Score: 2

      I would probably say the opposite. Lisp/scheme is a much more useful data-representation than XML. My eyes hurt by seing the lower expression :-)

    9. Re:Programs as flat text files - why? by I+didn't · · Score: 1

      Because computer memory is flat.

    10. Re:Programs as flat text files - why? by mystik · · Score: 2

      Definatly agree. Which begs the question, why is html still tag based, and wastefully duplicating information?

      --
      Why aren't you encrypting your e-mail?
    11. Re:Programs as flat text files - why? by krogoth · · Score: 2

      Because no one has come up with a better way. Show me a way that tags, colours, and fonts can make things easier for me and I'll use it.

      --

      They that quote Benjamin Franklin on liberty and safety deserve neither.
    12. Re:Programs as flat text files - why? by mmol_6453 · · Score: 1

      Methinks tags are more intuitive. How many eight-year-olds can look at your average C utility, then look at its code, and be able to figure out what does what?

      --
      What's this Submit thingy do?
    13. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      The prototype Apple Dylan implementation stored program code in a database, with indexing, cross-references, dependencies, etc. all built in. It was apparently very cool. Unfortunately, Apple won't release it. A few people have it on CD, but no one I've talked to.

      Actually, the Dylan language specification says that a file is only one possible form of "source record", the source record being the unit of compilation.

    14. Re:Programs as flat text files - why? by Mr.+Sketch · · Score: 2

      Along these lines, I agree. My general argument is that the storage of the files should be independant of the way it's viewed by my editor. Just some small examples:
      1) It shouldn't matter if the file has spaces or tabs, but if I like seeing things indented 2 spaces, and the guy next to me likes seeing it indented 4 spaces, then when I open the file, I should see 2 space indents and when they open the file, they should see 4 space indents.
      2) If I like seeing pointers declared:
      int* a;
      and they like seeing
      int * a;
      then when I open the file I should see the former and they should see the latter.
      3) If I want to see:
      for (int i = 0; i < 10; i++)
      {
      cout << i;
      }
      and they want to see:
      for (int i=0;i<10;i++) {
      cout<<i;
      }
      etc.

      I hope I'm making my point clear that the way code is seen by each person should be a property/configuration of their view, not related to how the physical file is stored on the disk. That way when I'm looking at someone elses code it won't matter how they format it or if they mix tabs and spaces for indents and I have my tabs length configured differently it won't look terrible, etc.

      The cpp file could be stored in some flat XML/HTML format as long as each view knows how to display it for each person, is all that matters.

    15. Re:Programs as flat text files - why? by aricusmaximus · · Score: 1

      Taking that argument further along, it's time to go back to programming in assembly, or better yet, binary. High level languages are overrated, anyhow.

    16. Re:Programs as flat text files - why? by zimbu · · Score: 1

      Because its much easier to detect and locate errors with tags rather than parantheses. If I'm missing a closing bold tag in HTML its simple for a parser to detect two open bold tags with no close in between. If you're only using parens you're out of luck. See XML is not S-Expressions for more in depth analysis.

    17. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      You mean like Smalltalk?

    18. Re:Programs as flat text files - why? by starling · · Score: 1

      :wq

      Use :x and save yourself a keystroke.

    19. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0
      I'm working on a system where programming tools operate on a program model in memory that gets serialized to XML. It's far from straight forward, but so far I've bootstrapped much of my own DOM implementation to use the system.


      While XML is hardly ideal for the end user if editing it directly, it's sufficiently clean that I can work with the XML files until I get an editor that can hide the details going.

    20. Re:Programs as flat text files - why? by PainKilleR-CE · · Score: 1

      VB's just a front-end to the flat text files. Open a .frm file in a text editor and you'll see the code at the end of a string of properties that describe the form, which is simply hidden by the VB editor.

      That being said, the IDE does a lot to make those flat text files less flat, even moreso in VS.Net with outlining, regions, and so on.

      --
      -PainKilleR-[CE]
    21. Re:Programs as flat text files - why? by rabidcow · · Score: 2

      It's wierd, when you think about it, that programming is still done in flat text files. Almost nothing else is still done that way. One could argue for programs in HTML, with the code bracketed in XML so that the compiler could find it.

      Ok, first of all, the actual storage method is irrelevant. As someone else mentioned, XML/HTML is still flat text files, at least as far as source is. (is it really flat if it's got nested namespaces?) Databases can be stored to flat text files.

      What you're really interested in is how you find a piece of code and its documentation, whether you have to scan through that flat text file yourself to find it, or if there's some other access method. There *is* another access method, it's called an IDE. Ever use MS DevStudio? You can browse the source by objects, by project, "flat text file" groups, all sorts of things. You can jump from a call of a function to its implementation very quickly, or to the definition of a variable. I think it's probably the best Microsoft product ever.

      Now, as for why flat text files (despite the fact that it's irrelevant), it's easier for the current tools to work with, it's backwards compatible, it's easy for the programmer to understand if the sugar on top fails to work right, it's portable. There is no good reason to *not* use flat text files. (well, ok it fails the buzzword test.)

    22. Re:Programs as flat text files - why? by PainKilleR-CE · · Score: 1

      The cpp file could be stored in some flat XML/HTML format as long as each view knows how to display it for each person, is all that matters.


      I agree up until that point. There should be no need to change the existing cpp format, the editor should be able to handle this on it's own with the existing un-marked-up text. Maybe it's just me, but I don't get it when the damned thing can be colour-coded, outlined, syntax errors underlined, and on and on, but the editor can't simply strip white space when it saves the file and then add spaces (and/or tabs, breaks, etc) according to user settings when it's loaded. Someone invariably doesn't indent any of their code or is completely inconsistent throughout their code and I end up having to read it. Bleh, maybe I'll just work on it to figure out why it's not already done in VS, considering how many things it already does.

      --
      -PainKilleR-[CE]
    23. Re:Programs as flat text files - why? by Ed+Avis · · Score: 3, Informative

      Programs are not stored in 'flat text files', at least not unless 'flat text' also includes XML. Programs follow a particular structure and syntax which can be automatically checked and parsed, just like any particular XML format.

      Think about it. You could have a programming language with a ... construct. Or you could have exactly the same logical structure using { and } instead. XML or non-XML is mostly a red herring.

      Some very weird languages like Unlambda or Forth might qualify as 'flat text', but almost all languages used today have a hierarchical tree structure in each file.

      --
      -- Ed Avis ed@membled.com
    24. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      Use emacs. Write your own customized extensions. Use other people's extensions. It's not *that* hard.

    25. Re:Programs as flat text files - why? by Tablizer · · Score: 2

      (* It's wierd, when you think about it, that programming is still done in flat text files. *)

      It is odd that *files in general* still uses hierarchical directories. I agree that trees are (initially) conceptually easy to understand than the alternatives, but being easy to understand is not necessarily the same as being productive. It is time we byte the bullet and grow up from trees to sets. Sets are more general-purpose and handle orthogonal organizational criteria much better.

      My rant on altnerativges

      Sometimes I put code in tables also.

    26. Re:Programs as flat text files - why? by grumbel · · Score: 1

      The problem is not the storage format, but the editors that present the format. The editors make the error of presenting the file as plain text, instead of taking advantage of the structure of the code.

      So instead of getting the indention level and coding style you prefer (dynamicly at load), you get what ever the author who wrote the code liked and you have to enter your text in that way.

      The problem is that:

      main() { puts("123"); }

      and

      main()
      {
      puts("123");
      }

      are two completly different things for a text-editor, while being equal for the compiler.
      And editor which took advantage of the programm structure could display both programms equally and completly hide the underlying structure as text files.

    27. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      I also agree. Maybe the answer to "why wastefully duplicate information" is because xml/html is popular, and we're sticking to it. Maybe some people think it's more readable, or maybe the creators never thought of any better way to do it.

      Man I hate typing that crap in manually. Lisp/scheme style looks a lot more pleasing.

    28. Re:Programs as flat text files - why? by Tablizer · · Score: 2

      (quote) If I like seeing pointers declared:
      int* a;
      and they like seeing
      int * a;
      then when I open the file I should see the former and they should see the latter. (end quote)

      One problem with on-the-fly reformatting is that some things cannot be managed by a code parser.

      For example, being somebody who likes to see stuff organized by row and column, I sometimes do something like:

      inputBox("name", r.name, conText, 40)
      inputBox("rank", r.rank, conText, 10)
      inputBox("serial#", r.serno, conFmt, 11)

      Reformatting would de-align such because the parser does not know what we intended.

    29. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      emacs' "fontify-buffer", and most serious text editors have the ability to prettify code while you type it. I find it mostly useful, rarely annoying (when it's wrong).

    30. Re:Programs as flat text files - why? by BrotherSeminarian · · Score: 1

      I'm not much myself on the idea of font changes and such in an XML-commented source file, but programming itself is much more than "communicating instructions to the computer." This is especially important in the eyes of literate programmers, who emphasize the fact that programs are primarily meant to be read by fellow human beings and secondarily by computers.

      A lot of the articles on literateprogramming.com can expand on this theme.

      Communicating instructions to the computer is easy enough. Lights, switches, and papertape can do that well. Communicating a complex process to people is difficult. Object-orientation and literate programming can help that process.

    31. Re:Programs as flat text files - why? by Theom · · Score: 0

      If you are using a good editor...

      --

      mp3: l33t term for empty.
    32. Re:Programs as flat text files - why? by RelentlessWeevilHowl · · Score: 1

      Then again, S-Expressions are not XML.

      XML's default-to-text nature makes writing documents easy, but you then have to work more to express code in i (e.g., XSLT). XML's verbose, redundant syntax is more robust in the face of errors, but Lisp editors have been effective at dealing with the concise S-Expression syntax.

      For directly editing code or strongly hierarchical data, I think S-Expressions are a better choice. For directly editing text or weakly hierarchical data, I think XML is a better choice. Since a literate programming environment is much more likely to hide text markup (bold text, underlined hyperlinks) than code markup, I think the balance tips towards S-Expressions there.

    33. Re:Programs as flat text files - why? by alext · · Score: 1

      Interesting post.

      On the 'weakly hierarchical' front, surely both sexps and XML are limited if all your (say) italic and bold sections are different but overlap?

      There seems to be a requirement for an extra level of indirection here - a solution to all CS problems, as we know.

    34. Re:Programs as flat text files - why? by rycamor · · Score: 1

      Tablizer, your tireless persistence is somehow gratifying ;-)

      Has any OS ever implemented a set/predicate-oriented filesystem, instead of a heirarchical one?

      I like these ideas, although I'm not sure I see all the ramifications.

      "byte the bullet" -- cute

    35. Re:Programs as flat text files - why? by swagr · · Score: 2

      (Lisp/Scheme) are base on "S-Expressions".
      But you are 100% accurate. S-Expressions save space, eliminate redundant information, and any programmer worth his salt can easily write a simple S-Expression parser in under an hour.

      Take a look at this if you want some reading material. It's by Ron Rivest (the R in RSA).

      --

      -... --- .-. . -.. ..--..
    36. Re:Programs as flat text files - why? by judd · · Score: 2

      Dave Winer's Frontier (http://userland.com) uses outlines combined with a block-structured language (think Python-flavoured C). It's a very nice environment.

    37. Re:Programs as flat text files - why? by Tablizer · · Score: 2

      (* Has any OS ever implemented a set/predicate-oriented filesystem, instead of a heirarchical one? *)

      The IBM AS/400 allegedly has, but there is some debate about how to classify it.

    38. Re:Programs as flat text files - why? by krogoth · · Score: 2

      "Prettify" or indent? vi has excellent automatic indenting, and KDevelop (which I use most of the time) is decent - nearly every advanced/programming editor has some form of auto-indenting.

      --

      They that quote Benjamin Franklin on liberty and safety deserve neither.
    39. Re:Programs as flat text files - why? by Mr.+Sketch · · Score: 1

      No, because emacs sux and vi rules. And I will never give in to the dark side of emacs.

    40. Re:Programs as flat text files - why? by Mr.+Sketch · · Score: 2

      Hence why I said it could be stored that way, but as you pointed out, it doesn't have to be. I don't know why VS doesn't do it, but there might be a plugin for it, however, I doubt it'll be natural/seamless, maybe like having to run a macro upon opening the files, instead of being automatic, etc.

    41. Re:Programs as flat text files - why? by Anonymous Coward · · Score: 0

      ColorForth

      Here, color is important to the actual language. But I don't know if it actually qualifies as easier.

    42. Re:Programs as flat text files - why? by GlassHeart · · Score: 1
      It is a logical and physical way to break up your code.

      True, but it is not the only logical way to break up code. For example, consider the following functions: main function A, which calls B and C. B is sizable, so it was broken down to call B2, B3, and B4. C is similarly broken down into C2 and C3. A flat file cannot physically represent the "sibling" relationship between B and C, and the "parent-child" relationship between B and B2/B3/B4.

      Another example is object-oriented code. In C++, for example, you are encouraged to declare variables as "private", and provide an accessor function to read their values. However, this leads to a large number of functions that contain nothing more than a "return" statement. It may help readability if these can simply be hidden from view.

      Yet another example: flat file comments have the problem of getting in the way of code, as well as not being able to precisely point at the code they describe.

      You can argue that a good GUI can hide many of the defects of a flat file structure from the user, and you'd be right. However, the fact that defects can be worked around doesn't mean there was no defect, or that changing the fundamental underlying mechanism is not a good idea.

    43. Re:Programs as flat text files - why? by Maax · · Score: 1

      Well, in that vein, I found these ramblings about ReiserFS rather interesting...

    44. Re:Programs as flat text files - why? by Spy+Hunter · · Score: 2
      Why do you need different fonts? Fonts are for layout and presentation, not for communicating instructions to the computer.

      This is EXACTLY the attitude that literate programming tries to discourage. The philosophy of literate programming is that the most important thing to do is communicate the intent of the code to the reader. Communicating things to the computer is secondary (though still important of course). It sounds funny at first (I hear you saying "but the whole *point* of programming is..."). But if everyone who reads the code can figure out exactly what it is supposed to be doing, it becomes much easier to modify and debug.

      If you make a mistake in the code, it is much easier to find if you can compare the code to its documentation to find the discrepency. If you make a mistake in the documentation, it is much easier to find than a mistake in code because it is spelled out in plain english. It makes sense if you think about it.

      --
      main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
    45. Re:Programs as flat text files - why? by klaviman · · Score: 1

      i don't know about you, but i write my code by making cool 3-D boxes come together on 6 different screens connected to 3 different networks. you people that edit text files are *so* 20th century.

    46. Re:Programs as flat text files - why? by Tablizer · · Score: 2

      (* Well, in that vein, I found these ramblings [reiserfs.org] about ReiserFS rather interesting... *)

      Interesting. At least we both agree that "sets" are where it is at and trees are limiting. As far as its funky new syntax, well that's another matter.

      It declared relational technology "legacy" more or less. That is the first I ever heard that (other than the now silent OODBMS crowd.) A set-based system can use existing database engines. I don't see a need to reinvent yet-another database engine being that relational thinking is partly based on set theory. However, relational databases may not be fully optimized for file systems (being that they are somewhat general purpose in nature.)

    47. Re:Programs as flat text files - why? by voodoo1man · · Score: 1

      Another big plus for SGML-style tags is the fact that they can easily be processed with regular expressions. You need a parser that understands Lisp style lists to do anything with sexprs. This is probably the most tangible reason to go with tags over sexprs for shared data.

      In defense of sexprs, they are much easier to type, can be more readable than tags, and (if you're using a Lisp) are very convenient to auto-generate. Really, tags and sexprs are completely interchangeable, and should be treated as such - the only thing that counts is the markup lingo.

      Also, the comments on Lisp documentation in that link are a bit misguided. The only attempts at an sexpr-only documentation markup that I know of were made by the Lisp machine companies, and not exactly being standards, they died with those Lisp machine companies. Nowadays the docs are kept in Tex format because it's a good standard - it would be pretty stupid to make up a new typography system just for the Lisp community. Maybe if the author would bother to look at some of the Lisp systems, he'd find that they do contain excellent utilities for processing and converting Lisp lists to Tex (and from there to other formats), and vice-versa. Oh, and since when have XML people done anything for decades? And while I'm making fun of that link, it should be pointed out that the author apparently understands neither Lisp lists nor the hypothetical sexpr markup - the "Starting with Syntax" section makes me giggle.

      --

      In the great CONS chain of life, you can either be the CAR or be in the CDR.

    48. Re:Programs as flat text files - why? by shibboleth · · Score: 1

      One could argue for programs in HTML, with the code bracketed in XML so that the compiler could find it.

      Yes, and as i recently posted, i've found that it does in fact further program understanding to be able to embed xml tags of various types into the code and the surrounding documentation, if one can make use of it. Example benefits, achievable in code and non-code sections using the Amaya editor:

      * Formatting, as you point out. XHTML, CSS works.
      * Hyperlinking to other files, sections, and urls.
      * SVG for drawing. (limited capability at present)
      * Automatic (re)creation of hierachical table of contents based on <h> tags (Amaya shows this nicely in a separate window, and allows drill-down from it into the document). Here's your outline.

      I implemented this as a tiny PHP/XSLT program.

      Since the above mentioned post, in addition to getting its two qn's answered, I added code to use as the target filename the <title> element of the source document (sudo'ing to root when necessary (which it wouldn't be for Windows)).

      The code sections are id'ed by being in a a named ("code") style, which simultaneously formats them.

      Using Amaya's also nice because it allows editing of html content in the same window in which the html is interpreted (and without any of the flood of non-standard tags MSWord uses).

      I plan on creating a Sourceforge project based on this w/in a week. No name yet but it should be findable via search on ANDed terms: php, xslt, literate programming.

      --
      "Be thankful you are not my student. You would not get a high grade for such a design :-)" - Minix pro
    49. Re:Programs as flat text files - why? by agedman · · Score: 1

      I personally prefer reading Scheme/Lisp to XML, but to be fair, XML in all its glory is a bit harder to represent than the little snippet given.

      XML supports namespaces, entities, various links/references that could be mapped to lisp, but probably would begin to look pretty ugly.

  5. Re:COX by unicron · · Score: 0, Offtopic

    The Cox plan is not a T1, you newb. It's 1.5mbit down, 128 up. A T1 is 1.5mbit both ways. Wake up, ass.

    --
    Finally, math books without any of that base 6 crap in them.
  6. Just giving it a name... by wiremind · · Score: 4, Insightful

    Did ANYONE learn (sic.) pseudo code ???

    When i learned programming writing pseudo code was SUCH a big deal to the teacher that by the end of the year without even thinking i would write out the whole program in pseudo code, then, under each line of english add one line of code.

    And has it ever paid off!

    Now when I want to look at my own documentation, I just grep my java files and pull out all lines that begin with '//'

    now when I am writing 20 pages of java code, and all my boss see's are comments I can tell him i'm am just writing Literate code!

    Good day to you sir.

    1. Re:Just giving it a name... by wiremind · · Score: 1

      Note from the author or parent:

      The use of '//' commenting is because I come from a C programming background. Now that I use java, I also make use of javadocs, and all the other neat commenting features java provides.

      good day to you madam.

    2. Re:Just giving it a name... by Anonymous Coward · · Score: 0

      Check out some of the examples of literate programming on the links. It's somewhat different than just comments.

      It's programming that works kind of like writing a book.

    3. Re:Just giving it a name... by jgerman · · Score: 4, Insightful
      Ugh, there is certainly such a thing as over-commenting, and from the sound of it you have contracted this disease. If I were reading someone's code and saw:

      // set min equal to max

      min = max;
      // increment i

      i++;


      I'd rip his (or her) head off. There's a balance involved in commenting. Comments are only needed when program flow isn't obvious. Though a comment block summary in front of subroutines is certainly a good idea.

      --
      I'm the big fish in the big pond bitch.
    4. Re:Just giving it a name... by gorilla · · Score: 5, Insightful
      That's not overcommenting, that's commenting wrong. You should be commenting why you are doing something, not what the code does.

      // Default Minimum to be same as Maximum
      min = max
      // We have finished this data cell, Move onto next data cell
      i++;

      Is good commenting, even though it's the same number of comments.

    5. Re:Just giving it a name... by wkitchen · · Score: 2, Insightful

      Pseudo code works especially well with languages that are inherently hard to read. Thanks to pseudo code, I can still easily understand PIC assembly language programs I wrote 10 years ago. Without it, it can be hard to comprehend something I wrote 10 days ago.

      The assembler uses a semicolon to identify comments. For my pseudo code lines, I put a slash immediately after the semicolon so I can extract the pseudo code but ignore other miscellaneous comments.

      Funny thing is, having no formal training as a programmer, I hadn't heard of pseudo code before I reinvented it for myself. I even called it by that name, well before discovering that it was already a common technique.

    6. Re:Just giving it a name... by jgerman · · Score: 1

      Better but I'd still be pissed. Just like any author form of expression, you have to assume a basic level of literacy and not explain every last detail to death. I'll admit that that's personal preference to some extent, but in my book, well written code needs only a few well placed comments.

      --
      I'm the big fish in the big pond bitch.
    7. Re:Just giving it a name... by DataPath · · Score: 2

      That kind of commenting usually only results when someone is told that they need to comment their code after the fact. If you write out in english (or whatever or your native language may be) the process that you'll be using for this method or class or whatever, and then develop the code within your outline, then you don't get extraneous code. And then of course there's the plain and simple need to explain certain not-so-obvious constructs or the reasoning behind solving a problem a certain way, but just think of the questions you ask yourself when you read someone else's code -
      "What is he doing here?"
      "How does this work?"
      "Why did he do that?"

      and try to answer them yourself when you're coding.

      --
      Inconceivable!
    8. Re:Just giving it a name... by edream · · Score: 1
      IMO, this topic has been explored fully in the book, Code Complete, by Steve McConnell, Microsoft Press, Chapter 19, especially pages the dialog between "pro" and "con" on page 457 and following. To summarize, some balance and perspective is needed ;-)

      However, as the creator of Leo, I would like to say that Leo does not, in fact, make documentation primary; it makes organization primary. In a sense, both code and documentation have secondary roles. So your view of the proper role of documentation really doesn't affect how you might use Leo.

      I discuss the roles of Leo and documentation and literate programming in detail here

      - Edward K. Ream

    9. Re:Just giving it a name... by Tablizer · · Score: 4, Funny

      If I were reading someone's code and saw:... // increment i ... i++; I'd rip his (or her) head off.

      I feel that punishment should mirror characteristics of the crime itself.

      Tie them to the ground, get a perm marker and write "eye" on their eyelids, "nose" on their nose, "neck" on their neck and so forth, and for a good summarizing comment, "STUPID!" on their forehead, and finally "Brain" on their ass.

    10. Re:Just giving it a name... by j7953 · · Score: 3, Insightful
      // Default Minimum to be same as Maximum
      min = max

      I'm not sure if this is a good comment. Of course it depends on the context, but if I read this comment, I'd immediately wonder why the default minimum is the same as the maximum. Imho it would be much better to explain the complete algorithm at the beginning of the routine, and then have only few comments within the code. However, as I said, this depends on the context and in some situations the above comment might be useful.

      // We have finished this data cell, Move onto next data cell
      i++;

      This is not a good comment, imho. Or at least an unnecessary one. If it is not clear from the context (e.g. the loop is short enough) what the variable i is being used for, you should give it a more explanatory name. Your example could be much better written as

      cellIndex++;

      Using too many comments instead of self-explaining code is not only unnecessary, it often also causes the problem of the comments not being updated when the code is modified.

      --
      Sig (appended to the end of comments I post, 54 chars)
    11. Re:Just giving it a name... by budgenator · · Score: 2

      I was taught to use psedo-code in COBOL class and try to still use it, but I notice that as a learn a language better, the pseudo-code is less pseudo and more code.

      as for greping out the comments I did something like that in FORTRAN, I sorted out all of the comment cards and ran them through the card reader seperately, saved typing stuff twice

      interesting that you use psuedo-code in java, UCSD pascal compiler outputed what they called p-code or pseudo-code that was supossed to be interpereted., just like java compiles to byte-code to be interperted.

      --
      Apocalypse Cancelled, Sorry, No Ticket Refunds
    12. Re:Just giving it a name... by frozenray · · Score: 1

      >I feel that punishment should mirror characteristics of the crime itself.

      That's an interesting idea. I'm sure this would reduce the amount of goatse trolling here on slashdot significantly.

      --
      "There are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare." - Blair Houghton
    13. Re:Just giving it a name... by Steveftoth · · Score: 1

      How in the world are you useing // in C? C doesn't support anything but /* */ comments...

      (But really I joke, I joke.)

    14. Re:Just giving it a name... by Anonymous Coward · · Score: 0

      [I feel that punishment should mirror characteristics of the crime itself.] That's an interesting idea. I'm sure this would reduce the amount of goatse trolling here on slashdot significantly.

      But those kind of people *like* punishment.

  7. look at the screenshot of pg 10 from the perl samp by Anonymous Coward · · Score: 1, Funny

    i never seen so many freakin task bar icons!

    i assume leo turns illiterate users into literate programmers?

  8. Anyone with 20 icons in their system tray is nuts! by override11 · · Score: 0

    Good lord, I get ticked if I have more than 3 or 4!!!

    --
    No I didnt spell check this post...
  9. good code is... by jukal · · Score: 3, Insightful

    literate, without literate programming :)

    1. Re:good code is... by RailGunner · · Score: 2
      Actually, I'd have to agree. There is such a thing as comment overkill. If you can't understand the language to a certain degree, then you need to study it harder. Comments are mainly useful to me when I'm looking at source and trying to determine the algorithm behind a function. I understand the language enough to where I really don't need every line commented. For example, I really don't need to see stuff like this:

      // increment the counter

      i++;

      Also, it's my personal preference, but I don't want to have to wade through line after line of comments to find that the person who checked in the source file wrote:

      if (n = 0)

      instead of

      if (n == 0)

      Overcommenting like this just slows me down, and as a professional developer, I HAVE DEADLINES.

    2. Re:good code is... by smagoun · · Score: 2
      Also, it's my personal preference, but I don't want to have to wade through line after line of comments to find that the person who checked in the source file wrote:

      if (n = 0)

      instead of

      if (n == 0)

      That's a good example of why more + better comments are necessary. Perhaps the author meant to write "if (n = 0)". Without some indication of intent, nobody knows which is correct without some detective work. The comments are there to verify that the code wasn't mistyped. As a professional developer, I'd rather know for sure what the code is supposed to do than have to guess (and potentially introduce a regression if I guess wrong).

    3. Re:good code is... by ceswiedler · · Score: 2

      An obscure (though syntactically correct) usage like if (i = 0) definitely should be commented. A real world example would probably be

      if (i = SomeFunc())

      where you want to set the variable and test it at the same time. I prefer

      if ((i = SomeFunc()) != 0)

      which clearly indicates that you're setting the value, and then testing it as well. Whether you agree with this convention or not, this is what people mean when they talk about "self-documenting code." Make things obvious, not clever.

    4. Re:good code is... by edream · · Score: 1
      I am the creator of Leo. As I said on another thread, Leo does not, in fact, enforce any particular viewpoint about comments. In fact, Leo makes organization primary, not either code or documentation.

      Indeed, Leo often eliminates the need for comments, and certainly "roadmap" comments typically used in traditional literate programming. I discuss the roles of comments and literate programming here

      - Edward K. Ream

    5. Re:good code is... by SerpentMage · · Score: 2

      Exactly....

      When I lead teams I always enforce the coding style that code should be readable like a book. After all does that not make sense since we are paid to read code for a living.

      I hate code like the following:

      if( i++)

      or

      ++i = ++ n;

      Stuff like that annoyes me because it is like short hand notation. Sure any competent programmer should be able to read that, but it is short hand that requires just an additional thought. As an example:

      On the weekend we went swimming and it was bad.

      Sentence says everything and is compact, but is still not a good sentence. A novelist would write:

      On the weekend we went swimming in the lake at our cottage in Canada, and the water was too cold, which made it unbearable.

      This sentence says everything that needs to be said. Sure it is verbose, but anybody who can read that will understand immediately what is being referred to.

      Likewise I prefer the notation

      destCounter = srcCounter;
      destCounter ++;
      srcCounter ++;

      Easier to read...

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    6. Re:good code is... by jukal · · Score: 2
      > In fact, Leo makes organization primary, not either code or documentation.

      Well, you make a lot of sense :) . My first comment was intentionally provocative. Especially from design (and architecture) point of view, Leo seems very interesting.

    7. Re:good code is... by thomas.galvin · · Score: 1

      If someone meant to write
      if (n = 0)
      they should be shot. I hate some of the shortcuts C/C++ lets you get away with.

      n = 0;
      if (false)
      {
      ...
      }
      is much easier to understand (though I'd probable vote for cluesticking him anyway, because of the if false).

    8. Re:good code is... by RailGunner · · Score: 2
      Why anyone would want to write

      if (i = 0)

      is beyond me, and it's also beyond the creators of C#.. C# will actually catch this mistake at compile time.

      I can't think of any reason to do this. Any reason that anyone else can come up with can be argued that there's a clearer, cleaner way to accomplish the same task. But my point remains, it's quicker for me to find that bug if I'm not wading through line after line of useless comments. If the code is written is a good style, preferably using Hungarian notation, then I don't need over-commenting.

    9. Re:good code is... by maxwell+demon · · Score: 1
      But your own comment doesn't meet your demands!

      Let's see how to improve:

      Exactly....
      Here we have a prime example of an extreme shortcut, comparable to while(*p++=*q++); in C. A more literate (and therefore better) way to express this would have been:
      I agree completely with everything you wrote in that comment I am answering to. You got it exactly right.


      When I lead teams I always enforce the coding style that code should be readable like a book. After all does that not make sense since we are paid to read code for a living.
      This can also be improved:
      When I lead teams of programmers working on a programming project, I always enforce the coding style that the source code of a program should be readable just as much as I think a book should be readable. After all, does that not make sense since we are paid to read code for a living?
      (Side node: You are payed for just reading the code? Must be a great job! :-))

      I hate code like the following:

      if( i++)

      or

      ++i = ++ n;

      Now, this again is quite short. To be more literate, you could have written
      I hate code written in a style which I'll illustrate by giving the following examples, which are snippets of C or C++ code:

      Example 1:
      if (i++)
      Example 2:
      ++i = ++n;
      (Side note: The latter isn't legal code in C, and in C++ only if using an user-defined operator++ and/or operator= - and even then there's more wrong with the code than just the style).

      Ok, I'll stop here, I guess you already got the message :-)
      --
      The Tao of math: The numbers you can count are not the real numbers.
    10. Re:good code is... by belroth · · Score: 2
      I hate code like the following:
      if( i++)
      or
      ++i = ++ n;
      Likewise I prefer the notation
      destCounter = srcCounter;
      destCounter ++;
      srcCounter ++;
      Shouldn't that be
      destCounter ++;
      srcCounter ++;
      destCounter = srcCounter; ?

      I prefer the fromer as I can see more code on the screen at once.

      --
      I hereby inform you that I have NOT been required to provide any decryption keys.
    11. Re:good code is... by PythonOrRuby · · Score: 2
      destCounter ++;
      srcCounter ++;
      destCounter = srcCounter;
      Except of course that this could be more concisely, and yet literately written as:

      srcCounter ++;
      destCounter = srcCounter;

      Since the assignment makes the incrementing of destCounter irrelevant. ;-)

      Of course, in all seriousness, the key issue here is operator precedence, and programmers have to figure that out eventually.
  10. Re:COX by nullgel · · Score: 0

    Oh, little you know. I'm in a "special" condo unit with Fibernet. I just checked DSL reports. I'm getting 1.4 up and down to Linkline. Sorry to disappoint you.

  11. i dont get it.. by Anonymous Coward · · Score: 2, Interesting

    what does leo do for me?

    it looks like the oldschool windows help browser with code samples pasted into it.

    I'm not trolling - I really want to understand how this makes for better code? And my employers definition of better is faster/cheaper - they could give a rats ass about structure and good documentation. They couldn't read a program design in english any better than they could in the most cryptic C syntax I can muster.

    Something like this could help a beginner or student break down code and learn to think logically, but unfortunately I had to move to the 'real world'..

    Sometimes I can't document something until I figure out how its going to be done.. And I figure out how to do it by writing code that works. Then I document the code.

    So far this brand of rapid prototyping is the only thing that gets results fast enough to keep my bosses happy. They care not for proper technique and well-structured code and attention to detail at the design phase. 'Design' around here is no more than a vague definition of the problem to be solved. They just want it out the door.

    I'm sure I'm not alone.. How does leo help me?

    1. Re:i dont get it.. by edream · · Score: 1
      Apparently many people have become confused about Leo from reading the initial article.

      Please read my posting, "The creator's view of Leo." The short answer: Leo makes structure primary, rather than either code or docs.

      Edward K. Ream

    2. Re:i dont get it.. by Anonymous Coward · · Score: 0

      Actually, making a good structure and documentation makes your coding faster. In the future, that is.

      Not making a good structure in your program is called a hack, and it will cost you more in the future by making the program more difficult to understand or change.

      This is ok if your project is very small ( maybe around 3000 lines ? ) and no one is likely to change it after release, but this is rare in the programming industry.

      You might be interested to read the book
      "Martin Fowler: Refactoring - Improving the Design of Existing Code"

      also "Andrew Hunt, David Thomas: The Pragmatic Programmer" is a good one that discusses similar issues.

      A boss who doesn't care about structure or documentation is a bad boss.

  12. must use his nifty GUI ..... by Shaleh · · Score: 3, Interesting

    Yuck. Leo is a "nifty" GUI which helps you do the outline. As I comment on another thread -- we programmers like our text editors thank you very much. I am ok with a visualization program but not one which takes over my workflow.

    1. Re:must use his nifty GUI ..... by jgerman · · Score: 2
      yeah that doesn't quite work work those of use who use vim, and not gvim, but command line vim.


      I still think that there are people out there (probably calling themselves "usability experts") who seem to think that a GUI is the answer to everything, and that a GUI based app is inherently better than a command line app.

      --
      I'm the big fish in the big pond bitch.
    2. Re:must use his nifty GUI ..... by Anonymous Coward · · Score: 0

      Well, aren't you in fact saying that a GUI app is inherently better than a command line app, since these features are only possible in a GUI?

      You did say that vim can't use them, did you not?

      (ducks...)

    3. Re:must use his nifty GUI ..... by thomas.galvin · · Score: 1

      What I wouldn't mind is a little window floating somewhere off to the side of my editor that lists:

      PackageOne
      ClassOne
      FunctionOne()
      FunctionTwo()
      ClassTwo
      FunctionOne()
      PackageTwo
      ClassOne ...

      And clicking on and item in the list would have your editor jump to that section of the code. Actually, There are a couple of IDE's that do this, but nothing that plugs into my editor, as far as I know. Maybe if I get bored enough...

    4. Re:must use his nifty GUI ..... by Chundra · · Score: 2

      If you use emacs check out speedbar.

    5. Re:must use his nifty GUI ..... by jgerman · · Score: 2
      Hah nice try, give you credit for that. However, it's not that the features are only possible in a GUI, it's that they were only implemented in a gui. Although the question of whether or not command line vim is a gui could be considered a bit fuzzy (other command line apps as well). It's just a different kind, most importantly to me one where I don't have to remove my hands from the keyboard to move around a silly little mouse ;). Well that and I prefer a text based app when writing code, I actually fired up gvim today and was going to attempt to use it but it just didn't do it for me.


      The point I was trying to make was that the best UI is the one that you work the fastest with which varies from person to person.

      --
      I'm the big fish in the big pond bitch.
    6. Re:must use his nifty GUI ..... by thomas.galvin · · Score: 1

      EYARG!

      Sorry...emacs...shudder.

      I'm a jEdit guy, myself.

  13. A good example: by El_Smack · · Score: 3, Interesting


    The main.cf config file of Postfix. Without the comments it's maybe 30 lines of actual settings. With comments its 540 lines, and it's clear enough that a relative n00b like myself got it up and running in 1 hr with minimal trips to the website. Good documentation was a major factor in my picking Postfix over Sendmail. No dis to Sendmail, you understand. :)

    --


    There are 01 kinds of cars in the world. The General Lee, and everything else.
    1. Re:A good example: by Reziac · · Score: 2

      That's exactly why I like detailed comments. As a non-programmer who sometimes has to root thru source code looking for whatever, piling on the comments does wonders for my understanding of what's going on in there.

      I can understand how Q&D coding doesn't have time for it, but IMO source aimed at relative newbies should be commented both generously and explicitly, even for "obvious" functions -- which may not be so obvious to a beginner.

      It also helps a lot when the code is self-documenting. I have some Pascal source that's entirely comment-free, yet anyone can figure out what's going on because of how everything is named and laid out. Reading the source is like reading comments!!

      ISTM that Q&D code, where commenting goes by the wayside because there's just not time for it, is even more in need of being self-documenting, if only so when you look at it again next week you can get a clue what you were thinking.

      --
      ~REZ~ #43301. Who'd fake being me anyway?
  14. Inline Documentation is evil by lkaos · · Score: 3, Interesting

    If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten.

    With most languages, the code itself is ample documentation. For instance:

    Person &p = Person::findPerson("Harry");

    cout p.name() endl;

    Is pretty self-explanatory. Anyone can tell the output of this code. It's not that programmers need more documentation, rather they need better abstraction and encapsulation (insert your favorite argument for object oriented programming here).

    --
    int func(int a);
    func((b += 3, b));
    1. Re:Inline Documentation is evil by lkaos · · Score: 2

      yeah, there should be two sets of insertation operators (<<). Stupid /.

      --
      int func(int a);
      func((b += 3, b));
    2. Re:Inline Documentation is evil by Anonymous Coward · · Score: 3, Funny

      Anyone can tell the output of this code

      Yes, it is :-


      error C2143: syntax error : missing ';' before 'constant'
      error C2146: syntax error : missing ';' before identifier 'endl'
      warning C4551: function call missing argument list

    3. Re:Inline Documentation is evil by Da+VinMan · · Score: 2

      I agree to some extent. However, you're assuming that the developer will start with a good design. That may not be the case. Literate programming helps you get the design sorted out in an easily changed format, with or without code present. Think of it as re-factoring, but in the detailed design stage.

      Now, one could argue that you really ought to have a design before you start coding. However, there seems to be no end to people who seem incapable of this and there seems to be no end to customers who are unable to articulate requirements well enough to make this possible.

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    4. Re:Inline Documentation is evil by rgmoore · · Score: 2

      Not necessarily true. While it is true that code should be written so that it's easy to understand what it's doing, you will frequently need comments to let people know why it's being done that way. When I make changes to my code to fix any non-obvious bug (frequently a result of the inputs it's processing not being quite as well formatted as promised) I always try to put in a comment about what subtle problem that code is fixing. I know that this is important because when I've looked back on code months or years later I haven't been able to figure out why certain things are done without the hints provided by those comments. For particularly bug-addled problems, that may result in a lot of comments.

      --

      There's no point in questioning authority if you aren't going to listen to the answers.

    5. Re:Inline Documentation is evil by gwernol · · Score: 5, Insightful

      If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten.

      I think you're missing the point. All code can be described at several different levels. At the highest level, you might describe a program as (for example) "an online banking application", which is a complete description of the app. However there are obviously a lot of details below this level of description :-)

      Different people need to understand a program at different levels of description. The CEO may only need to know the highest level description. At the other end of the spectrum, someone working on the optimal algorithm for maintining user session should be isolated from the implementation details of other parts of the program. The architect should be concentrating on the interconnection of modules within the code, not the implementation itself.

      The code itself is good at describing some levels of description and very poor at describing others. The example you give doesn't need any documentation to understand what those two lines do, but it will need documentation to understand their relevance to the higher levels of the system.

      Programmers tend to see the details and often miss the larger context. This can lead to unstated and often false assumptions about what role the code fulfills and how it interacts with the rest of the system These are the hardest bugs to find and fix.

      There are many ways to solve this "levels of description" problem. Inline documentation is one very valuable tool. Of course it shouldn't be:

      // Adds two numbers together
      a = b + c;

      It should describe the functional role of the code in relation to the higher-level components of the system.

      As you point out, abstraction and encapsulation are good mechanisms for constructing higher-level descriptions of functionality. Why stop there? Why not try to build up beyond these levels as well? Perhaps we will evolve to high-level languages that can express these high-level designs. Until then inline docuemntation and literate programming are excellent tools to help you achieve these goals.

      --
      Sailing over the event horizon
    6. Re:Inline Documentation is evil by Stonehand · · Score: 2

      Not if you're going math, it isn't. At the very least, if you're implementing a non-incredibly-obvious algorithm such as Strassen's matrix multiplication or solving the integrations and nonlinear systems required to do maximum-likelihood estimation of a normal distribution with two unknown truncation points, you should cite a source so that the reader can figure out the logic behind it all.

      Likewise, many equations may have seemingly standard parameter names that are non-intuitive to the layman. For instance, 'lambda' is a fairly common name for the power in an exponential distribution pdf, if memory serves -- but to somebody who doesn't know that distribution, it's a completely meaningless term. So you either go with the "common" name a statistician would use and recognize, or you go with something non-standard.

      Sure, basic data manipulation can use self-documentating code very well. But do anything that is intrinsically non-obvious to your potential audience, and you /need/ to document more.

      --
      Only the dead have seen the end of war.
    7. Re:Inline Documentation is evil by Viking+Coder · · Score: 5, Insightful

      I can't tell what your code should do if it can't find a person named Harry.

      I can't tell what your code should do if it finds multiple people named Harry.

      I can't tell how to use your code to find a person whose name requires Unicode to represent it.

      I can't tell if .name returns a char * that I'm supposed to free or delete [], if it returns a const char *, if it returns a string that I can modify but won't modify the original Person, if it returns a string reference which I can use to modify the original Person's name, if it returns a wstring reference which I can use to modify the original Person's name, if it returns a const string reference, or if it returns a const wstring reference, or if it uses some other string representation like a Qt one, or some custom one - heck, it could even use an MFC-style CString.

      I don't like that the function you've called is named "findPerson" - wouldn't it be far better to call it something like "findPersonByFirstName"? Or "findFirstPersonWithFirstName"? For that matter, why am I calling "Person::findPerson"? Isn't that slightly redundant? Wouldn't "Person::find" be just as clear, and less verbose? Therefore, the function should be something like "Person::findFirstWithFirstName". Wouldn't that be much more highly documented than what you've got?

      While we're on it, if it is returning the "first", by which method is it sorted? Shouldn't I be able to pass in a parameter which describes the order in which I want the results returned? And shouldn't you get an iterator instead of a reference, anyway?

      Back to "name", is that their entire given name? Is it a nickname? Is it in last-name first format? Is there some additional identifier in the name if two people have the same name?

      And I still don't know if I'll get a special Person which is supposed to be a Non-Person, if it can't find "Harry", or if this is going to throw an exception.

      I don't like that your code uses a hard coded-value, "Harry".

      I don't like that your code has the variable "p". Granted, you've got a pretty amazingly short scope in your example, but code tends to grow. It would be better if the variable had a slightly longer name.

      There are all sorts of things to nit-pick about, that a new coder could be confused about, or bugs which might be on the verge of instantiation, even in code as simple as yours.

      But my real point is this :

      If I've just walked in to your code, I don't know what behavior it's SUPPOSED to have, since you haven't documented that. All I can tell is what it DOES do. And since code changes over time, it's impossible for me to distinguish between the two, unless you document it.

      --
      Education is the silver bullet.
    8. Re:Inline Documentation is evil by SanLouBlues · · Score: 2

      What if I wrote a library with functions that take flags as arguments? You're assuming all code I use will be open source.
      Even worse, what if I'm a mantainence programmer (and I am)? Say there's an inefficient block of code which is self-explanatory, but had to be done as such to get around some esoteric bug in a system library. Documentation would allow me not to repeat said bug.
      And what about complicated algorithms (3d navigation with quaternions)? Should math books remove explanatory text about theories and the derivation thereof because "the code itself is ample documentation"?

    9. Re:Inline Documentation is evil by shaper · · Score: 3, Insightful

      Nope. You've given an example that is far more simple than any real-world situation where you might encounter uncertainty about code functionality. But I'll match you strawman for strawman. Same code sample...

      Person &p = Person::findPerson("Harry");
      cout p.name() endl;

      Questions: what do you do when findPerson() doesn't find Harry? Come to think of it, what are the preconditions for using the Person class in the first place? Do you have to set up a JNDI datasource first? Or maybe it uses an LDAP server so you need to have one for it to work? Why in the world is it looking for "Harry" in the first place? Who is this Harry person and why do we care about him at this point in the code? Should we send him a page if we can't find him? Is it the responsiblity of the caller of the code to use alternate means to locate the mysterious Harry or do we just give up and look for Jane? Uh oh, Harry quit last week! Now what?

      Oh and too bad for me that you quit last week and moved to Mongolia with Harry so I can't ask anyone these questions about the code that you failed to document and that I now have to support in my copious spare time.

    10. Re:Inline Documentation is evil by Usquebaugh · · Score: 2

      Rubbish.

      Why is the question code documentation should address not how. In your example does the line of code explain why you are looking for a person called Harry? No it merely shows that you are looking.

      Self explanatory, what a joke. Nobody can tell the output of this code. Big deal we've looked for Harry now was that because we like Harry or because Harry is catch all for bad guys?

      I'm not sure who I'm more annoyed at, you for this lame brain amateur idea or the idiots who modded you up. grrr

    11. Re:Inline Documentation is evil by Anonymous Coward · · Score: 1, Insightful

      i like the last part of your comment "And since code changes over time, it's impossible for me to distinguish between the two, unless you document it.", since its total crap. code changes over time, yes, and code is the documentation if written well, and if not written well the coder should find a different job. its too hard to update comments when you are updating code, if you have a code that has a chain of things to be changed for it to work right(say you figure out 5 different exploits to your code for a server app, related to 1 or 2 main bugs, and they branch out), you will end up breaking your thought process if you update the comments while updating the code; however if you do not update the comments a month or year later when it is used again and needs to be changed someone will have to go though a massive debugging because they beleive the comment is correct when really it says something like "//int MyFunc(int foo)" when it should say something like "//int MyFunc(long foo)", problems like that happen a lot when you comment a large project, which is why in the long run it is easier to just not comment, in the short term as well.

    12. Re:Inline Documentation is evil by starbirdman · · Score: 2, Interesting

      I agree with the overall point that you are trying to make. However, your main argument against this snippet of code seems to boil down to you don't know how the function is supposed to behave. Shouldn't that be commented on the function itself and not the function call?

    13. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      its too hard to update comments when you are updating code,

      I think you're the one who needs to find a different job. If your argument is that the benefits of updating comments are far outweighed by the costs, then make that argument. Don't whine about "too hard".

      if you have a code that has a chain of things to be changed for it to work right ... you will end up breaking your thought process if you update the comments while updating the code;

      Fine - update the comments immediately after you update the code. Your thought process isn't interrupted, changing the comments isn't really all that hard, and you're left with good documentation that you can use as the basis of your work, the next time there's a problem in the code.

      however if you do not update the comments a month or year later when it is used again and needs to be changed someone will have to go though a massive debugging because they beleive the comment is correct

      That's why I think you should update the comments. You seem to be switching sides in your argument, here.

      problems like that happen a lot when you comment a large project, which is why in the long run it is easier to just not comment, in the short term as well.

      There turns out to be no actual logical argument to what you've said. Your argument boils down to two points: it's hard to modify the documentation, and bad documentation is misleading. Well, it's not hard to modify the documentation, and bad (or no) documentation IS misleading - that's why coders should put effort into creating and maintaining good documentation.

      I will offer several points as the converse to your arguments: it's far easier to document code immediately after writing it than it is to document it several months down the line - and it's very hard to understand the INTENDED behavior of bad code without any documentation.

      --
      Education is the silver bullet.
    14. Re:Inline Documentation is evil by drwatson49 · · Score: 1

      To me commenting is not for explaining the immediate line(s) of code that follow, sometimes it is needed to put things in proper context. While we all can tell what the output is, it is not clear why ... "Harry"? That is what comments are for, not to say that you are cout-ing the Harry-Person-object (since it is obvious fromthe code itself), but to explain why, i.e. to put it in proper context.

    15. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      *shrug* I was trying to knock the wind out of the implied argument that the code was so simple, there's no reason for anyone to complain.

      So, I complained.

      As to your point, yes - documentation on an API is far more valuable than documentation in the usage of an API. But, I think I've made it clear that the intended behavior of that code was not at all clear.

      --
      Education is the silver bullet.
    16. Re:Inline Documentation is evil by maiden_taiwan · · Score: 2, Insightful

      Most of your criticisms are questions about the behavior of findPerson. These properties should be documented within findPerson, not in the caller.

    17. Re:Inline Documentation is evil by Anonymous Coward · · Score: 0

      I agree to some extent. However, you're assuming that the developer will start with a good design. That may not be the case. Literate programming helps you get the design sorted out in an easily changed format, with or without code present. Think of it as re-factoring, but in the detailed design stage.

      Now, one could argue that you really ought to have a design before you start coding. However, there seems to be no end to people who seem incapable of this and there seems to be no end to customers who are unable to articulate requirements well enough to make this possible.


      Good points. Now, how is forcing a programmer (incapable of good designs) to use a particular documentation tool going to instantly turn them into a programmer capable of good designs?

      Basically, these tools are nice and if people like working that way they will be useful. But a tool like this won't inherently change anything.

    18. Re:Inline Documentation is evil by maxwell+demon · · Score: 1
      There are many ways to solve this "levels of description" problem. Inline documentation is one very valuable tool. Of course it shouldn't be:

      // Adds two numbers together
      a = b + c;

      It should describe the functional role of the code in relation to the higher-level components of the system.
      Well, of course you can over-do this, too:
      // This finally calculates the total amount of characters in
      // the document stored in the object pointed to by the local
      // pointer p (not used in this statement, since we already
      // calculated the number of alphanumeric letters, stored in the
      // variable b, and the number of other characters, stored in the
      // variable c), which itself normally points to the currently
      // selected document, unless the function count_chars_other_doc()
      // was called. Since the number of characters in the document is
      // just the sum of the number of alphanumeric characters and the
      // number of other characters in the document, we calculate the
      // number of characters by adding those other two numbers, and
      // storing the result in the variable a, which is the reference
      // argument of our function intended to return this count.
      a = b + c;
      --
      The Tao of math: The numbers you can count are not the real numbers.
    19. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      *shrug*

      If your argument is that documentation is worthless, then make your case. I'm not really that interested in the original code. I'd rather debate the topic at hand. What was offered was a concrete example - so I tried to knock it down.

      Even if you resolve all of my complaints, though, I think the intended behavior of the code is still unclear, without documentation.

      --
      Education is the silver bullet.
    20. Re:Inline Documentation is evil by praxim · · Score: 1
      I don't like that the function you've called is named "findPerson" - wouldn't it be far better to call it something like "findPersonByFirstName"? Or "findFirstPersonWithFirstName"?

      No- function overloading means that Person::find () should work fine no matter what (reasonable) parameters are given. If you want different funtions for finding by name, age, birth date, and social security number, feel free to use another language. ;-)

      I agree with most of your other points, even the ones that really should be defined at the function definition, not the caller.

    21. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      If a Person has two attributes with the same type, function overloading doesn't help you document behavior at all. You still need to name the attribute you're looking for.

      I don't know if Person::find("June 26, 1975") is looking for date of birth, or date of death, date of marriage, date of hire, etc.

      "even the ones that really should be defined at the function definition"

      Keep in mind, this poster thought that NOTHING (not even function definitions) needs documentation.

      --
      Education is the silver bullet.
    22. Re:Inline Documentation is evil by Matthew+Weigel · · Score: 2

      Blockquoth lkaos:

      If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten.

      There are two very big reasons why in line documentation is good. First, having user documentation in the source (as with PerlPOD or javadoc) makes it easier to maintain documentation that reflects the reality of implementation.

      Second, algorithm description is important. If you ever try to read 500 lines of uncommented, complicated code, with your only reference is a vague explanation of the algorithm in a book: you'll see what I mean.

      Algorithm description is probably the most important part of literate programming, at least in my view. Particularly when you have to make changes to the general algorithm, or the steps of the algorithm are lost in memory management and error-checking.

      And for mathematical programming, equation formatting (either automatically and in line how CWEB does it or manually the way noweb lets you do it) is essential to bug hunting. With noweb, you can compare raw TeX and C fairly easily, and you can do so with the knowledge that the TeX is a correct expression of the equation.

      --
      --Matthew
    23. Re:Inline Documentation is evil by astroboy · · Score: 2
      If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten. [...stupid example deleted ...]

      I work on an academic simulation code. It's 300KLOC; small by commercial standards, sizable by academic standards.

      It might be (but isn't) true that each and every line of the code is self-documenting; that at every line, it's clear what's happening.

      But you know what?

      There's three hundred fscking *thousand* of them! Sure, it might be clear that two lines do a matrix multiplication, but *why* is it doing it, and what are the implications for the remaing 299,998 lines of code?

      Hell, without documentation running through the entire code, and probably alongside in manuals, how would you even know how to look at those particular 2 lines of code - constituting 0.0007% of the total code base?

      Anyone who thinks that clear code doesn't need to be documented has never written a program more than a few hundred lines long.

    24. Re:Inline Documentation is evil by edream · · Score: 1

      The pros and cons of documentation, inline or not, are not really relevant to what Leo is about. Please read my posting, "The creator's view of Leo". - Edward K. Ream

    25. Re:Inline Documentation is evil by crysogonus · · Score: 1

      >If a Person has two attributes with the same type, function overloading doesn't help you document behavior at all. You still need to name the attribute you're looking for.
      >I don't know if Person::find("June 26, 1975") is looking for date of birth, or date of death, date of marriage, date of hire, etc.

      class HireDate : Date
      {...};
      class BirthDate : Date
      {...};

      p = Person::find(HireDate("June 26, 1975"));

      What was your point again?

    26. Re:Inline Documentation is evil by maxwell+demon · · Score: 1
      If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten.

      Even if your documentation only states behaviour of your code, it may not be superfluous: It may be needed to distinguish intended behaviour from accidental behaviour.

      For example, say you have a list of structures containing a numeric field, and you need a function which is given a value, and which returns an item from the list whose numeric field has the given value (any item having that value will do).

      Now you decide to do a linear search in the list and return the first item which complies with the condition. Since the code is obvious, you decide not to comment.

      Two years later, the lists have become quite large, therefore another programmer now working on your code decides it's an advantage to change to a sorted list, and to do a binary search. Now, not having documentation for your code, he looks at it and sees that you return the first item with this value. Therefore he makes sure that he returns the first item either. Now, if he had known that any item with the correct value had been Ok, he not only would have saved some programming time, but his code would have been more efficient (stopping as soon as one matching item was found, instead of making sure it's the first one).
      --
      The Tao of math: The numbers you can count are not the real numbers.
    27. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      I agree with you that I overstated. But I disagree with you that overloading on classes solves the general case problem. For instance, if I want to find everyone who was hired before a certain date, overloading find on some "HiredBeforeDate" class is pretty absurd.

      I think using functors is a much better approach. Wouldn't you agree?

      --
      Education is the silver bullet.
    28. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      Your post is not really relevant to what we were discussing, as we were not directly discussing Leo.

      I was asserting that documentation is good and necessary, in response to the other poster saying that documentation is never necessary. I don't really think that "inline or not" comes close to describing what we were debating.

      --
      Education is the silver bullet.
    29. Re:Inline Documentation is evil by Anonymous Coward · · Score: 0


      That was fucking Beautiful. I mean really, really beautiful.

      As the poor soul who finds myself fixing other people's shit far more often than I should have to (because I'm extrordinarily good at it), I'm floored by how well you've summed up the frustrations involved in dealing with un- or poorly documented code.

      I just had to post a reply to this even though it's as AC and no one will see it.

    30. Re:Inline Documentation is evil by praxim · · Score: 1

      True enough.

    31. Re:Inline Documentation is evil by lkaos · · Score: 3, Interesting

      I can't tell what your code should do if it can't find a person named Harry.

      Good point. The code was a quick example. It likely would have expanded to included error checking if the item wasn't found.

      I can't tell what your code should do if it finds multiple people named Harry.

      Assume that the list is unique.

      I can't tell how to use your code to find a person whose name requires Unicode to represent it.

      And indeed your shouldn't know how. I don't see how commenting would help this situation. If the code snippet supported Unicode, then there would be special Unicode handling classes that likely would be explanatory.

      I can't tell if .name returns a char * that I'm supposed to free or delete [], if it returns a const char *, if it returns a string that I can modify but won't modify the original Person, if it returns a string reference which I can use to modify the original Person's name, if it returns a wstring reference which I can use to modify the original Person's name, if it returns a const string reference, or if it returns a const wstring reference, or if it uses some other string representation like a Qt one, or some custom one - heck, it could even use an MFC-style CString.

      Of course, this is C++ and therefore would return a std::string as all C++ programs should.

      I don't like that the function you've called is named "findPerson" - wouldn't it be far better to call it something like "findPersonByFirstName"? Or "findFirstPersonWithFirstName"? For that matter, why am I calling "Person::findPerson"? Isn't that slightly redundant? Wouldn't "Person::find" be just as clear, and less verbose? Therefore, the function should be something like "Person::findFirstWithFirstName". Wouldn't that be much more highly documented than what you've got?

      Again though, how would commenting help this? This only goes to prove my point that properly written code doesn't need commenting. It also reenforces the idea that commenting may lead to laziness on the part of symbol naming.

      While we're on it, if it is returning the "first", by which method is it sorted? Shouldn't I be able to pass in a parameter which describes the order in which I want the results returned? And shouldn't you get an iterator instead of a reference, anyway?

      Your assuming that the container is not unique. That is a bad assumption.

      I don't like that your code uses a hard coded-value, "Harry".

      Life's a bitch. Constants are only good if they are going to be used multiple times and represent some abstract concept. To have a constant HARRY or something similiar would be silly.

      I don't like that your code has the variable "p". Granted, you've got a pretty amazingly short scope in your example, but code tends to grow. It would be better if the variable had a slightly longer name.

      There are a certain set of variables reserved for local semi-anonymous operations. For me, these are things like ptr, i, p, j, etc. It makes more sense to an experienced programmer to use variables like this since it is obvious that the variable isn't important.

      There are all sorts of things to nit-pick about, that a new coder could be confused about, or bugs which might be on the verge of instantiation, even in code as simple as yours.

      Why must we always write code to be indestructable by a "new coder"?


      If I've just walked in to your code, I don't know what behavior it's SUPPOSED to have, since you haven't documented that. All I can tell is what it DOES do. And since code changes over time, it's impossible for me to distinguish between the two, unless you document it.


      The code is the behavior its SUPPOSED to have. The maintainability nightmare arrises when there are two sources of behavior (i.e. a comment says code should be doing one thing was the code is doing something else). The code is always describing what the programs doing whereas noone really knows what the comments mean or were meant to mean.

      Comments are inferior to code because 1) they are not syntatically verified by a compiler 2) are not tested in anyway 3) and have no effect on runtime behavior.

      The real problem isn't that experience programmers don't comment well enough, its that beginner programmers expect comments to allow them to not learn the underlying language. A new-hire programmer is going to learn more (and be less productive in the short term) by reading code without any comments. In the long term, this translates to higher-productivity. The question is are we going to make this investment in our industry?

      --
      int func(int a);
      func((b += 3, b));
    32. Re:Inline Documentation is evil by Anonymous Coward · · Score: 0

      A disturbence in force I felt.

      Through the Force, things you will see. Reaches across time and space it does. Other places. The future; the past. Old friends long gone.
      A Jedi uses the Force for knowledge and defense, never for attack.

      The master leaves his Jedi, a strong one you are.

    33. Re:Inline Documentation is evil by CommieOverlord · · Score: 1

      I can't tell what your code should do if it finds multiple people named Harry.

      Assume that the list is unique.


      And why would I assume the list contains only unique elements? Hmm, perhaps because it is specified/explained in the documentation. Unless the documentation specifies that the values are unique, then the only safe assumption I can make is that there are duplicates.

      And how do I handle duplicates? Hmm, perhaps it's specified in that documentation stuff again...

    34. Re:Inline Documentation is evil by Viking+Coder · · Score: 3, Interesting
      It likely would have to be expanded to include error checking if the item wasn't found.

      That task would either have to be performed by the original coder, or by someone else. In either case, documentation would help. Something along the lines of:

      // TODO : error check if it can't find a person named Harry.

      Wouldn't you agree?

      Assume that the list is unique.

      Well, that would be a good thing to document, now, wouldn't it? Otherwise, when a new coder comes in, they'll be all paranoid about the possible existence of other People with the same first name. And if the requirements of your program change to encompass the possibility of multiple People with the same name, wouldn't it be good to have a comment along the lines of:

      // ASSUMPTION: assumes uniqueness of Person

      Granted, your code could be bloated to actually test all of these conditions in each use case - but I'm just asking for comments at the top of the Person class, for instance. I think it would be more useful to document in each function that you're making such an assumption.

      And indeed you shouldn't know how.

      I agree with another poster that you could potentially overload each function that takes a string to take both a string and a wstring, for instance, in order to handle Unicode input. What I was actually suggesting was that it would be better to call your function like this:

      Person::findPerson(L"Harry")

      Of course, this is C++ and therefore would return a std::string as all C++ programs should.

      Actually, I would argue that your function should return either a "const std::string&" or a "const std::wstring&", so that it's clear that you can't modify the output, and so that less useless byte-copying is performed. Granted, string is pretty light-weight, but it's a good coding practice to get into.

      Again though, how would commenting help this?

      Doing away with comments doesn't magically make existing code better. Many people have argued with me - saying that adding comments does make code worse. I think they're crazy. Code will always have mistakes, but documentation gives you insight into the mind of the coder like code cannot. Especially when you see something like "// FIX THIS" sprinkled around. =)

      This only goes to prove my point that properly written code doesn't need commenting.

      I would argue that by your definitions the only "properly written code" would be code that meets at least one of these two criteria:

      1. It was written by someone with total recall. (In other words, they could recall the initial requirements perfectly, and had no need to write them down for posterity.)
      2. It can be proven to contain no bugs.
      Since neither criteria is very common, I would argue that almost no code is "properly written". I use your initial snippet as an example. Even something as simple as that had, in my mind, many problems. And you even agreed with one of my complaints! Therefore, your code was not properly written! COMMENT IT!

      It also reenforces the idea that commenting may lead to laziness on the part of symbol naming.

      Bad habits will always exist. One good habit is documenting unfinished code. Another good habit is documenting the design of any code, and the expected results under outlier conditions.

      Your assuming that the container is not unique. That is a bad assumption.

      If you'd documented your code better, I would have realized that. That sounds like a communication problem between two coders. One way to address that (not "solve", but "address") is that each coder try to document their assumptions, where it makes sense to do so. "At least once" would be nice.

      Constants are only good if they are going to be used multiple times and represent some abstract concept.

      Or, if their value ever needs to be changed in the future. (Such as making it Unicode compliant.) Or if the existence of the constant itself needs to be documented. Or if the constant itself comes from an original source, such as a paper describing an algorithm, or requirements specifications. Or if the constant needs to be translated into multiple languages. Or if the behavior of the constant needs to be checked by regression tests. I could go on, but I think that I've shown that your statement was rubbish.

      There are a certain set of variables reserved for local semi-anonymous operations.

      Who reserves them? Oh, you do. What about every other coder who'll have to look at your code? Do they get reserved variables, too?

      If you've ever written code like this:

      for (int i=0; i<max_i; i++)
      { ...
      } ...
      for (i=0; i<max_i; i++)
      { ...
      }

      Then you're guilty of writing non-portable code. The variable "i" is neither reserved by the compiler, nor do all compilers check to make sure that "i" is properly in scope in the same manner.

      ...since it is obvious that the variable isn't important.

      I believe you meant to say "since it is obvious that the variable name isn't important."

      I kind of like the rule that the length of a variable name should be proportional to the log of the length of its scope. *shrug* I know what you're getting at, but you must agree that as soon as the usage conditions on "p" become greater, it should probably be renamed. *shrug* Not really one of my main arguments.

      Why must we always write code to be indestructable by a "new coder"?

      Good code is a journey, not a destination. I think everyone should at least make an attempt to constantly improve their technique. If I didn't care what other people think or do, I wouldn't bother to argue with you.

      The code is the behavior its SUPPOSED to have.

      Wait just a minute. Let me go back and quote you to you, again:

      It likely would have expanded to included error checking if the item wasn't found.

      Well, WHICH IS IT? That code was either SUPPOSED to crash, if the item wasn't found, or it "likely would have to be expanded to include error checking."

      This really pisses me off. Can't you see how dumb you sound, here? I know that you're an intelligent person - you're making pretty good arguments - they just happen to be incorrect. But these two statements here, more than anything else, prove that your argument contains inconsistencies.

      The maintainability nightmare arrises when there are two sources of behavior

      Let me list sources of behavior:

      1. What the user thinks they want
      2. What the user really does want
      3. How the conditions will change in the future
      4. How the coder meant to type in the code (typing in an algorithm it's possible to have typos - it's VERY useful to CITE your sources, so they can be checked, later. Otherwise, I have to figure out, by hand, what's wrong with the code you typed in.)
      Since there are always multiple "sources of behavior", I think it would be far better to document the choices that the coder made, than to leave them up in the air, undocumented.

      Comments are inferior to code

      Code without comments is inferior to code with comments.

      Granted, I'm expecting a certain level of maturity in the people writing the comments, but your assertion seems to be that the code is somehow BETTER if you intentionally REMOVE intelligent comments. That is an untenable position.

      I disagree with your summation of "the real problem", in your parting paragraph.

      I think "the real problem" is that it's impossible for the computer to understand the intention of a coder. It is only possible to verify the intended behavior of code, by having another human read the code. That process is aided by good documentation. I agree with your assertion that bad documentation is misleading. However, code with documentation is guaranteed to be AT LEAST AS GOOD as code without documentation. It is always possible for a human to remove documentation, and look at just code. At the very least, cite your sources for algorithms that you implement - that alone would dramatically improve the quality of a lot of code.
      --
      Education is the silver bullet.
    35. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      Actually, I back-peddled too far, in my original response to this message.

      You're still naming the attribute you're looking for - you're just using a different mechanism to do it. (New classes instead of new functions.)

      And, like I originally responded, functors are a better general mechanism.

      --
      Education is the silver bullet.
    36. Re:Inline Documentation is evil by harlows_monkeys · · Score: 2
      If your code requires massive documentation within the code to make it understandable, then your code likely needs to be rewritten.

      Or you are doing complex problems, using algorithms that you developed or that are otherwise likely to be unfamiliar to the reader.

      Read the examples in Knuth's book. His system makes it much easier to understand what is going on, AND makes it much easier to write correct code.

    37. Re:Inline Documentation is evil by MajroMax · · Score: 2
      I don't like that the function you've called is named "findPerson" - wouldn't it be far better to call it something like "findPersonByFirstName"? Or "findFirstPersonWithFirstName"?

      Actually, I think it should be called findTheFirstPersonWithTheFirstNameThatIsSpecificed ByTheFirstArgumentToThisFunctionCallAndThereAreNoM oreArguments_TheFunctionThrowsPersonNotFoundExcept ionIfItCannotFindThePersonWhoseFirstNameYouSpecify

      There is something to be said for short function names.

      --
      "Evil company X is threatening to restrict our rights! Let's all get together to stop--OOOH! SHINEY!!!" -- AC
    38. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      Okay, let's call it "f".

      Or, better yet, how about if we just overload operator() on the class to make it into a functor, and overload it for every possible function - using new classes to specify the types of parameters.

      I think you're onto someting. *chuckle*

      --
      Education is the silver bullet.
    39. Re:Inline Documentation is evil by civilizedINTENSITY · · Score: 2

      f? I thought functions were all named "lambda"!

    40. Re:Inline Documentation is evil by maiden_taiwan · · Score: 1
      My response was incomplete. What I meant was this:

      You make a very good point. Several of your examples illustrate that point well. However, most of the examples are flawed because the cited documentation belongs in the callee, not inline in the caller.

    41. Re:Inline Documentation is evil by lkaos · · Score: 2

      That task would either have to be performed by the original coder, or by someone else.

      The code I used in the example was a quick snippet to illustrate a point. In this circumstance, I would have to say that implementing error checking would have been as difficult as writing the TODO comment. I have been known to use TODO comments though and I agree that they are useful.

      Assume that the list is unique.

      Well, that would be a good thing to document, now, wouldn't it?


      Well, that documentation would be at the class level, not at the usage level. Notice I didn't include the class. API references are much different than the kind of documentation discussed in this thread IMHO.

      I agree with another poster that you could potentially overload each function that takes a string to take both a string and a wstring, for instance, in order to handle Unicode input.

      Unicode and ASCII aren't the only types of character sets... For most applications, that doesn't matter though. It definitely is outside the scope of this program (and most programs for that matter).

      Actually, I would argue that your function should return either a "const std::string&" or a "const std::wstring&",

      boost::call_traits::param_type

      Much more portable (and accurate in the long term) since you can change the behavior on a per-type level throughout your program (if for some instance, you have a class where a function that should be const isn't, that you can't modify, you can specialize call_traits to return just a reference).

      call_traits will likely end up in the next standard too.

      Doing away with comments doesn't magically make existing code better.

      So, I assume we've all had the project managers or have been in the code review where some entry-level person starts complaining because in college, pseudo-code was included with the regular code. Stuff like.

      int iIterator = 0; // initialize iIterator
      const int LOOP_LENGTH = 10; // loop length constant // write Hello World ten times to the screen
      for (iIterator = 0; iIterator Who reserves them? Oh, you do. What about every other coder who'll have to look at your code? Do they get reserved variables, too?

      They're not officially reserved. It's just the common variables that anyone who's done software developer for any length of time is used to. I don't think I have to explain myself here.

      Good code is a journey, not a destination.

      It's amazing, and I'm saying a prayer for the desperate heart tonight ;-) Sorry, couldn't resist.

      Well, WHICH IS IT? That code was either SUPPOSED to crash,

      Perhaps like a map, if the item isn't found, an element is created and a reference is returned (with a default name derived from what's being searched for). There's no reason to assume the function could fail or even that the results are undefined in the event that the person couldn't be found.

      Granted, I'm expecting a certain level of maturity in the people writing the comments, but your assertion seems to be that the code is somehow BETTER if you intentionally REMOVE intelligent comments.

      Not at all, but rather that I believe it is harder to write and maintain good comments than to write and maintain good code. Far to much emphasis is put on commenting and documentation IMHO and not enough on coding style itself. Just look at the typical new-hire. They tend to lack any kind of useful design skill or coding style but have been engrained with this over commenting nonsense as if it was necessary to have detailed psuedo-code with all code that is written.

      IMVHO, a software project is more maintainable is strict design reviews are enforced along with strict style guides than if strict comment guides are enforced. In fact, I have not found that strict commenting guides have helped make any project I've worked on more maintainable.

      In fact, they have typically done the opposite which of course resulted in my writing nice little scripts to s/\/\/*^//. I'm sure you have experienced this. Header files that are 70% comments of which, nothing is particular useful ("This file implements the MyClass class" type things).

      --
      int func(int a);
      func((b += 3, b));
    42. Re:Inline Documentation is evil by Viking+Coder · · Score: 2

      Let me just go back, one more time, and point out how inaccurate and inconsistent your arguments are. This statement is inaccurate:

      The code is the behavior its SUPPOSED to have.

      For instance, if you code a bug, by your axiom, the buggy behavior is the behavior the code is SUPPOSED to have.

      So, sometimes there is a need to distinguish between what code says (and literally does), and what it means (and what it's supposed to do). One truly excellent way to express that code has meaning beyond the actual text of the code is to comment it.

      And here's an example of your inconsistency:

      Inline Documentation is evil

      And then you said:

      I have been known to use TODO comments though and I agree that they are useful.

      Maybe it's naive of me, but I guess I thought that "evil" and "useful" were complete opposites, in the framework of this discussion. Although, I guess I believe that Microsoft is evil and can be useful, so I guess I can't completely mock your opinion on this point. =)

      Thanks for bringing boost::call_traits::param_type to my attention. I'll look into it.

      --
      Education is the silver bullet.
  15. Questions. by bons · · Score: 3, Insightful
    When programming in a literate system do you describe the objects and methods from a programming viewpoint, a business viewpoint, or from a metaphor viewpoint?

    When we build systems, we work directly with the client and we are able to describe the system in three equal, but very different ways. Depending on the documentation required and the target audience, we can describe the system in a way that allows everyone involved to communicate effectively. This is an advantage I don't want to lose.

    From what I've read, literate programming seems to be a discipline that works best when the programmers are isolated from the client. How it works when the programmers and the client closely interact is something I simply don't understand.

    1. Re:Questions. by Matthew+Weigel · · Score: 3, Insightful

      Blockquoth bons:

      When programming in a literate system do you describe the objects and methods from a programming viewpoint, a business viewpoint, or from a metaphor viewpoint?

      At its heart, literate programming creates multiple documents from a single master document. The common case is creating two documents - a document that is a paper on a program, and a document that compiles to the program - from the master document; but it's entirely possible to create more than just the two documents with a tool like noweb.

      As an example, you could produce API documentation, algorithm descriptions, a description of the interaction of the whole schebang, and the program source itself from a single set of master documents.

      And, again, the gain of literate programming is that you can keep all these forms of documentation close to each other and close to the code, which is a win.

      Now, noweb isn't perfect: it's optimized for creating just one set of documentation, so the other documentation would have to be treated as code. It would be a lot better if you could name documentation blocks just like code blocks, but oh well...

      --
      --Matthew
  16. Re:COX by unicron · · Score: 1, Offtopic

    So your condo is wired with fiber? Well, unless Cox has a CO inside your living room, I really don't think that matters.

    --
    Finally, math books without any of that base 6 crap in them.
  17. Curing unmaintainable code by gwernol · · Score: 5, Interesting

    Roedy Green has written an excellent, humorous online article on writing unmaintainable code. This relates directly to Literate Programming, especially Roedy's points about maintaining existing code. He writes (here): "[the maintainence programmer] views your code through a toilet paper tube. He can only see a tiny piece of your program at a time. You want to make sure he can never get at the big picture from doing that. You want to make it as hard as possible for him to find the code he is looking for. But even more important, you want to make it as awkward as possible for him to safely ignore anything. "

    Literate programming in general, and Leo in particular, would be the ultimate cure for this. It allows you to easily navigate between multiple levels of description of a program. This is critically important if you are coming fresh to an existing piece of code. You need to constantly cross-reference the high-level design and low-level implementations (and the various levels of description between these extremes).

    --
    Sailing over the event horizon
    1. Re:Curing unmaintainable code by edream · · Score: 3, Informative
      Thanks for this comment!

      A lot of people seem to feel qualified to comment about Leo after just reading the original slashdot article. Most have no clue about what Leo is or isn't. I've spent seven years working on Leo. I'm getting pretty annoyed about people commenting about Leo without even taking seven minutes to play with it.

      Leo really isn't all that much about either literate programming or documentation. I explain what Leo is in my posting, "The creator's view of Leo."

      Edward K. Ream

  18. Re:Anyone with 20 icons in their system tray is nu by docbrown42 · · Score: 1

    Really? Why? I have ~56 icons in my tray (for all the major programs I use). I find it's alot faster to click the icon than find it in the Start Menu, and I dont clutter up my work space (the desktop).

    -Ed

    docbrown.net NEW!
    Graphic Design, Web Design, Role-Playing Games...all the good stuff

    --
    Ed Wedig
    Graphic design services
    docbrown.net
  19. Re:COX by nullgel · · Score: 0

    All that matters to me is the near 1.5 up and down. Sure I have to share it with hogs occasionally, but I can hog it too, serving a game now and then. (And yes, I'm a posting newb, posted to the wrong story even.)

  20. It still won't take off.. by Da+VinMan · · Score: 3, Interesting

    I've tried Leo in the past, and while I support the author's ideas and the idea of literate programming in general, I do not believe that the practice will become significantly more common in the near future.

    There are two reasons I believe this:

    1. More and more modern IDEs support the idea of folding sections of code at multiple levels. Combine this with some well placed comments, and you achieve a very high degree of readability. This nullifies the primary benefit of Leo and ensures that most developers won't ever look at literate programming tools.

    2. Changing over to literate programming is, at least superficially, a large change. It's a large change because it requires that developers switch their primary environment. That's a big deal. Even if developers had the tools for literate programming in their preferred programming language already in their hands, they probably wouldn't use it.

    I do hope I'm wrong about the above though. I think a shift in the industry (even for a relatively short time) to literate programming would give us new ways of thinking about systems design, development, and would greatly ease long term maintenance.

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    1. Re:It still won't take off.. by beme · · Score: 1

      One cool thing about Leo is that you can mess with source inside leo and it'll update your source files, and you can also mess with your source in your preferred editor and leo will just suck in the changes. So, you could start out a program using the outlining editor, jump into your preferred editor to fill out the actual code, then jump back into leo to update comments, add features, move blocks around, etc. Jumping around is a bit of a pain, but maybe the payoffs are great enough. I'm going to give it a shot, just in case.

      --

      -beme
      1971
    2. Re:It still won't take off.. by edream · · Score: 1
      Last summer I added @file directives to Leo; if you haven't used Leo since then you might want to give it another look.

      The difference between @root and @file trees is that files derived from @file trees are the primary documents (redundant information is also stored in .leo files). This means that if you change something in the derived (source) file, those changes automatically will appear when you next reload the outline. This makes it much much easier to integrate Leo into already existing workflows.

      I would love it if all IDE's had outlining even remotely as powerful as Leo. Alas, none do, that I know of.
      1. Leo allows the user to reorganize outlines freely by adding, deleting and moving nodes. IDE's dont.
      2. Leo opens an outline as it was when the user last used it, restoring the selected node, the top visible node, and the expansion state of all nodes.
      3. Leo supports cloned nodes, a crucial feature in project management.

      - Edward K. Ream

    3. Re:It still won't take off.. by Da+VinMan · · Score: 2

      I would say that IDEs do not support outlining at all. My observation was just that code folding (such as that provided in Visual Studio.NET) would provide everything that most developers think they need. Of course, it's not the same as literate programming, but it does bear a superficial resemblence.

      More importantly though and FWIW, I think we all owe you a big "Thanks". You've brought the literate programming discussion back to life for everyone and I'm sure we're all better off for it.

      And a quick question: Do you think you'll ever put together a commercial version of Leo that functions within mainstream IDEs? I can see how Leo's features would be particularly useful within the context of products like VS.NET, Eclipse, etc.? I'm just curious on this count, but I know what a big effort this represents.

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    4. Re:It still won't take off.. by Louis_Wu · · Score: 3, Insightful
      Combine this with some well placed comments, and you achieve a very high degree of readability.
      [sarcasm]

      Good writers know how to spell, and will catch spelling errors while proofreading for content and style. Besides, all good writers have dictionaries sitting on the desk for clarification of subtle meaning of words, and thesauri to remind them of better ways to express the idea. Knowing this, spellcheckers are unnecessary, and often counterproductive. I can't tell you how many times I've been writing a technical paper and had some stupid spellchecker choke on acronyms or technical terms! A good writer's skill nullifies the primary benefit of a spellchecker.

      [/sarcasm]

      But seriously, the problem isn't that it is IMpossible to write good, well documented code with Your-IDE-Of-Choice, but that Literate-Programming + Leo might make it easier to write well documented code. Hmm, sounds like the language selection process for a project; text manipulation in Perl, sound driver in C. You could write your text mangler in C, but Perl makes text processing easier. That's the point of Leo, make documentation easier.

      Consider any spelling errors intentional. :) BTW, I tried to post this two hours ago, but /. disappeared from the net. Since the discussion continued, I can only conclude that it's the computers at work which were being stupid.

  21. Been there, done that by devphil · · Score: 4, Funny
    It's wierd, when you think about it, that programming is still done in flat text files.

    Every compiler vendor who has sold a mainstream language compiler/IDE using a "program database" or some other such approach has tanked. (Note that I mean program database as the primary means of storing the code -- a replacement of flat files, not an addition to them.) So far, it's not really been a technological lack, it's just that programmers don't like it.

    I recall reading some papers written by the major language guys a decade ago, and one of the things they all wanted to see was per-function recompilation (instead of per-translation-unit), better program information (like "where is this function used?") and other things that would require a more database-like format. Still hasn't happened except in research environments. (Pity.)

    One could argue for programs in HTML, with the code bracketed in XML

    One could, but one would be a lunatic.

    (I'm too tired to write it all down now, but I'll just summarize by saying that XML is not a silver bullet.)

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
    1. Re:Been there, done that by kawika · · Score: 2, Interesting

      Every compiler vendor who has sold a mainstream language compiler/IDE using a "program database" or some other such approach has tanked.

      Well, except for Microsoft. Visual Studio 6 didn't go far enough in that direction, but it was a start.

      Visual Studio.NET does a lot more. In addition to its own use of the database, the IDE is built so that third parties can hook into it and add their own functionality. For example, one vendor will be releasing an add-in that takes UML and creates source for the appropriate C# or VB classes. If you later change the classes in source, it updates the UML.

      Sorry to sound like a marketing pitch.

    2. Re:Been there, done that by kawika · · Score: 1

      I'm too tired to write it all down now

      And I'm too tired to be writing coherent posts, obviously. As you said, the solutions that put the source INSIDE the database have failed. But that's because it's not necessary. I don't think that needs to be done in order to have an effective design/code environment.

    3. Re:Been there, done that by colnago · · Score: 1
      I work in an environment that uses Argo Data's Bankpro - a "language" using a program database.

      I suppose at its inception 10 years ago it was pretty cutting edge but now it's a dinosaur unable to stay on the edge or take advantage of the latest technology. It's holds its market share because large financial institutions don't want to give up the dollars invested in their applications in order to rewrite them.

      Perhaps its the way they built their "IDE" and not necessarily the implementation of the language but I have never worked in a more difficult to manange environment. It's nearly impossible to keep logic straight in your head since, in the Bankpro way, you must move to seperate physical areas within the ide to define variables. The debuggers, and find utilities suck. Automated testing tools don't function well since the application interfaces are controlled by proprietary code. The amount of code in any one "file" is limited by the number of characters in use so you need to be careful not to put too many comments in the code. It's very difficult to partition functionality in logical ways since it's coupled to a physical layout of the IDE. And on and on.

      I wouldn't wish it on anyone except an ex-dotcommer who needs a job really bad. Oh...that would be me.

    4. Re:Been there, done that by mmol_6453 · · Score: 1

      As far as Microsoft and your average PHB (as well as the general public):

      If Microsoft does it, it's necessary.

      It's an old argument but think of it this way: The only people who have problems with what Microsoft does are those who get trodden on. In the mean time, they were taking advantage of other people being trodden on, without realizing it.

      Sounds like spa

      --
      What's this Submit thingy do?
    5. Re:Been there, done that by Tablizer · · Score: 2

      (* I wouldn't wish it on anyone except an ex-dotcommer who needs a job really bad. *)

      What is wrong with ex-dot-com-ers????

      I got into web stuff because I saw it as a decent solution to some fat-client problems, not because I was a gold-digger. (And, I was in the computer biz long before the craze hit.)

      I think what you have in mind is somebody who jumped into web stuff when it was big bucks (or at least big promises).

    6. Re:Been there, done that by Anonymous Coward · · Score: 0

      You were a "dot comer" because you have no real technical expertise. You code VBScript and talk out of your ass on several forums about your misunderstandings of computer science. You find trivial special-case rules from simple languages "hard to grasp." Your comments have always made me nearly shit myself with laughter.

    7. Re:Been there, done that by RelentlessWeevilHowl · · Score: 4, Interesting

      IBM's Visual Age for Java used something similar, adapted from their Visual Age Smalltalk. My problem with VAJ was that you couldn't do anything in their environment except what they had specifically designed for you to do. If you have files in disk, you can run whatever tools you want on them. But in VAJ or Visual Studio .NET? "I dunno, what's in the context menu?"

      To avoid flat text files, you'd need an interactive scripting language powerful enough to perform any task you'd care to think of (viz., Emacs). Plus you'd need enough support libraries available to you to interact with third-party utilities, and finally bindings for the abstract syntax trees of all the languages you want to program in, so you could manipulate them programatically.

    8. Re:Been there, done that by Anonymous Coward · · Score: 0

      Tera's compiler starts with normal source files
      but then compiles them into a program database.

      This allows for much better optimizations because
      the compiler knows about the whole program.
      For example: it's really good at inlining.
      Also, it only re-compiles code which changed
      since the last run. A good thing since it's kind
      of slow.

      It seems like a natural way to compile programs.
      I don't know why more compilers don't do it.

    9. Re:Been there, done that by jerryasher · · Score: 2

      ;;; lisp is not a research environment ;;; http://www.orbitz.com ;;; http://store.yahoo.com

      t

    10. Re:Been there, done that by Anonymous Coward · · Score: 0

      ...by saying that XML is not a silver bullet.

      Maybe it is...with every silver bullet comes the ability to shoot yourself in the foot ;)

    11. Re:Been there, done that by Tablizer · · Score: 2

      (* You were a "dot comer" because you have no real technical expertise. You code VBScript and talk out of your ass on several forums about your misunderstandings of computer science. *)

      I will pit my programming skills for real applications against yours anyday, AND they will stand up to change at least as well!

      I am good and I can kick your ass at software design any day!

      OOP is an unproven fad and you know it because there is no fricken evidence that it is better for common domains.

      No
      God
      Damned
      Fricken
      Real
      Evidence, Just fan noise.

    12. Re:Been there, done that by Anonymous Coward · · Score: 0

      You code VBScript and talk out of your ass

      Uh, what's wrong with VBScript? It is not my first choice, but whoever said there was choice in cubicle-land? I miss named parameters and it is a little buggy sometimes, but what else don't you like about it?

      By the way, what language do you think is the cat's meow that is in common usage?

    13. Re:Been there, done that by Anonymous Coward · · Score: 0

      XML doesn't need to be a silver bullet to be useful in this situation, so perhaps you should explain why you think it lunacy?

      I mean, the article is showing a program that effectively stores your code in XML anyway, and transforms it, and I can already see the usefulness of this application.

    14. Re:Been there, done that by CommieOverlord · · Score: 1

      Every compiler vendor who has sold a mainstream language compiler/IDE using a "program database" or some other such approach has tanked. (Note that I mean program database as the primary means of storing the code -- a replacement of flat files, not an addition to them.) So far, it's not really been a technological lack, it's just that programmers don't like it.

      I recall reading some papers written by the major language guys a decade ago, and one of the things they all wanted to see was per-function recompilation (instead of per-translation-unit), better program information (like "where is this function used?") and other things that would require a more database-like format. Still hasn't happened except in research environments. (Pity.)


      IBM VisualAge is hands down the best IDE I've worked with yet. No files to work at with all, everythings done by modify the database. Per-function compilation, excellent navigation, amazing debugger. It took a little bit more time to learn to use, but every now I then while I'm programming in Visual Studio I remember all the useful features that are no longer available.

      I have had experience with the Java version, and there are also C and SmallTalk versions

    15. Re:Been there, done that by pacc · · Score: 2

      Yup, the proposal was to edit in HTML code to be able to see the results while coding, not to get a lot of brackets all over the place. XML lets you do that, the other alternative is to create a totally new standard to store all the extra information...

      Though I admit that editing XML raw without any auto-completion, syntaxchecking etc is pretty useless.

  22. Re:Bogus by Kasperitus · · Score: 1

    Any sort of program that you plan on using long term will almost undoubtedly need updating. Do you really thing you are going to recall how some program you wrote a year or more ago was structured? That's ignoring the very likely possibility that it isn't the original programmer that is updating the code. It may be faster to just build a new program from the ground up.

    Without proper documentation or comments, code is (almost) completely useless.

  23. Re:COX by unicron · · Score: 2

    No, you're more than a posting newb if you think just because your house is wired with fiber that you're going to get speeds like that. Because from the nearest CO, that shit is all coax, so unless your running fiber all the way there, which can be some distance away, you're full of shit.

    --
    Finally, math books without any of that base 6 crap in them.
  24. The Problem With Literate Programming by raytracer · · Score: 4, Insightful

    The biggest problem with literate programming is that most people don't write programs that are worthy of exposition. Most programs are written under extreme time constraints to solve immediate or practical problems, and their complexity arises from handling exceptions, special cases, and last minute or ill conceived extensions. Documenting these with prose actually doesn't help very much, as the prose reads pretty much as the code does: as a set of ill conceived exceptions rather than bold themes. Making the prose flow well is just work that could be used to make the code better.

    If your code doesn't have these faults, then the code is already an expression of the program ideas, and one that you can excecute, so in that case literate programming techniques are needed to a much smaller degree.

    There is no doubt that literate programming (like extreme programming) has its benefits, but their principal benefits are to encourage an attitude of critical evaluation to your coding efforts. This criticism is encouraged in literate programming
    but not a unique feature of that approach.

    1. Re:The Problem With Literate Programming by edream · · Score: 1
      Leo really isn't all that much about either literate programming or documentation; it's about structure and clarity of vision.

      Please read my posting, "The creator's view of Leo."

      Edward K. Ream

    2. Re:The Problem With Literate Programming by terminal.dk · · Score: 1

      I write literare code. Have been writing it for almost 10 years. I document what I am trying to do, and then write the code. I repeat the same thing when I get to more complex parts.

      Means my code is well documented, and just as important, debuggable by other people.

      No comments in the code means no brain in the code.

  25. Re:Bogus by tj2 · · Score: 1

    If your goal is "getting it right the first time", you've missed with this post.

    No, my car doesn't have little notes, but it doesn't need them, because I am a *user*. But I'd be willing to bet that the manufacturer has beaucoup documentation about each part. How it was designed, who built it, where it goes, etc.

    If you don't document the code, where are the references that others will need to understand the code? Frankly, you sound like someone who doesn't really believe that they'll ever miss a spec, mis-code an algorithm, or make a mistake. Perhaps you don't understand that the purpose of a program is to accomplish some goal. To achieve the goal, it must be written by someone. In order for someone to write it correctly, they have to be able to effectively parse the logic.

    I'm not sure that Literate Programming is the answer, but your argument makes little sense. "Read it a story"? Hell, why use a language at all? Just get a hex editor and start punching bits in pure machine code. Surely you're that good, but some of us lesser mortals might have trouble.

  26. Re:COX by nullgel · · Score: 0

    Simmer down... There's no fiber in the house. It's all CAT-5 from the disto box outside. There is a COX Fibernet box out there. (seen it) I know the BW is there for a fact. I've montitored it extensively.

  27. Re:Anyone with 20 icons in their system tray is nu by override11 · · Score: 0

    No no, I have a lot in my quick launch bar too, I mean actual running programs, by the time in the lower right. Unless you happen to be sporting gigs of ram, why in the world would you have all that stuff start up every time you turn on your computer?? :)

    --
    No I didnt spell check this post...
  28. Re:COX by unicron · · Score: 2

    Yeah, but do you honestly think you're "pulling one over" on Cox?

    --
    Finally, math books without any of that base 6 crap in them.
  29. Even more Bogus... by Midnight+Ryder · · Score: 2

    Hey Jack - I think your example is actually more bogus than what you are complaining about. Let me yank this one section out, and put things in perspective...

    The goal of a programming language is to provide a machine with a set of instructions, not to sit down and read it a story. Do you expect your car to be made of parts which have little embedded notes explainging how they were engineered? Of course not, that's just silly

    And, when you look at your compiled program, you don't see comments or documentation inside of it either. The compiler strips it out, as it should. However, when you code, you document. When a car builder designs a machine, they document it into such detail level it makes programming documentation look sparse (most of the time - I've seen it be overdone before ;-) It doesn't matter what you do, building cars, wiring offices, or programming, you better be documenting what you do - and those who don't regret it later, and lack of planning up front causes serious issues.

    I probably shouldn't pick on your example - but it was a really nasty example.

    Now, I don't completely disagree with your opinion that it's gimmicky, but, this provides yet another process for people to adopt if they so choose to. Any method that people feel comfortable with for software engineering or documentation that gets them to DO IT, well, sounds like a good idea to me.

    --

    Davis Ray Sickmon, Jr - looking for something to read? Check out my three free novels at MidnightRyder.org

  30. lit vs unlit? ;-) by sstory · · Score: 1

    Literate programming is how Wolfram wrote Mathematica. Perhaps because of that, it has remarkable structural consistency. I doubt it'll catch on, though, because it takes more discipline and brains to determine the structure before coding, than to code it up, and then explain it.

    1. Re:lit vs unlit? ;-) by renehollan · · Score: 2
      Ah, but Wolfram is a mathematician, no? Presumably, then he thinks in a way that an expository style would match well to a first cut at code -- I'd bet his comments are merely code for a non-existent programming language in his mind.

      I tend to do this too, when I'm developing, but I use a less precise C++ish pseudo code. It's the best way for me to think about code that will have to be shoehorned and implemented in a particular language that's likely a good implementation fit.

      --
      You could've hired me.
  31. Re:COX by nullgel · · Score: 0

    No. They just don't seem to care. There are two COX employees in the same complex. Perhaps they have something to do with it. I don't push my luck though. Well, not very often.

  32. More focus on API Doc and Unit Testing by one9nine · · Score: 3, Insightful

    I don't think what he has is bad, but I think there a better ways to achieve cleaner code.

    Many people have mentioned that writing cleaner code is the best form of documentation. This is definitely true, unfortunately you still have people who use letter for significant variables (i.e. not loop indexes) and who don't format their code or try to do too much in one line of code.

    I think a better approach to documentation is the test driven approach that is used in XP and with packages such as JUnit and Cactus. Basiclly, you write your test cases first, which will force you to pin down the exact functionality for your components. These unit tests are essenailly doecumentation on how your components should work. Granted, this doesn't document the specific code but I think that one of the reasons why so much code is hard to read is because the functionality was not clearly thought through.

    I also think API documention is more important. Alot of times I am trying to use an open source package and I have a hard time understanding how to use the API to achieve certian fucntionality. I can read the code just fine but it isn't clear how to use the objects themselves.

    1. Re:More focus on API Doc and Unit Testing by momo-chan · · Score: 1

      I also think API documention is more important. Alot of times I am trying to use an open source package and I have a hard time understanding how to use the API to achieve certian fucntionality. I can read the code just fine but it isn't clear how to use the objects themselves.

      Your example is precisely why high-level overviews are just as important as class- or
      method-level docs: without something that tells you how it all ties together, and what ends can be be achieved, the most detailed API doc is frustrating at best.

  33. Re:Bogus by Anonymous Coward · · Score: 1, Funny

    "The goal of a programming language is to provide a machine with a set of instructions, ..."

    No. From SICP: "...a computer language is not just a way of getting a computer to perform operations but rather that it is a novel formal medium for expressing ideas about methodology. Thus, programs must be written for people to read, and only incidentally for machines to execute."

  34. The right balance by teetam · · Score: 4, Interesting
    Too much documentation is just as bad as too little documentation, even when the documentation is good. It is very difficult to strike a balance.

    For example, many of the core java apis are well written and well documented. If you see the HTML javadocs, you can get a pretty good idea of the class.

    However, when you open the source code of the same class, it is not good looking anymore. Why? Because each method is preceded with dozens of lines of javadoc, each of which is embedded with HTML markup. That is good when the javadoc HTML pages are finally generated, but not so good when you look at the source itself. C# is worse with its XML based documentation!

    When I look at the source code, I want to see the flow of the code easily. All the documentation in the source should only aid this and not hinder this. Javadoc does both. The explanation part of the javadoc can be very useful in understanding what the author's intent was when he/she wrote the method, but I am not so sure about the rest. The param, return and exception tags are no doubt useful, but often developers don't explain these very well. Plus, these are the tags that can easily become outdated.

    I would prefer short and succint pieces of information documenting the code, preferrably close to the line of code that it documents.

    --
    All your favorite sites in one place!
    1. Re:The right balance by e2d2 · · Score: 2

      I agree with the idea of having it both hinder and help at the same time. When you see 30-50 lines of comments for each method it can sometimes get in the way. I (partially) like the way Microsoft has handled this with their C# compiler, allowing the developer to generate xml a meta document similiar to JavaDoc or the developer can choose to place the comments in an external file and reference them from within the code comments using the tag. But I did not like the way it outputs only xml, so if I want an html document I have to either use VisualStudio's tool to output html comments based on their templates (poo poo) or parse the xml myself.

      A standard for Literate Programming certainly wouldn't kill any of us.

    2. Re:The right balance by e2d2 · · Score: 2

      doh, it ripped out the include tag in my post above for obvious reasons. The C# include comment tag is what I was talking about.

    3. Re:The right balance by Anonymous Coward · · Score: 0

      For example, many of the core java apis are well written

      Bwaaaa haa haaaaa ha haaa ha!

      You a funny man. You make me belly jiggle with laugh, like jelly in Sun man head when make API.

  35. Nice step forward by MrBoring · · Score: 1

    At least the idea is nice. Attempt to keep the doc in sync with the code. Except in our environment most of the doc is actually in presentation forms, some diagrams, word documents, etc. These also need to be kept in synch with the code.

    As for the extraction/folding schemes most editors probably do this to some extent. Visual SlickEdit does folds, organizes things by method, class, file or whatever you want.

    As for the text comments, the problem with text seems to be the tagging, and search/replace algorythms. Maybe I'm the last person to still use C++, but sometimes VSlick gets confused with templates, and can't follow pointer->method calls when the method is inherited (sometimes). It *would* be nice to have the code intelligently digested, paying attention to preprocessor symbols, doc, etc.

    As for documentation, my hat's off to those who do this. Unfortunately, most if not all languages don't force this, because it's either difficult or impossible. I'm not sure that Leo forces anything more either.

  36. Low-level, high-level, ultra high-level by Walt+Dismal · · Score: 1

    I agree and disagree with Jack.

    Leo seems to support only a linear tree structure. That seems restrictive. I would argue that a directed flow diagram is a better way to show the overall structural relationships of code modules. Thus a more graphic IDE would be better, something like Visio combined with an editor. I used to create prototypes in pseudocode diagrammed in Micrografix Flowcharter, which supported hyperlinks from graphic objects. So I could draw flowcharts and click on a node and jump to the underlying code text.

    I do not agree with Jack's philosophy. If the only goal of a programming language were to provide instructions, we'd all be writing assembly language. The power of computers is that they support creating intellectual power tools. Why should a human have to remember 1001 esoteric rules in order to write bugfree code? Let the machine do the heavy lifting. An ultra high-level PL environment would let you tell it a story, and it would fill in the details for you. Which would you rather do: drive 3000 miles with a map in one hand every step of the way, or simply get on a plane?

    I think a programming language and its usage environment should provide an intellectual buffer between the ideas of a programmer and the specific mechanization of those ideas. They should be power tools for expressing thoughts and organizing them. Documentation should be a natural part of that environment, integrated into the expression of the code.

  37. thought for java geeks out there by kisrael · · Score: 1, Offtopic

    I'm not liking EJBs very much, and I think this post points to some of the reasons why...there's so much damn boiler plate code there, just to do the same simple tasks. (and making it worse, I have a general distrust of those fancy-shmansy editors that try to do all that bean stuff for you.) Approach someone else's code and you first have to figure out where to begin...naming conventions can help, but still.

    EJBs (especially entity beans; session beans (especially stateless ones) are ok, though for 90% of uses regular java classes and static classes could do the same thing) seem to be the antiperl in some respects; it makes the easy jobs difficult and the difficult jobs impossible.

    --
    SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
  38. Another Idea... by Sj0 · · Score: 2

    Another idea which would work well in this respect would be altering the language used to be more reader freindly. Much C code is written whose syntax is a greater barrier to understanding the code than any concept underneath. Seperating some aspects of the language from regular syntax (such as pointer notation -- Sure, it's simple in theory, but in practice, it takes a fantastic long-term memory to remember whether you are witnessing a pointer being set to a memory address, or a value being placed into a variable without flicking around the source code or using a third party utility, which just slows you down and interrupts your thought process). Sure, an experienced coder can decipher obusficated(spelling?) code, but if the language makes it one step easier, that's a little bit of brain power to the question of "Why the hell did the original code do that?", and takes a bit away from the question "what the hell does this code do?".

    --
    It's been a long time.
  39. literate programming is great.. by Anonymous Coward · · Score: 0

    ..and i suggest anyone who wants to turn their 5-line useless programs that look like shit into a 500-line useless program that looks like you know something use it..honestly, why would you possibly want to spend that much time commenting, if you really have that much trouble understanding your code i suggest you either learn the language your using, or if you think you already did that, find another profession.

    1. Re:literate programming is great.. by Bush+Pig · · Score: 0

      Try coming back to something complex six months after you wrote it, and see how well you understand it. Or try maintaining someone else's code. Then you'll appreciate well- (not self-) documented code.

      --
      What a long, strange trip it's been.
  40. Interesting, old, and better methods exist by Anonymous Coward · · Score: 0

    I've seen this before, but typically from the other way around. Browse databases generated from C++ source. You also have XMLDoc in languages like C# where every class, method, etc. is prefixed by a section of XML that describes that item and each piece of that item. And then you have intentional programming which is the concept of programming to a database instead of a flatfile where the database contains all of definitions for symbols for various languages and can flip without effort. For example you can change from C++ source to flowchart to circuit schematics and back into C++. This is called intentional programming.

  41. Depends on lifecycle by Hayzeus · · Score: 1
    Do you really thing you are going to recall how some program you wrote a year or more ago was structured?

    Really, it depends. Some code has a pretty short life-cycle prior to a complete rewrite. The company I used to work for generally produced this kind of software. Requirements for a product might change pretty radically within a year or two.

    The people I work for currently, on the other hand, expect to get a lot more life out of a given piece of code. In this case, the extra effort on design and code documentation, as well as the work required to keep it up to date, is easily warranted by the need for long-term maintenance.

  42. Outlining and LitProg by DarkMan · · Score: 2

    One of the advantages of Literate Programming is (at least from my experinece) is that one can start with a general idea of what is needing done, and then fill down to the end, as it suits the programmer. For example, when writing a sorting routine, at some point I know I'll need code to swap the contents of two pointers. I can (in CWEB) just put a place holder in, and write it later, or, if I've got the code in my head, just write it down directly.

    This method models the way that (for me at least) code is thought about. That's the key idea in LitProg - to put the source code / documentation down in a manner that models the thought processes of the programmer.

    I don't have a full, firm, outline in mind right at the start. That's not to say I don't think about it - but it's not final. Using an outliner at the start would not work well with me. CWEB forces me to document the thought behind each step of the algorithm, and presents it in logical order, even though it was not written in that order.

    Maybe if I had a cast in stone plan for the code before I start, I'd write better code. But I work well enough with CWEB &c that I don't see the addition of an outliner assisting.

    Frankly, looking at the web page, it looks just like an outlining code editor - nothing that dramatic, and I'd rather stick to vi + CWEB.

  43. Works transparently with other tools by jko9 · · Score: 3, Informative

    Something I didn't put in the original notice but now regret that I left out - Leo has another new feature more difficult to describe, but that which solves the problem that several people have mentioned about not wanting to abandon an existing text editor or tool. Leo can embed an outline structure in comments, so that one programmer can work with the file in JBuilder or EMacs, and a third programmer can still work with the program(s) in Leo. In effect, Leo is a meta-text editor. When Leo opens an outline containing a file that has been edited with another editor, all of the edits are retained. This is a further extension of LP because you are getting code read back into the documentation, which means that LP techniques can be used for understanding and/or teaching existing programs. It also means that Leo allows LP to be a secondary technique to add additional structure and documentation, rather than necessarily being the primary technique. This is explained in more detail in the tutorials and Leo docs.

    It is true that there are other IDEs that allow folding, e.g. Visual Studio .NET, but this ability to separate the outline from the program is something new, as far as I know. Also, unmentioned in the original article is the idea of having clone nodes, which means your outline can put the same code section into different branches simultaneously.

  44. Why this doesn't work. by FreeLinux · · Score: 4, Insightful

    The following statements will be highly inflamatory to many people. They are not intended to be inflamatory but, rather a simple observation.

    Basically, Leo is yet another tool to automate the documentation of programming code. There are dozens, possibly hundreds, of programs available for this task. Yet, the problem that these tools were designed to solve remain very prevalent, if not pervasive.

    The reason that the problem remains and that Leo will not solve the problem either is relatively simple. Simply put, the problem is garbage-in, garbage-out (GIGO). These tools are not able to determine the purpose of the code or the intent of the programmer that is writing it. These tools cannot read the minds of the programmers. The tools rely on the programmer to write out their thoughts and the intended purpose of the code.

    Most programmers are unwilling or incapable of performing this critical step thoroughly. All too often, they use shorthand and expect the reader to understand what they mean. Or, they believe that the reader should be able to understand their thought process by reading the code itself. Furthermore, they assume that if the reader can't do this, they are simply not a good programmer (1337).

    To go a step further, many programmers are not capable of clearly expressing their thoughts in their native tongue. These people are quite brilliant and can do amazing things with their code but, they can't express their thoughts to another person unless that person is indeed, able to read and comprehend the code itself.

    Now, in fairness to the programmers, we have to look at what they do and what they are taught. Most programming languages are all about efficiency. They rely heavily on abreviations and aliases, why do you think it's called code? They are designed to require a minimum or typing while providing a maximum of functionallity. The programmers themselves are always striving for increased efficiency both in their code and in the way they get the code done. They always try to put out more which leads to further shortcuts and abreviations. This all tends to make programmers minimalists and their documentation clearly reflects this.

    So, Leo is unlikely to provide any documentation breakthroughs. The old rules still apply, garbage-in, garbage-out. The best idea I've seen was an earlier post, where the documentation is written first and then the code is developed to match the documentation. But, honestly, which of us going to do it that way. That's a lot of work and our ingrained habits are going to be hard to break.

    1. Re:Why this doesn't work. by PigleT · · Score: 2

      "Furthermore, they assume that if the reader can't do this, they are simply not a good programmer".

      Well, as an asumption as you mention this would be bad. Note, however, that there's a very prevalent half-way state: those who really shouldn't be looking at a program because they don't know the language with its idioms, but still somehow declare it to be "illegible", more because of their own shortcomings than any other.
      IOW, ability to *read* source is a distinctive feature of a good *programmer*. I've experienced folks who can spew code like the proverbial curry after a few pints, but were strangely unable/unwilling to look in any detail at it to debug it later...
      Just a point to raise in your considerations...

      "why do you think it's called code?"

      I absolutely hate calling a good program "code", and therefore don't. I suggest you confine your use of the word to garbage that the compiler can understand and your Typical Average Humanoid, even one well-versed in the language, can't (at second inspection).

      "This all tends to make programmers minimalists and their documentation clearly reflects this."

      By and large, I'll agree, although I think minimalism can be a form of elegance in the program itself.

      FWIW (karma whoring, no doubt), <a href="http://haskell.org/">Haskell</a> has had a "literate" mode (*.lhs instead of *.hs sources) since the get-go as well. Leo is definitely not the first.
      And the rest of the language is pretty darn' minimal too - the "list composition" [expr | condition ] stuff reads almost like Perl-meets-SQL to me ;)

      --
      ~Tim
      --
      .|` Clouds cross the black moonlight,
      Rushing on down to the circle of the turn
    2. Re:Why this doesn't work. by jko9 · · Score: 1

      Leo is not a tool for automating the documentation of a program. Did you look at the tutorials?

      Secondly, Leo does indeed solve the problem of programmers not being able to write out a clear explanation of the program. The way it works is, the programmer shows the Leo outline to someone else who says "What the hell are you trying to say?" And the programmer just has to keep working on it until it makes sense. There is no excuse for the programmer not to show his code to another person, since it now has an outline IN ENGLISH. That is a much better situation than having this programmer just write out code that no one ever checks for logical clarity - this code will presumably have the same problems that the programmer's prose does.

      If you can't explain something, you don't understand it.

    3. Re:Why this doesn't work. by edream · · Score: 1
      I am the creator of Leo. Your comments are not inflamatory, they are simply wrong. It is a gross violation of common courtesy to pontificate about that which you know next to nothing.

      Edward K. Ream

  45. Re:Bogus by joto · · Score: 2

    This wouldn't be so bad if you actually was funny, Jack. But regrettably, you are not, and if someone laughs, it is you they are laughing off.

  46. Mod Parent Up by Anonymous Coward · · Score: 0
    If I've just walked in to your code, I don't know what behavior it's SUPPOSED to have, since you haven't documented that. All I can tell is what it DOES do. And since code changes over time, it's impossible for me to distinguish between the two, unless you document it.

    Someone mod this up! You've hit the nail right on the head.

  47. Re:Bogus, truly! by alienmole · · Score: 4, Insightful
    I've been a Q1 member of the IOOC 911.11 committee for programming languages since the early 90's

    IOOC 911.11? Would that be the International Olive Oil Council, or the Iranian Offshore Oil Company?

    Not to feed the troll, but for the benefit of any impressionable young programmers:

    The goal of a programming language is to provide a machine with a set of instructions, not to sit down and read it a story.

    Programming languages intended for use by humans (as opposed to languages intended primarily for machine generation) have multiple goals, three of which are to be human-writable, human-readable, and human-maintainable.

    Literate programming may not be a perfect solution, but it's addressing a real issue. Current programming languages tend to be pretty horrible at expressing abstractions in a human readable way. The ideal programming language would be one that allowed you to express abstractions at the level of the problem domain, yet was able to translate that into something as efficiently executable, or close to it, as something written in a lower-level language. Literate programming allows you to do something along these lines, although it still involves a fair amount of "manual intervention" on the part of the programmer.

  48. emacs Mode? by bozoman42 · · Score: 1

    This seems like it should be easy to implement as an emacs mode of some sort. Anybody know if it's been done / is being done? I'd be remiss to give up XEmacs, thanks.

  49. Well this is very clear code by cpex · · Score: 1

    I am sure most of you have seen this but this is some of the most clear codeI have ever seen.

    1. Re:Well this is very clear code by bytesmythe · · Score: 1

      Obviously it implements a semaphore. ;)

      --
      bytesmythe
      Hypocrisy is the resin that holds the plywood of society together.
      -- Scott Meyer
  50. Best multi-platform multi-language editor? by Anonymous Coward · · Score: 0

    While on the topic of tools for development, what's the best open source editor out thete with support for multiple languages (C, C++, Java, Perl, Python, etc) that runs on multiple platforms (Linux/*BSD/Windows) and supports basic stuff like syntax highlighting and more advanced stuff like code block folding/collapsing, etc?

    1. Re:Best multi-platform multi-language editor? by Anonymous Coward · · Score: 0

      emacs

    2. Re:Best multi-platform multi-language editor? by Theom · · Score: 0

      Emacs?

      --

      mp3: l33t term for empty.
    3. Re:Best multi-platform multi-language editor? by Bush+Pig · · Score: 0

      vi.

      --
      What a long, strange trip it's been.
  51. Re:Bogus by Tonetheman · · Score: 1

    You are sorely wrong and obviously do not work any where for a living. I spend more time reading code than I ever will writing it.

  52. Dunno how literate I am, but here's what I do... by smartfart · · Score: 2
    IANAP, but I've slipped into a mode of typing what I'm trying to make my program do in comments, then I'll dig through my PHP book to figure out how to implement it. Once I get some bit wortking, I'll add another comment saying, "ok, I can make that array work, but now I need to figure out how to put this data into it from a form or something...".

    Its ugly, but it seems to help me out.

  53. Excellent program, but not really new by murr · · Score: 1

    While I agree that Literate Programming is a promising concept and Leo is a promising approach to that concept, and while it's great to see some buzz for LP, Leo is not really a "new program".

    As far as I remember, it has been around in some form for more than 5 years, although the Python incarnation may indeed be new (Leo started its life as a Macintosh application).

    1. Re:Excellent program, but not really new by jko9 · · Score: 1

      The Python 3.5 version, which brings the Python version up to the level of the C++ version is new. Also, the @file feature is new. The @file feature is a breakthrough, since this is what allows Leo to work transparently alongside other tools. It may be this feature more than any other that will make it easier for people to use LP techniques in the workplace, since it allows people to introduce LP techniques as a secondary technology. This is explained better in the Leo docs and the online tutorial. I probably should have said "the new 3.5 version of Leo" in the article instead of just "Leo", but I was trying to be as brief as possible.

  54. Amen by ArcSecond · · Score: 4, Insightful

    I am more of a technical writer than a programmer (well, really, I'm not much of a programmer at all), but it was always clear to me that 90% of the software development headaches I lived with at various companies could have been resolved with minimal effort early in the project.. IF anyone cared about using a methodical approach to project documentation.

    But nobody likes documentation. Writing it. Reading it. Just the word makes some people itch. For some reason, this is something that BOTH business managers and programmers don't get: documentation saves work. It is a way to produce a testable set of requirements, then a testable architecture/design, then a way to match up features and metrics in production and testing.

    I mean, why does everybody think writing the manual is the LAST thing you do when you make software? With all the snarky "RTFM" comments I hear from geeks, I should start a new variant...

    "PUHLEASE! BEFORE YOU START CODING, WTFM!"

    --

    I've got a bad attitude and karma to burn. Go ahead. Mod me down.

    1. Re:Amen by G-funk · · Score: 4, Insightful

      The reason geeks don't like writing too much documentation is simple. It's not laziness (well not always), it's just one simple thing.

      Documentation written before the project completion is wrong.

      Always.

      Full stop.

      No matter how good your documentation is, people in charge will look at it, and go "great!" then half way through, they look over your shoulder and say "that's not how i want that to work" and they make a "simple" change that creates a whole new use case, or sends an existing one off on a tangent. Or, a programmer half way through will come up with a better idea himself, and discuss it with the boss, and so it changes from spec again.

      And the worst thing in the world definitely isn't no documentation, it's wrong documentation.

      --
      Send lawyers, guns, and money!
  55. programmers can't write by Anonymous Coward · · Score: 0

    Though sometimes they think they can.

    That can cost sales when prospective clients read the hideous grammar and the glaring misuse of words.

  56. Literate programming versus continuing development by Phronesis · · Score: 5, Interesting
    Although literate programming has a lot of potential, all too often literate projects become completely ossified. M.D. McIlroy's criticism of Knuth's literate programs (CACM 29, 471-83 (1986)), that they tend to be like "industrial strength Faberg eggs" as opposed to reusable tools, is still quite valid.

    For a project I am working on, I needed to extend CWEB to do some things Knuth hadn't thought of, and I found that excessive cleverness in the data structures made it much more difficult to extend than it should have been, so that Knuth could demonstrate clever data structures that probably add a few percent to the performance over what he could have achieved with more prosaic ones (Knuth does not document why he made these excessively clever design choices, nor whether the performance advantages they offer were significant).

    Similarly, a recent thread on comp.text.tex recently asking about the extensibility of TEX produced a number of comments from those who know about how unextensible and unreusable TEX really is.

    So, while I use literate programming (CWEB) to document a lot of my own code, I don't believe in all these years, that I have ever seen a good example of literate-programming that looks towards the future (refactoring, extending, reusing) as opposed to generating a fossil with that comes with a good story of its life and times.

  57. Sync code with docs, not vice versa! by dstone · · Score: 2

    At least the idea is nice. Attempt to keep the doc in sync with the code.

    I hope you meant "keep the code in sync with the doc". ;-)

    in our environment most of the doc is actually in presentation forms, some diagrams, word documents, etc. These also need to be kept in synch with the code.

    Ummm... You mean the code has to be kept in sync with these docs, right?! Please?

    From what I've skimmed of Leo, it's certainly not designed to generate/update docs after you wrote code. Thank goodness. Having to update docs to match the code can be a serious symptom. There are exceptions, of course, but in my opinion, if you're updating your docs -after- your code has already changed so often that you need a -tool- for it, welll....

  58. Sensible uses for Hungarian Notation by pommiekiwifruit · · Score: 1

    might include scoping (i.e. putting warts on globals and statics) and reminding you something is a pointer (pData). But none of this lpsz crap...

    1. Re:Sensible uses for Hungarian Notation by Sj0 · · Score: 2

      Old Qbasic had an interesting way of doing that. You just put the right symbol at the end of the variable. It forced you to follow the standard, because anything which wasn't declared otherwise was automatically a single precision floating point number(which hurts speed -- a lot.)

      --
      It's been a long time.
    2. Re:Sensible uses for Hungarian Notation by Anonymous Coward · · Score: 0

      I always put a prefix on member variables, to make the difference between member- and local variables clear. That's the only use I have for Hungarian notation.

      I particularly hate the next 'logical' step the typical Hungarian-style programmer seems to take: drop the name, and just use the type instead.

      const char *clpzs = "this sucks ;-)";

  59. Oh my, ignorance to a whole new level by Anonymous Coward · · Score: 0

    I can NOT believe this post got moderated up so high. Slashdot amazes me sometimes.

    The original post has nothing to do with what you are blathering on about. The original code makes perfect sense but is taken out of context. The problems you have with that snippit can not possibly be made for such a short piece of code.

    I could just as easily say "DAMN, that code won't run at all, there's no function declaration or anything. Hell, you can't just make some call like that, you need a main() ...".

    1. Re:Oh my, ignorance to a whole new level by Viking+Coder · · Score: 2

      The argument was made that good code is self-documenting. I'm saying that good code only documents its own current behavior.

      What is completely lacking is any indication of what should happen, as soon as the use cases become more complicated.

      The original poster was implying that the code was so perfect, that everyone should shut up and worship it as the end-all, be-all of self-documenting code. I found many, many flaws with the code. If you want to write the perfect version of it, that meets all of my demands, go for it.

      But - every time I add NEW requirements, you'll have to massively modify the code. As the code becomes more and more complex, it will have more opportunities to gain bugs. All this while, though, the documentation might remain constant, if it's written clearly enough.

      *shrug* You're welcome to your opinion, but I'd appreciate it if you wouldn't post as an Anonymous Coward, so I could have a real debate with you.

      --
      Education is the silver bullet.
    2. Re:Oh my, ignorance to a whole new level by Bush+Pig · · Score: 0

      I can't remember the last time I saw genuinely self-documenting code.

      --
      What a long, strange trip it's been.
  60. Re: Offtopic nitpick by juggleme · · Score: 1

    You know, I hate to nitpick your nitpick, but either way should be about as fast as the other since wq is one stroke if the ring and pinky move at almost the same time and that they are slightly more accessible than the x is (home row is easier than top row is easier than bottom row rule).

    </rant>

  61. guile 1.4.1.x uses twerp2texi by 10am-bedtime · · Score: 1
    (1.4.1.x is work-in-progress precursor to 1.4.2, fyi.)

    the trick here is to integrate texinfo (standard GNU documentation source format) generation with automake methodology (which assumes texinfo is hand-maintained). in the vein of foo2bar naming convention, the TWERP (Texinfo With Eval-Requiring Predelictions :-) file is processed to .texi with twerp2texi (which also handles indexing, automatic dependency tracking a la depcomp, and Makefile prep).

    here's a simple example (from doc/ref/scheme-compound.twerp):

    If you are unfamiliar with the inner
    workings of hash tables, then this facility
    will probably be a little too abstract for
    you to use comfortably. If you are interested
    in learning more, see an introductory textbook
    on data structures or algorithms for an
    explanation of how hash tables are implemented.

    @twerpdoc (hashq (C scm_hashq))
    @twerpdoc (hashv (C scm_hashv))
    @twerpdoc (hash (C scm_hash))

    The @twerpdoc directives expand to documentation on hashq (from Scheme) and scm_hashq (from C), mined from libguile/hashtab.c, and so forth. modify hashtab.c, do a "make" and the .texi (and .info and .html if enabled) is regenerated.

    this differs from the article's system in that outline info (and document organization in general) is maintained in .twerp files, which "pull in" reference docstrings and other bits as needed from source, rather than adhering to "one source" doctrine. probably we will introduce more @twerpFOO directives (e.g., to do bit-field diagram or embedded DAG layout) in the future. for more info, see documentation on twerp2texi itself in the guile docs (in tarball above).

  62. Re:look at the screenshot of pg 10 from the perl s by edream · · Score: 2, Interesting
    I am the creator of Leo. Leo shows that the "stream of consciousness" style typically associated with literate programming can be replaced with a more effective organization, one that is more like a reference book.

    So you could say that Leo turns literate programmers into reference librarians ;-)

    -Edward K. Ream

  63. Re:"Literate" was the word, right? by Anonymous Coward · · Score: 0

    Want something easier in the short and long terms? How about not hiring arrogant programmers whose grasp of everyday language is so poor that they can't post a coherent Web form?

  64. C# allows compiling to documentation by MBoffin · · Score: 1

    C# allows you to do this very thing. Basically the comments/documentation can be embedded right in the code itself in XML format. You can then compile the source code into documentation, as opposed to compiling it into binaries.

  65. Literate programming caveats by majordomo · · Score: 2, Interesting

    I've used both CWEB and noweb, the latter for a large scientific computing project involving (among other things) a large number of tensor operations. While I've thus found the TeX math typesetting features invaluable, literate programming has some serious drawbacks.

    The most common problem for me has been the function/code chunk dichotomy. You might have a code chunk like "Set initial conditions" and only later realize that your chunk is too long and you need a function: set_initial_conditions(). Literate programming makes it so easy to write chunks of code without wrapping them in functions that your code ends up with too many chunks. If you do take the time to make functions then you vitiate much of the advantage of your literate programming chunks, since you end up just deleting the chunks and replacing them with descriptive function names.

    Another serious problem is that it is very difficult to invert a literate program into human-readable source code; i.e., if you decide to junk CWEB and go back to C source and header files, you are in big trouble, since the machine-readable source code is horrendous -- not to mention stripped of all comments! So you really make a huge commitment if you decide to go the literate route.

    Having used lit. prog. for several small projects and one big project I appreciate some of its advantages, but on balance I think that well-documented standard code is better. The only thing I really miss in standard coding is TeX math typesetting, but this is easy to rectify. I just wrote a simple program to convert a regular source file into LaTeX. I use a Qt-style //! or /*! */ comment and then some TeX formatting in my source code and strip it out later to make my documentation.

    einstein.cpp
    ...
    /*! Einstein's equation
    is $G^{\alpha\beta} = 8\pi T^{\alpha\beta}$.
    */
    for (int i = 0; i != 4; ++i)
    for (int j = 0; j != 4; ++j)
    G[i][j] = 8*pi*T[i][j];

    ...

    The commands
    % simple_doc einstein.cpp > einstein.tex
    % latex einstein
    then produce a typeset version, with C++ code in typewriter font and the tensor equation in beautiful TeX math fonts.

    Lit. prog. might be good for some large, mainly single-author projects such as TeX or Mathematica, but it adds a layer of considerable complexity to your code base, forcing everyone who uses it to learn your system. It will also never make good programmers out of bad ones, and in some ways actually encourages sloppy code by making it easy to write chunks of code without good modular design. As a result, after my current project I'll probably not use a literate programming system again.

    -Michael

    1. Re:Literate programming caveats by Anonymous Coward · · Score: 0

      The Image Understanding Environment, a big computer Vision Library, used a literate programming method based on LaTeX. Despite almost all computer vision researchers being familiar with Latex for paper writing ,etc. this LP approach was rejected by users as too cumbersome. This is at least one of the reasons why the IUE is now considered as an interesting but dead experiment.

      Many of the libraries that went on to replace the IUE (e.g. VXL used heavily documented source in the doxygen style. This has proved much more friendly. I would suggest that one of the reasons is that a linear way of thinking about of code is insufficient for big libraries. Wrapping up the linear style in tree (as in leo) doesn't help either. People want to navigate straight to their documentation - which is what doxygen and a search engine provide.

  66. programmers can't write: the fly in the ointment by Xtifr · · Score: 3, Insightful

    There's an old saying (was on a "Murphy's Laws of Computing" poster I used to have): "make it easy for programmers to write in English, and you'll find that programmers can't write in English."

    Others have pointed out the all-too-common case where the code gets edited but the comments don't. This is bad, but not as bad as another common case: the programmer tries to comment the code, but his/her grasp of English isn't up to the task. This may be because English is a second language, or simply because the person specializes in computer languages, not human ones. In any case, the result is frequently misleading or incomprehensible comments that either do no good, or worse than no good. And, of course, deadline pressures never help.

    I think Literate programming is a wonderful idea, but I don't think it's a practical one in many (most?) real-world environments.

  67. In general ... by ii1yama0 · · Score: 0

    ... programming is all about generating code. The necessity and depth of documentation is determined by the context - if you're working as part of a development team, you will be strongly concerned about maintainability and reasonable code documentation will be necessary. If you're hacking together a bunch of assembly-optimized modules, then you might want to attach a minimalistic blurb to your routines, but nothing as comprehensive as most coding standards require. In the end, code documentation is all about maintainability and minimizing the 'discovery' curve for future work on your code.
    What is of paramount importance is documenting your design, which is where any engineer expends 90% of their energy. Design work is what separates an engineer from a programmer; indeed, the ability to design complex software systems is what stratifies the field of software development into it's levels: CTO, architect, engineer, programmer, etc. Design work is where your college student loan payments are justified, since it really does take an advanced degree to design certain classes of systems. Implementation just requires programmming drones, but some sort of design document must exist to guide their efforts. The point here is this: code documentation is to be encouraged, and lexical programming is a good way to do it. But the significance of that pales in comparison to that of properly documenting your design.

    --

    HelpUsObi 1
  68. Evisa.com bad example by Srin+Tuar · · Score: 2


    Apparently literate programming was not enough to allow the developers of evisa.com to avoid making yet another site that only works with IE 5.5+.


    Unimpressive.

    1. Re:Evisa.com bad example by jko9 · · Score: 1

      The fact that evisa.com's language apps require IE has nothing to do with LP. The fact that they exist at all has everything to do with LP, since the resources weren't available to create comparable functionality in something other than DHTML using Leo, which greatly sped up development. E.g. Coding the apps in Java would have been much more time consuming.

      evisa.com's language apps were written before Netscape 6 was released, at which time IE was the only browser supporting DHTML. In addition IE is required for the pages that have speech, since that uses MS Agent, and there is no comparable technology for Netscape.

      Only the dynamic pages in the languages apps section of evisa.com require IE, all other pages support IE, Netscape and Opera.

  69. Re:Bogus by Anonymous Coward · · Score: 0

    Wagner LLC Consulting Co. - Getting it right the first time

    And losing customers along the way!

  70. Self Documenting is better by afidel · · Score: 2

    Minimal comments and a language that creats documentation for you is much better. With Eiffel your classes automatically have their public members documented, and with the design by contract model the interaction between classes is obvious.

    --
    There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    1. Re:Self Documenting is better by Tablizer · · Score: 2

      Minimal comments and a language that creats documentation for you is much better. With Eiffel your classes automatically have their public members documented, and with the design by contract model the interaction between classes is obvious.

      I see it like a newspaper. You can still read and navigate it without the headlines/titles, but it would be tough. If the detail is self-explanatory, that is fine. However, summaries of sections and modules is really nice to have. Just think "newspaper" when commenting.

      Also, "self-commenting" code often ends up with huuuuuge long variable/routine/method names that make code harder to read, at least for me.

      I would rather have a slightly cryptic abbreviation that is described in a comment once in the declaration than a 50-character variable name repeated over and over again, making all the lines wrap and be hard to read.

      A rule of thumb is that the more times a name (var/func/meth) is referenced in the code, the shorter the name should be. IOW, name length should be inversely proportional to its usage frequency.

      Thus, if you reference FormatHTMLInputCell 200 times, then shorten it to something like FmtCell. (Of course, at the function/method declaration a fuller description should be given.)

      I know some will balk at this suggestion, but it works for me. What sinks your boat may not sink mine, and visa versa.

      The logic is that a reader will only have to look up definitions of frequently used names once, but rarely-used stuff can be more self-documenting since it is often easier to read it once than look it up once. And, being infrequent, it does not contribute nearly as much to repetitious bloat that a repeated long name does. IOW, a long name does it job once or twice, but after that just gets in the way by wrapping and hogging eye-space. They are like an alarm clock that just keeps on ringing long after you are already awake.

  71. Every heard of Libero? by randomErr · · Score: 2

    Imatix, the makers of the awsome open source webserver Xitami, has a similar product called 'Libero'. It allows you chart and build your code as you go.

    http://www.imatix.com/html/libero/

    --
    You say things that offend me and I can deal with it. Can you?
  72. Until it becomes out of date by bluGill · · Score: 2

    I am not that old, and I seen several cases of someone cutting as pasting some similear code, comments and all, and then not updating the comments with the minor changes. When the comments references one register, and the code a different one, the comment is useless. Even though the code is similear, you can be sure that something is different, otherwise the two functions would be combined into a different one. But what logically is different between the two? What was missed?

    When the orgional was written 25 years ago in assembly for a different CPU,(previous model, old code will still run) by a guy who is dead, you are in trouble. (I'm thinking of a real case here)

    Great documentation also doesn't help when it covers the wrong thing. I read the documentation for one module I needed to make minor changes in and discoverd nothing about the code, instead I found the rough draft for a book: Advanced tricks with internal OOA process (Don't look on amazon, it never got further, and in any case is just enough specific to that companies old precess that it wouldn't apply elsewhere).

    The problem with documentation is that good documentation rarely exists, not that it is hard to get at. Literate programing sounds good, and it would be if everyone wrote good documentation, but nobody could find it afterwards. Instead nobody writes good documentation, but at least it is in accessable places. (Generally company specific, but most companys do a fairly good job of keeping it)

  73. How about a flowchart? by throatmonster · · Score: 1

    I now they are 'old fashioned', but box-and-line flowcharts are my program outline, and terse comments in the code correlate to the boxes and lines on the flowcharts. I can show people a flowchart, and most can understand what is happening faster, or more fully, than with any other type of documentation.

    Programming is half rubix-cube like puzzle solving and half multiplication-table recital. (Those of us doing it for a living must be slightly [at least] off-kilter.) Documentation is a personal skill/habit; the way for a program to teach you this isn't by forcing you to do both simultaneously. The only way to learn this habit (if you haven't already) is to have your final work gone over and problems pointed out, and be willing to work on it. It seems like stuff like Leo is great for people with the habits already, but yields little more than confusing documentation to go along with confusing code for the rest of us.

    You've got to develop some some kind of outline first, then write the code, then test, test, and document (with flowcharting, for me) what's actually happening.

    --
    All pass beyond reach of medicine. None pass beyond the reach of love.
  74. I think you haven't been in certain jobs yet... by Anonymous Coward · · Score: 0

    the above example was a bit simplistic, but if you've been in the workforce for some time, you've for sure been in the unfortunate position of 'chief archeological engineer'.

    By this I mean that you've been handed a coupla-tens-of-thousands (hundreds of thousands if you're esp. unlucky) piece of spaghetti code that started its life when somebody (usually the founder) of the company 'prototyped' an idea years ago, and that got perverted and 'enhanced' countless times by countless different people, and you're asked to implement a new major 'feature' on top of it with a two-weeks deadline and everybody breathing down your neck.

    While in a 5 line function the line 'i++ means go to the next cell' is obvious, in a 2000 line function with multiple exit points that can be called directly, as a callback, via pointer reference and so on, that i++ is not going to look very enlightening by itself.

    [rant]
    In every single profession other than software development, when something you've built before can't do the job you need it to do, you tear it down and rebuild to the new specs.

    Why is it that with software there is the assumption that just because you have a cubicle shop full of caffeinated programmers you can take your old code for, say, a word processor, and with a few mandatory overtime weeks make it also be a SQL database?

    How long before laws are enacted to mandate all software's source code to be open and audited before a software product is put on the market? With programs used for more and more critical applications, where lives are at stake, where Windows NT is used to guide a naval destroyer, it is really incredible that companies are allowed to sell the buggy crappy that these days passes for software.

    And don't tell me that it's 'too hard' to QA software well: do you think it's easy to QA the project for a skyscraper with all the structural, electrical, hydraulical and so on work that it needs?

    Ship now and fix later and 'no warranties' EULAs should be made illegal IMHO, and if this adds another 6 months of QA to a new release, so be it, better 6 months of QA for the manufacturer, than 6 months of buggy hell by the client. It's their product, why should I be on the hook for bugs I wasn't responsible for?
    [end rant]

    1. Re:I think you haven't been in certain jobs yet... by jgerman · · Score: 2
      I don't disagree with you. Well not totally at least. If you can't read code and understand it you shouldn't be writing it (note that that is a general you, not blaming you in particular). I don't need my code with subtitles thanks, I know how to read code and only need commentary in places that might be misinterpreted.


      Your example actually is about a different area of poor coding skills, though it does relate to commenting. Obviously, the poorer the code the more comments that are needed to understand it. For example: If I was non-english speaking and had to take a translator with me to make myself understood. If my command of english is bad, my translator will have to jump in more often and say "he means ...". However, if my command of english is perfect, my translator rarely has to explain my meaning, if at all.


      As far as your rant, the problem is real enough, companies do sell some crappy software I won't deny that. But your implied solution is completely wrong. The idea that "companies should not be allowed" to sell anything no matter what the quality is just nonsense. Nobody has the right to dictate to anyone else what they can or cannot attempt to sell. The fault doesn't lie with the companies selling the software it lies with the consumer who continues to purchase it. It's completely about demand. Consumers have given their approval of companies selling buggy software by their willingness to buy it. The reason that you are on the hook for bugs you weren't responsible for is your fault (or someone higher up who bought the software for your company), not the developer of the software. If you knowingly buy software that a company has attached a 'no warranty' EULA to the responsibility is yours plain and simple. Claiming that they should be illegal is one step away from banishing the GPL.


      Software that could potentially put lives in danger should be thouroughly examined by the people responsible for buying it. Should the government only buy software that is warrantied by the developer, sure. We have to put our faith in the government for our safety. Does this mean it should be illegal for any company to put out no warranty software, hell no.


      When it comes to EULA's I don't feel they should be legally binding when they are legally binding before someone has the chance to read and accept them (sorry UCITA you're a crock of shit), or at least if after purchasing software and reading the EULA the place where you bought the software is legally required to accept a return in you don't agree to the license. It shouldn't be a long drawn out process to contact the manufacturer and have them refund your money.


      As a side note, there or dozens of other problems with EULA's not directly related to this discussion that I have problems with, possibly the most serious being the belief of corporations that they can nullify your rights through them.

      --
      I'm the big fish in the big pond bitch.
  75. It's structure, not literacy by fermion · · Score: 1
    The problem with most code is not in literacy, usually to mean basic reading and writing, but a lack of respect for structure.

    As a metaphor, lets take the five-paragraph essay. This is a simple form of basic literacy. There is a head paragraph with a few statements leading to a strong thesis. There are three paragraphs that argue for those statements in an effort to validate the thesis. Finally, there is a conclusion paragraph where the thesis is formally validated. A literate person is expected to be able to apply this structure to a hypothetical issue. This, however, does not mean that the person will have enough respect for this structure to use it in communicating on a daily basis. Often, the bogus literati believe that it is more important to be complicated in an effort to create a perceived intelligence, rather than to be direct and allow statements to be judged on their own merit.

    The same is true for code. Code has it's own vocabulary, grammar, and idioms. It also has a structure that can be generalized for all code, as well as structure that is unique for each language and application. It is the application of these structures that creates legible code.

    This was very clear to me a several months ago when I was wading through some code written in VC++. The person who wrote the code, though likely to do well on VC++ test, was totally ignorant the standard structures and grammar of not only OO code, but even structured programming. Repeated tasks were not converted into a generalized function. Variables were ambiguously retrieved from the registry. Identical conversions were done differently in various areas of the code. Related variable and function were not encapsulated into classes. This has nothing literacy. It had everything to do with a lack of respect for structure. I was able to take this code that worked and convert it into code that legible without the inclusion of foreign syntax.

    Two last things. First, there are situations where rules of structure and grammar must be broken. There are even times when it is fun to do so. That said, it is one thing to intentionally break well known rules, and a totally different thing to be too ignorant to realize their importance. Second, translation tables are still needed between human languages and computer readable languages. The trick is to create code using existing structures and idioms in an effort to make the translation tables as simple as possible.

    --
    "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
  76. Re: Re: Re: Offtopic nitpick by BTO · · Score: 1

    Ha ha. You closed a tag instead of a tag!

    --

    Banach-Tarski Overdrive
  77. Re:Literate programming versus continuing developm by Peter+S.+Housel · · Score: 2, Interesting

    In one respect, literate programs are a lot easier to maintain in the long term than illiterate programs because it's much easier to come back to them after a few months away.

    Since Pascal didn't support modules and separate linking, TeX and WEB weren't designed with any sort of reusability in mind. I don't think that there's anything inherent about literate programming that causes inseparable blobs of code like TeX and METAFONT to be produced.

    I generally program so that one document == one reusable library. The Monday Status page contains links to some of the literate libraries written for the Monday Project.

  78. Re:Literate programming versus continuing developm by Tablizer · · Score: 2

    For a project I am working on, I needed to extend CWEB to do some things Knuth hadn't thought of, and I found that excessive cleverness in the data structures made it much more difficult to extend than it should have been, so that Knuth could demonstrate clever data structures that probably add a few percent to the performance over what he could have achieved with more prosaic ones

    Generally, collection management API's should be "wrapped" such that you can change the implementation without changing or reducing change to the application code that uses collection management.

    Whether there is a performance penalty to such wrapping is hard to say. Generally, there will be some performance penalty for the "indirection" needed for hiding implementation.

    For many domains, making the software easier for programmers to maintain is more important than speed. Some programmers get obsessive over speed for no good reason, and make stupid (change-unfriendly) code as a result. They should be embedded systems programmers if they get off on that.

    (BTW, you don't need OOP to wrap collection handlers.)

  79. Hey I don't know much but... by LucidBeast · · Score: 1
    I've seen a lot of code that has been documented and even more that hasn't been. Problem usually isn't that the code is hard to read or that the structure of the application is somehow messy.

    Following things always make me take an extra coffee break.

    • If you write a library. Please don't just write class reference library with your doxygen. I can see what the classes are and what they are derived from. Write also a cook book that explains how you think this library should be used.
    • If you wan't to write something using a certain technique please learn it first before attempting it on a time critical task that everybody else is relaying on. Too many times have I seen somebody attempt to write STL style template library for some trivial problem.
    • Draw pictures for goodness sake... Two boxes that connect to each other via line whether UML or just some word scrible tell me in a second more that two paragraphs of jibba jabba fancy SC lingo...
    Any how I don't think the documentation and code should mix at all.
  80. I maintain code for a living by dr_l0v3 · · Score: 1
    I work with other peoples code everyday. I don't think my life would be made any easier with literate programming -- there is far too much documention to go through in the time available anyway.

    The things that make debugging easier are logging (the ability to turn logging on to a high level is priceless) and simple code. The fancy distributed OO monsters are the worst things to maintain -- adding heaps of description text would just makes this worse. Since I've had to work with other peoples code my whole programming world view has changed. Good code isn't clever or fashionable.

    Incidentally, the most useful tools I've found for problem solving an unknown mass of program are gnu grep (grep -ri) and find (find -mtime -1).

  81. Not all developers speak English well... by Chief+Typist · · Score: 1

    In the real world, development teams are made of of people from places where they don't learn English as a first language.

    Looking around my current team, I see people from China, India, Norway, Japan, Germany, Malaysia, Iran. All are very competent developers, but many of them have writing skills that suck.

    Personally, I would prefer to look at their code rather than some tortured syntax that is pretending to be the English language.

  82. Wrong by Anonymous Coward · · Score: 0

    the idea of Literate Programming is basically that of making program documentation primary, and embedding code in the documentation, rather than vice versa.

    This is not anything like what Knuth meant, even if it is what people are calling literate programming these days. (I'm not even sure what the above means.)

    Literate programming is writing your code so that it doesn't require comments and documentation to be understood. The main points of this are clear formatting and use of whitespace (not such a common notion back then), descriptive and accurately named variables and functions (and objects), logical flow, 1 task per function, etc.

    A well written program should be able to be read without understanding all the details, the goal being that programmer A can understand and modify programmer B's code easier, safer, and quicker.

    1. Re:Wrong by Anonymous Coward · · Score: 0

      The above posting is misinformed.

      Check out the Literate Programming website cited in the original article for a look at what how Knuth and others define Literate Programming.

  83. step out of the mainstream by kuma · · Score: 1

    what a clarification--
    *mainstream language compiler*

    such languages were not designed for gui and rad

    such languages where created on legacy file systems

    out here in the jungle though drones are performing ghoulish rituals like clustering macs and developing in-house apps driven by marketing (irad or die baby)

    there are many niche products

    it's like a star trek universe

    and in this diverse eco-schism there are compiler/ides (out of the mainstream) which keep businesses going, and the vendors of these tools are *hanging on*

    they may be decomposing, but they composing still

    not all of these un-mainstream systems are a horror, i actually enjoy programming 4d (even though i have to export methods to text for personal archives)

  84. The creator's view of Leo by edream · · Score: 5, Interesting
    Hi. I am the creator of Leo and I'd like to say here what my own view of Leo is. Joe Orr has contributed greatly to Leo, and I would not characterize Leo exactly as he did in his original article. In this posting I hope to clear up misconceptions about what Leo is, what it can do, and the relationship of Leo to literate programming.

    I would like to distinguish between the techniques of literate programming and the practice of literate programming (LP) as it has always been done before Leo (traditional LP). The key technique of LP is what might be called "functional pseudocode." For example, here is a fragment of code that can be written in Leo:

    def spam():
    done = false ; result = None
    while not done:
    << do something complicated >>
    return result
    The line: << do something complicated >> is a section reference. It works pretty much like a macro call. In particular, the code in the defintion of << do something complicated >> has access to the done and result variables. This is almost the entire content of noweb, one form of literate programming. It turns out that this technique can be extremely useful, as simple as it seems. Leo creates one or more "derived" files from an outline automatically when the outline is written, and Leo can update the outline from changes made to derived files when Leo reads the outline.

    In contrast to the technique of literate programming, the practice of traditional LP has focused on the central role of comments, and lots of them. Here is where Leo radically parts company with the LP tradition.

    One's view of the proper role of documentation in a project hardly matters to Leo. You are free to use comments as you always did, though you will probably find that LP as implemented in Leo helps you out in unexpected ways. I discuss at length and in great detail the relationship between traditional LP, comments and Leo here. In short, discussions about the role of comments in programming (literate or not) do not get to the heart of Leo.

    In fact, Leo often reduces the need for comments. Indeed, it is good style to organize Leo outlines like a reference book. Well-designed Leo outlines act both like self-updating tables of contents and self-updating indices. This is in marked contrast to the "stream-of-consciousness" or "narrative" style typically employed in traditional literate programming.

    In my view, the essence of Leo is this: Leo makes outline organization the most important part of a program or a project. Both code and documentation could be considered secondary. At every moment, the overall big picture of a function, class, module, file or project is always at hand. Moreover, Leo makes outlines structure a part of the computer language. For example, I often define a Python class as follows:

    class myClass:
    << declarations of myClass >>
    @others

    The @others directive acts as a reference to all the text in all the outline nodes which are descendents of the node containing this class declaration. Such nodes are copied to the output (derived) file in the order in which they appear in the outline. The reference << declarations of myClass >> ensures that those declarations precede the methods. There are several other ways that outline structure is important in Leo; I won't discuss them here.

    Leo fully exploits the organizational power of outlines. A single outline typically organizes an entire project. Outlines can handle large amounts of data with ease. Moreover, it is possible to clone any part of an outline so that changes to one clone affect all other clones. This is feature makes it possible for a single outline to contain multiple views of a project. For example, when fixing a bug, I clone all nodes related to the bug and gather them in a new part of the outline, called a task node. This task node effectively becomes a view of the project that focuses exclusively on the bug. Any changes I make to code are propagated to all other clones.

    Earlier I mentioned that a well designed Leo outline acts like self-updating tables of contents and self-updating indices. Tables of contents you get for free: an entire outline is the table of contents. Clones create self-updating indices. For example, each task node acts like the index entry for that particular task.

    - Edward K. Ream

    1. Re:The creator's view of Leo by holon · · Score: 2, Insightful
      I'm a long time outliner (15 years). Began with MaxThink then jumped to Ecco.

      Most people don't 'get' outlining. Most people are what I call linear thinkers. They use MS Word in page layout mode thank you very much, have no need to outlining, and will never understand brainstorming and the power of organization of thoughts thru outlining.

      Same thing with programmers. Most of the programmers here just aren't going to 'get it.' But I do. You're on to something big here. Makes complete sense... an orthogonal view of the physical artifacts of the system. And, the orthogonal view is the most important one - it's the logical view. But, the key that you succeeded with is clones. I'm a long time Ecco Pro user and the same effect is implemented there. It's multiple orthogonal perspectives that makes it truly work. You can shift perspectives, isolate certain elements and create a new perspective.

      I look forward to helping Leo evolve. I see many uses for it beyond a programmer's tool of course - as obviously do you.

      Congrats and right on,

      david bolene...

    2. Re:The creator's view of Leo by slamb · · Score: 2
      Well-designed Leo outlines act both like self-updating tables of contents and self-updating indices. This is in marked contrast to the "stream-of-consciousness" or "narrative" style typically employed in traditional literate programming. [...] At every moment, the overall big picture of a function, class, module, file or project is always at hand.

      Very interesting. You've exactly described one big reason I haven't liked literate programming in the past. I always felt it was too hard to the structure of the code and found a folding text editor to be a better guide. The cweb stuff seemed to completely flatten the structure. For example, when fixing a bug, I clone all nodes related to the bug and gather them in a new part of the outline, called a task node. This task node effectively becomes a view of the project that focuses exclusively on the bug. Any changes I make to code are propagated to all other clones.

      These task nodes seem interesting as well. Seems like they would be good ways to find candidates for refactoring. It would be especially useful if you could tie it to a version control system and/or a bug tracking tool. (I.e., "make a task node of what I changed in this commit. Associate it with this bug report.")

      Recently, though, I've been using API documentation tools (doxygen, javadoc). Generating output in these formats is really important - it's valuable and expected now for Java/C++ code. I probably wouldn't use leo if it interferes with their processing and can't replace it.

    3. Re:The creator's view of Leo by edream · · Score: 1
      I use the following rule of thumb: if a section's name is too long or complex it should be rewritten (refactored).

      Leo does indeed support javadoc.

      Edward K. Ream

    4. Re:The creator's view of Leo by edream · · Score: 1
      Thanks. It's good to be understood. I agree that clones are a key feature of Leo. Clones work in Leo exactly as they did in the old MORE editor on the Mac.

      Edward

  85. how can this help us poor programmer? by Anonymous Coward · · Score: 0

    i read some of the LP examples and got totally lost. how the heck can i understand the overall picture with so many more words around.
    if you want document how to do mul matrixs, pls give a good book name so i can understand it. the compiler doesnt need to understand matrix to do it's work.

  86. Old idea. by Anonymous Coward · · Score: 0
    Literate programming has been around for years. It was called COBOL and it refuses to die! Consider lines like:

    ADD 1 TO COUNTER GIVING INDEX.

    or one of my personal favorites:

    PERFORM UNUSUAL-ACTS UNTIL IT-STOPS-FEELING-GOOD

  87. diagrammatic documentation by Anonymous Coward · · Score: 0

    All of the schemes under discussion seem to define documentation as text . Is there any system which also includes graphics ? Not necessarily the much-maligned flow-chart, but rather support for the kind of quick sketches often found on the whiteboard in a programmer's work space -- ie the diagram useful to the person writing the code in the first place, but which never finds its way into documentation.

  88. Re:Bogus, truly! by edream · · Score: 1
    Apparently many people have become confused about Leo from reading the initial article.

    Please read my posting, "The creator's view of Leo."

    Edward K. Ream

  89. Limits of Javadoc by fm6 · · Score: 3, Insightful
    Well, specifying the API before you write is certainly a good idea. But you hardly need Javadoc to do that. The problem with Javadoc -- and all LP tools I've seen is that it confuses documentation with specification. A specification just has to be clear to other working on the project. It can be written by someone with no training in technical communication. The writer doesn't even have to have a full grasp of the language he or her is writing in -- computer terms are pretty universal.

    None of that is true for technical writing. It's a discipline onto itself. It's not just about good writing. (I've known computer scientists who'd written award-winning papers and articles, but couldn't write technical docs worth beans.) It's about understanding your audience and the (often painfully boring) task of writing in the clearest possible language.

    Not every project needs technical writers. If you're a small software shop, and you're building a set of components with an uncomplicated API, and hiring a professional writer isn't cost effective -- then yeah, use Javadoc or some other LP tools.

    But for big projects... Back in 1998, I was in charge of production for the doc set of a large Java framework. Having the API docs embedded in the source code was a nightmare. Javadoc was supposed to allow any of the engineers who wanted to to do their own API docs -- but many botched it, because they didn't understand Javadoc or HTML very well. We had professional writers, but many of them couldn't be trusted with source code. Hell, some of them didn't understand why they couldn't edit the SCCS archives!

    Worst of all was when the release cycle entered code freeze. Document freeze is always later than code freeze -- but you cannot let people modify the release code base during code freeze. The only solution was to split the source, then merge the docs back in after release. Very painful.

  90. The terror of the teletype by Cryogenes · · Score: 2

    still haunts us poor programmers. Backwards compatibility is hard to sacrifice.

    Do you believe in life after death?

  91. Re:Literate programming versus continuing developm by jaoswald · · Score: 3, Interesting

    This is absolutely on the mark.

    I believe that WEB was a great improvement over Pascal at the time that Knuth began to use it. However, it does not solve the underlying software engineering problem. Knuth's style at the time of TeX, etc., involved very little abstraction.

    The biggest problem this causes is that the major data structures in TeX do not have well-defined or factored interfaces that allow them to be easily changed or extended. Furthermore, important details of these data structures are basically undocumented, and often cause interdependencies between different portions of a WEB that are not at all obvious.

    If you wish to see the problem face-to-face, look through TeX: The Program at the "inner loop" and see how many different sections of the WEB that you would have to understand.

    A similar problem is his use of enumerations with certain magic values, where the magic is documented (or becomes apparent, while still undocumented) some distance away from the point of definition.

    Another serious problem with WEB is that it allows one to completely obscure the sequential nature of the program. Many times, one chunk depends on initialization that was performed by another chunk. If Knuth decided to make some laconic comment rather than remind you of that initialization, good luck reconstructing the sequential dependencies.

    If one is writing monolithic programs, writing them like a Russian novel might be easier to comprehend than one large unformatted source file. However, if one has the alternative of writing a highly modular program with clean interfaces, I don't really see any advantage to breaking up and rearranging the underlying code.

  92. The perfect documentation... by grahamtriggs · · Score: 1

    ... is the code itself.

    Probably a highly controversial opinion ;-), and definitely over simplified (you shouldn't have to read the entire source code of Windows to know what one of the API calls does / is meant to do (although if some recent posts are anything to go by, it would probably be wise...)

    But for me, over documentation is *far* worse than under documentation... code is a natural form of doucmentation - why? because it is a set of instructions that are followed blindly to the letter... it describes *exactly* what the computer is doing (although when calling some third party library / API, you are trusting the function to do *exactly* what the author claims it is supposed to)...

    What can be better than that? Certainly not half a page of drivel, of what someone vaguely thinks the code is doing...

    Of course, there are caveats - for starters, sensible, descriptive (although hopefully not to finger-blisteringly long) names for functions and variables are necessary, as is a clear, consistent layout of the code (and that means none of the old K&R style opening a program block on the line of an if / while / etc statement - block starts / ends should *always* be on clear lines at the same indentation level!!)

    Javadoc-style comments are handy and useful though - handy because they put space in between functions for easier navigation of a file, and for automatic generation of your API documentation... useful, as it ties the 'specification' (ie. what the code was meant to do) with the code itself - so when it doesn't do what it is supposed to, you don't have to go hunting for the specs...

    Other than that, if you need much more in the way of comments, then you can be pretty sure that the structure of the code is wrong... (unless of course speed is critical, and that is the best optimised code)

    1. Re:The perfect documentation... by Stonehand · · Score: 2

      You're ignoring the really important parts:

      - Preconditions.
      - Failure modes -- because you /know/ that with any exported function, it will be given bad input. Even without bad input, I/O failures et al happen. Document what happens.
      - The semantics of each input parameter. Yay, it's really bloody useful to say "blah" is a C-style string. The semantics of it should be in a well-documented API -- in fact, somebody else using your code shouldn't even have to look at its internals.
      - The semantics of each output value.
      - Postconditions.
      - When the function is useful and why.
      - What drawbacks might make the function less useful.
      - Sample calling syntax, including code that shows how the input was obtained.

      --
      Only the dead have seen the end of war.
    2. Re:The perfect documentation... by grahamtriggs · · Score: 1

      I'm not ignoring them as such - I'm just not making explicit reference to them...

      These are all function level comments - virtually all of which have some place in javadoc-style comments...

      Some things you have mentioned are not as useful as they might be... for example, comments about when a function is useful - whilst it can be helpful to explain such things in some cases, chances are you will only ever describe a subset of a function's actual usefulness... if that is the case, then you are as likely to find people not using your function when maybe they could / should, just because you never mentioned that it might be useful!!

  93. Get a clue by edream · · Score: 1
    A lot of people seem to feel qualified to comment about Leo after just reading the original slashdot article. Most have no clue about what Leo is or isn't. I've spent seven years working on Leo. I'm getting pretty annoyed about people commenting about Leo without even taking seven minutes to play with it.

    Leo really isn't all that much about either literate programming or documentation; it's about structure and clarity. I explain what Leo is in my posting, "The creator's view of Leo."

    Edward K. Ream

    1. Re:Get a clue by sethdelackner · · Score: 1
      I've spent seven years working on Leo. I'm getting pretty annoyed about people commenting about Leo without even taking seven minutes to play with it.

      Edward, there's only condescending ways to express this: chill out. This is slashdot. Many of the comments are going to be completely nonsensical and several negative ones will be from people who only read the slashdot article's headline.

      That said, I grabbed Leo and jumped with glee at the possibilities that lie ahead (how about replacing the text editor frame with a seperately running emacs session!). Thank you. Still, these negative posts really seem to get to you, so maybe you need to find a stress relief activity. My favorite professor had a stroke because he couldn't stop being too high strung.

  94. Re:Literate programming versus continuing developm by Phronesis · · Score: 1
    (BTW, you don't need OOP to wrap collection handlers.)

    Amen to that!

    Here is one such problem in CWEB:

    If you want to add new category codes for the tokenizer, Knuth has allocated all 127 lower-ascii codes to signify the 126 possible input characters, plus a special sentinal value for 127 (DEL).

    Codes above 127 are interpreted in a special way as a tricky encoding of pointers into a symbol table. If I want to introduce a new value, I must make it larger than 127, and then add lots of tests (if statements) at various places in the code to check for my special new value and not interpret it as an encoded pointer. There is not a single centralized place to do this, and it would have been very easy to implement a simpler two-stage token-lookup routine (first check whether the catcode == encoded_pointer, then lookup the pointer via an ancillary value).

    The code uses a lot of "magic numbers" that are neither #defined symbolically nor explained in a central point in the documentation, but scattered throughout, so the programmer must comb it looking for places at which bugs can arise.

    As you say, you don't need OOP, but a better job of structured programming would have been nice. Then again, this is a program by someone who wrote a whole paper on "Structured programming with goto statements."

  95. Re:Why this doesn't work.-The Tao of engineers. by Anonymous Coward · · Score: 0

    Maybe it *would* work, if we created programs in a different manner than we presently do. A lot of the process of creating a program is internalized.

    Going from vague idea to finished tool. How about from idea managment through tools that help decompose, down to output of code and documentation? Keeping in mind the highly iterative (as well as cooperative) process all up and down the chain Resisting the urge to work from bottom to top until the refinement phase (optimization) nears.

    *All steps available for inspection.*

    Also bring the social methods of engineers over.
    Instead of thinking "Oh this is cool to try". Think instead "this is an interesting idea, but it could have a hidden cost". Wouldn't want that "code" bridge to fail under pressure.

  96. C# allows compiling to documentation-Transparency. by Anonymous Coward · · Score: 0

    True however there isn't a particular process that *forces* the programmer to write "what he means".

    Or at the very least makes the process of documentation transparent enough that it gets done.

    Make coding indestinguishable from documenting and we'll have solved the problem.

  97. How depressing! by m11533 · · Score: 1

    I find this entire discussion pretty depressing as it demonstrates pretty dramatically the extremely poor state of software developer documentation.

    Good developer documentation facilitates a great deal of those things that our managers keep crying for... quality software, produced quickly and efficiently, that does what our customers want.

    Literate Programming was a terribly elegent way to integrate the documentation that we all should be writting into code in a way that suggests it would be far less likely to fail to keep documentation and code up to date and synchronized. This is VERY different from the current models of extractable embedded documentation, which I frankly don't find adding much. The problem is that we frequently look to tools to automatically generate the documentation when only a fully skill human developer can really explain what the intent and thought is behind each piece of code. Why is this the algorithm chosen? What others were examined and discarded, and for what reasons? These are all far more than describing the members of a class and assuming the reader can guess the USE of that class.

  98. Re:Dunno how literate I am, but here's what I do.. by ipjohnson · · Score: 1

    Thats the idea ... try to layout your design and flow before whacking at it with code. Not enough coders put alot of thought into the design before they start the problem.

  99. It's pointless by Old+Wolf · · Score: 2

    Maybe the reason Literate Programming never took off is because it wastes the time of good developers. I rarely have trouble reading code written by myself or the other developers at my work, and I can even completely rewrite someone else's software and get it almost all right.

    I guess it would be useful for novice programmers who do not know how to write useful comments (that is, 'self-documenting' code, as well as actual comments).

    If I spent the time writing document outlines and program plans and crap beforehand it would be just that, spending time for no reason; not to mention the design changes that often go on as you are actually writing code ; the last thing in the world I want would be to have to go back and change all these plans because I decided to change an aspect of what I was doing.

    1. Re:It's pointless by Stonehand · · Score: 2

      If APIs and system designs were documented first to the point that people agreed upon them, then perhaps you wouldn't have had to make significant design changes later.

      Programmers should not write code, hand it off, and say "it documents itself". Have you read the entire source code for the GNU C Library? Unless you're a developer for it, it's rather unlikely. That's because the writers actually had a clue: they wrote documentation so that you don't have to use the code as a manual. If you're working on projects of any significant size, the same applies.

      --
      Only the dead have seen the end of war.
  100. Comment overkill... by Anonymous Coward · · Score: 0

    As a computer science tutor, I see a lot of code, and people ask me to fix it. Sometimes I will read their comments, but usually I just look at the code because it is easier to understand. A good programmer shouldn't need to put a line on every line, and even comments like this can be annoying.

    /*switch a and b*/
    temp = b;
    b = a;
    a = temp;

    Hopefully your comments clarify some subtle algorithm or explain the general outline of what you've done. They shouldn't become a dissertation!

    1. Re:Comment overkill... by m11533 · · Score: 1

      Sure... there isn't much to the code you list. But, if you go through a big piece of legacy code and run into a sorting algorithm, wouldn't it be terribly helpful to know what the sorting algorithm is (and I sure hope a standard algorithm was either used or used as the basis for what is in the code), why it was chosen, and why other alternatives were not? This is the point of literate programming, to fully communicate the program, not stay so focused only on the particular programming language's level of description, which while very descriptive to a computer, communicating exactly what is needed to EXECUTE the algorithm, doesn't give humans much of an UNDERSTANDING of that algorithm.

  101. The real problem with Literate Programming by Simon+Spero · · Score: 1
    The real problem with Literate programming is that to you're probably not Donald Knuth. Trying to program in WEB brings this home in a way that's much too depressing to keep up for long.

    Knuth not only writes good code, he also writes intersting code, and usually that's too time consuming for regular mortals.

    I seem to remember Knuth submitting some literate programs for a pair of Jon Bentley's "Programming Pearls" columns [collected in "Literate Programming", online here and here

    The latter contains Knuth's solution to an assignment by Bentley: "Given a text file and an integer k, print the k most common words in the file (and the number of occurences) in decreasing frequency."

    Knuth's sumbission is a beautiful work of exposition, introducing and explaining an unusual data structure (the hash trie), and in general would not look out of place framed and hanging on the wall above one's dining table.

    However, in his critique of the program, Doug McIlroy provides a solution to the problem using a simple unix pipeline that takes up less than a paragraph. McIlroy finish his critique with the following remarks:

    Knuth has shown us here how to program intelligbly , but not wisely. I buy the discipline. I do not buy the result. He has fashioned a sort of industrial-strength Faverge egg - intricate, wonderfully worked, refined beyond all ordinary desires, a museum piece from the start.
    Simon
  102. Compiler errors? by BollocksToThis · · Score: 1

    I just skimmed through the two first introduction slidesets for Leo, and I thought it was quite cool to split your program into nodes, so you can quickly and easily skip sections of code you're not working on...

    But what about when compiling? Your compiler gives you a line number for the source file, and you need to edit that file for the line number to be any use, and then I think you'd need to manually re-locate the right node based on the code around the error... not fun in a larger program. Does Leo provide any way to translate the error line numbers back?

    --
    This sig is part of your complete breakfast.
  103. It's up to the PROGRAMMER by mindriot · · Score: 2

    I suppose the reason why Literate Programming has not caught on is simply that no major programming language forces you to do it.

    Given the right tools within a programming language---say, a documentation tool such as JavaDoc, and some code and commenting conventions---and proper understanding of some software engineering methods concerning the thoughtful design of your software, it is quite possible to achieve what Literate Programming tries to achieve.

    But Java, for example, doesn't require you to build a proper UML model, follow the code conventions, and JavaDoc everything in a way understandable for others. But nobody stops you from using those methods right now. The problem is just that doing Literate Programming---or, for that matter, any kind of proper, thorough documentation---eats up a lot of time, since easily around 50 percent or more of the total time spent on a project are concerned with documentation. And for most programmers, including me, it requires quite some effort to be disciplined enough to do such "proper" software development thoroughly.

    In other words, it might be helpful to use a Literate Programming tool that forces you to document your stuff, but it is still up to you to create a proper design and documentation for your software.

    1. Re:It's up to the PROGRAMMER by jko9 · · Score: 1

      Hmm.. this is a pretty standard (and justified) complaint about LP and I'm starting to think maybe Leo shouldn't be associated with LP at all, although it is an extension of it.

      As the creator of Leo has pointed out, with Leo you aren't writing a novel, you're writing an index. You're building a roadmap - a reference tool. It GREATLY speeds development time. It just is so much easier to program something when you have all the pieces arranged into a clear filing system that you can customize as much as you want.

      If you look at the evisa.com example in the tutorials, you'll see that the total of words in the entire Leo outline is maybe one paragraph. That is all that it takes to THOROUGHLY document the ENTIRE project. In fact, the need for a lot of other standard comments is eliminated because the outline shows the relationship of the parts to the whole, and you don't need to keep explaining what point you are at in the program.

      Programming with Leo is LP in the sense that you've got an explanation in English that is foundational, but in practice Leo programming is entirely different from standard LP. I hope people who have tried LP and been disillusioned will give Leo a try.

    2. Re:It's up to the PROGRAMMER by jaoswald · · Score: 2

      Any tool that is inflexible enough to force programmers to do things a certain way is not going to be flexible enough to solve every problem that a programmer might face.

      Programmers need more flexible tools, not less. Not that most developers would know what to do when they got them.

  104. Re: Offtopic nitpick by starling · · Score: 1

    Alright then, how about wear and tear on the keyboard. Not to mention the huuuge bandwidth saving. ;)

  105. Et, Jean-Paul, est-il libre? by Latent+Heat · · Score: 1
    Oohh, I run rings around you logically!

    You are a well-known advocate as collections, especially associative or keyed collections as an alternative to OO.

    But unless your collections are primitives in your language system, aren't object classes (or perhaps C++ templates) a proper way of managing that separation?

  106. Programming student speaks out by deadgoon42 · · Score: 1

    I believe most code is simply not commented properly. I have been trying for a while to teach myself to do some basic stuff in Python with little success. The main problem is that most code is poorly commented if it is commented at all. There is no telling how many times I've seen things like this:

    # Now we tie up some loose ends

    or

    # I inserted this to fix a few things

    No explaination is given as to what the code actually does or if it does explain, it doesn't tell specifically what is going on. I know that most programmers aren't writing comments for the sake of students trying to learn from their code, but I believe if they did so, things would be much clearer for everyone.

    --

    Smeghead every day of the week.
  107. Re:programmers can't write: the fly in the ointmen by doubtme · · Score: 1
    I think Literate programming is a wonderful idea, but I don't think it's a practical one in many (most?) real-world environments.

    What like structured programming? Or - God forbid! - Object Oriented Programming! That crap's all just too damn slow to run and to damn difficult to code!

    Sure, LP's not perfect now... but if you bother to learn only what's currently in fashion, by the time you've learnt it, the Next Bit Thing has arrived...

    That said... you're perfectly correct when you say that no tool - be it OOP, LP, or any other silly acronym - can prevent bad programmers writing bad code - it can only help good programmers write better code.

    --

    There's no $$$ in 'team'...
    www..--..net - for incisive, w
  108. Re: Brace indention doesn't matter!!! by Anonymous Coward · · Score: 0
    (and that means none of the old K&R style opening a program block on the line of an if / while / etc statement - block starts / ends should *always* be on clear lines at the same indentation level!!)

    All right, I agree with most of what you said, but lay off the indention style! Some people actually like K&R style blocks! Some people even think *gasp* putting the opening of the block on a new line is ugly, annoying, and useless!

    I have one friend who hates it so much that if he has to work with code like that, he'll spend half an hour reformatting to K&R style.

    Perhaps that's a bit of overkill, but really, it just doesn't matter!

  109. Why not document on the interfaces? by Bodrius · · Score: 3, Informative

    I'm not a big fan of abusing Java's interfaces (an interface for each implementation hierarchy), but in a big project that has to be properly documented and strictly specified, this would seem to help.

    The interface is after all closer to the specification level, so your documentation can be strictly about the specification. Then you can let the programmers code, document and freeze the implementation independently from the interfaces.

    Since an interface doesn't have any implementation sourcecode, writers could be trusted with the files, and since the interface API per se is frozen at design, they can keep modifying the Javadocs without affecting the coders.

    If the writers have to modify the API per se and recompile an interface, they are changing the specification (re-design) and of course the coders are forced to adapt their code to those changes.

    But otherwise there would be no need to "split the source" and then "merge". All you would have to do is provide the Javadocs for your interfaces (plus a manual based on this, perhaps) and the Javadocs for your implementation (if implementation details are to be exposed, such as efficiency guarantees, etc).

    If anything, I would think the split would improve documentation.

    --
    Freedom is the freedom to say 2+2=4, everything else follows...
  110. Visual Studio .NET? by Bodrius · · Score: 2

    I may be a bit confused here:

    What exactly is it that you cannot do with your source code in Visual Studio .NET?

    I don't mean that the wisdom of MS has allowed them to put all functionality ever needed in Visual Studio.

    I mean that every time I checked my source code was still there in a flat file, and I could modify it with a text editor, a perl script, or whatever I wanted.

    I haven't seen any repository system from which I have to import/export source code or anything like that. Am I missing something?

    --
    Freedom is the freedom to say 2+2=4, everything else follows...
  111. Re:Dunno how literate I am, but here's what I do.. by Bush+Pig · · Score: 0

    I _am_ a programmer, and what you suggest is also the way I prefer to write code, only it's perhaps slightly less experimental in my case and I don't have to reach for the language reference manual quite so often.

    --
    What a long, strange trip it's been.
  112. Re:Literate programming versus continuing developm by Pseudonym · · Score: 1, Redundant
    Whether there is a performance penalty to such wrapping is hard to say. Generally, there will be some performance penalty for the "indirection" needed for hiding implementation. [...] Some programmers get obsessive over speed for no good reason, and make stupid (change-unfriendly) code as a result.

    Repeat until enlightened: Unless you have an unlimited amount of programmer time to expend, long-term performance is a consequence of maintainability.

    The "big" performance improvements are generally algorithmic in nature. They're what you get when you replace an O(N^2) algorithm with an O(N log N) algorithm, or when you replace an O(N log N) algorithm with an O(N log N log log N) algorithm which exploits cache coherency much better.

    When you find that you need to change one algorithm or data structure with another (and you will), you might think twice before doing that to an unencapsulated implementation, whereas doing it to an encapsulated implementation will be much cheaper. Moreover, with an encapsulated implementation, you can play with several different implementations until you find the best one for the situation at hand.

    Yes, your code may have perform better had you written an unencapsulated version of the most appropriate algorithm/data structure to begin with. What a wonderful world it would be if software engineers were also clairvoyants. :-)

    (BTW, you don't need OOP to wrap collection handlers.)

    No, you don't. You at least need abstraction and at most you need encapsulation. These are a subset of the problems that OOP solves, but OOP is not the only solution to those problems.

    So while you don't need OOP, if you're working with a system which already has it, you might as well use it unless there's a good reason not to.


    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  113. Debate away... by gregfortune · · Score: 2
    I'm not the anon from above... Regardless, you have your real debate.
    1. "Code should document the program"

      Of course it should. Anywhere that the code does not "document" the program, the progammer needs to provide explicit documentation or write clearer code. That's very very simple if you just consider that the code *is* the program. What documentation could be more correct than the code if you want to know what the program does.

    2. "Documentation should document what a program *should* do."

      Very nice idea, but I've never seen this work in practice. The problem is basically this: You just introduced an entirely different vector under which bugs can occur. These new bugs do not break the program in any visible manner, they just destroy the productivity of a maintenence programmer.

      Example... Client decides to change the behavior of a component of a system after the program has been released. Programmer goes in and changes the code, but never changes the documentation. While making the change, the programmer notices that another requested change will cause the first piece of code to break in a very subtle way if it had not been changed.

      6 months later, another programmer makes some changes and notices that a line of code is clearly not doing what the documentation says it should be doing. Feeling almighty and powerful, he modifies the line so it fits the documentation, thus overwritting the change from 6 months ago and introducing a subtle bug.

      What happened? If documentation is not kept up to date (one more bug vector to worry about), the maintenence programmer will either lose time verifying which is correct or will "fix" a bug that shouldn't be fixed. Neither case is a good thing. Documentation bugs are especially bad because they are so transparent.



    So which is worse? I would warrant that the second is far worse. Any documentation that can be embeded directly into the statements of the language through variable names, function names, language constructs, data structures, etc are a great benefit as they cut down on the number of instances where doc bugs can occur.

    Nonetheless, it's is definitely necessary to document particulary nasty chunks of code, but keep the documentation at the highest level possible. If it is a system overview comment, it belongs in a design doc. If it describes how a black box *should* work, it belongs at the highest level of that box (ie, class or function). If it is a single line genius piece of code, by all means, document it. But be assured that anyone who changes it will probably have a tough time understanding it, will have to read the documentation, and will likely remember to update the documentation out of appreciation if nothing else.

    If this is tough to accept, look at one of your own statements..

    But - every time I add NEW requirements, you'll have to massively modify the code. As the code becomes more and more complex, it will have more opportunities to gain bugs.
    Really? And so as it becomes more complex, it will likely need documentation to describe the additions that are being glued to the side of the original design, right? Oh, right. Maybe it will remain constant? .....

    All this while, though, the documentation might remain constant, if it's written clearly enough.
    Yes, it might. Are you going to remember to check it, especially if it is right *most* of the time...

    So, there you go :) Debate away
    1. Re:Debate away... by Thorrablot · · Score: 1
      Don't bother keeping code documentation up to date because somebody may write code assuming the documentation is up to date? I'm getting dizzy...

      I'm surprised that anyone would attempt to argue the merits of using any computer language as the appropriate mechanism for communicating the intent of an algorithm/function/method. The code is for the machine, not for humans! It's more precise, but only because it's so much more constrained. If you want to quickly port it, or have any hopes of releasing your work as an API for somebody else to code to (or test against), you've simply got to have good documentation.

      In your scenario, the problem was not simply that the documentation was out of date. If you're operating in a shop where a change can be made in a core component without triggering regression testing, or core components can have their functionality change without revving the API, you need to fix your process.

      It is bad to have out of date documentation, but this typically occurs because it's too far away from implementation. Making documentation coincident with implementation, either by convention (embedding comments), or by language design (Literate Programming languages) is an improvment.

      In general, I prefer less high-level documentation and more at the class and library level. I know I'd much rather have a well documented class header and methods (with code fragment examples) and a good unit test than having to dive into an implementation and reverse engineer somebody else's code.

      For that matter, for C++ I prefer incorporating documentation into the code itself, and use packages like Doxygen or Cocoon to extract it (there are many more, I'm sure).

      BTW, now in danger of getting on topic, Leo does look pretty interesting... esp. for web work.

      --
      Any sufficiently advanced technology is indistinguishable from a rigged demo. -- James Klass
    2. Re:Debate away... by Viking+Coder · · Score: 2
      Six times* in your comments, you argue for the existence of documentation beyond the mere existence of the code. In the context of the debate, there were two positions:
      1. Documentation is worthless.
      2. Documentation is valuable.
      I agree that there are many more layers to the debate, but each of the arguments you have made implies the existence of SOME documentation. Can't you see that you're on my side? It's not much of a debate, if you agree with me. =)

      I'm not saying that I have the solution to everything, but I do know one thing for a certainty:

      The worst of all possible solutions is no documentation, at all. (Excluding the consideration of "code as document".)

      I don't believe you disagree with my statement. If you do, feel free to phrase your retort for maximum effect.

      * Here are the six times (with emphasis added) you referenced the existence of documentation, beyond just the code.
      1. Anywhere that the code does not "document" the program, the progammer needs to provide explicit documentation or write clearer code. (Self explanatory case.)
      2. In your second case, you essentially argued the case for a revision control system, with strong documentation, and regression tests. I would argue that, being external to the actual functioning of the code, that regression tests qualify as additional documentation. I particularly feel that regression test code should contain high-level documentation in the form of comments - specifically, when the tests can cite design documents or requirement specifications.
      3. Nonetheless, it's is definitely necessary to document particulary nasty chunks of code, but keep the documentation at the highest level possible. (Again, fairly self-explanatory case.)
      4. If it is a system overview comment, it belongs in a design doc. (A design doc is written primarily not in code.)
      5. If it describes how a black box *should* work, it belongs at the highest level of that box (ie, class or function). (I believe "it" referred to documentation beyond the code.)
      6. If it is a single line genius piece of code, by all means, document it.(Self explanatory.)
      Or did I miss something?
      --
      Education is the silver bullet.
    3. Re:Debate away... by gregfortune · · Score: 2

      I'm not stating either 1 or 2. The posts above are arguing both extremes and I'm leaning towards the idea that the code itself is a damn good documentation tool. I'm also pointing out that no documentation is many times better than incorrect documentation (so no, I do not agree with you). Strong regression testing would most likely catch what you call my second case, but that won't always be true. I will concede that regression tests are probably the most vaulable form of documentation that has been mentioned so far, but again, incorrect documentation (or regression tests here..) are deadly.

      So again, I'm not imply or recommending that we try to get away with *no* documentation. I'm just pointing out that it's in our best interest to allow the code to document as much as absolutely possible.

    4. Re:Debate away... by gregfortune · · Score: 2

      I'm surprised that anyone would attempt to argue the merits of using any computer language as the appropriate mechanism for communicating the intent of an algorithm/function/method.
      Howdy, here's one. Actually, I'll argue the merits if we remove algorithm from that list... The merits from my point of view: Concise, minimized number of changes, "documentation" is always up to date. Now, before anyone gets crazy, I did state in my last post that some documentation is necessary. In particular, high level documentation is a must and documentation of very tricky pieces of code makes it much easier for a maintainer to work with your code. Other documentation just gets in the way or, in extreme cases, misleads the maintainer.

      And I regard algorithm more as a paper thing than a code thing. A function or method is the implementation of that algorithm and if you've put that much thought into a piece of code to justify it as an algorithm, you've probably got some very nifty diagrams and design docs to go along with it. Documenting the implementation is unnecessary unless it deviates from the specified algorithm. "Reference: My cool algo" is probably enough.

      In your scenario, the problem was not simply that the documentation was out of date. If you're operating in a shop where a change can be made in a core component without triggering regression testing, or core components can have their functionality change without revving the API, you need to fix your process.
      That works. So now the code and documentation match, but the regression test fails. Or the code and regression test works, but the documentation says something like, "This should be fixed. Possible risk for thread contention" when in fact, the risk for thread contention has been removed. So which is correct? Regression testing is perhaps the best form of documentation, but it's not quite so "invisible". If a regression test fails, you know it. If documentation is incorrect, you might miss that for months or years.


      In general, I prefer less high-level documentation and more at the class and library level. I know I'd much rather have a well documented class header and methods (with code fragment examples) and a good unit test than having to dive into an implementation and reverse engineer somebody else's code.

      That is high level documentation, isn't it? Design documents are higher level, but not by much. The api documentation is critical and having a separate individual who's responsibility is to maintain api documentation is not too bad an idea (poor, poor soul though....). And as long as the api stays consistent, it's a write once and forget. With a rapidly change api, it's probably more of a burden initially and Leo seems to push for api solidity. I don't know about you, but I'm constently extending and improving the api of my personal libraries as I learn more or need more out of the api. Minimal documentation seems to be a better use of my time than trying to exhaustivly document a changing api.

    5. Re:Debate away... by Viking+Coder · · Score: 2
      I'm just pointing out that it's in our best interest to allow the code to document as much as absolutely possible.

      Absolutely.

      Nothing beats good code. Given that sometimes there is bad code, it would be better if the code contained documentation - that's my position.

      I'm also pointing out that no documentation is many times better than incorrect documentation

      That's an absolute statement which I think you don't really mean. For instance:

      // this algorithm comes from page 293 of the book "Numerical Recipies in C"

      Well, what if the algorithm actually came from page 294? The documentation is incorrect. But even that HINT of the source of an algorithm is SO MUCH BETTER than no documentation at all, that it's killing me that people are disagreeing with me on this point! =)

      I agree, we're both coming awfully close to making absolute statements - to which there are always exceptions. But I'd rather have the hint of the coder's state of mind (even if they do a crappy job of explaining themself), than no hint at all - when faced with code which is provably misbehaving. *shrug* Especially since I can always just keep hitting that "del" key to make their bad comments disappear, but the only thing I can do to make comments appear is figure out the intended behavior of their damned code, and type it in, myself. Which can be pretty tough, sometimes - I've seen some Grade-A Horseshit code, in my day. *shrug*

      --
      Education is the silver bullet.
    6. Re:Debate away... by gregfortune · · Score: 2

      Your example for the documentation is a good one and your closing statements make good sense too. So far, I've been lucky enough to work with some pretty talented developers so minimal documentation is an asset. I guess I'm wishing for ideal situations :)

    7. Re:Debate away... by Viking+Coder · · Score: 2

      Thanks. I wish we were all so lucky. =) I agree, there are situationa when anything beyond minimal documentation just gets in the way. Especially when an API is changing dramatically. *shrug*

      Damnit. Why isn't there a magic bullet that fixes all problems?! =)

      --
      Education is the silver bullet.
    8. Re:Debate away... by Thorrablot · · Score: 1
      I suspect our disagreement is due, at least in part, to differences in the definition of "documentation". I'm primarily refering to API documentation - which is most certainly NOT "write once and forget"! You said yourself that "I'm constently extending and improving the api of my personal libraries as I learn more or need more out of the api."

      This is best accomplished by writing and editing documentation for all public methods, and class/library level documentation, including variables, overloads, side effects, etc. at the time of implementation whether or not this is a new class, or just a bugfix. The longer you wait, the more you forget. If that doesn't happen to you, congratulations - wish I had your memory. Still, you'll be the one individually training in every new coder for the next N years.

      I also have found that writing API documentation during implementation often causes me to consider aspects of the problem that hadn't surfaced before, because it forces me to think (not in code) about how a client will be using the code. Once high-level design is done, my strategy is:

      1. Write unit test
      2. Write class/lib API documentation
      3. Write implementation
      4. Lather, rinse, repeat

      It's certainly true that some organizations use outdated, overzealous, and under-tooled documentation procedures as a crutch for process and auditing purposes. If your documentation isn't electronic, doesn't refer directly to active source code, and isn't stored isn't the same source code control system, chances are good that it will get left behind during implementation. This doesn't seem so important in the "fog of implementation", but is ultimately a major loss, and can drastically shorten the life-cycle of software.

      Environments like this cause documentation to get a bad rap, and cause engineers resort to drastic measures to fob off "documentation" work to new hires, interns, or frustrated bosses. Understandable, because it isn't adding much value if it's so divorced from the development cycle.

      Some code is self-explanatory, but the vast majority is not. While I personally feel that Literate Programming goes too far afield, programmers should document the interfaces (minimally) to their code to the best of their abilities, and be responsible for the state of the documentation. To my mind, this is no different than expecting architects to place measurements on their blueprints. You can argue that it's unnecessary, because the information is already there in the scale drawing - but it's more efficient and reliable to use multiple representations (text and geometry) to communicate the information.

      --
      Any sufficiently advanced technology is indistinguishable from a rigged demo. -- James Klass
  114. Re: Brace indention doesn't matter!!! by grahamtriggs · · Score: 1

    I will make one concession to this, in that it can depend on the editor you are using...

    If your editor does brace matching, then it *may* not matter about how you indent/format blocks...

    If you ever have to look at code as just a plain text document, then K&R blocks can be a *severe* problem...

    K&R style blocks make it much harder to see where braces match... this is especially true if you ever use default program blocks (ie. an if statement with a single statement in the 'then' clause, without the use of any braces)

    Yes, you can mitigate the problems greatly by always explicitly defining your blocks (ie. always using braces, even where they are not strictly required by the language), and being absolutely strict about how you indent code (esp. with regards to spaces vs. tabs)... however the second point can be quite hard to enforce, when you may need to use a variety of editors in different circumstances, and you have a reasonable size team working on the project...

    As one of the most important aspects to understanding how code works is to be able to see where the program blocks are, and exactly what they are doing - not to mention the number of bugs caused by errors in the definition of program blocks - K&R style formatting can be the cause of many headaches, and result in a lot of wasted time / effort.

  115. literacy meets the web by Ragica · · Score: 0
    Yes, welcome to the brave new world of literate programming ... where you need javascript enabled browser apparently just to read your own documentation.

    At least the link provided requires it to get to any actual information.

    I think i'll just remain an illiterate programming ludite, thanks. It's worked so far.

  116. I have used CWEB by r6144 · · Score: 1

    Well, it does make programs more extensible, but if you are having race conditions or other delicate problems, tough. Another problem is that I often make 2000-line functions unwittingly --- although they are no harder to understand, they take much more time to compile with gcc.

  117. Design vs. Documentation by jared9900 · · Score: 1

    I think I've arrived here a little late, but here's my contribution:
    It seems to me that a lot of people who've posted hold the opinion that documentation and coding can (or should) be done at the same time. I think that what is most important in a programming project (as in any other engineering project*) is the design. Documentation != Design. The design is an essential part to most projects bigger than "Hello World!" Without properly designing your project before beginning the coding/documentation phases you will end up with a mess of code and only an idea of how it all ties back together in your head.

    * Yes, programming is a form of engineering, no you're not designing a building or a processor, but when you're talking about a large scale application or operating system it might as well be a physical structure. Without using proper techniques most projects will end in failure.

  118. Shivver by Srin+Tuar · · Score: 2


    In addition IE is required for the pages that have speech, since that uses MS Agent, and there is no comparable technology for Netscape.


    You used MS-Agent and technology in the same sentence! I can think of a portable systems which provide text-to-speech (festival), and its certainly possibly to provide the page without "speech", or with a few sound clips in ogg or mp3.


    Also, some languages are trivial to text to speech, such as japanese. (trivial as in a perl script and a directory with sound clips could probably doit in real time)


    Well, mostly my problem is that I have no way of getting any version of IE going, and I really wanted to try the language sections, so I am bummed :( If they ould at least allow me to attempt to use it with Moz/linux, maybe I could get a reduced functionality version, rather than being redirected by the cgi.

  119. Re: Offtopic nitpick by Anonymous Coward · · Score: 0

    3 characters versus 4 every so often, though I guess it worth it if you're using 300baud (or less) where every character counts.

  120. funky RAmen by castlan · · Score: 2

    The reason geeks don't like writing too much documentation is simple. It's not laziness (well not always), it's just tedium with human language (or poor speeling and grammer to).

    Project completion includes documentation.

    Professionalism demands it.

    Always.

    Full steam ahead.

    The worst cause of feature creep and software bloat is delineated in your rationalization. The "simple" change should be to your documentation, and then the code should be updated to reflect that change. Note that that change in the spec is usually considered a valid reason for an increase in the revision number.

    The worst thing in the world for a software company (profit motivated) is a moving feature set, and never reaching 1.0.

  121. You are missing the point by ArcSecond · · Score: 2

    Of course the documentation will change. I forgot to mention how important docs are in the process of "change management". It's like war: no battle plan survives the first engagement with the enemy, but that is no reason not to have one. As long as you change the docs to reflect the new features/behaviour, there is no problem with docs "getting out of date" with respect to the code.

    Besides, if you are writing the docs and someone notices a glaring issue, you can resolve it before telling someone to start coding. The earlier, the better. And you WILL do the same changes later in the project anyhow, with a few hundred percent increase in the workload.

    This is why (most) programmers make horrible tech writers: they are too involved in the code to be concerned about issues that affect usability and project management.

    --

    I've got a bad attitude and karma to burn. Go ahead. Mod me down.

  122. Reading the tutorials by ozten · · Score: 1

    Leo is great! It works with whatever toolchain you are already using, and doesn't get in the way.

    You could write the software, help manual, and project manage it all from file exported through Leo.

    Bravo, I am definetly going to try this one out.

  123. Re:why is html still tag based? by Sharkeys-Day · · Score: 1

    Because it's a text markup format, not a programming language.

    I think I'll go write a 10MB technical report as one big nested S-expression. Yeah, right.

    One clue too few...

  124. Not what I meant by MaryAlice · · Score: 1

    People already want the computer to do what they want instead of what they say. I wonder if they still will complain 'that is not what I said.'

  125. Why do you waste your time? by Anonymous Coward · · Score: 0

    Young Jedi,
    Why waste your time with these losers? Enjoy the last moments of summer before it retreats.

    -Master

  126. Visual Age for Java tools by John+Harrison · · Score: 2
    I've been using VAJ for over three years and once I got used to its quirks I found it to be very powerful and never felt constrained by it.

    If you REALLY need to do something that the IDE isn't capable of then you can write your own tools. VAJ provides a Java API for this and it is really easy to use. You can then make the IDE do anything that you want, as long as you are able to code that behavior in Java. You can also you vi and Emacs to edit your code in VAJ if you really want to.