Slashdot Mirror


Source Code Browsing Tools?

Marco Sanvido asks: "I often look at source code (especially C, but this question is valid for other languages as well) and I have a really hard time in understanding how it works. Documentation is often missing or quite outdated, and the only way to see how the program works is to try to understand the source code. Which tools do you prefer to use for browsing and studying source code? So far I have used LXR for Linux, Eclipse for java, and CScope, but I'm not sure that these tools are the best solution." It's tempting to flood this question with answers for your IDE, but the key thing here is _browsing_, not _development_. What decent, lightweight programs would work well as source code viewers?

11 of 165 comments (clear)

  1. A couple of options by plover · · Score: 5, Informative
    If you're looking for really lightweight, run the code through a prettyprinter first. Pick the style you can most easily read. For example, I personally don't like K&R style, but that's entirely up to you.

    If you're looking more for documentation of existing code, doxygen is great. It produces click-to-follow hierarchies, graphical pictures of trees, and can will intelligently display some of the comments it encounters. It can produce output in html, LaTeX, rtf, PS, PDF, and even man pages. And I know from experience that it can handle some pretty massive projects.

    --
    John
  2. The only option by Frogbert · · Score: 3, Funny

    Real programmers use "type".

    1. Re:The only option by Alfred,+Lord+Tennyso · · Score: 5, Funny

      Actually, real programmers use cat.

    2. Re:The only option by popeyethesailor · · Score: 4, Funny

      Um no. They may grep, sed, awk, diff, tr, tail,head or more; but they never cat.

    3. Re:The only option by Catastrophator · · Score: 3, Funny

      Bah! Real programmers program with the switches on the front panel! Damn whippersnappers... And get of my lawn!

    4. Re:The only option by Bastian · · Score: 3, Funny

      And get of my lawn!

      Real programmers know that forgetting even a single byte in any stream of data can turn it into gibberish or worse.

  3. OpenGrok by Lucractius · · Score: 4, Informative

    the opensolaris code browser is built off a bunch of open source stuff.

    OpenGrok
    its incredibly easy to use, and makes things very easy to read. and is now packaged for your enjoyment.
    and available at http://www.opensolaris.org/os/project/opengrok/

    --
    XML - A clever joke would be here if /. didn't mangle tag brackets.
  4. codeviz by meowsqueak · · Score: 4, Informative

    You can make some useful call graphs with codeviz + graphviz. I sometimes find this useful for tracing the heirarchy of abstraction through a set of C source files.

    http://www.csn.ul.ie/~mel/projects/codeviz/

  5. gdb by Bastian · · Score: 4, Interesting

    I'm actually a fan of using a debugger to step through code I'm trying to understand. I can let it keep track of the call stack for me and it saves me from having to manually surf around multiple source files to figure out where the next function I need to look at is.

    It's not a good way to figure out how every nook and cranny of the code works, but it's great for an initial scan-through to see the overall structure of a module. And if you are at liberty to throw in an embeddable scripting language (I use F-Script) you can poke and prod at anything you want with ease.

  6. Re:Nothing Can Beat a Good Editor by plover · · Score: 4, Informative
    For windows, I've completely replaced "notepad.exe" with "notepad2.exe" And when I say completely, I mean I crawled through my system registry editing every occurrance of "notepad.exe" to "notepad2.exe". Shell opens, file associations, defaults of every sort use it. I love it. And unless someone using the computer is particularly observant, they don't even notice it's not the original notepad.

    It has a very simple interface that looks like the original notepad, it does syntax coloring for two dozen different languages and file formats, shows bracket matching, adds line numbers, word wrap features, support for UNIX- and mac-style line terminations, regexps, and is in general what notepad itself should have been back in the 1990s. Plus, it's freeware. What more could you want?

    --
    John
  7. Not *browsing* but *understanding* by PurplePhase · · Score: 3, Interesting

    Unfortunately the story poster was a bit vague. They could mean that they or the person assigned don't read code, yet they need to know how a program works, or what it does. There are many times when you don't want to or cannot run/debug a program to analyze it.

    There have been many links posted which I'm going to have to explore - not the editor links (jEdit and Emacs rulz!) but the conceptualization links. Unfortunately most if not all IDEs are still code-file based. The most prominent other tool for project conceptualization is UML which has been gaining IDE integration. Yet there are still a couple problems with that:

    1. The UML usually generates accurate structures for classes, but doesn't or cannot generate execution diagrams (what, 4 types in UML?) or state diagrams.

    2. These static diagrams represent only the level of the code instead of being an interactive object with drill-downs or abstract-up commands!

    To understand a new set of code or codebase, I need something that analyzes the code and reports back to me on its tactics and strategies - what patterns are used, what weaknesses are in the code, ... Current tools give you unuseful amounts like cyclomatic complexity, or other ratings like test coverage or Fowler's class interdepence/brittleness/(whatever) measure. However those things are useful to me only: if you know nothing about code, have any resources to plug testing holes, or are actively managing a codebase, respectively. None of them say what the code *does* or how it does it. So we need something that covers concerns orthogonal to what already exists.

    Which makes me more curious about the comment asking if anyone uses the tools researchers are working on for visualizing a project. I haven't kept up on academics - where do I start looking? And is there anything there with demos, products available, or in post-beta releases?

    8-PP