Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ISO Studies of underscores vs MixedCase in Ada or C++

179 views
Skip to first unread message

Andy Glew

unread,
Sep 26, 2003, 12:32:40 AM9/26/03
to
I am in search of any rigourous,
scientific, academic or industrial studies
comparing naming conventions in
C++ or similar languages such as
Ada:

Specifically, are names formed with
underscores more or less readable
than names formed with MixedCase
StudlyCaps camelCase?

...and similarly, any measurements
of programmer productivity, bug rate,
etc.; although IMHO readability matters
most.


* Religion - NOT?!

I understand that this is a religious issue
for many programmers, an issue of programming style.
I am not interested in a religious war.
I obviously have my own opinion, but I am
open to scientific evidence.


* Ada Studies?

I thought that I had seen studies like
this in some of the early design documents
for Ada, but I have not been able to find
such references on the web. Which is not
entirely surprising, since Ada was designed
prior to the web.

The Ada 83 and 95 Quality Guidelines recommend
underscores to improve readability, but provide
no source justifying this statement.


* What such studies might look like

Simple readability and recall:
- present a test subject with
a list of compound words
formed with underscoresand mixed case
- remove the list, and ask test subject
to write it
- score on accuracy

Program debugging
- present programs that are otherwise identical,
differing only in their use of underscores/MixedCase
to test subject programmers (e.g. a CS class)
- program has a known bug
- ask test subjects to find bug
- score on accuracy locating bug

Cruel TA study:
- Two sections of a CS class
- Enforce programming standards,
underscores vs MixedCase
- Pose a programming problem
- Score according to success
completing assignment

Empirical:
- Given version control databases
of large programs, some written in underscore
style, others in MixedCase
- Total bug rates normalized by LOC, name count, etc.
- OR: count only bugs that can be attributed
(after inspection of checkins) to misnamed variables

For that matter, I would be interested in any surveys
folks may have done that count projects and their
coding standards, possibly weighted
- open source (e.g. sourceforge)
- industrial
- textbooks, weighted by sales
- websites of coding standards, weighted by Google score...
Although this is less convincing than a rigorous study.


* Explanation of Newsgroups Chosen

I hope it is obvious why I have chosen these
newsgroups to post this search to:

comp.software-eng, comp.programming,
- an issue of software engineering
comp.lang.c++,
- the language I am most interested in
comp.lang.ada
- because I vaguely recall historical work

Attila Feher

unread,
Sep 26, 2003, 1:43:21 AM9/26/03
to
Andy Glew wrote:
> I am in search of any rigourous,
> scientific, academic or industrial studies
> comparing naming conventions in
> C++ or similar languages such as
[SNIP]

The underscore convention work also in case insensitive languages.

The InnerCaps convention fails to solve the issue of all caps words like
SMTPTCPIPConnection. Usual solution is to write them wrong as
SmtpTcpIpConnection.

The underscore convention tends to make lines longer, which can have bad
effect on readablity.

IMO it is a personal preference issue, and also an issue of what fonts and
development envirnmoent is in use.

IMO if one has to select *one* convention for a whole company using many
languages then only the underscore one stands. With InnerCaps there is a
possibility to create hard-to-find name collisions, especially in languages
where the type of variables can change runtime by a simple assignment.

--
Attila aka WW


Jakob Bieling

unread,
Sep 26, 2003, 1:54:51 AM9/26/03
to
"Andy Glew" <andy...@amd.com> wrote in message
news:2cfd1a4e.03092...@posting.google.com...

[snip]

> Specifically, are names formed with
> underscores more or less readable
> than names formed with MixedCase
> StudlyCaps camelCase?

Write a large text (several lines) with mixed-case and the same again
with underscores. Then give it people to read and ask them what they find
easier to read. I would not be surprised if the majority favours the text
with underscores.

[snip]

> The Ada 83 and 95 Quality Guidelines recommend
> underscores to improve readability, but provide
> no source justifying this statement.

The underscore can easily be view as a space which seperates the words,
whereas mixed-case does not provide a seperation like that, but rather a
'large' here-comes-a-new-word-mark (ie. the captial letter). The problem I
see with this: non-captial letters can be 'large' as well. just have a look
at the 't', 'h' etc, which, imo, does not make reading a mixed-case text
easier.

Personally, I prefer underscore for the reason above.

Just my .02c
--
jb

(replace y with x if you want to reply by e-mail)


Matt Gregory

unread,
Sep 26, 2003, 3:11:23 AM9/26/03
to
Jakob Bieling wrote:

> The underscore can easily be view as a space which seperates the words,
> whereas mixed-case does not provide a seperation like that, but rather a
> 'large' here-comes-a-new-word-mark (ie. the captial letter). The problem I
> see with this: non-captial letters can be 'large' as well. just have a look
> at the 't', 'h' etc, which, imo, does not make reading a mixed-case text
> easier.

I think we just need a programming font that has half-sized underscores
in front of all the capital letters. That would solve all these problems.
I personally don't like typing underscores, but I agree they are more
readable. Emacs does have a view-camel-cased-identifiers-as-underscored
mode, so that's a step in the right direction.

Ludovic Brenta

unread,
Sep 26, 2003, 3:27:40 AM9/26/03
to

Personally I prefer underscores, too, and for that reason I really
like Emacs' glasses-mode. So, use whatever you want, *I* will always
see underscores :)

--
Ludovic Brenta.

Steve

unread,
Sep 26, 2003, 9:43:19 AM9/26/03
to
I think a more relevent test would be to give two versions the same code,
one with underscores, one with mixed casing, to different groups of
programmers to analyze. Include a quiz asking questions about the code.
See which version results in more correct answers, and which version
achieves the answers more quickly.

Steve
(The Duck)

"Jakob Bieling" <net...@gmy.net> wrote in message
news:bl0ka8$n7h$07$1...@news.t-online.com...
[snip]

Frank J. Lhota

unread,
Sep 26, 2003, 11:40:00 AM9/26/03
to
Underscores are basically a way to provide spaces in an identifier. Since
identifiers are generally phrases (nown phrases for objects, verb phrases
for procedures) and phrases often consist of more than one word, I find the
use of underscores to be quite natural.

The opposing argument is that underscores are too large, and that a case
change is a more readable way to indicate how to divide the decomposition
into words. To me, the upper / lower case method of delineate the words in
an indentifier has always looked like the transcript of a very fast talker.
Yes, you can make out the words, but just barely. Moreover, the use of
letter case to delineate words prohibits any other use of letter case. It
rules out using all caps for a certain category of identifiers, for example.

There is an easy way to test which convention is more readable. Here is one
of Shakespeare's sonnets rendered in the mixed case format:

FromFairestCreaturesWeDesireIncrease,
ThatTherebyBeautysRoseMightNeverDie,
ButAsTheRiperShouldByTimeDecease,
HisTenderHeirMightBearHisMemory:
ButThouContractedToThineOwnBrightEyes,
FeedstThyLightsFlameWithSelfSubstantialFuel,
MakingAFamineWhereAbundanceLies,
ThySelfThyFoeToThySweetSelfTooCruel:
ThouThatArtNowTheWorldsFreshOrnament,
AndOnlyHeraldToTheGaudySpring,
WithinThineOwnBudBuriestThyContent,
AndTenderChurlMakstWasteInNiggarding:
PityTheWorldOrElseThisGluttonBe,
ToEatTheWorldsDueByTheGraveAndThee

It may be a matter of taste, but I certainly found the original sonnet to be
more readable and more beautiful.


Randy King

unread,
Sep 26, 2003, 12:22:35 PM9/26/03
to
<snip> op <snip>

This is a somwhat offtopic post, but the OP did ask the question about
readability.

Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer
inwaht orredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be a
total mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae
the huamn mnid deos not raed ervey lteter by istlef, butthe wrod as a
wlohe. Aolbsulty amzanig huh?

Hyman Rosen

unread,
Sep 26, 2003, 12:51:45 PM9/26/03
to
Randy King wrote:
> Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer
> inwaht orredr the ltteers in a wrod are, the olny iprmoetnt tihng is
> taht the frist and lsat ltteer be at the rghit pclae. The rset can be a
> total mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae
> the huamn mnid deos not raed ervey lteter by istlef, butthe wrod as a
> wlohe. Aolbsulty amzanig huh?

