r/ProgrammingLanguages • u/ebol4anthr4x • 4h ago
Go with manual memory management / no garbage collector?
Go is my ideal programming language, except for there being no ergonomic way to work without the garbage collector (to my knowledge). Is there a language that has the simplicity and elegance of Go, but without a garbage collector?
Some big pros for Go in no particular order:
- dead simple cross-compilation
- first-class support for unit testing
- quick builds
- first-class support for debugging and profiling
- goroutines and channels are extremely ergonomic primitives for concurrency
A con for Go:
- the runtime is pretty hefty and results in large binaries.
Zig is the closest thing I have found, though I do find the build system a little complex. Profiling is do-able, though not great; the best way I've found is to use Tracy.
I am not a fan of Rust's syntax and am not able to develop at the speed of thought like I can with Go. This is definitely a skill issue but Rust just doesn't feel very ergonomic to me.
Odin is a strong contender. For profiling, Tracy seems to be the best option again, which isn't ideal. An allocator stored in context is exactly what I wish Go had. The syntax leaves something to be desired for me.
I need to look more into C3.
Any other languages I've missed?
8
u/SilvernClaws 4h ago edited 4h ago
Odin is pretty much the closest you'll get to Go syntax wise.
V is also pretty close in many aspects and has manual memory management in theory. Unfortunately the language is basically built around lying about how it manages memory and a bunch of other issues, so your mileage may vary.
C3 and Zig are both great options, but both not exactly similar to Go. It takes a while for Zig's build system to click, but then it gets much better. It's not declarative, you're basically building a graph of dependencies and steps programatically. Which other build tools also do, just not as explicitly.
6
u/vmcrash 4h ago
What exactly do you want to improve by removing the GC? Is Go too slow for your project? Do you notice some delays caused by the GC?
3
u/ProgrammingLanguager 1h ago
What are you looking for in a language, exactly? Why do you want full memory control?
Zig and Odin are, generally speaking, languages made for someone who has spent years writing C or C++. Zig, which is the language I have more experience with, is indeed simple and very flexible - much of its modernity derives straightforwardly from an intuitive extension of a const context to metaprogramming. Any language with significant metaprogramming faculties (especially, arbitrary compile time code execution) is going to get slow in larger projects utilizing them - although the tradeoff Zig takes for its implementation generally results in far better compilation times than rust's proc-macros. LLVM is a constant across both.
To make a wider point though - there is a reason the systems languages most often adopted by higher level programmers are often as complex as C++ and rust. Getting close to emulating the power of a GC (with its power to arbitrary derail execution at any point, etc) at compile time and/or with RTS-friendly dynamics is a hard problem! In some cases, it is better left to the user, but once your project gets large enough the burden of managing this will prevent you from "speed of thought" programming if you lack experience in the area (apologies if I'm making an undue assumption on that).
For simplicity and speed of thought writing, where you don't /need/ full manual memory management, languages like Nim or Swift, which borrow only the simplest of rust's tricks (move semantics and optimisations) and combine them with nicely abstracted reference counting via ARC, might be the better choice. You'll get good memory usage, tiny binaries, and predictable performance characteristics, while the source code can remain at a a level of abstraction and simplicity comparable to Go. This also applies to third party high performance/low footprint/embedded focused implementations of other, simple GC languages
8
u/coderemover 4h ago edited 4h ago
The language you’re looking for is Rust, don’t judge it by the syntax. Syntax is a very subjective thing and don’t get fooled by the number of keywords. Using a dedicated keyword for e.g. controlling visibility is not any more complex than using capital / small letters or underscores.
3
u/potzko2552 3h ago
You are looking for Odin i think. But id give rust a try first
2
u/tandycake 4h ago
Another choice would be Jai.
Odin and C3 are great options though.
However, all 3 of these are lacking in a good desktop GUI framework. If you're more into games, CLI apps, and/or immediate-mode GUIs, then no problem.
1
u/Glittering_Gur5701 1h ago
C with something like libtask
1
u/kanareyka 12m ago
Hare might fit
1
u/Rigamortus2005 3h ago
Odin