Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Source Code Browsing Tools?

Cliff posted more than 8 years ago | from the emacsen-are-right-out dept.


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?

cancel ×


Sorry! There are no comments related to the filter you selected.

A couple of options (5, Informative)

plover (150551) | more than 8 years ago | (#15492204)

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.

Re:A couple of options (2, Interesting)

diverscuba023 (615113) | more than 8 years ago | (#15492288)

The only problem with doxygen is the amount of time it takes to generate the documentation for an entire project. I had one project it would take almost 48 hours to produce the documentation for and it could not generate the graphs for two of the hiearchies since they were too big. The source code was only about 500K lines.

Re: Pretty Printer (1)

eikonoklastes (530797) | more than 8 years ago | (#15492434)

Here's what I use:
a2ps -o --prologue=color SOURCECODE.c
I love it.

Re: Pretty Printer (1)

Poltras (680608) | more than 8 years ago | (#15493349)

a2ps already sends to default player if you don't specify the -o tag :) Just so you save 20-30 characters.

Nedit (1)

ishmalius (153450) | more than 8 years ago | (#15493429)

Any editor with good syntax highlighting would probably give you most of what you want. Nedit [] has long been my favorite. Simple, light, and with (last time I counted) 28 grammars.

Graphical Displays (0)

Anonymous Coward | more than 8 years ago | (#15492232)

I personally would like to see tools for visually displaying objects at runtime in an animated graphical display. It would be a quick way to figure out a large code base rather than having to read all the code.

The only option (3, Funny)

Frogbert (589961) | more than 8 years ago | (#15492234)

Real programmers use "type".

Re:The only option (5, Funny)

Alfred, Lord Tennyso (975342) | more than 8 years ago | (#15492272)

Actually, real programmers use cat.

Re:The only option (4, Funny)

popeyethesailor (325796) | more than 8 years ago | (#15493047)

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

Re:The only option (3, Funny)

Catastrophator (919528) | more than 8 years ago | (#15493071)

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

Re:The only option (0)

Anonymous Coward | more than 8 years ago | (#15493253)

heheh, close but no cigar :)

I build software on-the-fly using [url=" tml#TOC3"]tcc -run[/url],

including my build workstation! Hell, it's 9 times faster than gcc too!!

Re:The only option (1)

martin-boundary (547041) | more than 8 years ago | (#15493258)

Actually, real operating systems use cat.

Re:The only option (2, Funny)

shenanigans (742403) | more than 8 years ago | (#15493260)

Bah. Real programmers use hexdump.

OpenGrok (4, Informative)

Lucractius (649116) | more than 8 years ago | (#15492237)

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

its incredibly easy to use, and makes things very easy to read. and is now packaged for your enjoyment.
and available at []

Re:OpenGrok (2, Interesting)

Anonymous Coward | more than 8 years ago | (#15492459)

That looks very interesting but the requirement page lists a servlet container, such as Glassfish or Tomcat, just to use it. Is there a way to use it without installing Tomcat or Glassfish or is it primarily a web app? I have no interest in any of the online functionality it offers and requiring a servlet container seems to be overkill for my needs. Running Tomcat or Glassfish in the background simply for this application definitely removes it from being a "lightweight" option.

Re:OpenGrok (1)

Lucractius (649116) | more than 8 years ago | (#15492701)

while the above post was anonymous and probably not seen by many. it asked if there was a way to run this on a more local/lite deployment. i dont know myself, ive already got a tomcat box lying round for testing so it wasnt hard for me. But if you dont have a servlet container available. theres a few non tomcat options [] has a list of quite a few. and from the list [] seems to be the best candidate. (though it quotes no resource figures)

Same difference (0)

Anonymous Coward | more than 8 years ago | (#15492241)

Personally I use vim/vi for both, but then I guess I'm old school :-)

Vim too (1) (583400) | more than 8 years ago | (#15493139)

I'm using Vim [] 7.0 too with a 'tags' file generated with Exuberant Ctags [] .
See :help tags-and-searches

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:Vim too (1)

sgarg (197658) | more than 8 years ago | (#15493812)

Try the Tag List extension for Vim. Great & it rocks!!!

Nothing Can Beat a Good Editor (2, Insightful)

justanyone (308934) | more than 8 years ago | (#15492259)

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. /bin/less or vi or emacs is silly, when I don't want to remember all their key combinations for moving around the file - top, bottom, page up pagedown, etc.

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 (4, Informative)

plover (150551) | more than 8 years ago | (#15492373)

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?

Re:Nothing Can Beat a Good Editor (2, Informative)

b17bmbr (608864) | more than 8 years ago | (#15492544)

or, you could have copied the executable to C:\windows and renamed it notepad.exe. it sucks that windows doesn't use symlinks though. would make it a whole lot easier. but then again, isn't that the point of windows, making what need to do impossible, everything you don't want to do easy.

Re:Nothing Can Beat a Good Editor (1)

willie150 (95414) | more than 8 years ago | (#15492827)

Unless you really try, windows file protection (under XP at least) wont let you do that. Talk about making what you need to do impossible.

Re:Nothing Can Beat a Good Editor (2, Informative) (583400) | more than 8 years ago | (#15493182)

Notepad.exe is both in %WINDIR% and %WINDIR%\System32 and as the other poster pointer, it is a hard task to replace them in XP due to system file protection.

Re:Nothing Can Beat a Good Editor (1, Informative)

Anonymous Coward | more than 8 years ago | (#15493244)

I've not really used XP, but if the guy can edit the registry then I'd wager he can do the above. Am I missing something here?

Re:Nothing Can Beat a Good Editor (1)

cronot (530669) | more than 8 years ago | (#15493898)

Not really. When I need to install metapad, I just make .BAT file that has something like:
copy /y metapad.exe c:\windows\system32\dllcache\notepad.exe
copy /y metapad.exe c:\windows\system32\notepad.exe
copy /y metapad.exe c:\windows\notepad.exe

place that batch file on the same directory as metapad.exe, and run it. That's it. Windows will complain that "system files" were replaced and ask for the install CD to recover, just cancel an go on your merry way. Far easier and quicker than editing a bunch of registry keys.

Re:Nothing Can Beat a Good Editor (1)

shyster (245228) | more than 8 years ago | (#15493271)

or, you could have copied the executable to C:\windows and renamed it notepad.exe. it sucks that windows doesn't use symlinks though. would make it a whole lot easier.

Well, symbolic links are out (unless you want to link to a directory, then you can use junctions [] , but a hard link [] is available and should work.

Re:Nothing Can Beat a Good Editor (1)

corychristison (951993) | more than 8 years ago | (#15492691)

I really like metapad [] when I am stuck with Windows[mostly at school]

I can't stand syntax highlighting. Although, I think that is mostly because it looks terrible and is mostly unreadable when you use a dark background. :-)

Re:Nothing Can Beat a Good Editor (0)

Anonymous Coward | more than 8 years ago | (#15493017)

I've been waiting for a syntax highlighting implementation that would be based on more subtle typographical hints, such as italics, weight, and minor typeface changes. Syntax highlighting shouldn't have to jump on your face, minor cues would be much less distracting and pleasant to use. Anyone know of something along these lines?

Re:Nothing Can Beat a Good Editor (1)

Matilda the Hun (861460) | more than 8 years ago | (#15493054)

I prefer Crimson Editor [] myself, even though the author's gone to ground and the project hasn't been updated in awhile. Syntax highlighting for a bunch of languages, plus customizable color/italic/bold combinations for displaying keywords and whatnot.

Re:Nothing Can Beat a Good Editor (1) (583400) | more than 8 years ago | (#15493206)

The problem is to keep character alignment when using differents fonts/weights. Often different weights with fixed font break display.

If you still want to use it, in vim/gvim you can use bold/underline/undercurl/reverse/inverse/italic/st andout. See :help attr-list

Re:Nothing Can Beat a Good Editor (1)

Council (514577) | more than 8 years ago | (#15493312)

I used Metapad for a couple years, but discovered it had certain problems where it would insert a junk character at the end of files unexpectedly. This was really bad as I was using it to edit code, so I had to switch to WordPad.

Re:Nothing Can Beat a Good Editor (1)

BaronGanut (780013) | more than 8 years ago | (#15493240)

why didn't you just replace the notepad.exe file with the new one? Would save you some work i guess :p

Re:Nothing Can Beat a Good Editor (1)

cerberusss (660701) | more than 8 years ago | (#15493409)

What more could you want?

Command mode.

Re:Nothing Can Beat a Good Editor (1, Flamebait)

cerelib (903469) | more than 8 years ago | (#15492472)

Okay, I almost started laughing when you said " a "heavy editor" vs ... emacs". I view emacs as quite a heavy editor, especially vs something like vi/vim. It has features for mail and news for crying out loud. Hell, I used to use Emacs, but have switched to vim. I switched partly because it was much lighter, even the gui. You really start to see it if you run it remotely using X.

Re:Nothing Can Beat a Good Editor (1, Interesting)

Anonymous Coward | more than 8 years ago | (#15492732)

Vim is not much lighter then Emacs, strictly speaking it actually is an emacs (not by keyboard layout, but by programability). They both are light compared to the IDEs of today.

Re:Nothing Can Beat a Good Editor (1)

Eideewt (603267) | more than 8 years ago | (#15492852)

Doesn't Emacs weigh in at about six times Vim's size?

Re:Nothing Can Beat a Good Editor (1)

JPyObjC Dude (772176) | more than 8 years ago | (#15492497)

I love UltraEdit as well when I have to windoze my way through code.

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.


Krugle (2, Informative)

WeAzElMaN (667859) | more than 8 years ago | (#15492264)

If I'm looking at third-party code (instead of my own), I like to use Krugle [] . It's still in beta and I was lucky enough to get a beta invite, but it's an extremely powerful tool for searching through repositories and documentation.

Well... (-1, Offtopic)

creimer (824291) | more than 8 years ago | (#15492271)

I'll say Notepad to just to avoid a religious war between Emacs and Vi. Or was that Vi and Emacs? Or does Pico come between Emacs and Vi? No wonder I stick with Windows. :P

LXR (2, Informative)

ashridah (72567) | more than 8 years ago | (#15492276)

I've always considered stuff like LXR (linux cross reference) [] to be good for this kind of thing.

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, declaration etc, and cramming them into a db for retreival. It can also handle interfacing with CVS to pull source code directly from a CVS server, which is interesting. Also handles full text searching too, if you get glimpse or whatever.

Of course, the interface to LXR is a web browser, which makes it less than ideal if you consider that it isn't integrated into an IDE, but for the purpose of tracing/searching large amounts of code, it's still pretty useful.


Re:LXR (1)

schngrg (590418) | more than 8 years ago | (#15492564)

I really fell in love with LXR when I used it to dig in Mozilla source code [] . It works really well for large code bases.

I can't say if this is the best because I havent looked at many other options, I just use MS VisualStudio for most of the development and it has nice browsing features.

Re:LXR (1)

nacturation (646836) | more than 8 years ago | (#15492724)

LXR, how unique! Just like the submitter put right there in his question!

codeviz (4, Informative)

meowsqueak (599208) | more than 8 years ago | (#15492292)

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. []

SlickEdit (1)

the_skywise (189793) | more than 8 years ago | (#15492301)

Yeah I know we're not supposed to discuss IDE's. But its class browser (which can handle multiple languages) can greatly simplify trouncing through a code base.

One excellent option... (2, Informative)

dracken (453199) | more than 8 years ago | (#15492308) Redhat Sourcenavigator [] . You can look at class hierarchy, static call graphs, jump to function declarations/definitions/callsites. Try it out.

Re:One excellent option... (1)

antime (739998) | more than 8 years ago | (#15492859)

It's a nice tool, but unfortunately at least the Windows version is rather unstable and it seems that development has stopped completely. (Yeah I know, open source, DIY, blah blah.)

JEdit (2, Interesting)

ChaseTec (447725) | more than 8 years ago | (#15492318)

I needed an easy to use C source code browser because I'm porting an old bbs game to Java. JEdit fit the bill perfectly. Out of the box it's not much more then a text editor with syntax highlighting(130+ languages). It has a feature call HyperSearch that can be used for search through single files or multiple files and have a little box of hyperlinked results. It has lots of plugins to extend it's funtionality but nothing extra to get in the way when you first install it. Check it out at [] . The only thing some people might take issue with is that it requires Java.

Notepad (1)

jarg0n (882275) | more than 8 years ago | (#15492325)


gdb (4, Interesting)

Bastian (66383) | more than 8 years ago | (#15492329)

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.

Re:gdb (1)

vandalman (746235) | more than 8 years ago | (#15493103)

That is a great idea! I'll have to try that, thanks for the tip.

Re:gdb (1)

Hast (24833) | more than 8 years ago | (#15493296)

Do you know of any way of putting traces from a debugger back into the source browser?

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.

SciTe (2, Informative)

stony3k (709718) | more than 8 years ago | (#15492361)

I prefer to use SciTe - it's really lightweight - supports code folding, syntax highlighting and it's open source.

Re:SciTe - no (1)

eyal (774028) | more than 8 years ago | (#15492662)

...and also totally irrelevant to this discussion. The question was about source browsing tools, not about source editing tools. The "find" and "find in files" functions that SciTe provides don't really count as browsing tools.

Source Insight (2, Interesting)

Anonymous Coward | more than 8 years ago | (#15492364) []

Not really a browser, but helpful (2, Informative)

Klowner (145731) | more than 8 years ago | (#15492376)

I've found Doxygen to be pretty handy, it'll output to a bunch of HTML files and even create nifty relationship graphs for OO languages like C++ []

cscope (1)

addaon (41825) | more than 8 years ago | (#15492384)

You mentioned scope... what exactly doesn't it do that you'd like? Other than the time to build to source database (minutes for large projects, amortized heavily if you're only reading), it seems perfect to me.

Re:cscope (1)

ZMerLynn (129227) | more than 8 years ago | (#15492684)

Agreed. I really like cscope, and it works well with emacs (just dig up cscope-mode.el). The time to create the database is large, but the search capabilities it gives are wonderful.

Re:cscope (1)

javax (598925) | more than 8 years ago | (#15492698)

cscope [] ! Mod parent up! :)

Re:cscope (1)

bhima (46039) | more than 8 years ago | (#15492776)

I use cscope from within VIM... I'm pretty sure it's compiled by default in the available binaries... but I'm not sure.

Anyway it works really well and I like VIM for the rest of my devleopment anyway so no extra tools are really needed.

FishEye (2, Interesting)

pajama (48556) | more than 8 years ago | (#15492516)

If you develop in Java you could try FishEye: []

A query language for browsing (2, Interesting)

mmacdona86 (524915) | more than 8 years ago | (#15492522)

To plug a personal project of mine--
Browse-by-Query [] 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.

Notepad++ (1)

hotarugari (525375) | more than 8 years ago | (#15492525)

Notepad++ is opensource, available on most platforms, allows tag/function/logic expansion, has preset color coding for most all popular languages. The find/edit capabilities are comprable to Dreamweaver's allowing regular expressions if your into that thing. It does color labeling to find snippets you ran a find on, of you can do the traditional up and down find. If anything, if has too many features.

It is what you would expect the microsoft people to produce if they were trying to sell notepad/wordpad on the featuresets like they used to in order to engulf the market.

Re:Notepad++ (1)

Southpaw018 (793465) | more than 8 years ago | (#15493644)

Let me second that. I used to use Ultraedit until they triple billed me and wouldn't fix it (I eventually had to do a chargeback). When I went looking for a replacement, I tripped over Notepad++ [] and have never looked back.

Understand for C++ (2, Interesting)

barries (15577) | more than 8 years ago | (#15492551)

We use Understand for C++ [] (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.

- Barrie

Re:Understand for C++ (1)

Merlin42 (148225) | more than 8 years ago | (#15493933)

I use Understand for Fortran quite regularly and I really like it. The GUI has lots of little anoying quirks ... but those anoyances are more than made up for by the real meat of the program which realy does help you understand your code. Plus their support is _very_ responsive, every bug report or feature request I have submitted has been dealt with in 2 weeks or less. Also, they put out a new build every monday.

Emacs (2, Interesting)

sdfad1 (880883) | more than 8 years ago | (#15492558)

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 just have to position the cursor at the right symbol, and press M-. (that's usually Alt-DOT) and it'll take you to the function definition. (vim has a similar thing)

I haven't used it too much, since I'm a Lisper, and the Slime development environment (Emacs addon mode) for Lisp has a similar thing (and it doesn't need to create any tables beforehand) that also provides a "stack-like" functionality. That means you can jump to the function definition, then pop back to where you were. This can be handy for quick detours just to lookup small functions for example.

The advantage here is that you have the all the files locally, so it's faster than browsing through a web interface (html-ized source files, like the Sourceforge CVS frontend - I still use that a lot, and it is SLOW), and you can also edit the source (just a bonus).

Re:Emacs (1)

toybuilder (161045) | more than 8 years ago | (#15492728)

I second the recommendation for etags for Emacs users. It's a good way to dig down through code and then pop back up.

Re:Emacs (and V) (1)

Drubber (60345) | more than 8 years ago | (#15492796)

One great thing about Emacs is that a directory browser is built-in. It doesn't use the native operating system's file/directory browse dialog by default (although it's there in GUI builds). The browser is in the same window as the editor. This means you don't have to use the mouse and click on five things to open a file.

You can navigate from one directory to another just by pressing the up/down keys and enter. For example, pressing enter on the '..' line moves you up one directory. You can then 'close' the directory as if it were a text file and you're back where you started from. This makes traversing directories and files a very quick process, with stack behavior--all from the keyboard.

Of course, it comes with the attendant price of the Emacs learning curve. One mitigating factor is that directory browsing is often covered early in the tutorials and if that's all you're using it for, it shouldn't be too painful.

I learned Emacs because I needed to master an editor on Linux (I came from the Windows world). I can't live without it. Even though I'm back on Windows most of the time these days, I pop out of my "latest and greatest" Visual Studio 2003, 2005, ... be-all-and-end-all IDE dozens of times a day to use Emacs. It's just faster when all I want to do is find a file and search through it or edit it.

On a seprate but related note, I use V 2000 [] . It's faster than any directory/text-oriented file browser than anything I've used (even Emacs). It saves a couple of keystrokes for each file, compared to Emacs, and they add up. I've used it for years and love it.

Re:Emacs (and V) (1)

tetabiate (55848) | more than 8 years ago | (#15492977)

I like Emacs a lot and use it each time I have to code but for most activities like modifying a file or to writing scripts I prefer gvim. Emacs takes ages to start and its UI is not consistent with most desktop environments. Unfortunately, the port to modern widget toolkits like GTK never worked nicely. In marked contrast, the Windows version is really nice but I hardly remember the last time I booted on Windows.

Re:Emacs (1)

ObsessiveMathsFreak (773371) | more than 8 years ago | (#15493104)

Don't forget some of the other features of EMACS too.

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

That said, I would only use emacs when browsing individual files. For an overall project structure, something like doxygen is the way to go. If only Firefox had an Emacs plugin, you could get the best of both!!!

Re:Emacs (1)

martin-boundary (547041) | more than 8 years ago | (#15493276)

Try the Emacs Code Browser ( and Doxymacs (

Re:Emacs (1)

chthon (580889) | more than 8 years ago | (#15493344)

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 (1)

chthon (580889) | more than 8 years ago | (#15493348)

And emacs misses folding.

Once there was an elisp folding package, but last time I searched, it was nowhere to be found.

Re:Emacs (1)

holle2 (85109) | more than 8 years ago | (#15493549)

Usually the folding-mode is available to both, gnu emacs and xemacs. See folding.el for details. Though it does not fold source right away as other folding tools do, it can be told to fold anything you like. The command folding-foldify-region inserts begin and end fold-marks into the current buffer. Those are usually pre-defined for C/C++ etc. and look like this:

// [[[

// ]]]
/* [[[ */

/* ]]] */
Comment style can be tweaked by setting folind-mode-marks-alist accordingly.

The nice part about this is, that you control what the editor folds and what not as well as you can enter some text prefixing the [[[ like this:

// Some block I wanted to fold [[[
When folded in emacs it looks like this:
// Some block I wanted to fold [[[...
thus giving you the opportunity to add your own comments and messages to a block.

Yes, I am missing some sort of magic extension to the folding-mode, like add little +/- signs in the first column to automatically calll folding-foldify-region, but then again:

  1. bind the lisp function mark-paragraph to something you like, unless it is already bound (M-h)
  2. learn the shortcut for folding-foldify-region (C-c @ C-f) as well as the shortcuts for folding-shift-in (C-c @ >) and folding-shift-out (C-c @ <) or you can use the right mouse button to toggle the fold (folding-toggle-show-hide: C-c @ C-q)

The plus here is that you can operate the folds without using the mouse.

Slicing, anyone? (1)

babble123 (863258) | more than 8 years ago | (#15492679)

This is a question, not a recommendation: Does anybody out there using program slicing tools? Or any of the other "program understanding" tools that people doing software engineering research seem to spend a lot of time developing?

How dare you... (1)

tanveer1979 (530624) | more than 8 years ago | (#15492712)

think beyond ed []

Re:How dare you... (2, Funny)

Per Wigren (5315) | more than 8 years ago | (#15492917)

Hey, we weren't supposed to talk about IDEs!

ViewVC is handy... (1)

tcopeland (32225) | more than 8 years ago | (#15492766)

...if your code is in a CVS or Subversion repository. It uses enscript [] for syntax highlighting which works pretty well for a variety of languages (for example, Ruby [] ).

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

useful tools (1)

TehBlahhh (947819) | more than 8 years ago | (#15492799)

find, grep, less, and cat. Seriously, if a combination of that doesnt find what I'm after, and cant display it, there is something wrong.

Understand from Scitools (2, Informative)

Flu (16236) | more than 8 years ago | (#15492806)

I regulary use Understand C/C++ from SCITools [] (is available for Java and other languages) to browse source code (in my case, embedded sources that is supposed to be compiled using the Keil compiler). It's "right-click, for information" attetude makes browsing around a breeze. The reason is that it builds an internal database when loading the project (which takes a second or a few, depending on the size of the sources), and once built, the interface is astonishingly fast!

One of the things I like most, is that it also colours all parts of the code that is #ifdef'ed out. Another thing is that the information windows for any token displays all kind of information: calls, callees, references, uses (including sets/get/modifies), used locals, used globals, exposed globals etc - all of which in a tree view, so it is very easy to decide what's important and what's not.

It is possible to use it as an editor as well, which I do, but as such it isn't perfect.

Also, importing a completely new project requires almost no intervension - it will simply prompt for where any missing #includes are located and add them to the searchpath, so just setting it up for a quick test is done in no-time.

jGRASP - code browser & more... (1)

CaptThunderbolt (980806) | more than 8 years ago | (#15492831)

Try jGRASP ( /grasp/ [] ). Some good points below. 1) IDE front-end to compilers. 2) Generates CSD (source code visualization). 3) Runs on all platforms that use JVM. 4) Supports Java, C/C++, Ada, VHDL & Objective-C. 5) In-built debugger for Java.

ctags! (1)

wkr (72390) | more than 8 years ago | (#15492864)

Is there anything better? Run ctags recursively over your code base, and then use your favorite editor (vim, right?! or emacs, if you must[1]) to follow paths through your program logic, jump to variable definitions, and all kinds of other fun stuff. It keeps a stack, so you can pop back up to a higher frame and recurse down another path, ad nauseum.

It supports 33 languages, and is used on all 7 continents (don't know why that matters, but hey, it's on the home page). []

[1] I had to.

Re:ctags! (0)

Anonymous Coward | more than 8 years ago | (#15492877)

"recurse down"? wtf, man, wtf.

Try PSpad. It's free (1)

fluor2 (242824) | more than 8 years ago | (#15492924)

Try PSpad. It's free.

Browsing (1)

dodobh (65811) | more than 8 years ago | (#15492983)

This depends on what you want to do.

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.

Vim: but you gotta' want it.... but it's worth it. (1)

WgT2 (591074) | more than 8 years ago | (#15493254)

Vim [] and tags.

But, you have got to want to learn it if you are not already required to learn it.

The upside?

  • It's an absolutely efficient text editor (once you learn the basic command set)
  • Variation on some of its basic command set are already used as shortcuts elsewhere
  • It's command super set is very huge (and worth programmers getting to know
  • It's free.
  • It's practically ubiquitous on *Nix machines (Mhy Gentoo's installer doesn't have it is a mystery. For the record: I hate Nano)
  • It has a small footprint
  • It's predicessor, Vi, is tollerable despite not having the same 'expected behavior' for some commands (if it has that command at all)

Tools I have used, GNU Global & NCC (2, Informative)

ZorroXXX (610877) | more than 8 years ago | (#15493257)

Lxr is good for browsing "static" code like the different linux releases. But as a tool for browsing arbitrary source code it is too cumbersome to set up and use.

I have sometimes used GNU Global [] 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 kernel tree? Fine, just run gtags and htags from that directory (and no other setup is necessary).

I have also used NCC [] which "compiles" each file and makes a index file with information like "function AAA calls functions BBB, CCC and DDD, reads variables EEE, writes variables FFF and GGG". The format is not exactly like that but you get the idea. NCC includes a text mode gopher-like variable usage/function call browser and there is a script to make graphical call graphs (via dot from graphviz). At work I have also used information from ncc files in combination with with information from the map file to find maximum stack usage.

This study [] (which I just found while writing this) seems to have an interesting analysis of this topic.

sourcenav? (1)

k8to (9046) | more than 8 years ago | (#15493302)

It doesn't really look maintained, but I really enjoyed Cygnus Source Navigator when I need to read a lot of source bases for a living. You can find it at [] or probably as 'sourcenav' in the distribution of your choice.

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 all that already.

Not browsing, source code finding is the issue (0, Offtopic)

wysiwia (932559) | more than 8 years ago | (#15493304)

I'm amazed, even the title of this story is wrong. For browsing any tool who can display code is sufficient. Sure tools which can syntax highlight or have name reference lookup are better but the real issue is to find the source code first hand.

Whenever I search for a solution I first go to [] but their index seems a little limited. Still just try once looking up "wxSingleInstanceChecker". There are others like but I've forgotten their names. Next I try to think of a most fitting statement for code and feed it to Google (e.g. "class App: public wxApp", but beware of the white space) which at least returns some hints which project might have source code available. Yet the free text search isn't very suited for searching code since it produces too much wrong results.

When I've found a project which might have fitting code I either look into their LXR if it's available or simply download the source tarbal and use a decent editor (e.g. [] ).

It's said that none of the current CVS web tools are searchable, nor that Google is able to restrict results to CVS pages, else it would be much easier to search for source code.

O. Wyss

Browsing C (1)

noz (253073) | more than 8 years ago | (#15493310)

Browsing and, incidentally, development. Use ctags (or compatible) and in vim press ^] over a symbol and vim will launch to the location that symbol is defined. Pop back by pressing ^T. See C++ development using vim and ctags [] for more options. Awesome.

Brilliant source code browser (2)

heretic108 (454817) | more than 8 years ago | (#15493336)

Leo - []

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 (2, Funny)

ceeam (39911) | more than 8 years ago | (#15493338)

Just rewrite it. Reading others' code is for wimps.

Wrong way, use debugegr (1)

cerberusss (660701) | more than 8 years ago | (#15493413)

You're doing this the wrong way. Pouring over code is very useful, but doesn't show you the layering. So, whip up trusty old gdb, set a breakpoint and run the damn code. Then use the step and next commands and just see where this leads you.

I like G (1)

ananamouse (943446) | more than 8 years ago | (#15493501)

I bleed to National instruments so that I can use thier graphical programming language. If anyone knows an alternative pipe up.

For PHP use PHPXref. (1)

zuffy (17881) | more than 8 years ago | (#15493524) [] PHPXref is a great tool which builds an HTML-based outline of your source code. It's been an indespensible tool for working on a very large project, [] Moodle), especially when getting my hands dirty with a new section of code I haven't used yet as it makes following an execution path very easy to do.

From the site description:
        * Minimal requirements, minimal setup.
        * No web server required to view output.
        * Cross-references PHP classes, functions, variables, constants and require/include usage.
        * Extracts phpdoc style documentation from source files.
        * Javascript enhanced output provides:
                    o Mouse-over information for classes and functions in the source view.
                    o Hot-jump to the source of any class/function definition.
                    o Instant lookup of classes, functions, constants and tables by name.
                    o Search/lookup history.
        * Pretty-prints PHP files from the browser.
        * Stays crunchy in milk.

Not *browsing* but *understanding* (3, Interesting)

PurplePhase (240281) | more than 8 years ago | (#15493710)

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?


ConTEXT (1)

jbrannon (881627) | more than 8 years ago | (#15493944)

On Windows, I use ConTEXT ( [] ) extensively. It has built-in syntax highlighting for several languages, and you can download highlighters for hundreds more. Also, it usually takes well under a second for it to startup (uncached).
Plus it's free, which you can't beat (OK, OK, maybe with open source...).
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>