"Anidroccg to crad cniyrrag lcitsiugnis planoissefors at an uemannd,
utisreviny in Bsitirh Cibmuloa, and crartnoy to the duoibus cmials
of the ueticnd rcraeseh, a slpmie, macinahcel ioisrevnn of ianretnl
cretcarahs araepps sneiciffut to csufnoe the eadyrevy oekoolnr."

Matt Gregory

unread,
Sep 26, 2003, 1:12:00 PM9/26/03
to
I wrote:

> I think we just need a programming font that has half-sized underscores
> in front of all the capital letters. That would solve all these problems.

Nevermind, that was a terrible idea. It was almost good though.

Jack Klein

unread,
Sep 26, 2003, 1:24:57 PM9/26/03
to
On 25 Sep 2003 21:32:40 -0700, andy...@amd.com (Andy Glew) wrote in
comp.lang.c++:

> I am in search of any rigourous,
> scientific, academic or industrial studies
> comparing naming conventions in
> C++ or similar languages such as
> Ada:
>
> Specifically, are names formed with
> underscores more or less readable
> than names formed with MixedCase
> StudlyCaps camelCase?

My team is currently working under this guideline as a compromise:

Function names must be CamelMode, but optionally underscores are
allowed, e.g. Camel_Mode.

...or should I say "compromised" guidelines?

Interestingly I see a lot of programmers who prefer CamelMode for
function names, yet prefer under_scores in variable names. In every
single case where I have checked, the programmer has done at least
some coding for Windows and its Pascal, BASIC, etc., API. And in
every single case they claim that is not where their style came from.
Go figure.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

Programmer Dude

unread,
Sep 26, 2003, 1:44:14 PM9/26/03
to
Jack Klein wrote:

> Interestingly I see a lot of programmers who prefer CamelMode for
> function names, yet prefer under_scores in variable names. In every
> single case where I have checked, the programmer has done at least
> some coding for Windows and its Pascal, BASIC, etc., API. And in
> every single case they claim that is not where their style came from.

I've tried just about every combination over the years. At one
point it was underscores in function names, not in data names.
OOP added enough other basic types of things it got hard to have
a style for each. Currently, I use lower_case_with_underscores
for local names and CamelCaseMode for functions/methods and
for global data.

I'm considering switching to Mixed_Case_With_Underscores for
global data. In fact, with the fairly recent addition of
several new languages to my tool kit, it's probably time to
once again re-think my whole naming convention thing.

--
|_ CJSonnack <Ch...@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|_______________________|

Mike Smith

unread,
Sep 26, 2003, 2:02:33 PM9/26/03
to
Hyman Rosen wrote:

Yes, it's possible to take it *too* far. But I *was* able to read the
quoted text at maybe half the speed at which I could have read it if it
were spelled correctly. And the text in Randy King's post is even more
readable than that - I can read it at almost full speed.

--
Mike Smith

tmo...@acm.org

unread,
Sep 26, 2003, 2:25:47 PM9/26/03
to
> > I think we just need a programming font that has half-sized underscores
If you want to get into fonts etc, look at "Human Factors and Typography
for More Readable Programs", (c) 1990 ACM Press, ISBN 0-201-10745-7
(It doesn't appear to address naming questions, however.)

Michael Feathers

unread,
Sep 26, 2003, 2:41:32 PM9/26/03
to

"Matt Gregory" <bleah-no-...@earthlink.net> wrote in message
news:Ar_cb.6981$pP6....@newsread2.news.atl.earthlink.net...


Let's see, what if an IDE had a toggle which converted identifier names back
and forth on demand, flagging any clashes. ;-)


Hyman Rosen

unread,
Sep 26, 2003, 3:05:35 PM9/26/03
to
Mike Smith wrote:
> Yes, it's possible to take it *too* far. But I *was* able to read the
> quoted text at maybe half the speed at which I could have read it if it
> were spelled correctly. And the text in Randy King's post is even more
> readable than that - I can read it at almost full speed.

Which clearly means that the first/last letter thing isn't the
only factor in comprehension.

Default User

unread,
Sep 26, 2003, 3:56:07 PM9/26/03
to


That's because it's not well scrambled at all. Examine the larger words,
they almost all have large unchanged or barely changed segments. Most of
the time double letter combos are kept together, very little reversal of
segments. I think the given example (I've received it many times) does
not provide much evidence for the contention at all.

Brian Rodenborn

Default User

unread,
Sep 26, 2003, 3:57:55 PM9/26/03
to
Jack Klein wrote:

> Function names must be CamelMode, but optionally underscores are
> allowed, e.g. Camel_Mode.


We are allowed underscores when acronyms appear in the name.

InitiateFMS_Executive();

Brian Rodenborn

Message has been deleted

Mad Hamish

unread,
Sep 27, 2003, 7:18:45 AM9/27/03
to

But produces more compilation errors.
Hence the mixed case format must be better for programming.
--
"Hope is replaced by fear and dreams by survival, most of us get by."
Stuart Adamson 1958-2001

Mad Hamish
Hamish Laws
h_l...@aardvark.net.au

Gerry Quinn

unread,
Sep 27, 2003, 7:44:00 AM9/27/03
to
In article <3F747AEE...@Sonnack.com>, Programmer Dude <Ch...@Sonnack.com> wrote:
>Jack Klein wrote:
>
>> Interestingly I see a lot of programmers who prefer CamelMode for
>> function names, yet prefer under_scores in variable names. In every
>> single case where I have checked, the programmer has done at least
>> some coding for Windows and its Pascal, BASIC, etc., API. And in
>> every single case they claim that is not where their style came from.
>
>I've tried just about every combination over the years. At one
>point it was underscores in function names, not in data names.
>OOP added enough other basic types of things it got hard to have
>a style for each. Currently, I use lower_case_with_underscores
>for local names and CamelCaseMode for functions/methods and
>for global data.

I use:

ClassName // need not start with C
FunctionName()
m_MemberVariable // misc. variable
m_pPointerVariable // common typed variable
localVariable
pLocalPointer
SOME_CONSTANT

I guess I could use underscore more if I wanted. Don't like typing it
much, though.

I think what I dislike about underscores is related to what some people
like about them: they look like spaces. That interferes with my ability
to break up a statement into individual identifiers.

When someone posts code with lots of underscores, I find it hard to
read.

Gerry Quinn
--
http://bindweed.com
Kaleidoscopic Screensavers and Games for Windows
Download free trial versions
New screensaver: "Hypercurve"

Richard Heathfield

unread,
Sep 27, 2003, 12:35:50 PM9/27/03
to
[Uncomfortable with crosspost, but not sure which groups to trim]

Jack Klein wrote:

>
> Interestingly I see a lot of programmers who prefer CamelMode for
> function names, yet prefer under_scores in variable names. In every
> single case where I have checked, the programmer has done at least
> some coding for Windows and its Pascal, BASIC, etc., API. And in
> every single case they claim that is not where their style came from.
> Go figure.

Add another one to your tally. I have written a fair few Windows programs.
But /before/ that, I had already invented MixedCase for myself. I was quite
pleased, actually, to discover that the Windows API people had copied my
style. :-)

--
Richard Heathfield : bin...@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton

Robert I. Eachus

unread,
Sep 27, 2003, 7:38:30 PM9/27/03
to
Richard Heathfield wrote:
> [Uncomfortable with crosspost, but not sure which groups to trim]

I trimmed comp.lang.ada. I don't know about the other languages, but in
Ada names like Ada.Text_IO.Integer_IO are a part of the standard.
Mixing that with any other style looks uglier than any unmixed style.
So it is sort of forced on anyone who cares, and most are happy with it.

--
Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the
goal of Art. It remains to work these concepts into a practical,
down-to-earth context, and for this there is nothing more practical or
down-to-earth than what I have been talking about all along...the repair
of an old motorcycle." -- from Zen and the Art of Motorcycle
Maintenance by Robert Pirsig

Ian Woods

unread,
Sep 27, 2003, 8:23:51 PM9/27/03
to
Richard Heathfield <dont...@address.co.uk.invalid> wrote in
news:bl4e95$re2$2...@hercules.btinternet.com:

> [Uncomfortable with crosspost, but not sure which groups to trim]
>
> Jack Klein wrote:
>
>>
>> Interestingly I see a lot of programmers who prefer CamelMode for
>> function names, yet prefer under_scores in variable names. In every
>> single case where I have checked, the programmer has done at least
>> some coding for Windows and its Pascal, BASIC, etc., API. And in
>> every single case they claim that is not where their style came from.
>> Go figure.
>
> Add another one to your tally. I have written a fair few Windows
> programs. But /before/ that, I had already invented MixedCase for
> myself. I was quite pleased, actually, to discover that the Windows
> API people had copied my style. :-)

