7 ms·
> Why does gc disqualify a language as a system's language? AFAIK a "system programming language" should have deterministic performances, obviously Go hasn't.
by camus2 10y ago
> Why does gc disqualify a language as a system's language?
AFAIK a "system programming language" should have deterministic performances, obviously Go hasn't. But different people might define "systems" differently.
- vardump 10y agoI think Go should be pretty deterministic, if you don't allocate or free at all at runtime. Just like C. You lose determinism with malloc() and free(). As any embedded/kernel developer knows, malloc() takes often unacceptably long time. Or even free().
- sqeaky 10y agoGo does allocate and free at runtime, it just isn't explicit because its a garbage collected language and the garbage collector handles most of the freeing for you. Different GC'd languages handle allocations differently, some have a keyword, some do it whenever creating an instance of a type over a certain size. With C, C++ and Rust allocating memory often boils down to calling something equivalent to malloc and free. While the cost is not precisely known all modern OS provide guarantees are the time to execute relative to the size of the amount requested. This is almost always such a simple and fast operation that allocation is what gets optimized only after the algorithms and data structures have been tuned and this is a known bottleneck. Many application never get to the stage of optimizations (Games almost always do, stupid fixed time frame budget). Consider the amount of work the GC does and understand why any GC is generally considered no-deterministic: https://blog.golang.org/go15gc https://blog.golang.org/go15gc
- greenhouse_gas 10y agoDoes modern C++ or rust allow you to say "deallocate this pointer here" (like free or delete)? I was under the impression that Rust (and safe_ptr) deallocate at scope end, which could also cause framerate issues (unless you do ugly scope hacks). I do agree that you're unlikely to bump into this issue, though.
- dbaupp 10y agoYes, you can explicitly call drop ( https://doc.rust-lang.org/std/mem/fn.drop.html https://doc.rust-lang.org/std/mem/fn.drop.html ) in Rust, which just uses move semantics to force it out of scope. A similar function could be implemented in C++, and called like drop(std::move(value)).
- openasocket 10y agoWith Rust there is the drop() function in the standard library (which is just a no-op function that takes an owned value as an argument) which allows you to shorten the lifetime of the value without having to do ugly things with blocks.
- deleted 10y ago[deleted]
- sqeaky 10y agoThe are a couple of options in C++. You can just use delete, as you mentioned, it is a C++ only construct as far as I know. For the std library smart pointer, you can get their value (the raw pointer), delete that then assign nullptr to the smart pointer. I would consider this a code smell, and ask hard questions of the authors of such code. The simplest thing to do is to add new scopes. You can introduce as many blocks with { and } as you like. It is a common pattern to lock a mutex with a class that releases the mutex in its destructor (and acquired it in the constructor). The std library includes std::lock_guard[0]. To insure the smallest possible use of the lock a new scope can be introduce around just the critical section and the first line of the block can pass the mutex to the scope guard and it should be about as small and efficient as can be, while be exception safe and easy to write. Hopefully this is also easy to read. You can introduce new scopes with std::shared_ptr or std::unique_ptr as well. This seems common and reasonable. [0] - http://en.cppreference.com/w/cpp/thread/lock_guard http://en.cppreference.com/w/cpp/thread/lock_guard
- jeremyjh 10y agoThere are techniques used in GC languages to reduce or even eliminate runtime allocations. Basically - you re-reuse objects and pre-allocated collections rather than creating new ones. These techniques are common in games programming; and libraries like libgdx[0] (for Java) offer object pools to make this easier. I know some Java server applications use similar techniques. [0]https://github.com/libgdx/libgdx/wiki/Memory-management#object-pooling https://github.com/libgdx/libgdx/wiki/Memory-management#obje...
- deaddodo 10y agoThe people who define Go as a "systems language" use their own terribly useless definition of "systems language". Per wiki: "For historical reasons, some organizations use the term systems programmer to describe a job function which would be more accurately termed systems administrator." So for them, a language that can be used by DevOps Engineers is a systems language. While for sane developers, a systems language is one with deterministic attributes and the ability to be compiled to native code with no/a minimal runtime. I.e. one you can code "a system" in.
- mindcrime 10y agoI.e. one you can code "a system" in Yeah, but "a system" doesn't necessarily mean "an operating system". There are lots of kinds of systems. Most people I know, who I've talked about this with, consider middlware'ish development (think, message queuing systems, application servers, etc.) as an aspect of "systems programming".
- pjmlp 10y agoPeople have been writing OSes with GC enabled systems programming languages since the late 60's. Would you consider the employees of UK Royal Navy, Xerox PARC, ETHZ, DEC, Compaq, Microsoft as insane developers?
- greenhouse_gas 10y agoAlso, it depends on how you define an "OS". If you're in the GNU/BSD/Windows/MacOS camp (where init, ls, sh, cat, etc. Are part of the OS), you can have go (as well as java) in the OS.
- greenhouse_gas 10y agoAlso, does the Go standard "require" a mark+sweep? If you write an implementation which uses Reference Counting, it can be "deterministic" and won't require a runtime.
- openasocket 10y agoSure, but then you'll leak data every time there's cycles in your data structures.
- nialv7 10y agoI can have non-deterministic performance even when using C. Also if I use Boehm GC with C, does that disqualify C as system language?