GARTHWILSON wrote:
I totally, totally disagree (although I suppose it would be like arguing over what favorite color is best). In prose, the lines on the page exist because a book is more manageable than a mile-long ribbon with a lump here and there for pictures. In programming however, the separation into lines becomes very significant for visual factoring, and having ascenders and descenders (as lower-case does) blurs those divisions. Similarly, numerals 0-9 are always "capitals." Do not mix lower-case a-f into them in hEx nUmBErS! Write for example $3EA9, not $3ea9. Here on the forum where the non-code sections are in proportional spacing, when someone writes for example 3fff, in whatever font is used here, it initially looks like 3111 to me because the f's are so narrow. It's no harder to type capitals with the caps lock on. (I do take it off for comments.) If you feel like the computer is yelling at you, then turn the font size down. Easy enough.
I'm going to agree on uppercase for NUMBERS, but for code-text, I'm just not so sure.
The first problem, for me, is outright practicality.
Like others, I disabled my CAPS LOCK key long ago. It's the CTRL key on my keyboard (and no, I didn't swap it, all of my CTRL keys are CTRL keys, sometimes one is just not enough, especially when you have a drink in one hand, and a cat in another). Mind, this leads to interesting times when using other folks keyboards…c'est la vie.
The problem with CAPS LOCK though, is that it's just a hard MODE. You're IN CAPS or you're not. And having to move in and out of that, not per se within your Forth work, but just interacting with everything else. Your command line, the internet, your documents. At least for me, I'm going to be in the wrong mode, somewhere, all the time, and having to switch back and forth (heh), just kind of yucky. As a whole, we live in a lowercase world.
Secondly, though, I had a recent experience doing some code that had an unexpected benefit.
I do a lot (LOT) of Java, where everything is camelCase, and then you have all of the other shifty keys for the symbols and what not. So, in Java, you're shifting a lot. You're not conscious of it, but you are.
But recently, I coded up a bunch of Common Lisp.
Now, CL is case sensitive, and basically all done in UPPERCASE, but accepts lowercase text -- it simply upshifts symbols it during parsing. There's all sorts of options for this, you can make it case sensitive, but out of the box, it's uppercase, and most folks leave it that way.
Consider:
Code:
[4]> 'lowercase
LOWERCASE
[5]> (first '(one two three))
ONE
[6]> '|lowercase-symbol|
|lowercase-symbol|
[7]> "A mixed case String"
"A mixed case String"
It's not a straight conversion, it's contextual. The |..| are escape characters for the reader to turn off the conversion.
In Java, as I said, everything is camelCase. In C, historically, you use underscore_separators for identifiers. In CL, they use dash, so long-function-name.
What I found was how comfortable it was to code in Common Lisp. The elimination of the shift key from the bulk of the code was really relaxing.
Yes, you need the shift key for the (), but those these to come in groups (setf int-var (+ other-var (thing-value my-thing))) vs intVar = otherVar + myThing.getValue(). The first is 5 shift events, the latter is 7. Also, with the (), the shift key (done with my left hand) is not shared with the typing of the (), so no contortions, or stretching, etc. Old school Lispers map the () down to not use shift, there were dedicated keys on the original Lisp Machines.
Anyway, In the end, all of those shifts add up.
Now, CL has a lot of indentation, more so than idiomatic Forth. I can see your point about CAPS for code in Forth, but then I look at other code in CAPS, whether its CL, or looking at old UCSD Pascal.
Code:
PROCEDURE GETNEXTBLOCK;
BEGIN
CURRENTBLOCK := CURRENTBLOCK + 1;
IF CURRENTBLOCK > REFBLK THEN CURRENTBLOCK := 0;
IF BLOCKREAD(REFFILE,REFLIST^,1,CURRENTBLOCK) <> 1 THEN;
END (*GETNEXTBLOCK*) ;
(No, I can't explain the last IF statement with the empty THEN…, yes this is actual UCSD code...)
Frankly, that looks more impenetrable to me than
Code:
procedure getnextblock;
begin
currentblock := currentblock + 1;
if currentblock > refblk then currentblock := 0;
if blockread(reffile,reflist^,1,currentblock) <> 1 then;
end (*getnextblock*) ;
My eyes get lost in the CAPITALS, it's just a big run on of letters. It's not SHOUTING, it's just all run together. I can barely see the ( after BLOCKREAD.
This, I find a bit more accessible (but I do a lot of Java, again, so…)
Code:
procedure getNextBlock;
begin
currentBlock := currentBlock + 1;
if currentBlock > refBlk then currentBlock := 0;
if blockRead(refFile,refList^,1,currentBlock) <> 1 then;
end (*getNextBlock*) ;
But you have the camel case to catch the eye, and break things up. Even with just lowercase, the ascenders and descender break the text up -- make it more manageable (for me)
or:
Code:
procedure get_next_block;
begin
current_block := current_block + 1;
if current_block > ref_blk then current_block := 0;
if block_read(ref_file,ref_list^,1,current_block) <> 1 then;
end (*get_next_block*) ;
But, those are all shifted. It costs more than you think.
But this:
Code:
(defun get-next-block ()
(setf current-block (+ current-block 1))
(if (> current-block ref-blk)
(setf current-block 0))
(if (<> (block-read ref-file ref-list 1 current-block) 1)))
is similar, but it's far easier to type. It's surprising, it's only one less shift event. But, it is more comfortable. For me. And it also looks a bit better to my eye, because the dashes lighten it up, while still having a presence. The underscores actually get washed out and sometimes it's hard to tell if there's a '_' or just a ' ', depends on the what surrounds it.
Finally, there's:
Code:
(DEFUN GETNEXTBLOCK ()
(SETF CURRENTBLOCK (+ CURRENTBLOCK 1))
(IF (> CURRENTBLOCK REFBLK)
(SETF CURRENTBLOCK 0))
(IF (<> (BLOCKREAD REFFILE REFLIST 1 CURRENTBLOCK) 1)))
That's as bad as the original Pascal, I think.
Anyway, it was just surprising to find out much more comfortable for me typing in identifiers that look-like-this is.
And, please, no tired cracks about Lisp and parens -- that's completely unrelated to what this post is about.