I find counting braces to be a pain.
Whether it be C-style braces, Lisp-style parentheses, or Python-style indents, the level of nesting is expressed in unary.
Are there any programming languages, even esoteric ones, that come right out and tell you the level of nesting? Where instead of:
function foo(x,y) {
bar();
baz();
if (x>y) {
xyzzy();
thud();
}
squeak();
}
you have:
0 function foo(x,y)
1 bar();
1 baz();
1 if (x>y)
2 xyzzy();
2 thud();
1 squeak;
At the very least, are there text editors which come right out and tell you, not just which brace matches a given brace, but how many braces deep you are?
Personally I don't like languages where whitespace means something. It's like trying to communicate with someone where the length of the pauses between sentences has some hidden meaning.
Personally I don't like languages where whitespace means something. It's like trying to communicate with someone where the length of the pauses between sentences has some hidden meaning.
I tend to agree, but the original development system for occam on the transputer (called TDS) used a folding editor that made visualisation very easy, which was useful, because the language allowed and encouraged nested function definitions.
When you're writing code and network configuration for tens of processors in a single compilation unit, it helped in managing the complexity.
Braces or Pascal-style "begin" and "end" would have bloated code unnecessarily - these were days when disk sizes were still in the tens of megabytes.
But still, you have to line up your indents just so, don't you?
No, you don't have to line up indents - the editor does it for you - in this case, constraint is a Good Thingtm
When you can have have one line of code running on one processor, and the next line running on a processor on the other side of the array, anything that can offload having to think too hard about how allowing you to concentrate on what is being done.
Instead of (for example) 5 spaces, why not the numeral 5?
The former, obviously, but littering a program with unnecessary characters is going to be confusing.
The eye is good at lining stuff up, not so good at rejecting clutter.
of course I auto format before posting any code on the forum, or some people moan :-)
I auto format early and often.
When I write a block I start by putting in both braces then going back up to fill. Or I try to remember when I'm not fixated on an idea that could slip away in a second.
if ( something )
{
}
becomes
if ( something )
{
whatever
}
Note also the whitespace around parenthesis. It's easier on the eyes which leads to slower burnout and fewer times confusing )) with 1) or )}. My eyes are so bad now I'm using 12 or 14-point font in the IDE (I forget which, it's probably 16 anyway) and 120% on the browser here.
Eyestrain makes head pain and that just slows me down.
I nearly got to play with Transputers, but the project never came to be. If I remember right there were Transputer boards you could plug into a PC and a development system. One thing I cannot get my head round is Quantum Computers and Qubits I wonder if I'll ever see one on a desktop?
I indent and line up braces vertically, but tend otherwise tend to avoid redundant whitespace - understand the eyesight problem though.
Editors that 'know' the language and automatically highlight comments etc. in different colors are a plus I think.