I don't like counting braces

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?

Indenting works for me, but I put the opening brace on a new line, I rarely get right across the page :-

function foo(x,y)
 {
    bar();
    baz();
    if (x>y)
       {
        xyzzy();
        thud();
       }
  squeak();
 }

of course I auto format before posting any code on the forum, or some people moan :slight_smile:

Like me. :wink:

Like all the Big 5 :slight_smile:

Are there any programming languages, even esoteric ones, that come right out and tell you the level of nesting?

I programmed a lot in [

occam

](occam (programming language) - Wikipedia), and it only uses the level of indentation to define blocks - no braces to count.

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.

AWOL:
I programmed a lot in [

occam

](occam (programming language) - Wikipedia), and it only uses the level of indentation to define blocks - no braces to count.

Did he also invent the razor. XD

AWOL:
I programmed a lot in [

occam

](occam (programming language) - Wikipedia), and it only uses the level of indentation to define blocks - no braces to count.

But still, you have to line up your indents just so, don't you? Again, unary.

Instead of (for example) 5 spaces, why not the numeral 5?

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?

You mean like back to BASIC? No thanks.

AWOL:

Instead of (for example) 5 spaces, why not the numeral 5?

You mean like back to BASIC? No thanks.

No, not like BASIC!
It's not a line number.

To give an analogy: which do you prefer:

x += 5;

or

x++; x++; x++; x++; x++;

The subject has come up before, and I can sort of picture colour coded braces ( or even the text between them )

To give an analogy: which do you prefer:

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.

It's like trying to communicate with someone where the length of the pauses between sentences has some hidden meaning.

  • .-. ..- . :slight_smile:

AWOL:

Are there any programming languages, even esoteric ones, that come right out and tell you the level of nesting?

I programmed a lot in [

occam

](occam (programming language) - Wikipedia), and it only uses the level of indentation to define blocks - no braces to count.

:astonished: You got to play with Transputers?

MAJOR Envy!

Boffin1:

It's like trying to communicate with someone where the length of the pauses between sentences has some hidden meaning.

  • .-. ..- . :slight_smile:

Neat chart for Morse Code:

You got to play with Transputers?

Play?

We had a 90 processor array at one point for real-time video processing - only ever built three of them.

Boffin1:
Indenting works for me, but I put the opening brace on a new line, I rarely get right across the page :-

function foo(x,y)

{
    bar();
    baz();
    if (x>y)
       {
        xyzzy();
        thud();
       }
  squeak();
}




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.

AWOL:

You got to play with Transputers?

Play?

We had a 90 processor array at one point for real-time video processing - only ever built three of them.

Back before 2000, anything I liked was play even if it was harder than chewing rocks.

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.

If I put my cursor over one brace the IDE puts a rectangle around the one it calls the match.

Please note that if you use state machine type code and keep the blocks small/short, you can usually avoid deep nesting altogether.