Slashdot Log In
Programmer's Language-Aware Spell Checker?
Posted by
kdawson
on Tue Sep 04, 2007 04:12 AM
from the hands-off-my-camelcase dept.
from the hands-off-my-camelcase dept.
Jerry Asher writes "Not all of my coworkers are careful about spelling errors. Sometimes this causes real embarrassment as spelling errors creep into software interfaces. Does anyone know of spell checkers for programming languages? I don't want a text spell checker, I want a programming-language-aware spell checker. A spell checker that I can pass all of my code through and will flag spelling errors in function names, variable names, and comments, but will ignore language keywords, language constructs and expressions, and various programming styles (camel code, or underscores, or...). I want a spell checker that knows that void *functionSigniture(char *myRoutine) contains one spelling error. Does anyone have such a thing for Java or C++? Are there any Eclipse plugins that do this?"
Related Stories
This discussion has been archived.
No new comments can be posted.
Programmer's Language-Aware Spell Checker?
|
Log In/Create an Account
| Top
| 452 comments
(Spill at 50!) | Index Only
| Search Discussion
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
|
2
(1)
|
2
Eclipse WTP 3.3 Europa seems to do this.. almost. (Score:5, Informative)
Man Dies Waiting for Eclipse to Launch (Score:5, Funny)
A software engineer in San Jose, CA was found dead at his desk yesterday, apparently having died while waiting for his Java editing program, Eclipse, to finish its boot process. Coworkers say the engineer came in that morning vowing to "get Eclipse working on his box or die trying." The last thing anyone heard him say aloud was the cryptic comment: "I see the splash screen is appropriately blue." Nobody knows what he meant. The man was then thought to have fallen asleep, but hours later it was discovered that the engineer had died suddenly of apparent natural causes. The forensics team's investigation that evening was reportedly interrupted unexpectedly when the dead man's Eclipse program suddenly finished launching. The team tried to interact with it to see if they could find clues about the man's death, but the program was unresponsive and the machine ultimately had to be rebooted. At this time, the police commissioner says there is no evidence of foul play, and they currently believe the man simply died of either boredom or frustration.
Re:Man Dies Waiting for Eclipse to Launch (Score:5, Informative)
Re:Man Dies Waiting for Eclipse to Launch (Score:4, Interesting)
Work in a windows environment in Virginia. Access the Eclipse workspace directory through a mounted drive pointing to your home directory on a UNIX box in Montana. On the UNIX machine, your home directory is actually mounted on a Windows box back in Virginia.
God help you if you have the "compile on save" option enabled. And don't even THINK of rebuilding the workspace.
And yes, I know this from experience.
Re:Eclipse WTP 3.3 Europa seems to do this.. almos (Score:5, Funny)
(Last Journal: Sunday June 17, @02:35AM)
ego != good_open_minded_programmer (Score:5, Insightful)
You clearly fail to see a programmer can also create their own function names, as well as use other peoples functions. So you prove you are a very inexperienced programmer, (and close minded), which adds weight to the idea you are either young or just arrogant. Also your very apparent need to show hostility, shows a degree of insecurity, where you are over compensating, by verbally hitting out at others, in an attempt to appear to be more knowledgeable than you really are.
The easiest way to become a better programmer, is to be more open minded. So far you have failed to demonstrate this.
As a side note, (back in the DOS days of programming), I found the the spell checker in Multiedit very useful (especially when having to work very late at night, after the coffee stopped working!
Re:ego != good_open_minded_programmer (Score:5, Funny)
We're the do-anything team that specialises in imaginging new ways for you to reach your audience.
The word "pwned" doesn't spell check correctly either, but it is applicable.
Re:What the fuck is the OP on? (Score:5, Funny)
Re:Eclipse WTP 3.3 Europa seems to do this.. almos (Score:5, Funny)
(http://66.249.93.104/ | Last Journal: Monday November 20 2006, @09:27AM)
"You appear to be creating an infinite loop. Would you like me to increment your counter variable?"
"You appear to be writing a virus, would you like a list of the latest Windows Vista sploits?"
Visual Assist (Score:3, Informative)
Next silly question, please.
Re:Visual Assist (Score:5, Funny)
(http://linux-studie.nl/ | Last Journal: Wednesday April 21 2004, @01:22PM)
Re:Visual Assist (Score:4, Funny)
(http://66.249.93.104/ | Last Journal: Monday November 20 2006, @09:27AM)
How about eyeball Mk 1? (Score:5, Funny)
Re:How about eyeball Mk 1? (Score:5, Insightful)
Re:How about eyeball Mk 1? (Score:5, Funny)
(http://andyc.ac/)
Re:How about eyeball Mk 1? (Score:5, Insightful)
(http://www.veryshortpier.com/)
Re:May I suggest.... (Score:5, Insightful)
Responses like this entirely miss the point of the question. Same with the "just review your code" responses. It's not a matter of making the language more readable. It's a matter of making the code more usable. Certainly, correct spelling is pointless without other elements of good code practice. However, bad spelling can add a lot of frustration.
I joined a project which already had a few misspelled class names. I'm a fast typer and often I've typed out more of a filename than is spelled correctly before hitting tab to complete the name. Needless to say, I've been trained to hit tab earlier for a few choice files. But it's certainly been an irritation. Similarly, I've been confounded more than once when a function or variable couldn't be found by the compiler, only to realize that I'd spelled a word correctly rather than how the actual name was spelled.
We choose to use English words for our class, function, and variable names for a reason. That reason is mostly defeated by misspelling the English word. A dictionary is a great idea, even for coding languages that don't "read like English".
Re:May I suggest.... (Score:4, Insightful)
Re:May I suggest.... (Score:4, Insightful)
It strikes me that the problem is that most spell checkers try to check everything, and that a lot of code has things that really shouldn't be spell checked at all, mixed with things that should. I imagine that one way to start would be to only alert on those errors that are almost correct -- if it looks like garbage, ignore it, but if it's close, assume it should be right. Perhaps ignore prefixes / suffixes as well -- pSomething is fine, pSometihng isn't. Also, CamelCase ought to be easy enough to detect -- treat it as word boundaries, and spell check the individual words. Again, egregious misspellings probably aren't -- nextObjFoo is ok, even though Obj isn't a word -- it's so far from being a word that we assume the programmer meant it that way.
Similarly, there should probably be a set of words added that aren't "English" but are used often enough to be worth adding to the dictionary. Things like Obj, Int, and Ptr.
I think the reason such spell checkers don't exist already is fairly simple -- everyone just assumes they're impossible, and doesn't try. Couple that with the fact that a mediocre quality one would be so annoying as to be worse than useless, and you have a recipe for a program that won't get written. I don't think either of those would have to be the case if someone sufficiently clever decided to attack the problem, though.
Sounds like a good idea (Score:5, Interesting)
(http://www.int64.org/)
vim 7.0 anyone? (Score:3, Insightful)
(Last Journal: Tuesday May 10 2005, @03:47PM)
It's a good question ... (Score:5, Interesting)
(http://www.echtehelden.org/)
People here making fun of his request and saying that this should be set in stone in design documents, or be checked in peer code reviews are obviously not working in a run-of-the-mill software company where there's neither the inclination nor the time to do everything the formal way. Also, I have to see the first design document that correctly enumerates all the requirements for the software, let alone all the names for the variables to be used.
Re:It's a good question ... (Score:5, Informative)
(http://slashdot.org/~Corporate%20Troll | Last Journal: Friday July 06, @03:55AM)
As a non-native English speaker, working in a non-native english speaking team (mainly french speaking people) it is a real problem. The biggest problem happens when you search something and don't find it because you wrote it right and your coworker wrote it wrong. (Or the inverse, I don't claim to be perfect in English)
Sure, you might say, "Write your code in French", but that's not a solution. My mother tongue is Dutch, we have a German coworker, and you never know if the next guy will be Italian. There is also this team that has to maintain code written by Spanish people.... in Spanish.... and they don't know Spanish. Fun times, if you like to hear them curse....
In multilingual environments this problem increases drastically.
TextMate does some... (Score:3, Interesting)
(http://runawaynet.com/)
You can right-click on any "word" (variable name, subroutine name, whatever, just generally a whitespace-delimited group of characters) and it will check the spelling and present alternatives in the context menu. It also recognizes things like perl's sigils so correcting '$teh' turns into '$the', not 'the'.
It _won't_ automatically check spelling except in strings (so e.g. if I have '$teh = "This is a tset.";', 'tset' will be underlined, '$teh' won't). It doesn't include comments in its automatic checking either, which is probably the most annoying part about it.
Overall I typically just don't bother with it, but someone _has_ thought along these lines, at least.
Re:Syntax Highlighting (Score:4, Insightful)
aspell? (Score:4, Insightful)
Re:the problem is really prevalent (Score:5, Funny)
(http://uncyclopedia.org/wiki/Slashdot | Last Journal: Friday April 20 2007, @10:50AM)
How about this (Score:5, Interesting)
(http://membled.com/)
Enough rant. How about this:
perl -ne "s/([a-z])([A-Z])/$1 $2/g; tr/A-Za-z/
That will give a list of unique words in your source code (use find and xargs to scan the whole source tree). Then you can run that list of words through an ordinary spellchecker such as ispell. Unfortunately when you find a mistake you have to go back and grep for it to find where it occurs. You would also need a personal dictionary for things that are not English words but nonetheless appear in code.
I would probably keep the private word list containing things like 'foreach' and 'const' with the program source code, and have a makefile target 'make spellcheck' that runs a command like the above and then prints out all words found that are not in
find . -type f -name '*.c' | xargs perl -ne "s/([a-z])([A-Z])/$1 $2/g; tr/A-Za-z/
sort -u private_word_list
diff -u allowed_words found_words | grep -E '^[+][^+]'
The private word list can be kept under version control and checked in whenever you add a new non-English word like 'Frobule' to your source code.
Adding filenames and line numbers to the output is left as an exercise for the reader. You might also want to change the perl command to ignore words with length < 5.
FxCop (Score:5, Informative)
http://www.gotdotnet.com/Team/FxCop/ [gotdotnet.com]
Visual Assist (Score:3, Interesting)
(http://myspace.com/SandSuk)
I'm not associated with Whole Tomato, but if anyone from WT sees this, can I have a free subscription
Annoying perhaps but (Score:5, Interesting)
HRESULT MFGetService(
IUnknown* punkObject,
REFGUID guidService,
REFIID riid,
LPVOID* ppvObject
);
You'll probably just end up spending all your day removing false positives.
Ken Thompson and creat() (Score:5, Interesting)
"If I had to do it over again? Hmm... I guess I'd spell 'creat' with an 'e'."
Emacs - ispell-check-comments (Score:3, Informative)
I'm sorry... (Score:3, Interesting)
(http://www.gamerslastwill.com/)
I don't think I'd like to hire someone who can't spell. It shows volumes about you.
Intelligence starts with a keen understanding and application of your language.
if you simply must have it, editplus has syntax highlighting and offers spellchecking dictionaries.
English (or $YOUR_LANGUAGE_HERE) (Score:3, Insightful)
(http://www.io.com/~snewton/)
At least in the real writing business there are editors trained and paid to catch these errors.
Being unable to spell correctly makes you look really stupid to most people.
Just FYI, if you have a decent programming environment, it should at least flag cases where you've mistyped an existing identifier. If there's an ImmediateFlag in your code, you'd get a warning if you typed ImediateFlag or ImmediateFalg or whatever. Not much help when the programmer is creating new identifiers, of course. Although I've seen cases where the programmer in question for whatever reason decided that because ImediateFlag was undefined then they would just define it, even though ImmediateFlag existed and was what they meant. That ought to get you fired in my book.
Hey by the way, pair programming is a great way to have continuous code reviews and a check on some of the more typical fumble-finger errors.
Re:How about the Built-in OS X spell checker? (Score:5, Funny)
We're talking about programming, friend.
Re:simple (Score:5, Insightful)
(Last Journal: Wednesday October 19 2005, @06:04AM)