Indeed! It's not exactly a huge leap of imagination to go from

somename

to realise that

someName

or

SomeName

is generally easier to spot.

I'm just wondering when someone will pull out a patent on such an obvious
thing.

Ian Woods

Martin Dowie

unread,
Sep 28, 2003, 5:26:54 AM9/28/03
to
"Mad Hamish" <h_l...@aardvark.net.au> wrote in message
news:l3nanv42t229aao9a...@4ax.com...

> >It may be a matter of taste, but I certainly found the original sonnet to
be
> >more readable and more beautiful.
> >
> But produces more compilation errors.
> Hence the mixed case format must be better for programming.

Are you arguing that more compilation errors are a godd thing or a bad
thing?...


> "Hope is replaced by fear and dreams by survival, most of us get by."
> Stuart Adamson 1958-2001

"Nice quote" says Dunfermline resident.


James Dow Allen

unread,
Sep 28, 2003, 6:17:43 AM9/28/03
to
> On 25 Sep 2003 21:32:40 -0700, andy...@amd.com (Andy Glew) wrote in
> comp.lang.c++:

> > Specifically, are names formed with


> > underscores more or less readable
> > than names formed with MixedCase
> > StudlyCaps camelCase?

In the discussion I haven't yet seen the *correct* answer. :-)

CamelMode, camel_mode, etc. are all quite *readable*; when using long
names the important thing is to make them *writable*, i.e.
easy to remember.

Consistency is therefore the important thing. If you abbreviate words,
abbreviate them as the first 4 (or whatever) letters, consistently.

(I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
remember if 0 is SEEKSET or SEEK_SET.)

James

Georg Bauhaus

unread,
Sep 29, 2003, 1:34:42 PM9/29/03
to
>>>>> "Frank" == Frank J Lhota <NOSPAM.lho...@verizon.net> writes:

: Since identifiers are generally phrases (nown phrases


: for objects, verb phrases for procedures) and phrases often consist
: of more than one word, I find the use of underscores to be quite
: natural.

But we should, I think, consider non-phrases or almost-non-phrases
being used as identifiers, and "juxtapositions" of identifiers. The
isolated identifiers might be shorter and thus more easily broken
into parts during the "reading process".

theFools(42);

the_fools (42);

the_Fools(42);

The_Fools (42);

...

y := doYouMind.ifI();

y := do_you_mind.if_i ();

y := do_You_Mind.if_I();

y := Do_You_Mind.If_I ();


takeAction(doYouMind.ifI(openTheWindow));

take_action (do_you_mind.if_i (open_the_window));

take_Action (do_You_Mind.if_I(open_The_Window));

Take_Action (Do_You_Mind.If_I (Open_The_Window));

So in context, your "Shakespearean" argument might still apply,
even if short identifiers are readable in dense mixed case?

: There is an easy way to test which convention is more readable. Here


: is one of Shakespeare's sonnets rendered in the mixed case format:

: FromFairestCreaturesWeDesireIncrease,


Also, looking closely at letters, fonts certainly do matter.
In a string such as "glubf()" it might or might not be easy
to distinguish the two characters 'f' and '('. It depends on
how ink would be spread, or on how pixels would appear on some
display screen. You can see this comparing foo(a) and oof(a),
using different fonts for the letters and symbols.

Georg

Mike Bandor

unread,
Sep 29, 2003, 7:19:15 PM9/29/03
to
I was once told by a TRW employee that on one particular project they had a
coding standard that used underscores in lieu of running the names together.
One of their "measures" of readability was to take copy of the code, remove
the underscores, and run it through a spell checker. If it made it through
the spell checker, it was deemed "readable".


--
Mike Bandor, Software Engineer, BS-CS/SE
Ada83, Ada95, C++, Delphi, JavaScript, WinHelp, PL/SQL, SQL, JOVIAL, MASM,
Java, HTML
Creator of MEGATERMS, Military Terms & Acronyms
http://home.satx.rr.com/bandor/megaterm/megaterm.htm

"Georg Bauhaus" <ge...@strudel.futureapps.de> wrote in message
news:863cefj...@strudel.futureapps.de...

Peter Ammon

unread,
Oct 2, 2003, 12:20:33 AM10/2/03
to
Andy Glew wrote:
> I am in search of any rigourous,
> scientific, academic or industrial studies
> comparing naming conventions in
> C++ or similar languages such as
> Ada:
>
> Specifically, are names formed with
> underscores more or less readable
> than names formed with MixedCase
> StudlyCaps camelCase?

[...]

Since camelCase and MixedCase seem to be getting routed by underscore
proponents, here's one example of where something in mixed case is
significantly more readable. It's an excerpt from a bison grammar file
I'm working on.

classmethod :
access_specifier method_type_specifier method_return_type_specifier
method_declaration method_body

In the body, I reference things like $4, which (for those who don't
know) refers to the fourth symbol in that space delimited list above.
Can you quickly count which is the fourth? I can't, since spaces look
similar to underscores.

Compare to

classmethod :
accessSpecifier methodTypeSpecifier methodReturnTypeSpecifier
methodDeclaration methodBody

The second is much more readable IMO. The effect is even more dramatic
without Usenet's line wrapping.

-Peter

Programmer Dude

unread,
Oct 2, 2003, 10:35:47 AM10/2/03
to
Peter Ammon wrote:

> classmethod :
> access_specifier method_type_specifier method_return_type_specifier
> method_declaration method_body
>

> Can you quickly count which is the fourth?

> Compare to
>
> classmethod :
> accessSpecifier methodTypeSpecifier methodReturnTypeSpecifier
> methodDeclaration methodBody

Compare to

classmethod :
access_specifier
method_type_specifier
method_return_type_specifier
method_declaration
method_body

Or my preference if the tool allows

classmethod :
access-specifier
method-type-specifier
method-return-type-specifier
method-declaration
method-body

(In proportional fonts, hyphens are usually skinnier than
underscores and (to my eye) make the text more readable.
It's not as noticable with monospace fonts, but I think the
lower example looks better (read: more readable :-).)

Leif Roar Moldskred

unread,
Oct 3, 2003, 7:53:34 AM10/3/03
to
"Mike Bandor" <mba...@satx.rr.com> writes:

> I was once told by a TRW employee that on one particular project they had a
> coding standard that used underscores in lieu of running the names together.
> One of their "measures" of readability was to take copy of the code, remove
> the underscores, and run it through a spell checker. If it made it through
> the spell checker, it was deemed "readable".

This touches on one of my pet annoyances with development tools today:
no way to easily spell-check your code. In my opinion, a development
environment should at the very _least_ let you easily spell-check all
the text in comments, and preferably the individual words in variable
and function names (whether the words are separated by mixed case,
hyphens or underscores.)

Unfortunately, nobody else seems to mind. *sighs* Oh well,
spell-checkers are overrated anyway.

--
Leif Roar Moldskred

William

unread,
Oct 3, 2003, 10:13:00 AM10/3/03
to
"Leif Roar Moldskred" <rmol...@online.no> wrote in message
news:86ad8i7d...@huldreheim.huldreskog.no...

>
> This touches on one of my pet annoyances with development tools today:
> no way to easily spell-check your code. In my opinion, a development
> environment should at the very _least_ let you easily spell-check all
> the text in comments, and preferably the individual words in variable
> and function names (whether the words are separated by mixed case,
> hyphens or underscores.)

I've used a few things that did have spell checking. (One had a spell
check button on certain text fields in its forms, kinda neat.) My favorite
text and source editor, Ultraedit, has a pretty good spell checker and it
can be expanded to handle reserved words. I don't think it handles
mixed case (or case at all) though. I've never used it except to check
comments or display text. -Wm

William

unread,
Oct 3, 2003, 10:20:37 AM10/3/03
to
"William" <Re...@NewsGroup.Please> wrote in message
news:s9adnXrUZfx...@giganews.com...

>
> I've used a few things that did have spell checking. (One had a spell
> check button on certain text fields in its forms, kinda neat.) My favorite
> text and source editor, Ultraedit, has a pretty good spell checker and it
> can be expanded to handle reserved words. I don't think it handles
> mixed case (or case at all) though. I've never used it except to check
> comments or display text. -Wm

