golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.63k stars 17.61k forks source link

Proposal: Add options in editor to allow visually replace {} brackets with indentation only and vice versa #69967

Closed Liebenfiels closed 4 hours ago

Liebenfiels commented 4 hours ago

Go Programming Experience

Novice

Other Languages Experience

Python, BASIC- learning

Related Idea

Has this idea, or one like it, been proposed before?

NO

Does this affect error handling?

Should not as cosmetic visual fix only

Is this about generics?

Yes- about editor to match Python indentation

Proposal

I started learning programming last year... old school with '86 BASIC2 (GEM2 on 5.25" 360kb floppy) on 1986 8 MHz computer then 1991 QBASIC on 40 MHz PC386. Made QBASIC .exe functioning program and outcompeted Bing AI on math with both verions of programs. 1991 QBASIC had automatic formatting of text... n=1 would give n = 1 when Enter was pressed and applied to all.

No modern Visual Code has it or Python IDLE shell can do it- we moved backwards 30 years. BASIC syntax was clear, lots of good books (QBASIC by Example) teaching programming Foundation. I am learning Python since April 2024- both Python and BASIC have best syntax, hence Python takes lead. The Classes I don’t like- good it was dropped in GO.

The curly brackets I consider visual noise in all languages- they are not needed in modern times. When typying, brain gets used to indentation quickly and VC creates vertical lines anyway to know what is where. To bring back simplicity, the GO Environment should have option to auto hide brackets and replace with indentation or allow to type with indentation only (and auto create {} in the background- visually they not needed), option either type that or that. Auto convert instantly.

You would get more people from Python using Go- and it is good language but {} are no go for me. It is just noise.

This is example from W3School tutorial: ugly GO looking code, more complex code and you end up with too many brackets adding more lines of code, and time needed for brain to comprehend it, which is for what part. These {} old school way should be eventually dropped while compiler still recognize it on old code, but allow to type modern way and instantly convert to curly brackets if needed to review, for those that prefer it.

package main
import ("fmt")

func main() { 
  for i:=0; i < 5; i++ {
    fmt.Println(i)
  }
}

package main
import ("fmt")

func main() {
  temperature := 14
  if (temperature > 15) {
    fmt.Println("It is warm out there")
  } else {
    fmt.Println("It is cold out there")
  }
}

In Python it is triumph of simplicity, clean code and it was easier in BASIC compared to GO:

for i in range(5):
    print(i)

temperature = 14

if temperature > 15:
    print("It is warm out there")
else:
    print("It is cold out there")

There need to be some standardisation and I would say Python solved it the best. Regards Michal

Language Spec Changes

Applies to Editor only, environment code is typed

Informal Change

No response

Is this change backward compatible?

YES

Orthogonality: How does this change interact or overlap with existing features?

No response

Would this change make Go easier or harder to learn, and why?

Easier for Python developers

Cost Description

No response

Changes to Go ToolChain

No response

Performance Costs

No response

Prototype

No response

gabyhelp commented 4 hours ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Liebenfiels commented 4 hours ago

My proposal is about option to change in Editor as per user choice and convert if needed, not to get rid per say. Like you have options to change colors etc, but I would go for auto-formating and option to type with indentation and live convert instantly - should not time delay

seankhliao commented 4 hours ago

This looks like a proposal for an editor config setting, not something for the Go project.

Liebenfiels commented 4 hours ago

GO community could test it and start with their GO environment to get more adoption- so it is GO language related indeed.

ianlancetaylor commented 4 hours ago

It is Go related, but as the Go project does not provide an editor, this is not something that the Go project can fix. Opening an issue in this issue tracker is unhelpful, as we won't be able to make any progress on it. We don't use the issue tracker for general projects; we use it for things that we can fix. Thanks.