Beta

Slashdot: News for Nerds

×

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!

Programmer's Language-Aware Spell Checker?

kdawson posted more than 6 years ago | from the hands-off-my-camelcase dept.

Programming 452

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?"

cancel ×

452 comments

Eclipse WTP 3.3 Europa seems to do this.. almost. (5, Informative)

pringlis (867347) | more than 6 years ago | (#20461575)

The version of Eclipse I run, Eclipse WTP 3.3, does spell checking on comments as standard. Not for variable, function names and the like though. It's a decent first attempt though. In truth, I turned it off within the first few hours. It underlines any mistakes in red which I find really annoying when scanning code as I keep thinking I've seen syntax errors. More often than not my eyes are drawn to a spelling mistake, which in many cases isn't even really a mistake, which distracts me from what I'm actually trying to look at.

Re:Eclipse WTP 3.3 Europa seems to do this.. almos (0, Troll)

monk.e.boy (1077985) | more than 6 years ago | (#20461605)

WTF is this guy on? So now 90% of my code will have red squigglies under the variable names?

i=0;

So now the 'i' has a red underline?

That is the most nuts thing I ever heard. The spell checker would need to be sentient to figure out the rules.

Hey, I got a good idea - LEARN TO SPELL.

monk.e.boy

(all spelling mistakes in this post were intentional ;-P )

Re:Eclipse WTP 3.3 Europa seems to do this.. almos (2, Informative)

iapetus (24050) | more than 6 years ago | (#20461761)

For the record, 'I' is a word. Also plenty of spellcheckers will ignore one or two letter words.

The idea isn't anywhere near as nuts as you think it is, provided you make a habit of using meaningful variable/class names.

Re:Eclipse WTP 3.3 Europa seems to do this.. almos (5, Funny)

Bastard of Subhumani (827601) | more than 6 years ago | (#20461869)

Also plenty of spellcheckers will ignore one or two letter words.
So if you use fortran, you're screwed? No change there, then ...

Re:Eclipse WTP 3.3 Europa seems to do this.. almos (2, Informative)

thetartanavenger (1052920) | more than 6 years ago | (#20461873)

More like WTF are you on man?? If a compiler is able to work out what a variable is, what piece of code does what, which bit's of text are going to be displayed, then another spell checking program can be written to recognise this too!! It would be tricky, and there are many circumstances where it could be circumvented but why not still use it to prevent a possible spelling error, and the circumstances where it cannot tell what the word is, so what. Those circumstances you learn to spell but there's nothing wrong with another program to help prevent it!

This is a good idea, and one that can be implemented. Just because it's hard to do it right, and would need to be done seperately for different languages doesn't change the fact it would still be useful and help prevent errors.

Re:Eclipse WTP 3.3 Europa seems to do this.. almos (2, Interesting)

KiloByte (825081) | more than 6 years ago | (#20462055)

In fact, there are only two kinds of things to look at:
  • string literals (not what the poster wanted, but this is what needs spelchekars the most)
  • identifiers
The former can be done by a simple regexp, the latter... you can do a LALR parser, but why even bother? Just look for _any_ potential identifier; in most languages, that's [a-zA-Z_][a-zA-Z_0-9]+; and simply add the few keywords which are not English words to your dictionary. In fact, this would be nearly programming language agnostic.

When it comes to StudlyCaps, anything identified as an identifier can be split _before_ any uppercase letter. This would produce a lot of single-letter tokens for ALL-CAPS #defines and the like, but as a nearby post said, you're going to ignore one-two letter tokens anyway. The usual conventions say XMLHttpRequest or XML_http_request so I wouldn't bother with XMLhttpRequest (and thus "lhttp").

How about the Built-in OS X spell checker? (0)

Anonymous Coward | more than 6 years ago | (#20461579)

You can add common function names, types, etc to the custom dictionary -- but all variables, etc in English will be checked as-you-type. Works in any OS X application (simplest example: TextEdit)

Re:How about the Built-in OS X spell checker? (5, Funny)

BadAnalogyGuy (945258) | more than 6 years ago | (#20461635)

How about the Built-in OS X spell checker?

We're talking about programming, friend.

Visual Assist (3, Informative)

Anonymous Coward | more than 6 years ago | (#20461583)

Visual Assist for Visual Studio does this.

Next silly question, please.

Re:Visual Assist (1, Informative)

Anonymous Coward | more than 6 years ago | (#20461837)

No, it doesn't. See listed spelling features. [wholetomato.com] It will spell check normal language (looks like only comments) and highlight *mistyped* symbols, not mispelled symbols.

Next wrong answer, please.

Re:Visual Assist (4, Funny)

nietsch (112711) | more than 6 years ago | (#20461947)

Please don't use the names of the tools the beast of Redmond uses to stupify the world. This is /. after all, if you have to code on/for windos, then please be humble and shy about it.

How about eyeball Mk 1? (5, Funny)

uucp2 (731567) | more than 6 years ago | (#20461589)

Some people call using it a "code review". If you are really serious about it, post the code to /. - plenty of people here seem to have time to point out any spelling errors.

Re:How about eyeball Mk 1? (5, Insightful)

Anonymous Coward | more than 6 years ago | (#20461639)

Um, let me introduce you to the famous spelling mistake: HTTP Referer [wikipedia.org] . How about we let computers and people each do what they're good at. Computers are good at comparing strings in a spell checker, and people are good at producing typos, spelling mistakes, and approving fixes. Discipline isn't the solution, better tools are. (I bet there's a spelling mistake in here -- which proves my point that Opera needs a spell check like Firefox!)

Re:How about eyeball Mk 1? (0)

Anonymous Coward | more than 6 years ago | (#20461679)

Some people call using it a "code review". If you are really serious about it, post the code to /. - plenty of people here seem to have time to point out any spelling errors.
We tried to solve this problem by hiring a /. spelling nazi but he quit because he didn't couldn't handle having a lower social rank than the drones in the marketing department.

Re:How about eyeball Mk 1? (1)

jellomizer (103300) | more than 6 years ago | (#20462033)

I would think they are use to it by now.

Re:How about eyeball Mk 1? (5, Insightful)

iapetus (24050) | more than 6 years ago | (#20461937)

You're aware of the concept that a bug is cheaper to fix the earlier you spot it? If it's flagged up as soon as it happens I have to rename that one variable in one place, and I can do it at virtually no cost. If it's flagged up after I've finished the work and committed it for review, then I'll need to change it across multiple files (sure, an IDE will do refactorings like that in most cases, but there can be side effects) and recommit. That's a far greater expense.

Re:How about eyeball Mk 1? (0)

Anonymous Coward | more than 6 years ago | (#20462025)

Sadly, Eyeball 1.0 is incompatible with Stupidity 1.0, unless you install the education hotfix. And you all know how diligent most people are with applying patches...

Quick! (0)

Anonymous Coward | more than 6 years ago | (#20461595)

Patent this idea!

simple (0, Troll)

Bizzeh (851225) | more than 6 years ago | (#20461599)

the easy thing to do, is to just spell things correctly in the first place.

Re:simple (-1, Flamebait)

Anonymous Coward | more than 6 years ago | (#20461621)

Your comment is stupid and worthless, and you are stupid and worthless too. Your life will never amount to anything. If I was you, I'd kill myself.

Re:simple (0)

Anonymous Coward | more than 6 years ago | (#20461775)

[...] If I was you, I'd kill myself.
Please, don't let that stop you.

Re:simple (0)

Anonymous Coward | more than 6 years ago | (#20461865)

If I was you, I'd kill myself.

If I couldn't use the subjunctive properly, I'd kill myself.

It's were, not was, you ignoramus!

Re:simple (0)

Anonymous Coward | more than 6 years ago | (#20461799)

Better yet have your users to do what the code does in there head. Even simpler for you.

Re:simple (4, Insightful)

YttriumOxide (837412) | more than 6 years ago | (#20461823)

It's not so simple when you're not the one writing the code, but have to deal with the results. There's an SDK that I use as a part of my job, developed by our head office in Japan - it's a set of C# classes, and nothing annoys me more than typing "Connection foo = new Connection();", then noticing Visual Studio isn't highlighting it as I'd expect. Hunting around for anywhere up to a minute and eventually finding out it is actually "Conectin" instead of "Connection". If there were a good "programmers spellchecker", I may not need to use it myself, but I could give it to my Japanese colleagues to make MY life easier! (note: the above example is fictitious, but is an illustration of the type of error that I deal with that this would prevent)

Re:simple (1)

MagikGimp (1057268) | more than 6 years ago | (#20461885)

By saying this am I right in also assuming that you never make mistakes with your coding either? Or are you trying to say that mastery of the English language is a much simpler skill than that of programming? Either way, I'm still a bad speller but I know I'd much prefer to brush up on good coding practice than start training for the next spelling bee... but that's just me.

May I suggest.... (2, Funny)

mark-t (151149) | more than 6 years ago | (#20461617)

.... that if you want your code to read like english, you consider a language like COBOL? Not that it would help you with spell checking, per se... but if one is going to be so pedantic about making sure that their procedure names can be found in an actual english dictionary why not go the whole 9 yards and write the whole program that way?

Re:May I suggest.... (5, Insightful)

DarkSkiesAhead (562955) | more than 6 years ago | (#20461719)

if you want your code to read like english, you consider a language like COBOL? Not that it would help you with spell checking, per se...

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.... (3, Insightful)

Splab (574204) | more than 6 years ago | (#20461759)

Also people tend to miss that our brains are very good at correcting spelling mistakes as we read, doing code review trying to catch spelling mistakes can be very tough.

Re:May I suggest.... (1)

Bastard of Subhumani (827601) | more than 6 years ago | (#20461895)

our brains are very good at correcting spelling mistakes as we read
But they're not so strong at spotting jokes, it seems.

Re:May I suggest.... (1)

jellomizer (103300) | more than 6 years ago | (#20462061)

Quite Ture^h^h^h^h^h True. Most of the time when I cam coding and I need to copy a variable name or a quite I just copy and paste it. Making all the spelling misstates consistent throughout the code.

eror: 312 varible naim mispelled

Re:May I suggest.... (1)

MythMoth (73648) | more than 6 years ago | (#20461783)

Hear hear.

Incorrect spelling in code causes all sorts of minor confusion - I'd love an Eclipse plugin to address this.

Re:May I suggest.... (3, Insightful)

evanbd (210358) | more than 6 years ago | (#20461935)

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.

Quit employing idiots? (-1, Flamebait)

NekoXP (67564) | more than 6 years ago | (#20461623)

Review your code, review their core, spell check everything by hand, from the design document down.

Actually, if you wrote a design document and a functional prototype of your software in the first place, a great deal of the user-visible API will be set in stone anyway. Including naming. You can use any word processor spell check in that case.

Re:Quit employing idiots? (1)

Double Entendre (1123719) | more than 6 years ago | (#20461703)

Why idiots? A great developer may not necessarily have a commanding grasp of English, especially if it's a second language for them. That doesn't make them stupid.

Other than that, I agree with everything else you wrote. Planning things out through proper software development techniques should isolate those issues in advance.

Re:Quit employing idiots? (1)

Nazlfrag (1035012) | more than 6 years ago | (#20461981)

I expect my artists to have spelling mistakes. I expect my coders to know the semantics of a language that they are using. If they don't I question their ability on the semantics of the language the project is coded in.

Re:Quit employing idiots? (1)

SLi (132609) | more than 6 years ago | (#20461983)

The funny thing is, in my experience the most spelling errors (compared to e.g. poor grammar in comments) in code are made by those coders who speak English as their native language.

Re:Quit employing idiots? (-1, Flamebait)

Anonymous Coward | more than 6 years ago | (#20462049)

The biggest fuckin misspelling fuckin idiots I've come the fuck across in my fuckin travels are dumb fuckin ass native English speakers.

Learn your own fuckin language ya dumb fuckin cunts.

(I'm not a native speaker).

Re:Quit employing idiots? (1, Funny)

Anonymous Coward | more than 6 years ago | (#20461933)

Review your code, review their core, spell check everything by hand

I think you meant, "review their code"...

(Although clearly no automated spell checker would have caught that.)

Sounds like a good idea (4, Interesting)

PhrostyMcByte (589271) | more than 6 years ago | (#20461629)

And not too hard to implement - all you need is a lexer and a few functions to classify different naming styles. lexertl [benhanson.net] even comes ready with a full example for C++, so get to it ;)

Re:Sounds like a good idea (1)

Xiph (723935) | more than 6 years ago | (#20461677)

This could possibly make it a lot easier to change between different naming conventions.
possibly even do cross convention linking.

I now have a new uni-project i care about :) Though it would be a shame to end a perfectly good flamewar...

maybe i should implement it in emacs.

Re:Sounds like a good idea (1)

Gordonjcp (186804) | more than 6 years ago | (#20461875)

Isn't that basically what syntax highlighting does anyway? A simple heuristic for a programming spellchecker would be "Did I highlight it? No? Well I'll spellcheck it, then" with a suitable syntax dictionary and language dictionary. Initially certain words wouldn't show up in the language dictionary, but you'd add "setDictPath" when you define it. A quick bit of code review to make sure that no mis-spelt words get into the dictionary, and you're done.

Good Idea (0)

Anonymous Coward | more than 6 years ago | (#20461637)

But not, I think, significant enough to warrant a separate program or IDE plugin.
It would certainly be a "pleasant surprise" addition in a new Visual Studio / Eclipse release, but I wouldn't hold my breath.

Keep text in dedicated files (1, Insightful)

oliderid (710055) | more than 6 years ago | (#20461645)

Anything that may appear in a user Interface should be kept in dedicated files. Use a standard format such as CSV, XML...It may be reviewed by non-technical people with built-in spell checker software such as excel. This is a trick mainly use for multilanguages project, but it really helps.

Re:Keep text in dedicated files (1)

Kjella (173770) | more than 6 years ago | (#20461695)

...which is an interesting problem, but really a different one. If you look at his example, he's talking about botched function names etc. which really is code. User-visible text is usually spellcheckable in whatever format is being used to do translations. And if you hardcode English everywhere, then well... you're probably not interested in this kind of quality-enhancing tools to begin with.

That said, I rarely see this as a big problem unless it's a very static internal interface. Pull the whole code tree, change function call and whatever's calling it, post a diff for "spelling correction". It's a function name, it's not even remotely important to the functioning of the code.

Re:Keep text in dedicated files (2, Informative)

Roofus (15591) | more than 6 years ago | (#20461747)

If you maintain a library that is used by customers, that would be a *very* big issue. You just broke backwards compatibility for a spelling fix.

Overall, the answers to the submitters question are absolutely horrible so far. If the tool he's searching for doesn't exist, it damn well should.

Re:Keep text in dedicated files (1, Redundant)

pasamio (737659) | more than 6 years ago | (#20461957)

The solution to this is simple, you use the Microsoft approach which is to keep old names of the functions around and wrapper them to the new names in the hope that people will start using the new name instead of using the old name. That said it shouldn't have been a problem anyway. I have translators who email me reminding me my English has mistakes from time to time (last one was writeable/writable, writable is supposed to be the right one but both come up as spelling errors in Safari anyway) so having a spellcheck intelligent enough to catch some things would be useful.

vim 7.0 anyone? (2, Insightful)

Janek Kozicki (722688) | more than 6 years ago | (#20461647)

I particularly like the spelling feature in new vim, right-click menu (:set mousemodel=popup) to select a corrected word or remember current word as correct. Perhaps writing a vim plugin as you explain could be possible? I'd be very glad to use it too ;)

Editors with a spell checker (1, Informative)

Peter_JS_Blue (801871) | more than 6 years ago | (#20461649)

On most Linux or BSD distros there is an editor called Kate. This has a spell checker built-in.

This isn't quite what you want because you have to select the text to be checked but its better than nothing !

Hope this helps

vim 7 does this (1)

sashang (608223) | more than 6 years ago | (#20461651)

Vim 7 does this for c/c++ code. Just turn on spelling (something like :set spell) and it picks out spelling mistakes in comments and strings.

Re:vim 7 does this (1)

Arimus (198136) | more than 6 years ago | (#20461723)

I think the OP wants more than the text displayed as output to be spell checked, things like badly spelt function names - e.g. verifySigniture( * ) should be flagged...

Re:vim 7 does this (1)

jj421 (642627) | more than 6 years ago | (#20462019)

Vim's on-the-fly spell checking is particularly well suited to programming. When syntax highlighting is enabled, it will only check the spelling of comments and strings. Try ':help spell' for more information.

should be fairly simple to implement (2, Interesting)

BoxedFlame (231097) | more than 6 years ago | (#20461665)

A small script to split up camelCase into seperate words, then feed the result through a normal spell checker. Then after that just whitelist certain words like maybe "m" as found in "mSomeVariable".

Re:should be fairly simple to implement (0)

Anonymous Coward | more than 6 years ago | (#20461779)

A small script to split up camelCase into seperate words

...or even split them into separate words.

(some mornings, I can be such a dick.)

It's a good question ... (4, Interesting)

YeeHaW_Jelte (451855) | more than 6 years ago | (#20461667)

We've got code here that refers to 'insurrances', 'insurances', 'insurrences' and 'insurences', I'm not kidding.

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

Corporate Troll (537873) | more than 6 years ago | (#20461755)

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.

Instead of putting the text in a program code (0)

Anonymous Coward | more than 6 years ago | (#20461669)

How about using a language tag like system( something similar to gettext http://www.gnu.org/software/gettext/ [gnu.org] )? And spellchecking those files. Makes it easier to make an application support multiple languages as well.

Re:Instead of putting the text in a program code (1)

wikinerd (809585) | more than 6 years ago | (#20461905)

He dosn't only want to spellcheck software interface messages etc, he also wants to spellcheck function names containing natural language.

Use Text Files (0, Offtopic)

Crispin Cowan (20238) | more than 6 years ago | (#20461671)

If you want your software to be internationalizable, then you are going to need all your interface text in external text files anyway. Just spellcheck that. Your programmers really shouldn't be embeddeding any message text in the software itself, so you can just use grep to search for " marks :)

Re:Use Text Files (1)

Corporate Troll (537873) | more than 6 years ago | (#20461763)

It's not what he means. He talks about problems like getBussinessObjekt() instead of getBusinessObject(). Apart from that, you're 100% right and it should even be that way if you don't want to internationalize it.

Write your own...? (0)

Anonymous Coward | more than 6 years ago | (#20461683)

1. I'm a programmer
2. I want a program that does exactly X, Y, and Z
3. ????
4. Profit!

how soon do you need it? (1)

indraneil (1011639) | more than 6 years ago | (#20461697)

I am currently working on a java-based universal spell checker (the kind that can do a decent job without involving knowledge of that language). By language, I mean, English, Hindi etc.
I am amused by the idea of being able to extend that to programming languages.

The most significant problem that I am facing has nothing to do with coding the spell-checker. Its about getting a sizable dictionary of words (finding one, converting to UTF-8 etc.)

The trouble is that programming comes with a very different set of words that are not common in a normal dictionary
- acronyms (XML, JRAD etc.)
- weird keywords (foreach, esac etc.)
- regex
- portmanteau words like regex
etc.

I have a feeling that if some one can take the pain and build a dictionary of such things, it can be done. I am not much of a lexicographer. If you can find such a dictionary, get back to me, and I will see if I can get this to work for you

Re:how soon do you need it? (0)

Anonymous Coward | more than 6 years ago | (#20461913)

Its about getting a sizable dictionary of words

Dude, you need to step outside of the world of proprietary Windows and Java development. Near-complete word lists have been available on *BSD systems for decades!

http://www.freebsd.org/cgi/cvsweb.cgi/src/share/di ct/ [freebsd.org]

The web2 and web2a files contain many, many words. The freebsd file contains a number of technical terms and acronyms. The propernames file contains a list of proper names.

FxCop (2, Informative)

W3bbo (727049) | more than 6 years ago | (#20461711)

Okay, so it's only for Managed Assemblies (C#, VB.NET, J#, etc), but it does spell-checking, acronym-checking, and case-checking, which is nifty. Along with the other slew of introspection rules (some of which are a PITA to implement, even if it does increase the quality of the finished product).

The $$$ version of Visual Studio (the Team Suite version) comes with an introspection engine for VC++ though, it's not as flexible as FxCop but does the basics.

Then there's the countless "Spellchecker" plugins available for IDEs everywhere, VS, Eclipse, NetBeans, etc...

Compile! (0)

Anonymous Coward | more than 6 years ago | (#20461721)

Compile your code and the compiler will find spelling errors in variables etc.

TextMate does some... (2, Interesting)

NNKK (218503) | more than 6 years ago | (#20461735)

TextMate on OS X has spell checking functionality that is semi-useful, but it's not really "aggressive" enough, and there doesn't seem to be a way to make it such with prefs/configuration.

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.

Syntax Highlighting (0, Offtopic)

ajs318 (655362) | more than 6 years ago | (#20461753)

What you're wanting is something that is very difficult for a computer but very easy for a human being. You want to be able to discern which parts of your text file constitute machine-readable instructions (which have to be spelt the way the machine expects them when it's running the compiler/interpreter) and which parts constitute human-readable messages (which have to be spelt the way a human would expect).

The real point is, you shouldn't have user interface messages hard-coded right there into your program at all! It will make it much harder to produce a foreign-language version three years down the line when your company expand and open their first offshore branch. Instead, you should abstract all messages out into a separate file of their own, which can then be spell-checked separately; refer to them only by means of meaningful constants within the code (e.g. if message 6 happens to be "number too small" then use something like NUMTOOSML for 6). This will make the task of internationalisation much simpler -- it can be handed off to anyone who speaks both the current and target languages, not necessarily a programmer.

If your program really is one that you will never need to internationalise, then your users probably will be able to deal with the odd mis-spelt message.

Re:Syntax Highlighting (1)

adnonsense (826530) | more than 6 years ago | (#20461781)

The OP's question was about spell-checking the source code itself (for consistency in variable names), not any UI messages that might or might not be contained in it.

Re:Syntax Highlighting (3, Insightful)

BasilBrush (643681) | more than 6 years ago | (#20461831)

The question wasn't about user interface strings. It was about spelling in APIs. e.g. One issue at my last company, which was British, is that they standardized on US spelling, but some British spellings crept in too. So sometimes you'd get a function containing "Initialize" and sometimes "Initialise".

Re:Syntax Highlighting (1)

Corporate Troll (537873) | more than 6 years ago | (#20461899)

What you're wanting is something that is very difficult for a computer but very easy for a human being. You want to be able to discern which parts of your text file constitute machine-readable instructions (which have to be spelt the way the machine expects them when it's running the compiler/interpreter) and which parts constitute human-readable messages (which have to be spelt the way a human would expect).

Bollocks, what you describe is absolutely possible, otherwise syntax highlighting would not be possible. In Java, everything between /* and */ and everything starting with // are comments and thus should be spellchecked. Everything between two ", should also be spellchecked since those are literal strings.

Of course, you're right that literal strings have no place in source code, but that was not the question.

Re:Syntax Highlighting (1)

Bloke down the pub (861787) | more than 6 years ago | (#20461951)

I almost wrote exactly the same thing as you. Luckily, I decided to RTFA first and avoid making a total berk of myself.

Re:Syntax Highlighting (0)

Anonymous Coward | more than 6 years ago | (#20462031)

What you're wanting is something that is very difficult for a computer but very easy for a human being.
I understand what you are saying, but if your boss sees that you are outsourcing the spellchecking of your code to India then might he also get the idea of outsourcing the actual coding as well?

Learn to spell (0, Offtopic)

frisket (149522) | more than 6 years ago | (#20461767)

Such a spellchecker might be useful and might even be possible, but it would be much more valuable if QA caught spelling mistakes in the user interface (menu labels, error messages, etc). "An error has occured" is far to common.

You can have the benefit of the doubt... (1)

plierhead (570797) | more than 6 years ago | (#20461883)

I'm guessing that your "far to common" is a subtle easter egg?

What is wrong with people? (0)

Anonymous Coward | more than 6 years ago | (#20461785)

I know I'm going to get flamed for this, but what is so difficult about learning to spell? Ignoring obvious developmental deficiencies, nothing is stopping you from going to the library and getting out a big fat vocab book designed for foreigners or child natives.

There is a great emphasis today on offloading skills to machinery. Sometimes this is a good thing; sometimes it's no better than crying out for a wheelchair because you have never bothered to learn to walk.

Why don't more software developers take a leaf out of Knuth, who "only proved it correct, not tried it" [grammar]? He made the effort to develop his mind such that he could be confident in his own ability to combine memorised results with logical deductions - the key skills of programming, spelling and pretty much any other ability you'll ever attempt to acquire.

Re:What is wrong with people? (1)

LarsWestergren (9033) | more than 6 years ago | (#20461861)

Why don't more software developers take a leaf out of Knuth, who "only proved it correct, not tried it" [grammar]?

Yeah, that's great and all, but this is something you can only do for small algorithms. Proving correctness of large systems takes huge amounts of time and resources, so for most developers this is just not feasible. Also a while ago, someone notable in the Java world (Gafter? Bloch? Can't seem to find the link) blogged about how he had discovered that one of the core textbook examples taught the last 30 years in the courses about proving code was in fact incorrect... The assumptions no longer held for 64 bit systems. If the experts can't get 5 lines of code right, what use is it in practice?

He made the effort to develop his mind such that he could be confident in his own ability to combine memorised results with logical deductions - the key skills of programming, spelling and pretty much any other ability you'll ever attempt to acquire.

Oh, so the easy solution is to become a genius, then all problems will be trivial. That's very smart of you AC, wonder why no one thought of that before?

Re:What is wrong with people? (1)

LarsWestergren (9033) | more than 6 years ago | (#20461929)

Also a while ago, someone notable in the Java world (Gafter? Bloch? Can't seem to find the link) blogged about how he had discovered that one of the core textbook examples taught the last 30 years in the courses about proving code was in fact incorrect...

Found it... Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken [blogspot.com] . I like his final paragraph:

"We programmers need all the help we can get, and we should never assume otherwise. Careful design is great. Testing is great. Formal methods are great. Code reviews are great. Static analysis is great. But none of these things alone are sufficient to eliminate bugs: They will always be with us. A bug can exist for half a century despite our best efforts to exterminate it. We must program carefully, defensively, and remain ever vigilant."

Re:What is wrong with people? (1)

Nazlfrag (1035012) | more than 6 years ago | (#20462043)

Well, all that he found was that it is easy to overflow a 32 bit signed int value, which is nothing new. The concept of an array of 2^30+ bytes is what broke this code - recompile the code on a 64 bit platform and it just works, bug free (up until 2^63 arrays, but still..). The fact that 'nobody will ever need more than 2^30 (over 1 billion) array entries' isn't a bug in the software per se, just a bug in the specification.

Re:What is wrong with people? (0)

Anonymous Coward | more than 6 years ago | (#20462065)

Oh, so the easy solution is to become a genius, then all problems will be trivial. That's very smart of you AC, wonder why no one thought of that before?


Natural talent may come into it, but it's also about hard work. I can spell not just because I was born fairly able but because, as a child, I learnt huge vocabulary lists every week. That doesn't involve learning random strings of letters - it means learning rules and exceptions, just as in programming. And it's an exercise with purpose beyond its own sake: by becoming intimate with your language's lexicon you will absorb what you read with greater ease and communicate more effectively.

By contrast, the context-ignorant automaton that is the average spellchecker does toe-curling things to the documents of people who don't really understand the words they're putting down to paper. Were is you're brain witch mite right hurrahs grater then this?

Re:What is wrong with people? (0)

Anonymous Coward | more than 6 years ago | (#20461973)

Fuckin right you are my son!

I hate these fuckin stupid ass fuckin little pussies having a fuckin cry about not being fuckin able to fuckin spell.

Read a fucking book, shit for brains. How fuckin dumb do you fuckin have to fuckin be not to be able to fuckin spell right.

Stop blaming your fuckin environment for your fuckin problems and learn to fuckin spell ya fuckin cunt.

Re:What is wrong with people? (1)

skrolle2 (844387) | more than 6 years ago | (#20462067)

the key skills of programming, spelling and pretty much any other ability you'll ever attempt to acquire.
In English enumerations, you have a comma before the last and. You should have written:

programming, spelling, and pretty much any other ability
Oh beautiful irony. Now go to a library and pick up a grammar book. Or maybe, just maybe, realize that everyone isn't perfect and that spelling isn't viewed as really important by that many, and that a spellchecker is a really useful tool.

Good Idea (0)

aug24 (38229) | more than 6 years ago | (#20461791)

Seriously, I think this is a terrific idea.

I have a real problem with coders who can't spell (even in code review, either Eyeball Mk1 is fallible or neither coder can spell). Functions called "markOrderRecieved" (for example) are just harder to find when I'm looking for some functionality that I know is there, and are a bump on the road when reading.

I'm primarily a java coder these days, so (1) there's no need to abbreviate for the language (2) All decent IDEs offer auto-complete, so there's no "but I hate typing long names" excuse.

An Eclipse plugin which checks all function and variable names for camel-case delimited real words would be a Good Idea.

That said, I've never heard of such a thing. Anyone not currently with a deadline (although reading /. counts as R&R ;-) care to write one?

Justin.

Yes, you have .... (0)

Anonymous Coward | more than 6 years ago | (#20461859)

... it's called a compiler.

Can it also spelll check slashot polls? (1)

moderators_are_w*nke (571920) | more than 6 years ago | (#20461891)

Cos I don't know what a Space compnay is.

Re:Can it also spelll check slashot polls? (1)

moderators_are_w*nke (571920) | more than 6 years ago | (#20461923)

Or even Slashdot posts?

gcc spell-en (1)

stdazi (1128281) | more than 6 years ago | (#20461919)

I simply use my gcc's spellchecker : gcc foo.c -spell=en la.c: In function 'main': la.c:15: warning: ambigious string value 'hellp'. Did you mean: 'help' ? la.c:17: warning: ambigious variable name 'i'. Did you mean 'index' ?

Fire them? (-1, Flamebait)

Anonymous Coward | more than 6 years ago | (#20461921)

Spelling mistakes are something you make when you're

(1) Drunk
(2) Ten
(3) A two digit IQ idiot fuckin cockbag

Without exception, programmers I've worked with that repeatedly made spelling mistakes for the simplest shit, have produced utter garbage for code.

Stop hitting the bong, fuckheads.

Slightly Off Topic, But.... (0, Offtopic)

bhima (46039) | more than 6 years ago | (#20461931)

OK I know this is a little off topic but why is it that Microsoft's spell checker guesses for what my English & German misspellings are, are far better than MacOS, Firefox on MacOS, and iSpell on OpenBSD?

Is this that hard of problem?

aspell? (3, Insightful)

atlep (36041) | more than 6 years ago | (#20461941)

I remember from spellchecking some html documents a while back ago that aspell is at least aware of html. I do not know how well it works with other kinds of documents.

the problem is really prevalent (1)

wikinerd (809585) | more than 6 years ago | (#20461955)

The idea is nice and I think the problem is really prevalent. I have seen large portions of source code, much of it commercial, containing not one or two but hundreds of spelling mistakes. I also believe the problem must be more prevalent in closed source and in small businesses than open source and Free software. Another thing is that developers from countries with non-English languages often mix English with their first language in code, making it hard to maintain by other nationalities.

Re:the problem is really prevalent (1)

codeshack (753630) | more than 6 years ago | (#20461987)

Agreed. Nothing makes me crazy like an interface at work with a spelling error in a function name, preventing me from AutoCompleting (the one damn reason I put up with Eclipse). If I go back and fix the error, I end up having to refactor 4000 source files and end up getting phone calls like "Hey, why did you mess with my code?" from people that grasp the concept of "svn log" but not "svn blame"...

Re:the problem is really prevalent (4, Funny)

Hognoxious (631665) | more than 6 years ago | (#20462041)

I have seen large portions of source code, much of it commercial, containing not one or two but hundreds of spelling mistakes.
Man, I was digging around in some SAP code recently and none of it made sense. Half of it didn't even look like English!

It's easy (1)

mhannibal (1121487) | more than 6 years ago | (#20461999)

Get new coworkers... Preferably someone who's passed fifth grade.

Eclipse plugin (1)

mlk (18543) | more than 6 years ago | (#20462007)

I'm sure I've got a plugin at work that does this. It covers my code in yellow squiggly lines.

Re:Eclipse plugin (1)

mlk (18543) | more than 6 years ago | (#20462047)

It is called eSpell
http://www.bdaum.de/eclipse/ [bdaum.de]

No one's offering solutions... (2, Interesting)

Chaset (552418) | more than 6 years ago | (#20462035)

Well, I'm a total newbie in terms of compiler architectures and such, but throwing it out there for the purpose of discussion...

I assume a compiler will parse the source and in the process identify which tokens are key words and literals, and which are programmer-defined identifiers in the code. The spell checker would either use the same algorithm, or latch into that part of the algorithm to get at all of the identifiers. There are two possible word separators in typical code--either capital letters or underscors. (If you have something more bizarre, then I think it's a lost cause). So pass those identifiers through a filter that chops them up at each capital letter or underscore (with some exceptions, say, if the identifier is all caps). So, now you've got a pile of strings which are either oddball programming convention stuff, like "p" and "g" for pointers and globals, and things that should generally be words. The rules can include "toss out single character identifiers", "toss out everything up to first capital or underscore", etc. If you have coding guidelines that enforce variable naming conventions, this should get you most of the way.

Now you have English words that you can pass through your standard spelling engine, possibly with a dictionary tweaked for your field of endeavor to decrease false positves and escapes.

Re:No one's offering solutions... (1)

mlk (18543) | more than 6 years ago | (#20462063)

I othered a solution. Just one post below your post. ;)

I don't think what you want is possible (1)

JoelKatz (46478) | more than 6 years ago | (#20462039)

The spelling error is that "functionSigniture" is not a word? Or are you suggesting that it should recognize mixed case and check each word individually? I just looked at some random code of mine, and it contains so many things that are perfectly legal that aren't English words, aside from language keywords.

For example, I have a function that provides a pretty-printed time called 'Gmtime'. The function that produces a GUID in BER form is called 'BERGUID'. In lots of places, "clear" is abbreviated as "clr". A few "Init*" functions are matched by corresponding "Deinit*" functions. An "operator new" assistant is called "OpNew".

C++ requires that a parameter passed to a function have a different name from the same class member. So it's not unusual to have two variables that do the same thing logically but must have different names. Deleting a letter from one variable name is not uncommon, like "first" and "frst".

A static version of a class member function that's used to hook into an API that doesn't support C++ natively often has an 'S' before it's name, so you may have 'ShutDown' and 'SShutDown'.

I believe that most other languages have similar issues.

You'd either have to have one crazy set of coding standards or you'd have to expect your programmers to pick the legitimate errors out of pages and pages of nonsense.

Tags (1)

starwed (735423) | more than 6 years ago | (#20462053)

Wow, I'm glad there's such agreement between those who read the article and left comments, and those who just tagged it. :)
I tagged this article badlytagged

gedit has a hiliteing tool (0)

Anonymous Coward | more than 6 years ago | (#20462071)

Gedit has a highlighting tool, that shows mistacs by not cuoloring them and or by giving them a reb backround (for insance is you foget a ; " the end of a line it will mark the nexed thing red,) and if you (due to fast typing misspell viod or float or another other comand it will not couldre the texed!!!!
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

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>
Create a Slashdot Account

Loading...