Talking to myself here... I occurred to me that its syntax highlighting
makes spell checking reserved words less necessary - and the syntax
highlighting can deal with case. -Wm


Leif Roar Moldskred

unread,
Oct 3, 2003, 2:39:24 PM10/3/03
to
"William" <Re...@NewsGroup.Please> writes:

> Talking to myself here... I occurred to me that its syntax highlighting
> makes spell checking reserved words less necessary - and the syntax
> highlighting can deal with case. -Wm

What I want though, is a spell-checker that, for instance for java,
will spot the errors such as this

// Number of misspelled words fuond so far
int noErorsInTetx = 0;

I want to spell-check this such that I get notified both on "fuond"
for "found", "Erors" for "Errors" and "Tetx" for "Text". They are all,
after all, words in natural language, and it should be possible to
spell-check them automatically.

--
Leif Roar Moldskred
demanding developer

Jim Rogers

unread,
Oct 3, 2003, 3:48:03 PM10/3/03
to
"William" <Re...@NewsGroup.Please> wrote in message news:<udWdnVqpxL4...@giganews.com>...

> Talking to myself here... I occurred to me that its syntax highlighting
> makes spell checking reserved words less necessary - and the syntax
> highlighting can deal with case. -Wm

Even more to the point -- any compiler should be
able to properly recognize reserved words.
Why use another tool to check what the compiler will also check?

Jim Rogers

Kevin Morenski

unread,
Oct 3, 2003, 6:04:44 PM10/3/03
to
> // Number of misspelled words fuond so far
> int noErorsInTetx = 0;
>
> I want to spell-check this such that I get notified both on "fuond"
> for "found", "Erors" for "Errors" and "Tetx" for "Text". They are all,
> after all, words in natural language, and it should be possible to
> spell-check them automatically.

Let's say you had a variable named "tHTa," for example. With respect to
your concept, this would be a misspelling of the word "that." Now, a lot of
programmers--myself included--use letters to represent certain things in
variable names. tHTa could mean "type HTa" or anything else a programmer
could think of. How could a program possibly differentiate between
conventions in the naming of variables?

It's much simpler to check the spelling of comments...programmers have
developed so many conventions for making their lives easier; a spell checker
on variable names just adds one more problem to overcome.

kevin


Peter Ammon

unread,
Oct 3, 2003, 6:42:20 PM10/3/03
to
Programmer Dude wrote:

> Peter Ammon wrote:
>
>
>>classmethod :
>>access_specifier method_type_specifier method_return_type_specifier
>>method_declaration method_body
>>
>>Can you quickly count which is the fourth?
>>Compare to
>>
>>classmethod :
>>accessSpecifier methodTypeSpecifier methodReturnTypeSpecifier
>>methodDeclaration methodBody
>
>
> Compare to
>
> classmethod :
> access_specifier
> method_type_specifier
> method_return_type_specifier
> method_declaration
> method_body

You've piqued my interest, since I'm the first to admit that my grammar
specifications are hard to read.

Where do you put the action in the above code?

classmethod :
access_specifier
method_type_specifier
method_return_type_specifier
method_declaration
method_body

{ doSomething(); }

What if there's more than one reduction possible?

classmethod :
access_specifier
method_type_specifier
method_return_type_specifier
method_declaration
method_body

{ doSomething(); }
| something_else
another_thing
even_more
blah_blah
{ doSomethingElse(); }

This looks like it's getting hard to read.

>
> Or my preference if the tool allows
>
> classmethod :
> access-specifier
> method-type-specifier
> method-return-type-specifier
> method-declaration
> method-body
>
> (In proportional fonts, hyphens are usually skinnier than
> underscores and (to my eye) make the text more readable.
> It's not as noticable with monospace fonts, but I think the
> lower example looks better (read: more readable :-).)

Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.

-Peter

Wes Groleau

unread,
Oct 3, 2003, 8:10:22 PM10/3/03
to
Peter Ammon wrote:
> Agreed! I wish that more languages allowed hyphen use in identifiers.
> Dylan is the only one I can think of off the top of my head.

Does Dylan prevent having variables named Max,
Max-Iterations, & Iterations in the same scope?

--
Wes Groleau
"Lewis's case for the existence of God contains fallacies."
"You mean like circular reasoning?"
"He believes in God. Isn't that illogical enough?"

Peter Ammon

unread,
Oct 3, 2003, 9:03:25 PM10/3/03
to
Wes Groleau wrote:

> Peter Ammon wrote:
>
>> Agreed! I wish that more languages allowed hyphen use in identifiers.
>> Dylan is the only one I can think of off the top of my head.
>
>
> Does Dylan prevent having variables named Max,
> Max-Iterations, & Iterations in the same scope?
>

No. Whitespace is more important in Dylan than in a language like C.

Max-Iterations <-- variable name
Max - Iterations <-- Max minus Iterations

Other strange characters can appear in Dylan variable names. This
allows for some nice naming conventions without the nastiness of
something like Hungarian Notation. See
http://www.gwydiondylan.org/gdref/tutorial/naming-conventions.html

-Peter

Steve

unread,
Oct 3, 2003, 11:07:11 PM10/3/03
to
If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
spell checking.

gcc -c dointxor.adb
dointxor.adb:30:28: "b_valu" is undefined
dointxor.adb:30:28: possible misspelling of "b_value"
gnatmake: "dointxor.adb" compilation error

If you use the GPS for programming Ada, you'll get a little wrench icon next
to the error in the output window. If you click on the wrench it corrects
the spelling error.

If you're really interested in having comments spell checked, the folks at
ACT (Ada Core Techologies) would probably add the feature for a fee.

Steve
(The Duck)


"Leif Roar Moldskred" <rmol...@online.no> wrote in message
news:86ad8i7d...@huldreheim.huldreskog.no...

[snip]

Matt Gregory

unread,
Oct 4, 2003, 4:45:39 AM10/4/03
to
James Dow Allen wrote:

> (I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
> remember if 0 is SEEKSET or SEEK_SET.)

The Vim editor is cool for things like this because you can add your
own words to the syntax highlighting. I write Windows programs and
I have over a hundred typedef's and constants in my word list.
Actually, Vim's C syntax file comes with the standard C constants
and typedef's highlighted.

Matt Gregory

unread,
Oct 4, 2003, 4:48:33 AM10/4/03
to
Peter Ammon wrote:

> Programmer Dude wrote:
>
>> Or my preference if the tool allows
>>
>> classmethod :
>> access-specifier
>> method-type-specifier
>> method-return-type-specifier
>> method-declaration
>> method-body
>>
>> (In proportional fonts, hyphens are usually skinnier than
>> underscores and (to my eye) make the text more readable.
>> It's not as noticable with monospace fonts, but I think the
>> lower example looks better (read: more readable :-).)
>
>
> Agreed! I wish that more languages allowed hyphen use in identifiers.
> Dylan is the only one I can think of off the top of my head.

Lisp and Scheme.

Leif Roar Moldskred

unread,
Oct 4, 2003, 5:44:18 AM10/4/03
to
"Steve" <nospam_...@comcast.net> writes:

> If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
> spell checking.
>
> gcc -c dointxor.adb
> dointxor.adb:30:28: "b_valu" is undefined
> dointxor.adb:30:28: possible misspelling of "b_value"
> gnatmake: "dointxor.adb" compilation error

That's not really spell-checking though - it doesn't check "b_value" to see
if "value" is a proper word in English.

--
Leif Roar Moldskred

Leif Roar Moldskred

unread,
Oct 4, 2003, 5:49:30 AM10/4/03
to
"Kevin Morenski" <k...@nospam.geekcenter.net> writes:

> Let's say you had a variable named "tHTa," for example. With respect to
> your concept, this would be a misspelling of the word "that." Now, a lot of
> programmers--myself included--use letters to represent certain things in
> variable names. tHTa could mean "type HTa" or anything else a programmer
> could think of. How could a program possibly differentiate between
> conventions in the naming of variables?

In the same way that spell-checkers for ordinary text today handles names and
other words that are correct, but not in the dictionary: When detecting the
unknown word the first time, ask the user what to do with it - whether to
correct it, accept this instance, accept all instances in this document or
add it to your private dictionary. (For a spell-checking of source-code we'd
probably also want the option "accept all instances with this case.")

This really isn't any different from the same problem in regular text,
except that your programming convention might cause a lot of unknown
words to appear. If that's a major headache, just don't spell-check.

