User: Password:
|
|
Subscribe / Log in / New account

Since you asked

Since you asked

Posted Oct 26, 2012 21:06 UTC (Fri) by ncm (subscriber, #165)
In reply to: No thanks. by cyanit
Parent article: Haley: We're doing an ARM64 OpenJDK port!

A "mainstream, fast strong-typed garbage-collected language"?

C++, for the present.

Not garbage-collected, you say? If what you want from a garbage-collected language is no "delete" statements, you already have that. It's entirely possible -- indeed, recommended -- to write large systems in C++ with no delete statements at all. The standard library provides all you need, starting with smart pointers. (Technically, smart-pointer implementations have delete statements, but you never need to see them.) Other libraries provide database handles, transactions, windows, and what-have-you.

If you know what you're about, you don't really want garbage-collection anyway, because it interacts badly with destructors. Without destructors, exceptions lose most of their value. The whole point of exceptions is so you don't have to hand-write exception-handling code everywhere. Besides being tedious, scattered exception-handling code, whether in catch blocks or under "if (rc)", is poorly exercised, so often buggy. It's better to collect up exceptions at subsystem boundaries with all the local cleanup already done. Destructors do that cleanup. They get exercised all the time, so you can trust them. Most of your what your destructors do, such as rolling back transactions, closing files, and freeing memory, is generated by the compiler from library code, so you never see it, and it's right every time. Memory management comes for free.

The Glorious Successor to C++, whatever it turns out to be, will also not need garbage collection.


(Log in to post comments)

Since you asked

Posted Oct 26, 2012 21:26 UTC (Fri) by Jandar (subscriber, #85683) [Link]

If there are pointer-cycles in the data-structures you have to be *very* careful or nothing can be freed in c++. I'm a fan of c++ and think it's the best of the bunch of similar languages like java or go, but to say it's easy to write without delete and gc is unrealistic. This considered I'm rather careful and have a deterministic behavior than rely on a kind of magic behind the scene. E.g. managing resources with RAII is pleasant.

Since you asked

Posted Oct 26, 2012 23:01 UTC (Fri) by ncm (subscriber, #165) [Link]

This cycle detection problem is always trotted out, but it never seems to happen in real programs. (Anyway it's never happened to me.) The corresponding problem in GC systems, of stale pointers to garbage preventing collection, is responsible for uncounted exabytes of leaked memory at any moment, and for my browser running no faster than Netscape on a 486.

The world needs a systems-programming language as powerful as C++, but without the cruft. (Cruft being the C type system, and failed experiments like exception checking and virtual functions.) It is unfortunate that current efforts at language design are almost always contaminated with CONSes. A sign of the strength of a language design is that library components do what had to be built into weaker languages. Virtual function support should be a library facility in the Glorious Successor to C++.

Since you asked

Posted Oct 27, 2012 6:43 UTC (Sat) by Cyberax (✭ supporter ✭, #52523) [Link]

Cycles happen all the time in any non-trivial program. In fact, a lot of non-trivial C++ programs now contain some form of cycle detection (Firefox, Chrome) or GC (gcc).

Since you asked

Posted Oct 28, 2012 16:32 UTC (Sun) by nix (subscriber, #2304) [Link]

OK. I have to ask... 'contaminated with CONSes'? Presumably this isn't a reference to Lisp, so what is it?


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds