What is a Good Open Source Code Analysis Tool? 53
carlmenezes asks: "I volunteer when I can to help a poor educational institution in India with their computing needs. As you can imagine, most computers are from donations and very little money (if any) can be spent on software licensing. Therefore, the installed software is all Open Source and I do all of the software installation by myself. I have already installed Linux on 16 PCs, with Firefox. The default desktop is KDE and the kdeedu package (klettres in particular) has several loyal fans. Incidentally, the kids don't find it hard to use at all and the lack of 3D doesn't bother them in the least :) I would like to ask the community about a good source code analysis tool. I have already installed Source Navigator. Is there any other comparable open source tool?"
"The analysis tools would be for those students that show more interest than the others in programming. There is a lot of source code in there for them to look at it if they want to. I'm looking more at C/C++ than anything else. There are some very bright students and I would like them to be able to move beyond ordinary school programming if they feel like it. No, there is no Internet connection. I bring in the software on CDs and install it."
Use Java instead (Score:4, Informative)
If you're teaching beginners how to program, Java is simpler anyway. You don't have to understand memory allocation and pointers because it's all taken care of for you. Also you can write non-object-oriented programs to start with by making all functions static.
This way you can start with very simple programs and work your way up to introducing more advanced concepts, like object-oriented, or memory allocation etc.
If you insist on learning with C/C++, I would lobby with the executives at a company like Borland. They usually have the power to throw a few copies your way, as long as they're convinced that it is a philanthropic effort (it makes them look good).
Re:Use Java instead (Score:3, Informative)
Re:Use Java instead (Score:2, Informative)
Burn Heretic!! (Score:3, Interesting)
In short, I disagree that Java is easier to teach to beginners. Not only must they immendiatly grasp object orientation and functions, they must also work with Java's quite restrictive language constructs. I do agree that C++ is not a very
Oh dear (Score:2)
I agree Java is a bad language to teach beginners, tho.
Re:Burn Heretic!! (Score:2)
And you want to give them perl? What's wrong with scheme?
Day 1: "Hello, World" in perl
Day 2: Regular expressions
Day 3: Where did everyone go?
Re:Burn Heretic!! (Score:2)
You don't want to scare the students...or the teacher.
Re:Burn Heretic!! (Score:1)
They can start as slow as they want, learn the concepts of programming, and when they want to enter in the "market", can always learn the language de jour, be it C++, Java or C#.
And squeak seem to run quite fast for what it does, and when they botch the runtime the restore is only an cp /whatever/image ~user/image
Regards
Re:Burn Heretic!! (Score:2)
C++ !!!!!!!
You don't have to use templates or even objects in every C++ program.
Just writing this: is C++. You have FREEDOM in C++ to use the paradigm you wish. If you don't want to use objects you don't have to go back to C.
Re:Use Java instead (Score:2, Insightful)
Re:Use Java instead (Score:1)
Unfortunately Java hides how computers actually work. I would first start out with a BASIC interpreter to teach basic algorithms and structured programming. I would then move to C to teach about pointers. Then move into Java or C++.
The proble
Re:Use Java instead (Score:2)
1: use javascript and a web browser if you want an interpreter, it's quite easy to setup and it's a skill you can take home and play with.
2: You can teach pointers in java, or at least memory addressing using lookups into arrays, which is close to protected mode than the flat memory model you get with C.
3: no way, I wrote java on a 486 years ago, ok I didn't write eclipse, but goto ebay, $50 in hand and get a pc that can run java.
4: I know how a computer works, I could buld one
eyeballs (Score:1)
seriously, pick an application everyone like, bring in the source, and have the students give it a new feature or fix a bug. Any text editor should be sufficient.
Re:eyeballs (Score:2)
Re:eyeballs (Score:2)
For confirmation of this there was a discussion on the security of FOSS projects by a FOSS author. The security bug lasted years in Mailman because no one saw it.
Automated checking of code is not the be all and end all of code however it is better than a poor set of eyeballs anyday.
What are the requirements? (Score:2, Insightful)
But what about popular C/C++ IDE's as KDevelop and Anjuta? Are those not the sort of tools you're looking for?
Mod Parent Up (Score:2)
Source-Navigator's "analysis" seems to be to "display relationships between classes and functions and members, and display call trees." Most IDEs will have this functionality, including KDevelop and Anjuta. I'm partial to Anjuta myself, but they are already using KDE. KDevelop would be the natural choice.
Re:Mod Parent Up (Score:2)
Source Navigator is fine (Score:3, Informative)
So, I think that its a fine tool for teaching. Most other "IDE"s tie you in to a particular system or language, which snavigator doesn't. I've used it for the Linux kernel, Solaris, and Windows (among other things).
Its a bit slow building its cross-reference database, though, so for larger source bases you do want access to a "big" machine. You can share the results after the xref is built (the same is possible with cscope).
Good luck with your project!
Ratboy.
Cscope, Lint (Score:5, Informative)
From the Split (a modern version of Lint) web site [splint.org]:
Re:Cscope, Lint (Score:3, Interesting)
Splint is already installed. What I would like to do is to show the tool to those that are interested, give them a short lesson on it and then leave them to their own devices and let their curiosity make them learn.
Code analysis? (Score:2)
P.
The best tool is the human body (Score:5, Insightful)
1) Learn how to program.
-- nuf said.
2) Write clean code
-- Proper indenting **
-- sufficient commenting
3) Less code is more
-- More lines is more intimidating that less
-- However, there is a limits (ie Perl)
-- More you can fit on one screen the easier to debug
4) Be a structured programmer
-- It should not matter what language you are programming in. The structures should always be the same.
5) Learn and use language level error handling
-- This will enable you to fully understand how to debug your code
-- Stack traces are a must for any procedural or OO code
6) Make your programs chatty
-- Log files are good but make sure there is a way to easily turn off logging features so that you can speed up programs when you are happy.
7) Learn how to tail log files
-- tail is available on every operating system
--- GNUUtils for win32
--- *nix (Linux, Unix, OSX
8) Write blind code as much as possible
-- IDE's are very powerful but I always write all my code in a text editor totally blind (no compilation, syntax validation...)
-- If you become dependant on the system to tell you what is wrong, you will not learn to SEE the problem.
--- Often times, when I get an error and I know I just changed a piece of code I will not even read the error. I'll just look at the line of code that I changed and visually look for the error. If you don't learn how to do this, then programming probably is not for you.
9) Got errors, don't worry
-- All coders get errors.
-- Only a few times I have written dozens of lines of blind code and not gotten at least one error. I was amazed when I did.
-- Don't get stressed out. Just be pragmatic and move being objective with the error.
That's probably a good start.
Personally I would not trust programs in telling me where coding problems are anyhow. I find it akin to using anti-spyware programs on a win32 box where it would be easier to just not use IE and be more concious of the operating system we use. The latter takes a little more understanding but in the end all will be better
JsD
(Java+Python+ObjC-on-BSD-with-firefox==hap
Re:The best tool is the human body (Score:5, Insightful)
8) Write blind code as much as possible
-- IDE's are very powerful but I always write all my code in a text editor totally blind (no compilation, syntax validation...)
-- If you become dependant on the system to tell you what is wrong, you will not learn to SEE the problem.
--- Often times, when I get an error and I know I just changed a piece of code I will not even read the error. I'll just look at
Thats probably a good way for learning programming (I learned like that, because today tools where magic at my time), but I doubt its a good way to work.
With a good IDE you are ten times faster than with notepad like simple editors. Even VI or VIM with a good ctags/jtags support and codecompletition is already nice.
For C++/Java etc. use Eclipse.
For Java use Eclipse/IDEA IntelliJ or CodeGuide (in reverse order).
Probably you should determine the language you want to teach first. If you use Python, you should look for a decent Python IDE.
angel'o'sphere
Re:The best tool is the human body (Score:2)
Re:The best tool is the human body (Score:1)
3) don't you mean make you code modular? I've seen some people who take the whole small thing to extreams and you end up chasing you tail trying to debug the stuff.
4) prolog, xsl, c++, lisp. go on then.
8) I have more errors writing blind code than using an IDE, modern ide's do.
Refactoring, real-time highlighting of errors, code compleation, code graphing, wysiwyg designers for gui's, graphical component designers (EJB and
valgrind (Score:5, Informative)
Nobody should be caught dead writing C++ programming without at least knowing about Boost's [boost.org] libraries. Not really analysis tools but useful nevertheless.
linux cross reference (Score:4, Informative)
PMD (Score:1)
http://sourceforge.net/projects/pmd/
cpd (Score:2)
Re:PMD (Score:2)
In a similar vein, Checkstyle [sourceforge.net] is also very good. I especially like the checks for variables that mask those in a higher scope, unused variables and unused imports. I'll deinitely be checking out PMD as well, as the rest of my team are novice Java programmers and I don't have the time to audit all their code. These kind of analysis tools are great, because they allow me to pinpoint likely areas of particularily bad code.
Re:PMD (Score:2)
Ahem.
Anyhow, if you're looking for Java bytecode analysis, FindBugs [sourceforge.net] is excellent. Nice folks, too, and the mailing list is pretty active.
myer (Score:2, Interesting)
http://home.comcast.net/~jyavner/myer/
LXR (Score:1)
gcc -Wall (Score:3, Informative)
You might want to read Steve McConnell on writing solid code to see a full explanation as to why.
Re:gcc -Wall (Score:3, Interesting)
Anyway, slightly OT, but I haven't been that impressed with kdeedu. It feels very much like an open source project to me (in the negative sense), or at least what comes with Suse 9.1 does anyway. I like gcompr
AutoDia (Score:2)
It's written as a set of Perl scripts so you'll need a perl installation on the machine.
jGRASP (Score:1)
Doxygen (Score:2, Insightful)
C source code analyzers (Score:1)