--
Leif Roar Moldskred

Martin Dowie

unread,
Oct 4, 2003, 6:19:49 AM10/4/03
to
"Matt Gregory" <bleah-no-...@earthlink.net> wrote in message
news:BPvfb.20445

> > Agreed! I wish that more languages allowed hyphen use in identifiers.
> > Dylan is the only one I can think of off the top of my head.
>
> Lisp and Scheme.

COBOL


Jakob Bieling

unread,
Oct 4, 2003, 6:41:41 AM10/4/03
to
"Leif Roar Moldskred" <rmol...@online.no> wrote in message
news:86zngh5...@huldreheim.huldreskog.no...


But it is that kind of word-matching I would personally like to see in
more compilers (specifically C++ compilers).

I do agree with Kevin Morenski (news:3f7df...@nntp2.nac.net) that a
real spell-checker for source code is not practicable. You said that the
spell-checker would just have to ask you whether to ignore it or how else to
proceed. Have you thought about how annoying 100s or even 1000s of those
messages boxes, asking how to proceed, will be when compiling already
existing source with this spell-checker?

regards
--
jb

(replace y with x if you want to reply by e-mail)


Corey Murtagh

unread,
Oct 4, 2003, 8:13:19 AM10/4/03
to
Martin Dowie wrote:

Isn't there a variation of Godwin's Law covering COBOL? :>

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

CBFalconer

unread,
Oct 4, 2003, 8:28:38 AM10/4/03
to
Matt Gregory wrote:
> Peter Ammon wrote:
> > Programmer Dude wrote:
> >
... snip ...

> >>
> >> (In proportional fonts, hyphens are usually skinnier than
> >> underscores and (to my eye) make the text more readable.
> >> It's not as noticable with monospace fonts, but I think the
> >> lower example looks better (read: more readable :-).)
> >
> > Agreed! I wish that more languages allowed hyphen use in identifiers.
> > Dylan is the only one I can think of off the top of my head.
>
> Lisp and Scheme.

Cobol

--
Chuck F (cbfal...@yahoo.com) (cbfal...@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


Georg Bauhaus

unread,
Oct 4, 2003, 9:29:17 AM10/4/03
to
>>>>> "Martin" == Martin Dowie <martin...@btopenworld.com> writes:

: "Matt Gregory" <bleah-no-...@earthlink.net> wrote in message

: COBOL

Also a few languages, like SNOBOL4, that allow you to have
any string as a variable name,

$'The Shoemaker - page 3' = 'Once upon a time'

ML allows minus {minus} as identifiers, and also ":->" and the like,
though not ":-)".


Georg

Leif Roar Moldskred

unread,
Oct 4, 2003, 2:29:47 PM10/4/03
to
"Jakob Bieling" <net...@gmy.net> writes:

> But it is that kind of word-matching I would personally like to see in
> more compilers (specifically C++ compilers).
>
> I do agree with Kevin Morenski (news:3f7df...@nntp2.nac.net) that a
> real spell-checker for source code is not practicable. You said that the
> spell-checker would just have to ask you whether to ignore it or how else to
> proceed. Have you thought about how annoying 100s or even 1000s of those
> messages boxes, asking how to proceed, will be when compiling already
> existing source with this spell-checker?

Oh, I wouldn't want it to be part of the compiler, or continiously on. Rather,
I'd just want to be able to run a command in my editor to spell-check the
source-code I'm currently working on - much like I today invoke ispell in
emacs for regular text files.

--
Leif Roar Moldskred

Default User

unread,
Oct 4, 2003, 2:41:02 PM10/4/03
to
James Dow Allen wrote:

> (I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
> remember if 0 is SEEKSET or SEEK_SET.)


The best choice for rewinding a stdio file stream is rewind().


Brian Rodenborn

Jakob Bieling

unread,
Oct 4, 2003, 3:06:16 PM10/4/03
to
"Leif Roar Moldskred" <rmol...@online.no> wrote in message
news:86r81s6...@huldreheim.huldreskog.no...


Ah, I did not consider this difference even. *g* My point was, checking
my own identifier names for spelling errors based on natural language rules
is a bad idea. Instead, a special code-spell-checker would be great:

a/ 'Created' identifiers are automatically added to the list of known
words (for the current compilation run only)
b/ When an identifier is used, but not found, the spell-checker tries to
find out what I meant (like any spell-checker)
c/ Comments are spell-checked like in any other word processor, except
that identifier names should also be considered

So let us assume we have this (rather useless) piece of C++ code:

1 int main ()
2 {
3 char* pRok = new char;
4 *pork = 'p';
5 delete pRok; // do not forget t delete pRok!
6 }

In line 3, the spell-checker should not question the identifier name and
try to tell me that I meant 'pork' (see a/ above). Instead, it should tell
me in line 4 that I most probably meant 'pRok' and not 'pork' (see b/
above). And last but not least, in line 5, the spell-checker should point
out the missing 'o' (ie. ".. forget to ..") but leave 'pRok' undiagnosed.

Frank J. Lhota

unread,
Oct 4, 2003, 6:13:35 PM10/4/03
to
"Default User" <first...@company.com> wrote in message
news:3F7F143E...@company.com...

> The best choice for rewinding a stdio file stream is rewind().

Nah, rewind() makes me think of tapes, and that makes me feel old.


John W. Krahn

unread,
Oct 4, 2003, 6:15:47 PM10/4/03
to
Georg Bauhaus wrote:
>
> >>>>> "Martin" == Martin Dowie <martin...@btopenworld.com> writes:
>
> : "Matt Gregory" <bleah-no-...@earthlink.net> wrote in message
> : news:BPvfb.20445
> :: > Agreed! I wish that more languages allowed hyphen use in
> :: identifiers. > Dylan is the only one I can think of off the top of
> :: my head.
> ::
> :: Lisp and Scheme.
>
> : COBOL
>
> Also a few languages, like SNOBOL4, that allow you to have
> any string as a variable name,
>
> $'The Shoemaker - page 3' = 'Once upon a time'

You can do the same thing in Perl:

${'The Shoemaker - page 3'} = 'Once upon a time';

And since perl interpolates in double quoted strings you can include any
8 bit value:

${"\xFF\0\t\cV"} = 'Once upon a time';


John
--
use Perl;
program
fulfillment

William

unread,
Oct 5, 2003, 11:08:54 AM10/5/03
to
"Jim Rogers" <jimmaure...@worldnet.att.net> wrote in message
news:82347202.03100...@posting.google.com...

Until we got faster machines, one of our builds could take an hour.
No fun to have the compiler detect a mispelled word 50 minutes in.
(Sure, if everyone did an incremental test build, the problem would
be avoided, but...) -Wm


William

unread,
Oct 5, 2003, 11:16:35 AM10/5/03
to
"Leif Roar Moldskred" <rmol...@online.no> wrote in message
news:86vfr55...@huldreheim.huldreskog.no...

>
> In the same way that spell-checkers for ordinary text today handles names
and
> other words that are correct, but not in the dictionary: When detecting
the
> unknown word the first time, ask the user what to do with it - whether to
> correct it, accept this instance, accept all instances in this document or
> add it to your private dictionary. (For a spell-checking of source-code
we'd
> probably also want the option "accept all instances with this case.")

Well, they will if you add the entire label to the dictionary, but none I'm
aware
of will break up words based on mixed-case. Ultraedit will break up words
on underscores - didn't know that until I just tried it I can make it ignore
mixed-case words, but not break them apart. (It does support multiple user
dictionaries, so you could have a dictionary-per-project defining all the
approved labels.) -Wm

Dave Thompson

unread,
Oct 6, 2003, 2:02:49 AM10/6/03
to
On Fri, 03 Oct 2003 15:42:20 -0700, Peter Ammon
<peter...@rocketmail.com> wrote:
<snip>

> > Or my preference if the tool allows
> >
> > classmethod :
> > access-specifier
> > method-type-specifier
> > method-return-type-specifier
> > method-declaration
> > method-body
> >
> > (In proportional fonts, hyphens are usually skinnier than
> > underscores and (to my eye) make the text more readable.
> > It's not as noticable with monospace fonts, but I think the
> > lower example looks better (read: more readable :-).)
>
> Agreed! I wish that more languages allowed hyphen use in identifiers.
> Dylan is the only one I can think of off the top of my head.
>
COBOL ! Only embedded, though. My compiler accepts -X as minus X with
a warning, but I don't think that's standard.

Also the usual suspects: FORTH allows everything but space (and
controls); and LISP everything but space, parens, period, quote,
backquote, and undoubled slash, if I haven't forgotten anything.

- David.Thompson1 at worldnet.att.net

Robert Stankowic

unread,
Oct 6, 2003, 8:58:46 AM10/6/03
to

"Kevin Morenski" <k...@nospam.geekcenter.net> schrieb im Newsbeitrag
news:3f7df...@nntp2.nac.net...

An editor which is capable of finding the definition of variables and
highlighting a name already defined/declared might solve that problem. VB
has that feature to a certain degree - if you use mixed case for names of
variables, functions etc. and you type a name already declared in lowercase
the editor will automatically convert it to the form in which it is
declared. If you know, the name is declared and case does not flip you know
you made a typo. IIRC Keil development system for embedded C programming has
a similar feature.

just my $0.02
Robert


Howard Ding <hading@hading.dnsalias.com>

unread,
Oct 6, 2003, 12:07:49 PM10/6/03
to
Dave Thompson <david.t...@worldnet.att.net> writes:


> controls); and LISP everything but space, parens, period, quote,
> backquote, and undoubled slash, if I haven't forgotten anything.
>

