Slashdot Log In
C, Objective-C, C++... D! Future Or failure?
Posted by
Hemos
on Mon Apr 19, 2004 08:03 AM
from the yet-another-programm-language dept.
from the yet-another-programm-language dept.
TDRighteo writes "OSNews is carrying a quick introduction to a programming language under development - D. Features include garbage collection, overrideable operators, full C compatibility, native compilation, inline assembler, and in-built support for unit testing and "Design by Contract". With all the discussion about the future of GNOME with Java/Mono, does D offer hope of a middle-road? Check out the comparison sheet."
Related Stories
[+]
The D Programming Language, Version 1.0 570 comments
penguinblotter writes in a journal article: "Soon, Walter Bright is scheduled to release version 1.0 of the D Programming Language. D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, documentation, management, portability and reliability. D has appeared on Slashdot a few times before, and Walter has continued to add more and more features. Most Slashdot community comments in these articles have been offered on feature X or spec Y without reading through the extensive D newsgroup archives. It has been here over the past seven years where extremely gifted and experienced programmers hashed out discussions and arrived at excellent implementations of all the ideas discussed." Read on for the rest of penguinblotter's writeup.
This discussion has been archived.
No new comments can be posted.
C, Objective-C, C++... D! Future Or failure?
|
Log In/Create an Account
| Top
| 791 comments
(Spill at 50!) | Index Only
| Search Discussion
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
|
2
wow (Score:5, Funny)
(http://en.wikipedia.org/wiki/User:Spangineer)
Oh, wait...
Re:wow (Score:4, Informative)
(http://llimllib.f2o.org/)
Re:wow (Score:5, Insightful)
(Last Journal: Friday June 11 2004, @11:15AM)
For the pedantic - I consider this post to be about the zlxrt language.
Here's one (Score:4, Funny)
(http://slashdot.org/)
How about "Double-D"? *That* will bring out the programmers in hordes.
Re:wow (Score:5, Funny)
(http://www.karmadillo.org/)
You guys are all behind the times. I'm already on E!
Yeah - turn up that thumping music man!!!
Re:wow (Score:5, Informative)
(Last Journal: Wednesday November 28, @05:59AM)
Re:wow (Score:4, Informative)
(http://www.negativenumber.com/jorkapp)
It was essentially BCPL stripped of anything Thompson felt he could do without, in order to fit it on very small computers, and with some changes to suit Thomson's tastes (mostly along the lines of reducing the number of non-whitespace characters in a typical program).
According to Ken, B was greatly influenced by BCPL, but the name B had nothing to do with BCPL. B was in fact a revision of an earlier language, bon, named after Ken Thompson's wife, Bonnie.
Microsoft will come out with it's own version (Score:5, Funny)
(http://slashdot.org/)
Re:Microsoft will come out with it's own version (Score:4, Funny)
(http://slashdot.org/~T-Kir)
Or instead of sharp, use the hash orientation and you could have D-bong... mind you'd have to be on drugs to be able to use it though ;-)
Re:Microsoft will come out with it's own version (Score:5, Funny)
(http://www.security-forums.com/)
Cue loads of VD jokes
Re:Microsoft will come out with it's own version (Score:5, Funny)
(Last Journal: Thursday February 24 2005, @11:27AM)
Re:Microsoft will come out with it's own version (Score:5, Funny)
(Last Journal: Thursday June 05 2003, @09:57AM)
Re:Microsoft will come out with it's own version (Score:5, Funny)
full C compatability? (Score:4, Interesting)
(http://www.beegle.org/)
In "small program" languages like perl, giving people lots of ways to do things is a feature. In a "large program" language, providing both C compatability and garbage collection is a maintainability nightmare. You'll have people who use both, or worse yet, who only understand one, so to understand the mixed code that results from a hybrid langage like this, you'll have to be utterly proficient with -both- languages.
Re:full C compatability? (Score:4, Insightful)
I wish the article actually compared to objective-c, as the story's poster seemed to imply...
Re:full C compatability? (Score:5, Informative)
Re:full C compatability? (Score:5, Insightful)
(http://www.int64.org/)
Because it's not handled by D's garbage collection, it still needs to be freed. I'm sure this will make those developers who love to leak memory even worse.
Re:full C compatability? (Score:5, Insightful)
It happens a lot. I've seen a few expensive C-based libraries that clearly show their designers struggled with the classic caller-callee allocation dillema and lost. Debugging memory leaks in programs that use these libraries is typically hopeless and requires high effort-versus-progress computationally-expensive run-time checks to find them. I like C quite a bit, but it is disheartening to see such a simple malloc() function cause so much pain.
Re:full C compatability? (Score:5, Interesting)
(http://iabervon.org/~barkalow/ | Last Journal: Saturday May 31 2003, @02:01AM)
One thing I'd really like to see in Java is Object.free(), which would tell the garbage collector that the object is garbage and can be freed, and cause any further use of the object to throw a FreedMemoryException. This would be useful both as a hint to the system (letting it get rid of things the object references early) and as a debugging aid (so you can find cases where stuff remains in use after you don't think it will). Of course, it violates Java's sandbox design to have a C-style free() which recycles the address space.
Re:full C compatability? (Score:5, Insightful)
Just about anything you need, there's a C library for it.
Think nice things like opengl,pam,openssl,GUI librairies, database
libraries, and heaps more.
Having access to those is very nice, and you don't have to wait anyone
to port those to a new language(which probably won't happen anyway.)
I'd imagine how far C++ had gotten if it couldn't use C libraries..
Don't need to imagine -- it was the whole point (Score:5, Informative)
(http://www.devphil.com/)
Stroustrup is on record many times over as saying that link compatibility with some existing language was a design criterion for him. If not C, then something else.
It is an axiom in the C++ community that compatibility with C is both C++'s greatest strength and its greatest weakness.
Re:full C compatability? (Score:5, Insightful)
(Last Journal: Sunday April 16 2006, @10:03PM)
For those of us who don't like unpredictable...
pauses...
in our programs while the garbage collector does its work, will we be able to turn off garbage collection entirely or run the garbage collector only at specified times?
directly, them you're a good enough programmer to ensure that you've called for each new. And with std::auto_ptr, it's as easy as How much simpler does it need to be?I'll answer my own question: even if this is possible, if D ever becomes a serious language, we will be using libraries written by other people, libraries that do rely on garbage collection.
So, no, we won't (realistically) be able to turn off the garbage collector, which means that we won't be able to write real-time programs, and it'll even be touchy writing programs, such as, oh, audio or video players, that require near real-time performance. (Not to mention the disappointment we all felt with the various java window-widget APIs (AWT, Swing) that looked great but couldn't run fast enough to respond to the mouse.)
Look folks, taking care of your own garbage wasn't possible in C for a library writer (even ones returning opaque pointers to structs that allocated their own memory) because you had to rely on the library user to call your cleanup function(s).
But the library user could clean-up. The problem was essentially that some programs didn't care enough to be careful -- pointers actually had to be tracked.
Now, it's fine if a library user wants to add on a garbage collector by re-writing malloc to track allocations. But libraries, which are intended to be used by lots of programmers, to write code, and by lots and lots of end users who run code should not use garbage collectors themselves -- because that forces the library user to use garbage collection too.
But in C++, library writers can write libraries that take care of their own garbage even when used by careless users, because the compiler will automatically call class destructors which can do clean-up. (Yes, except in the case of derived classes -- the writer of the derived class has to explicitly write a dtor to ensure the parent class dtor is called.)
And in C++, with the Standard Template Library, there's little need for non-library writers to do explicit allocation at all -- std::vector and std::string and std::auto_ptr, just by themselves, take care of most of the problems of memory leaks and buffer overruns.
If you're using C++ and you feel that you're a good enough programmer that there's real need for you to be calling
So why complicate things with garbage collector and tracking down circular references and unpredictable pauses? Garbage collection is a bad answer for non-trivial programs, and pretty much necessary for trivial programs.
Re:full C compatability? (Score:5, Insightful)
(http://www.winsper.org.uk/)
Re:full C compatability? (Score:4, Interesting)
Re:full C compatability? (Score:5, Informative)
(Last Journal: Sunday April 16 2006, @10:03PM)
My point was that to avoid the problem of circular references, the garbage collector does have to be more sophisticated, and sophistication takes time and (memory) space -- time and space that a program may or may not be able to spare.
"for very many applications modern garbage collectors provide pause times that are completely compatible with human interaction. Pause times below 1/10th of a second are often the case,"
Pause times below 1/10th of a second? Hmm, how much below? TV-quality video is 24 frames per second, so a one-tenth second pause means dropping two or three frames. Acceptable? Perhaps, but not desirable.
"Does garbage collection cause my program's execution to pause? Not necessarily."
Yes, if you read my post carefully -- perhaps you missed a word or two when the garbage collector in your head did some clean-up -- I didn't say that pauses were inevitable. My complaint -- and not just mine, it's no revelation that garbage collection has may detractors -- is that the pauses are not predictable by writer of the program.
With non-garbage collected language, I know that memory allocation will either succeed ort fail, and I know (or a library writer knew) when allocation happens, because I'm explicitly coding it. So I know, at this particular point in my program, either allocation succeeded or failed.
But garbage collection can happen at any time, and cause a pause at any point in my program -- even when I'm needing to re-fill under-run buffers or read volatile memory or make time-critical choices. With garbage collection, I no longer have an algorithmic program, in which I can say what it's doing at any particular point in the code.
Then come back and make some informed comments, instead of spouting nonsense. Thank you.
That overly hostile arrogance suggests you're either a zealot or a fourteen year-old. That sort of blustering generally indicates someone who isn't that confident in himself or his argument, and so wishes to preempt questioning by being a posturing like a "tough guy"; it's particularly prevalent on the net -- though I'll grant that you didn't hide behind an Anonymous Coward post. Adults can disagree and discuss things without resorting to insults and attitude -- and I think you'll be able to do that too, with a little more experience.
Re:full C compatability? (Score:5, Informative)
No it doesn't. Handling of circuler references falls naturally out of most GC algorithms. One of the simplest possible memory algorithms is the mark & compact GC, which handles circuler references naturally.
Pause times below 1/10th of a second? Hmm, how much below? TV-quality video is 24 frames per second, so a one-tenth second pause means dropping two or three frames.
You disable the GC in those cases. A good GC will give you the option to manually manage memory in certain cases (say, through a pool allocator), so in any time-sensitive paths, you can disable the GC and rely on those other options. There are also real-time GC's that have absolutely bounded pause times.
But garbage collection can happen at any time, and cause a pause at any point in my program -- even when I'm needing to re-fill under-run buffers or read volatile memory or make time-critical choices.
You do realize that you have this issue with any modern OS? A malloc() can take tens of thousands of clock-cycles if it decides to mmap() to get more backing memory, and the kernel decides to block the app.
Re:full C compatability? (Score:4, Informative)
(http://shapedwaves.blogspot.com/)
Then again, malloc needs sophistication as well, and can be every bit as slow as a good garbage collector. Indeed, even garbage collectors for C (try google with "garbage collector") can outperform the regular glibc malloc sometimes, even when there is NO reference counting involved. Which btw is another issue, reference counting + malloc pretty much combining the bad (and slow) things from both worlds.
Pause times below 1/10th of a second? Hmm, how much below? TV-quality video is 24 frames per second, so a one-tenth second pause means dropping two or three frames. Acceptable? Perhaps, but not desirable.
Such pausetime on a machine capable of playing TV-quality video in the first place indicate an awful garbage-collector. Even a stop-and-copy shouldn't take that much time, and these days we have generational collectors which only bother with the "youngest" stuff, that is, stuff most likely garbage. And you can make that incremental, it's not even very hard, and you can then slice the "pause" into almost as small parts as you want. There are collectors which provide real-time guarantees. Mallocs usually don't.
With non-garbage collected language, I know that memory allocation will either succeed ort fail, and I know (or a library writer knew) when allocation happens, because I'm explicitly coding it. So I know, at this particular point in my program, either allocation succeeded or failed.
Except this isn't necessarily true either. One example is Linux, which doesn't guarantee that there is memory left, because memory isn't allocated when you map pages, but when you touch them first time. If you allocate memory, and there's not enough free virtual memory to fill in the pages when you actually need them first time, then OOMkiller is called. Speaking of which, unless you lock (all) pages into memory, you won't know whether there'll be pauses anyway, since that memory of yours might just as well be a block of hard-drive space. Welcome to the world of virtual memory. Guess already which pause takes longer, a call to an incremental collector or the swap-in? Oh, and do you have a deterministic thread scheduler in your OS?
Finally, if you have an incremental collector (designed for this) you could run it with priority lower than your "real-time" tasks, and you could then collect only when the processor would be idle otherwise. Dijkstra's classical tri-coloring was actually developed for a scenario where there is one processor for running the task (mutator) and another for collecting the heap (collector). That you didn't think of this pretty much proves you've got no idea about garbage collectors.
Just because there are bad collectors doesn't mean they all are bad. And even stock solutions, over are the days when Lisp machines hanged for hours to collect their memory. Unless you are running the CPU at 100% all the time, you'll have plenty of time to collect.
Old news (Score:4, Interesting)
(http://www.intelligentblogger.com/ | Last Journal: Monday August 27, @11:47AM)
2. Java and
3. If a new popular language does come on the scene, you won't notice it until it has nearly taken over the world. Oh, and developers will love it so much they'll drop everything else (like what happened with Java).
Re:Old news (Score:4, Interesting)
(http://fforw.de/)
Java is successfull because:
- it offers a nice abstraction for system specific issues which is only seldomly leaky [joelonsoftware.com].
-
you can dive into an unknown project, select a random source file and understand it. You may have problems getting the big picture, but the code itself is there - there are no suprises like operator overloading, defines etc. All you need to know about the class is in it (and it's superclass and interfaces)
-
its complex enough to do some magic in it, but the idiot next cubicle can't run totally amok and wreck the whole system.
IMHO all these reasons are more important than for Java's success than hype.Obligatory java response... (Score:5, Informative)
Re:Obligatory java response... (Score:5, Informative)
That's because 1.4 is the CURRENT version (Score:4, Informative)
Well, since 1.5 is still in beta [sun.com] , I don't see how this is an invalid comparison.
Re:That's because 1.4 is the CURRENT version (Score:4, Insightful)
(http://fforw.de/)
Re:Obligatory java response... (Score:4, Insightful)
(Last Journal: Sunday April 16 2006, @09:28PM)
Templates.... great. It's like C++, but it's not.
Sounds like a good idea (Score:5, Insightful)
However, I it is doubful it will gain a foothold in the current ocean of multiple, semi-specialized languages.