Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal about GC #28689

Closed
johnlarfour opened this issue Nov 9, 2018 · 3 comments
Closed

Proposal about GC #28689

johnlarfour opened this issue Nov 9, 2018 · 3 comments

Comments

@johnlarfour
Copy link

@johnlarfour johnlarfour commented Nov 9, 2018

I'm a C programmer and I love Go. A very important feature that I think Go need is if you can use GC or not. I'll explain, GC it is useful in certain contexts but in other contexts no, for example in system programming. So I think for example one possible thing it could be "import GC" and you can code with GC, if you don't import GC you need to alloc the memory manualy. This would improve the language and also would leave a lot of freedom to developer's. In my dreams I would like to replace all my C programms with Go.

I rest avaiable to further clarifications.

@deanveloper

This comment has been minimized.

Copy link

@deanveloper deanveloper commented Nov 9, 2018

Perhaps it should be the other way around, I'd rather not break every existing Go program!

Also, while it's a good idea, Go doesn't make a distinction between pointers on the heap vs the stack, so you can't be entirely sure which memory you need to free and which ones you don't. Another confusion would be that "gc" also stands for "Go Compiler" (lowercase typically means Go compiler, uppercase means garbage collector)

On the other hand, I'd imagine that this would reduce the runtime size and speed up the program if you know what you're doing.

It'd also be weird to have libraries that have GC interacting with libraries that don't have GC. I feel like that'd complicate things a lot

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 9, 2018

Setting GOGC=off disables the garbage collector. You can use calls in the runtime package to force a manual garbage collection.

Go is not C. The garbage collector is an essential component of the language. At this stage of the language, what you propose would be an extremely invasive change which would go against the overall design choices made by the language.

@bradfitz

This comment has been minimized.

Copy link
Member

@bradfitz bradfitz commented Nov 9, 2018

Yeah, what @agnivade said. The design of Go assumes GC: the language, the APIs, etc. It can't be usefully turned off.

Sorry, but you might be looking for a different language.

@bradfitz bradfitz closed this Nov 9, 2018
@golang golang locked and limited conversation to collaborators Nov 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.