You can use any of those too, provided you're willing to escape
them. E.g. :


-- [7]> (defun | ().`'\\| (x) (+ x 1))
| ().`'\\|
[8]> (| ().`'\\| 4)
5

An identifier is defined in Common Lisp as:

identifier n. 1. a symbol used to identify or to distinguish names.
2. a string used the same way.

so pretty much any symbol would be a possibility.

Howard Ding
<had...@hading.dnsalias.com>

Isaac Gouy

unread,
Oct 8, 2003, 11:07:53 AM10/8/03
to
andy...@amd.com (Andy Glew) wrote in message news:<2cfd1a4e.03092...@posting.google.com>...
> I am in search of any rigourous,
> scientific, academic or industrial studies
> comparing naming conventions in
> C++ or similar languages such as
> Ada:

- SNIP -

> I hope it is obvious why I have chosen these
> newsgroups to post this search to:
>
> comp.software-eng, comp.programming,
> - an issue of software engineering
> comp.lang.c++,
> - the language I am most interested in
> comp.lang.ada
> - because I vaguely recall historical work

Maybe the "Psychology of Programming Interest Group" mailing list
would be a good place to ask?
http://www.ppig.org/lists.html

Programmer Dude

unread,
Oct 8, 2003, 12:22:25 PM10/8/03
to
Peter Ammon wrote:

>> classmethod :
>> access_specifier
>> method_type_specifier
>> method_return_type_specifier
>> method_declaration
>> method_body
>

> You've piqued my interest, since I'm the first to admit that my
> grammar specifications are hard to read.
>
> Where do you put the action in the above code?
>
> classmethod :
> access_specifier
> method_type_specifier
> method_return_type_specifier
> method_declaration
> method_body
> { doSomething(); }

I thought this was a grammar definition? I'd have thought that

method_body :== { doSomething(); }

But if they are different, the way you did it seems fine to me.

> What if there's more than one reduction possible?
>
> classmethod :
> access_specifier
> method_type_specifier
> method_return_type_specifier
> method_declaration
> method_body
> { doSomething(); }
> | something_else
> another_thing
> even_more
> blah_blah
> { doSomethingElse(); }

Probably break them up in some fashion:

class-method:
class-method-normal |
class-method-extended

class-method-normal:


access-specifier
method-type-specifier
method-return-type-specifier
method-declaration
method-body

class-method-extended:
something-else
another-thing
even-more
blah-blah


>> (In proportional fonts, hyphens are usually skinnier than
>> underscores and (to my eye) make the text more readable.
>> It's not as noticable with monospace fonts, but I think the
>> lower example looks better (read: more readable :-).)
>
> Agreed! I wish that more languages allowed hyphen use in
> identifiers. Dylan is the only one I can think of off the
> top of my head.

Others have already mentioned Lisp, so I don't have to!
(Well,... *didn't* have to... :-)

--
|_ CJSonnack <Ch...@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|_______________________|

Stephen Baynes.

unread,
Oct 10, 2003, 7:52:44 AM10/10/03
to
> takeAction(doYouMind.ifI(openTheWindow));
>
> take_action (do_you_mind.if_i (open_the_window));
>
> take_Action (do_You_Mind.if_I(open_The_Window));
>
> Take_Action (Do_You_Mind.If_I (Open_The_Window));

Once you start looking at the readability whole expressions, you also need
to look at the use of spaces. The above are not consistant about if a space
is used with round brackets. [And then there is the question - is it more
readable with the space outside or inside the bracket - my preference is for
inside - so the opening bracket is with the function name rather than the
first parameter.]
Take_Action (Do_You_Mind.If_I (Open_The_Window));
Take_Action(Do_You_Mind.If_I(Open_The_Window));
Take_Action( Do_You_Mind.If_I( Open_The_Window ) );

To go back to the original question - there have been studies that showed
underscores gave the most readable results - unfortunately I have lost the
reference and I would also like to get my hands on it again.

-
Stephen Baynes CEng MBCS
My views are my own

"Georg Bauhaus" <ge...@strudel.futureapps.de> wrote in message
news:863cefj...@strudel.futureapps.de...


Jacob Sparre Andersen

unread,
Oct 7, 2003, 2:56:35 PM10/7/03
to
Jakob Bieling wrote:
> "Leif Roar Moldskred" <rmol...@online.no> wrote in message
> news:86r81s6...@huldreheim.huldreskog.no...
>
>>"Jakob Bieling" <net...@gmy.net> writes:

> Ah, I did not consider this difference even. *g* My point was, checking
> my own identifier names for spelling errors based on natural language rules
> is a bad idea.

Why. They are hopefully spelled correctly. Otherwise you are adding an
unneeded complication to reading and understanding your code.

> Instead, a special code-spell-checker would be great:
>
> a/ 'Created' identifiers are automatically added to the list of known
> words (for the current compilation run only)

I wouldn't like that. Incorrectly spelled identifiers make code
maintenance more difficult.

> b/ When an identifier is used, but not found, the spell-checker tries to
> find out what I meant (like any spell-checker)

Would certainly be nice. But doing a proper job here basically means
trying to compile the code. If you decide to ignore visibility rules,
things will of course become much simpler.

> c/ Comments are spell-checked like in any other word processor, except
> that identifier names should also be considered

Since I don't think misspellings should be allowed in identifier names,
this point seems irrelevant to me.

Jacob
--
LDraw.org Parts Tracker FAQ:
http://www.ldraw.org/library/tracker/ref/faq/

Jacob Sparre Andersen

unread,
Oct 7, 2003, 2:47:22 PM10/7/03
to
Leif Roar Moldskred wrote:

> This touches on one of my pet annoyances with development tools today:
> no way to easily spell-check your code.

I just loaded a random source file into my standard IDE and did some
spell-checking on it. The code was written partially in French, so it
really needed it. :-)

Which IDE it is is revealed below.

Jacob
--
"Any newsgroup where software developers hang out is
an Emacs newsgroup."

Jakob Bieling

unread,
Oct 12, 2003, 4:07:18 AM10/12/03
to
"Jacob Sparre Andersen" <spa...@crs4.it> wrote in message
news:3F830C63...@crs4.it...

> Jakob Bieling wrote:
> > "Leif Roar Moldskred" <rmol...@online.no> wrote in message
> > news:86r81s6...@huldreheim.huldreskog.no...
> >
> >>"Jakob Bieling" <net...@gmy.net> writes:
>
> > Ah, I did not consider this difference even. *g* My point was,
checking
> > my own identifier names for spelling errors based on natural language
rules
> > is a bad idea.
>
> Why. They are hopefully spelled correctly. Otherwise you are adding an
> unneeded complication to reading and understanding your code.
>
> > Instead, a special code-spell-checker would be great:
> >
> > a/ 'Created' identifiers are automatically added to the list of
known
> > words (for the current compilation run only)
>
> I wouldn't like that. Incorrectly spelled identifiers make code
> maintenance more difficult.

I do not know how you choose your identifier names, but I usually give
them abbreviated prefixes, which would make every spell-checker flag a
misspelling. See Kevin's example (news:3f7df...@nntp2.nac.net)

> > b/ When an identifier is used, but not found, the spell-checker
tries to
> > find out what I meant (like any spell-checker)
>
> Would certainly be nice. But doing a proper job here basically means
> trying to compile the code. If you decide to ignore visibility rules,
> things will of course become much simpler.

Right. You got me thinking here, though. Since the code is
sort-of-spell-checked by the compiler already, point a and b are pretty much
superflous (unless you want the luxury of the compiler trying to guess the
correctly spelled identifier name). No need for a special spell-checker
anymore, except that it should only spell-check comments ;)

Georg Bauhaus

unread,
Oct 13, 2003, 5:32:29 AM10/13/03
to
In comp.lang.ada Stephen Baynes. <stephen...@soton.sc.philips.com> wrote:
: Once you start looking at the readability whole expressions, you also need

: to look at the use of spaces. The above are not consistant about if a space
: is used with round brackets.

Glad someone noticed, explicitly :-) Has anybody written Algol
programs (using spaces in identifiers)?


Georg

Jacob Sparre Andersen

unread,
Oct 14, 2003, 9:41:09 AM10/14/03
to
Jakob Bieling wrote:
> "Jacob Sparre Andersen" <spa...@crs4.it> wrote in message
> news:3F830C63...@crs4.it...

>>I wouldn't like that. Incorrectly spelled identifiers make code


>>maintenance more difficult.
>
> I do not know how you choose your identifier names, but I usually give
> them abbreviated prefixes,

I practically never use abbreviations or acronyms in identifiers -
except for those from the project specific "approved" list ("IO" is
always there, though :). And when I do, it is always as separate parts
like in "Integer_Text_IO". I would never write "IntegerTextIO",
"intTextIO" or "Int_Text_IO" in my code.

If you want more details on how I choose my identifier names, then
chapter 3 in »Ada Quality and Style« is hopefully a good description.

Greetings,

Jacob
--
There only exist 10 kinds of people: Those who know binary
numbers and those who don't know binary numbers.

Jakob Bieling

unread,
Oct 14, 2003, 11:30:59 AM10/14/03
to
"Jacob Sparre Andersen" <spa...@crs4.it> wrote in message
news:3F8BFCF5...@crs4.it...

> Jakob Bieling wrote:

> > "Jacob Sparre Andersen" <spa...@crs4.it> wrote:

> > > I wouldn't like that. Incorrectly spelled identifiers make code
> > > maintenance more difficult.

> > I do not know how you choose your identifier names, but I usually
give
> > them abbreviated prefixes,

> I practically never use abbreviations or acronyms in identifiers -


Not sure where I picked that habit up, but I guess it is pure laziness.
I could not imagine having to type those long names everytime you use them.
Especially counter variables in for-loops (posting from comp.lang.c++) ..
you also use simple i's and j's etc. there, right? As you seem to be posting
from comp.lang.ada, I am not too sure if Ada provides such constructs in the
same way C++ does, so maybe Ada has different means of looping in a
for-loop-kind-of-way (yes, I know pretty much nothing about Ada).

Also, sometimes I tend to abbreviate quite a lot, so that later I might
not know what it stands for. In cases like those I just put a comment next
to where I declared the variable and I can keep saving those keystrokes.

Peter Bushell

unread,
Oct 14, 2003, 11:50:13 AM10/14/03
to

"Jakob Bieling" <net...@gmy.net> wrote in message
news:bmh4q5$g9a$03$1...@news.t-online.com...

> "Jacob Sparre Andersen" <spa...@crs4.it> wrote in message
> news:3F8BFCF5...@crs4.it...
>
> Also, sometimes I tend to abbreviate quite a lot, so that later I
might
> not know what it stands for. In cases like those I just put a comment next
> to where I declared the variable and I can keep saving those keystrokes.
>

If you can't remember what it meant, pity the poor engineer who has to
maintain your code when you've gone! Having to look up a declaration every
few seconds is not acceptable.

There is evidence* to suggest that 80% of programming is (or should be)
thinking time. Saving keystrokes is therefore not an issue.

Regards,

Peter Bushell.

* My source was Glass, Robert L., "Facts and Fallacies of Software
Engineering". His source was some research material published in another of
his books: "Software Creativity".


Jakob Bieling

unread,
Oct 14, 2003, 12:46:59 PM10/14/03
to
"Peter Bushell" <DELETEnew...@software-inCAPStegrity.com> wrote:

> "Jakob Bieling" <net...@gmy.net> wrote:

> > "Jacob Sparre Andersen" <spa...@crs4.it> wrote:

> > Also, sometimes I tend to abbreviate quite a lot, so that later I
> might
> > not know what it stands for. In cases like those I just put a comment
next
> > to where I declared the variable and I can keep saving those keystrokes.

> If you can't remember what it meant, pity the poor engineer who has to
> maintain your code when you've gone! Having to look up a declaration every
> few seconds is not acceptable.

You do not have to. All declarations (loop counters etc. are an
exception) are at the beginning of the function, along with possible
comments. And for those identifiers where comments are necessary, I do not
think it is impossible to remember them.

> There is evidence* to suggest that 80% of programming is (or should be)
> thinking time. Saving keystrokes is therefore not an issue.

True, but it is still pretty annoying to type all kinds of variable
names out (we are talking about long names, anything over 10 letters,
right?) all the time you use them. The 'burden' of remembering 5 or 6 names
for which you always see the abbreviations is less, in my opinion.

To avoid misunderstandings, I do not approve using abbreviations for all
kinds of variables. But I do find it acceptable to use my way of
abbreviating (including comments) for function local variables.

hth

Alan Balmer

unread,
Oct 14, 2003, 1:34:37 PM10/14/03
to
On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <net...@gmy.net>
wrote:

> True, but it is still pretty annoying to type all kinds of variable
>names out (we are talking about long names, anything over 10 letters,
>right?) all the time you use them

A good editor can eliminate that problem.

--
Al Balmer
Balmer Consulting
removebalmerc...@att.net

Jakob Bieling

unread,
Oct 15, 2003, 1:34:33 AM10/15/03
to
"Alan Balmer" <alba...@att.net> wrote in message
news:hscoov4a1i762dd8j...@4ax.com...

> On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <net...@gmy.net>
> wrote:
>
> > True, but it is still pretty annoying to type all kinds of variable
> >names out (we are talking about long names, anything over 10 letters,
> >right?) all the time you use them
>
> A good editor can eliminate that problem.


For function local variables, mine does not. For class members or
identifiers in a namespace it does.

regards

Jakob Bieling

unread,
Oct 15, 2003, 1:43:23 AM10/15/03
to
<brou...@yahoo.com> wrote in message
news:h51pov4t28ujj3bql...@4ax.com...

> "Jakob Bieling" <net...@gmy.net> wrote:
>
> >Not sure where I picked that habit up, but I guess it is pure laziness.
> >I could not imagine having to type those long names everytime you use
them.
>
> Neither can I. I rarely abbreviate in a variable name. But I rely on
code
> completion in my editor to save typing those keystrokes.

As a said in the other post: For function local variables, mine does not
have that feature.

> The problem is that once you start abbreviating, odds are some
abbreviations
> are not going to be consistent. I've seen nbr, no, nu, or num instead of
> number. Using an editor that will complete nu to number might make your
> life easier in a multi-person project.

Yes, I do write 'num' instead of number. Or I also write 'msg' instead
of message, or 'ips' for an 'InterProcessSynchronisation' handle. In case of
ips, I might not know what it is without context. But when seeing that
variable used in a function call, it is clear what it is supposed to be.
Along with the comments in the code, I find it justified and not overly hard
to read.

Alan Balmer

unread,
Oct 15, 2003, 11:02:33 AM10/15/03
to
On Wed, 15 Oct 2003 07:34:33 +0200, "Jakob Bieling" <net...@gmy.net>
wrote:

>"Alan Balmer" <alba...@att.net> wrote in message
>news:hscoov4a1i762dd8j...@4ax.com...
>> On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <net...@gmy.net>
>> wrote:
>>
>> > True, but it is still pretty annoying to type all kinds of variable
>> >names out (we are talking about long names, anything over 10 letters,
>> >right?) all the time you use them
>>
>> A good editor can eliminate that problem.
>
>
> For function local variables, mine does not. For class members or
>identifiers in a namespace it does.
>

Mine will complete any symbol it knows about, or give you a drop-down
list if there's more than one choice. However, almost any editor will
allow you to code with abbreviations, then expand them to full names
with search and replace. This can be useful for some people who have
total recall in the heat of a programming session, but can't remember
what they were thinking a week later :-)

Frank Schmitt

unread,
Oct 16, 2003, 4:57:40 AM10/16/03
to
"Jakob Bieling" <net...@gmy.net> writes:

> "Alan Balmer" <alba...@att.net> wrote in message
> news:hscoov4a1i762dd8j...@4ax.com...
> > On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <net...@gmy.net>
> > wrote:
> >
> > > True, but it is still pretty annoying to type all kinds of variable
> > >names out (we are talking about long names, anything over 10 letters,
> > >right?) all the time you use them
> >
> > A good editor can eliminate that problem.
>
>
> For function local variables, mine does not. For class members or
> identifiers in a namespace it does.

But why would you want to make function local variables' names more than
10 letters long?
My local variable names tend to consist of only one word, e.g

OutputStreamWriter writer;

Or are your functions so long that you need longer variable names?

regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com

Jacob Sparre Andersen

unread,
Oct 20, 2003, 3:40:53 AM10/20/03
to
James Dow Allen wrote:

> CamelMode, camel_mode, etc. are all quite *readable*;

It may be a matter of personal taste (haven't seen any actual studies),
but I prefer underscores between words, when I am no allowed to put
spaces there. In Ada I follow the style guide and use both underscores
and capitalisation.

> when using long
> names the important thing is to make them *writable*,

Try to count how often you _read_ and _write_ an identifier. I think
you might be surprised by the difference. Easy writing of the
identifers is not anywhere nearly as important as easy reading.

> Consistency is therefore the important thing.

It is.

> If you abbreviate words,
> abbreviate them as the first 4 (or whatever) letters, consistently.

I prefer the suggestion from the Ada style guide (IIRC) that you don't
abbreviate words, and that you only use acronyms from a limited
project-specific list.

> (I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
> remember if 0 is SEEKSET or SEEK_SET.)

Very annoying with a standard library with an inconsistent naming of
identifiers.

One more point on the topic of consistent naming of identifiers. I find
the style with using different naming conventions for functions,
constants, variables, etc. very annoying. I _don't_ want to have to
worry if something is a function, constant or variable. Specially not
if it actually is an implementation dependent detail. So _please_ use
the same naming convention for all identifiers.

Jacob
--
"Any, sufficiently complicated, experiment is indistinguishable from
magic."

Jacob Sparre Andersen

unread,
Oct 20, 2003, 3:42:42 AM10/20/03
to
Jakob Bieling wrote:

> True, but it is still pretty annoying to type all kinds of variable
> names out

I suppose I should thank my mother for insisting that I learned how to
use a typewriter.

> To avoid misunderstandings, I do not approve using abbreviations for all
> kinds of variables. But I do find it acceptable to use my way of
> abbreviating (including comments) for function local variables.

Do non-local variables really exist? :-)

But yes, if you make sure that the declaration of the variables is
always immediately visible, when one is observing their use, then I can
understand your argument (although I still don't approve of it).

Jacob
--
"The current state of knowledge can be summarised thus:
In the beginning, there was nothing, which exploded."

Jacob Sparre Andersen

unread,
Oct 20, 2003, 3:44:31 AM10/20/03
to
Jakob Bieling wrote:

[ abbreviated identifier prefixes ]

> Not sure where I picked that habit up, but I guess it is pure laziness.
> I could not imagine having to type those long names everytime you use them.

Well. I tend to read code more often than I write it (even my own), and
most of my time is spent thinking about what to write, so saving a few
keystrokes really doesn't make sense to me.

> Especially counter variables in for-loops (posting from comp.lang.c++) ..
> you also use simple i's and j's etc. there, right?

No. (unless it is for matrix and tensor manipulation, where the
"documentation" actually says "i", "j" and "k")

> As you seem to be posting from comp.lang.ada,

Well. There and "comp.software-eng".

> I am not too sure if Ada provides such constructs in the
> same way C++ does, so maybe Ada has different means of looping in a
> for-loop-kind-of-way (yes, I know pretty much nothing about Ada).

The Ada for loop is not as flexible/error-prone as I remember the C++
for loop (which I haven't had to use for years :). A quick example:

for Day in Monday .. Friday loop
Put (Day); Put_Line (" is a workday.");
end loop;

(where I assume I have declared an enumerated type based on the days of
the week). The counter variable is created by the for loop statement,
so you don't have to worry about making an explicit declaration of a
variable for use as the counter. I seem to remember that you have to
have an explicit declaration of the counter variable in C++, which of
course makes a slight difference.

> Also, sometimes I tend to abbreviate quite a lot, so that later I might
> not know what it stands for.

Not good. That costs time and is a potential source for errors if you
misremember the meaning of the abbreviation.

> In cases like those I just put a comment next
> to where I declared the variable and I can keep saving those keystrokes.

I consider that a misuse of comments. I see comments as a means for
expressing what _can_ not be expressed in actual code. Otherwise you
risk ending up with code and comments that say different things. One
result of this view is of course that it differs from language to
language, what are reasonable comments.

My main worry with long identifier names is that they shouldn't make the
lines so long that they become incomprehensible.

Jacob
--
"There are only two types of data:
Data which has been backed up
Data which has not been lost - yet"

Wes Groleau

unread,
Oct 20, 2003, 9:08:06 PM10/20/03
to
Jacob Sparre Andersen wrote:

> James Dow Allen wrote:
>> abbreviate them as the first 4 (or whatever) letters, consistently.

So Bandshift should be abbreviated Band ?

Megahertz should be Mega, not MHz ?

Message should be Mess, not Msg ?

> I prefer the suggestion from the Ada style guide (IIRC) that you don't
> abbreviate words, and that you only use acronyms from a limited
> project-specific list.

And that list should be designed to include only
a limited number of items, using the abbreviation
that is already widely used in the problem domain.

(If no widely-used abbreviation exists, the item
should not be abbreviated.)

And the following practice is sad, but it does happen
in some places:

Problem: "Abbreviation is not on the approved list."
Solution: "Change the list; we're building TODAY."

--
Wes Groleau

Is it an on-line compliment to call someone a Net Wit ?

Stephen Baynes.

unread,
Oct 24, 2003, 7:55:18 AM10/24/03
to

"Jacob Sparre Andersen" <spa...@crs4.it> wrote in message

news:3F93925F...@crs4.it...


> Jakob Bieling wrote:
>
> [ abbreviated identifier prefixes ]
>
> > Not sure where I picked that habit up, but I guess it is pure
laziness.
> > I could not imagine having to type those long names everytime you use
them.
>
> Well. I tend to read code more often than I write it (even my own), and
> most of my time is spent thinking about what to write, so saving a few
> keystrokes really doesn't make sense to me.
>
> > Especially counter variables in for-loops (posting from comp.lang.c++)
..
> > you also use simple i's and j's etc. there, right?
>
> No. (unless it is for matrix and tensor manipulation, where the
> "documentation" actually says "i", "j" and "k")

To me the length of the name should reflect the size of the scope. A one
letter variable name is fine for the counter in a very short for loop, or a
temporary that is only used for a couple of adjacent statements. But if the
variable is used over many lines a longer more meaningful name is required.
Global variables tend to end up with the longest names as they have to be
used and understood in many more contexts.

Like all rules - there are exceptions. In particular if something is used
very frequently then a shorter name is desirable for convenience and
acceptable as it will be well known and understood. [eg 'stderr']

--

Gene Wirchenko

unread,
Oct 27, 2003, 8:16:36 PM10/27/03
to
On Fri, 03 Oct 2003 15:42:20 -0700, Peter Ammon
<peter...@rocketmail.com> wrote:

[snip]

>Agreed! I wish that more languages allowed hyphen use in identifiers.
>Dylan is the only one I can think of off the top of my head.

COBOL does.

Sincerely,

Gene Wirchenko

Oplec

unread,
Oct 27, 2003, 10:01:50 PM10/27/03
to
Gene Wirchenko wrote:

Is there a link to a document on ISO Studies of underscores... ?

Thanks, Oplec.

Dave Vandervies

unread,
Oct 27, 2003, 10:29:13 PM10/27/03
to
In article <fkgrpv0r6g82d4nh6...@4ax.com>,

As does Scheme, along with (if I'm not mistaken) most or all of the
other members of the Lisp family.


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca
Remember we're in a language where a misbehaving human can produce
quite a few kleenex-embedded demons.
--Chris Wolfe in comp.lang.c

0 new messages