Source Code Browsing Tools? 165
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?
A couple of options (Score:5, Informative)
If you're looking more for documentation of existing code, doxygen [stack.nl] 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.
Re:A couple of options (Score:2, Interesting)
Nedit (Score:2)
Re:A couple of options (Score:2)
Re: Pretty Printer (Score:2)
The only option (Score:4, Funny)
Re:The only option (Score:5, Funny)
Re:The only option (Score:5, Funny)
Re:The only option (Score:2)
I less. does that make me not real?
Re:The only option (Score:3, Funny)
Re:The only option (Score:4, Funny)
Real programmers know that forgetting even a single byte in any stream of data can turn it into gibberish or worse.
Re:The only option (Score:2)
Re:The only option (Score:2, Funny)
Re:The only option (Score:3, Funny)
Re:The only option (Score:2, Funny)
OpenGrok (Score:5, Informative)
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/ [opensolaris.org]
Re:OpenGrok (Score:2, Interesting)
Re:OpenGrok (Score:2)
http://servlets.com/engines/#embeddable [servlets.com] has a list of quite a few. and from the list
http://jetty.mortbay.com/jetty/index.html [mortbay.com] seems to be the best candidate. (though it quotes no resource figu
Re:OpenGrok (Score:2)
Re:OpenGrok (Score:2)
Nothing Can Beat a Good Editor (Score:3, Insightful)
Nothing Can Beat a Good Editor
As much as we might like to use some special purpose tool for this purpose, most of the time that I'm looking at code I'm not entirely sure if I'm going to be editing it or just peeking. Thus, it's silly to be in one program when I need another. And, the added "system weight" of running a "heavy" editor vs.
Syntax highlighting is THERE in an editor, and I don't have to restart if I change my mind about changing the file.
http://ultraedit/com/ [ultraedit] is a GREAT editor for Windows, or Jedit or Eclipse for Win or unix.
Re:Nothing Can Beat a Good Editor (Score:5, Informative)
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?
Re:Nothing Can Beat a Good Editor (Score:3, Informative)
Re:Nothing Can Beat a Good Editor (Score:3, Informative)
Re:Nothing Can Beat a Good Editor (Score:2)
Well, symbolic links are out (unless you want to link to a directory, then you can use junctions [microsoft.com], but a hard link [microsoft.com] is available and should work.
Re:Nothing Can Beat a Good Editor (Score:2)
Command mode.
Re:Nothing Can Beat a Good Editor (Score:2)
Re:Nothing Can Beat a Good Editor (Score:2)
Re:Nothing Can Beat a Good Editor (Score:2)
Re:Nothing Can Beat a Good Editor (Score:2)
If you still want to use it, in vim/gvim you can use bold/underline/undercurl/reverse/inverse/italic/s
Re:Nothing Can Beat a Good Editor (Score:2, Flamebait)
Re:Nothing Can Beat a Good Editor (Score:3, Informative)
On my personal system, emacs in text mode loads before I'm ready to edit the file, which is all I can ask for, and it's still the fastest XWindows editor I can open. It may be "heavier" than othe
Re:Nothing Can Beat a Good Editor (Score:2)
Now, if you're wanting to be a badass who uses an old version of vi that doesn't include decent scripting support, that's different. But me, I'm a programmer and I
Re:Nothing Can Beat a Good Editor (Score:2)
Re:Nothing Can Beat a Good Editor (Score:2)
Treepad is not that bad as an alternative though. It is missing the nice compact search and replace dialog but otherwise is very feature rich.
JsD
Krugle (Score:3, Informative)
LXR (Score:2, Informative)
LXR's claim to fame is that it started out being a cross-referenced browser for the linux kernel source code, but since it was released, the newer versions has moved towards becoming more of a general source browser. (might need to use cvs, don't know if a proper release was made)
It does neat tricks like processing source code, building function/variable/header/etc line references for usage, definition, declarati
Re:LXR (Score:2)
Re:LXR (Score:2)
It certainly helped me a lot while i was wading through the kernel source, and it does support non-kernel sourcecode in more than just C nowadays.
ash
codeviz (Score:5, Informative)
http://www.csn.ul.ie/~mel/projects/codeviz/ [csn.ul.ie]
SlickEdit (Score:2)
One excellent option... (Score:3, Informative)
Re:One excellent option... (Score:2)
Re:One excellent option... (Score:2)
I suspect that if it's stable anywhere, it's under Linux.
JEdit (Score:3, Interesting)
gdb (Score:5, Interesting)
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.
Re:gdb (Score:2)
For me the holy grail would be to have a system similar to Doxygen which would allow me to "load" a trace from a debug session and use that to step around in the code.
Re:gdb (Score:2)
Which reminds me; I don't know if other development environments do this, but XCode's "patch" feature is also really killer for figuring out what's going on. If you want to force the execution to go down a certain path, you can always break just before the conditional, comment it out, click patch, and continue without havin
Re:gdb (Score:3, Interesting)
Use GDB inside of Emacs (M-x gdb) That way, you have an entire buffer to navigate through the code, while the debugger output is displayed on another buffer. And, yes, the code buffer is always actualized to the running instruction when the debugger beaks.
SciTe (Score:2, Informative)
Source Insight (Score:2, Interesting)
Not really a browser, but helpful (Score:3, Informative)
http://www.stack.nl/~dimitri/doxygen/ [stack.nl]
cscope (Score:2)
Re:cscope (Score:2)
Re:cscope (Score:2)
Anyway it works really well and I like VIM for the rest of my devleopment anyway so no extra tools are really needed.
FishEye (Score:2, Interesting)
http://www.cenqua.com/fisheye/ [cenqua.com]
A query language for browsing (Score:3, Interesting)
Browse-by-Query [sourceforge.net] is a database for code with a query language specifically designed for finding things in code.
I was dissatisfied with fixed-function browsers, so I developed this.
Use expressions more powerful than regular expressions to search through and understand your codebase.
Works only with Java now (there's a standalone version and Eclipse plugin) but I hope I (or someone else) will extend it to others.
Understand for C++ (Score:3, Interesting)
We use Understand for C++ [scitools.com] (link is to the index of all "Understand for..." family members) when reviewing and designing formal unit tests for our clients' code. It's extremely useful for manual static analysis: understanding structure and inter-relatedness, so to speak.
However, to understand dynamic behavior you should look at various tracing options, even the lowly printf(), or try stepping through in a debugger. The larger, more complex and the more object-oriented the code, the more important understanding the dynamics are.
Anyway, Understand for C++ is much more interactive than any of the free comment extraction or cross reference tools and the database has a Perl API, though we've not had a chance to use it. It's worth the price if your doing this as part of your job.
- BarrieRe:Understand for C++ (Score:2)
No OS X version, FYI (Score:2)
Just FYI for anybody else looking into it.
Emacs (Score:2, Interesting)
I know you said no IDE's, but if you merge well with Emacs, it can do the work too. Emacs is not exactly a heavy weight, depending on how you install it (it's often built into your distro anyway). It uses this thing (I don't really know it that well to be honest) called tags - ctags or etags.
Basically you run etags (check your man pages) from the command line that will parse through your source files and create a lookup table in a file (name TAGS by default I think). While browsing the source file, you ju
Re:Emacs (Score:2)
Re:Emacs (Score:2)
First and foremost, syntax highlighting. I don't know a single program that highlights syntax as well as Emacs. Get your colour scheme right and code won't be the same without it. You can visually "see" the code structure at a glance without even having to read the words. Emacs indenting is also superior, and really helps when making out the overall structure. There's even a code folding option now, so you can finally collapse sections. Very useful at tim
Re:Emacs (Score:2)
Re:Emacs (Score:2)
Though I like Emacs and currently use it, I find the standard syntax highlighting of Vim superior.
Maybe it is because I mostly use Perl.
Two things stand out.
emacs only highlights variables in Perl when they are declared, and does not to highlighting on @ and % variables. In Vim all variables are highlighted anywhere.
The other thing is POD documentation. In Emacs one has to reload the file for POD sections to be highlighted, when in Vim they are highlighted from the moment you start a '=pod' section.
Re:Emacs (Score:2)
And emacs misses folding.
Once there was an elisp folding package, but last time I searched, it was nowhere to be found.
Re:Emacs (Score:2)
I finally found it at EmacsWiki [emacswiki.org].
Re:Emacs (Score:2)
Re:Emacs (Score:2)
All my previous gripes are based upon CPerl mode.
Re:Emacs (Score:2)
You may be right about vim's syntax highlighting being better overall, but you are wrong about perl. My emacs highlights @foo and %foo well enough; they get colored and, IIRC, underlined.
Re:Emacs (Score:2)
Emacs Code Browser and JDEE (Score:2)
Also worth mentioning (and related) is the Java Development Environment for Ema
How dare you... (Score:2)
Re:How dare you... (Score:3, Funny)
ViewVC is handy... (Score:2)
I agree with some of the other folks here, though - a good IDE makes an excellent code browser. IntelliJ IDEA is awesome if you're working with Java code...
Understand from Scitools (Score:2, Informative)
One of the things I like most, is t
Try PSpad. It's free (Score:2)
Browsing (Score:2)
If you are looking for this in relation to debugging a known bug, ctags + vim (or etags + emacs) is the way to go. This also applies in case you just want to learn the code.
If you are looking for this to audit the security of a program, then you need to follow code paths. While ctags will help you there, I don't see much stuff which is capable of showing flow paths in a program.
SourceNavigator (Score:2, Informative)
Tools I have used, GNU Global & NCC (Score:2, Informative)
I have sometimes used GNU Global [gnu.org] which makes indexed html pages of the code. Somewhat similar to lxr but there is no setup, just run two commands, gtags and htags. One nice thing about global is that it can be used on any incomplete subset of a software system. Want to just look at the files in the drivers/net/wireless directory in the linux ke
sourcenav? (Score:2)
The underlying technology is not the prettiest ever. Yeah it uses TCL. But it has a workmanlike efficacy in terms of interface. Give it a try.
For most smaller projects I just use vi and ctags, or maybe cscope with those, but I'm sure you're familiar with al
Browsing C (Score:2)
Brilliant source code browser (Score:3)
A GUI literate programming editor - can import sources in many languages, and break them down into classes/methods/functions.
You then have ability to create all manner of 'views' of the code.
Universal advise (Score:3, Funny)
Wrong way, use debugegr (Score:2)
Not *browsing* but *understanding* (Score:3, Interesting)
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,
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
Source Navigator (Score:3, Informative)
jGRASP (Score:2)
My choice (Score:3, Insightful)
14-inch greenbar, preferably printing on a color-capable impact printer.
Wide continuous paper, plus a large work surface, means I can stretch a module out and mark it up with highlighters and scribble notes. A straightedge and some detective work means I can verify "indentation" levels (code nesting).
Of course, run a source code beautifier over it first.
Why, yes, I am old; how did you guess?
In the UNIX world I use four tools: (Score:2)
(2) Red Hat's SourceNavigator [sourceforge.net].
(3) GNU Global [gnu.org] to generate a nice clickable HTML version of a source tree.
I used to also use CSCOPE, but I can't fine Solaris/Sparc binaries which don't require root access to install (pkg format isn't helpful for me -- I'm just a developer on the box, not an admin).
On the mainframe side, I usually use a combination of FINDREF, IACULL, and CULL, which together form a sort of superpowered CSCOPE, but I'm not aware of a similar tool in the
Old School... (Score:2)
If you really want to read some code, print it with a good old fashioned chain printer on green bar paper formatted with "pr" for page numbers, and get a set of colored highlighters to mark useful things.
For code you want to browse through, hack up a little perl script that gives you page number references for each symbol and subroutine/function/method, and print that out on a separate stack.
Go sit somewhere nice where you can relax, flip through your s
If it's not already understandable... (Score:2)
If you are just looking
$EDITOR (Score:2)
!tools (Score:2)
http://c2.com/cgi/wiki?TipsForReadingCode [c2.com]
"Comprehension and Visualisation of Object-Oriented Code for Inspections" http://www.cis.strath.ac.uk/research/efocs/abstrac ts.html#EFoCS-33-98 [strath.ac.uk] section 5.
Demeyer, Serge. Ducasse, Stephane. Nierstrasz, Oscar. Object Oriented Reengineering Patterns ISBN: 1558606394 [amazon.com]
Feathers, Michael. Working Effectively with Legacy Code ISBN: 013117 [amazon.com]
Vim too (Score:2)
See
I mapped Alt-Right and Alt-Left to quickly follow a variable/function name to its definition and go back:
map <M-Left> <C-T>
map <M-Right> <C-]>
Re:Notepad++ (Score:2)
Re:Notepad++ (Score:2)
Re:Well... (Score:2)
Re:Well... (Score:2)
Re:useful tools (Score:2)
I haven't tried it, so don't know whether it's any good. I seem to remember a while ago I stumbled on something else which does exactly what you're referring to, but can't find it in my bookmarks or history.