Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Java IT Technology

C, Objective-C, C++... D! Future Or failure? 791

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."
This discussion has been archived. No new comments can be posted.

C, Objective-C, C++... D! Future Or failure?

Comments Filter:
  • by mogrinz ( 548098 ) on Monday April 19, 2004 @09:10AM (#8903364)
    Looking at that comparison table, it's clear the author hasn't looked at Java since 1.4
  • D @ Google (Score:5, Informative)

    by Jugalator ( 259273 ) on Monday April 19, 2004 @09:11AM (#8903379) Journal
    Don't miss Google Directory if you're looking for more D info:
    Computers > Programming > Languages > D [google.com]

    New programming languages are interesting, and sometimes I wonder what the next "big thing" will be. Will we have another big, revolutionizing, new concept like "object-oriented programming" that you simply must know in a near future?
  • Summary (Score:5, Informative)

    by TheJavaGuy ( 725547 ) on Monday April 19, 2004 @09:11AM (#8903381) Homepage
    D drops archaic C++ features like the preprocessor and forward declarations. It adds modern features like design by contract, unit testing, true modules, automatic memory management, first class arrays, closures, and a reengineered template syntax. D retains C++'s ability to do low level coding, and adds to it with support for an integrated inline assembler. C++ multiple inheritance is replaced by single inheritance with interfaces. D's declaration, statement and expression syntax closely matches C++.
  • by Elbows ( 208758 ) on Monday April 19, 2004 @09:17AM (#8903431)
    Actually, the post was a bit misleading -- D only provides *link* compatibility with C. You can link to C libraries without any trouble, but you can't compile C source code in the D compiler.
  • by Nasarius ( 593729 ) on Monday April 19, 2004 @09:18AM (#8903438)
    I'm as excited about the new syntactic sugar in 1.5 as the next guy, but it *is* still in beta, and therefore not quite part of the "official" language. I for one can't and won't use the new features until there's a stable 1.5 JDK.
  • Comment removed (Score:4, Informative)

    by account_deleted ( 4530225 ) on Monday April 19, 2004 @09:21AM (#8903451)
    Comment removed based on user account deletion
  • by Anonymous Coward on Monday April 19, 2004 @09:38AM (#8903574)
    Catching a NULL value, a -1, 0, 1, 89, -999, -5000 or any of the other 4+ billion possibilities can only convey so much information and in the end you're still left guessing as to what really went wrong. Exceptions, on the other hand, automatically relay this information.

    In .NET specifically each Exception contains the description, a full stack trace back to the source of the error (if you compile with debugging the line number is included) and any exceptions that may have resulted in that exception being thrown. As such I have a detailed account of what went wrong so that I can address it specifically.

    Furthermore, at least in .NET, there are several ways to catch exceptions that were not explicitly caught by the code in a try...catch...finally block. I could marshal all unhandled exceptions to a function that logs the error in a file, shoots out a detailed error message with full stack and state information over SMTP, explains the problem to the user in laymen's terms and then returns the application to an idle state.
  • Re:Toss out C. (Score:3, Informative)

    by endx7 ( 706884 ) on Monday April 19, 2004 @09:40AM (#8903604) Homepage Journal

    Guys, it's time to face the facts. C is a relic from a time when compilers were stupid. Declare all your variables before executing code, declare all your functions before using them, include headers that almost invariably break one another, hurrah.

    I'm so glad that every time I write C I get to write each function signature several times, that's lovely. In addition, C takes much more time to compoile than Java/C# because all the stupid headers take forever to parse.

    What will you use for your low level device drivers? Or how about that code that needs run fast? I don't know about compile (C does compile faster than C++ though), but C runs faster than java and C# (only -sure- about the first one). In fact, the java virtual machine and compiler are both written in C. Face it, C isn't dead yet, even though people have been trying to say so for years.

    So, in conclusion, C compatibility is a bug, not a feature.

    Other posts have mentioned this is -link- compatibility. Remember, D is meant to live in the real world as a binary outside of a vm. Link compatibility becomes a pretty damn useful thing when you need to work with other people's libraries.

  • Re:Toss out C. (Score:2, Informative)

    by St. Alfonso ( 671334 ) on Monday April 19, 2004 @09:49AM (#8903699)
    OK, let's take your advice. No more C. Goodbye Unix - OS kernel written in C. Goodbye interpreted languages like Perl, that have their interpreter written in C. Goodbye device drivers. Most of these are written in C. Have fun re-writing all these things in D/Java/whatever.
  • Re:Old news (Score:1, Informative)

    by Eagle5596 ( 575899 ) <slashUser AT 5596 DOT org> on Monday April 19, 2004 @09:52AM (#8903720)
    Do you even know what you are talking about? C/C++ has all the error recovery facilities of Java, and has had them for quite a while now. All Java offers is a cross platform unstable graphics suite, and a set of annoying libraries, and bad object oriented design (Main should not be an object).
  • Checking return values is a horrible use for exceptions. Exceptions are for critical but recoverable errors. "Normal" error conditions shouldn't throw exceptions, not least of which because it makes the code so much nastier and twisting to deal with it. Exceptions are great and allow you to do a type of error handling that would be impossible without them, but I think that some C++ (and especially Java) people get far to enamored of them.
  • by Trejkaz ( 615352 ) on Monday April 19, 2004 @10:00AM (#8903788) Homepage

    Troll away, maybe people will start paying attention when the dozens of useful Java libraries are available from C#. *shrug*

    What I really need right now though is a nice, clean looking language with access to well-thought-out libraries for image loading/saving and virtual filesystem access. I can't find any of this stuff in a portable form other than on Java, unfortunately. :-(

  • by Haeleth ( 414428 ) on Monday April 19, 2004 @10:02AM (#8903805) Journal
    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.)

    Yeah, nice FUD. Java is slow because it's bytecode, not because it's garbage collected. (Incidentally, all the Swing applications I've used recently have been every bit as responsive as I could desire, so it isn't even necessarily slow.)

    So why complicate things with garbage collector and tracking down circular references...

    BOOM! And you reveal that you don't know what you're talking about. Circular references are irrelevant to any GC scheme more sophisticated than reference counting. They simply have nothing to do with it.

    I suggest you read this [iecc.com]. Pay particular attention to the bits that explain things like "Modern garbage collectors appear to run as quickly as manual storage allocators (malloc/free or new/delete)," and "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," and "Does garbage collection cause my program's execution to pause? Not necessarily.".

    Then come back and make some informed comments, instead of spouting nonsense. Thank you.
  • by PhrostyMcByte ( 589271 ) <phrosty@gmail.com> on Monday April 19, 2004 @10:03AM (#8903816) Homepage
    std::auto_ptr is good but rather limited if you want to use the pointer in various locations at the same time. boost's shared_ptr is very nice for this.
  • by bradkittenbrink ( 608877 ) on Monday April 19, 2004 @10:08AM (#8903850) Homepage Journal
    I didn't find how it deals with endianness specifically, but the idea is that D replaces a text-only preprocessor with actual sybolic features of the language. They definitely have support for conditional compilation and inline assembly code so I'm sure you could do whatever you need to handle endianness without a text-based preprocessor. The preprocessor itself isn't necessarily archaic, it's just unneccesary if your language isn't archaic.
  • by 21chrisp ( 757902 ) on Monday April 19, 2004 @10:09AM (#8903854)
    It's seems that a lot of people are complaining about something that was seriously mis-reported. D CAN'T COMPILE C CODE!! (Sorry for shouting.. but I'm hoping to get peoples' attention). D can link to C binary code.. wow.. what a concept.. almost every programming language can do this. It's almost a requirement for any new language. Without it you would start with 0 code base, and no one will use it. The below text is taken directly from the article. Notice 'Binary Compatibility' and 'Link Compatible.'

    Binary C Compatibility:
    D programs can import and link against C code and libraries, providing D with free access to a huge amount of pre-written code. Note, however, that D is not link-compatible with C++, so pure C wrappers are required to access C++ code in D.


    Personally, I've been praying for years for a language like this to get adopted. Why is it that I can only use full object oriented programming for web/network applications?! Sure.. I know you can do more than this with Java or C#, but is it really practical?? Usually it's just a massive drain on resources. If you need high performance, then you can't do better than C++. Unfortunately, C++ is a transitional language (just look at it's name..). A pure object oriented, fully compilable language that has no VM is desperately needed. I can't believe it's 2004, and such a thing still hasn't been adopted. I hope D (or something like it catches on.. As much as I loved it when it first came out, I'm sick of wrestling with C++ code.
  • by WWE-TicK ( 593858 ) on Monday April 19, 2004 @10:10AM (#8903871)
    > 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.

    This is wrong. If your compiler requires this, then your compiler is broken.

    The destructor in a base class has to be made virtual though to ensure that correct destructors will be called if you do something like this:

    Base* o = new Derived();
    delete o;

    where Base is some class and Derived is derived from Base. If Base::~Base() is not virtual, then Derived::~Derived() would never get called.
  • Re:Hmmm.... (Score:2, Informative)

    by Anonymous Coward on Monday April 19, 2004 @10:18AM (#8903951)
    There is a (surprisingly complete) port by David Friedman to GCC-3.4. It is being used on Mac and Linux with impressive results.

    For more information see the D.gnu newsgroup on news.digitalmars.com
  • C* (Score:1, Informative)

    by bsd4me ( 759597 ) on Monday April 19, 2004 @10:24AM (#8903996)

    C* actually is a language. It is the C-like parallel language used mainly on Connection Machines.

  • by the_Speed_Bump ( 540796 ) on Monday April 19, 2004 @10:27AM (#8904028) Homepage
    This would be a bigger deal if D templates weren't as robust as they are.

    It's quite a simple matter to write template classes that extend their template argument. In this way, you can arbitrarily compose things any which way you like in a way that very closely resembles multiple inheritance.

    Of course, it requires a bit of work, but it's my understanding that implementing MI involves making the compiler very arcane and complicated. One of the goals of D is to be easy for compiler vendors to implement correctly. (no waiting 10 years for a correct compiler!)
  • Re:Libraries (Score:4, Informative)

    by Tony Hoyle ( 11698 ) <tmh@nodomain.org> on Monday April 19, 2004 @10:28AM (#8904033) Homepage
    I'm not at all sure how the library compatibility will work in practice... all libraries come with header files, in C, which require a C compiler. Converting them will be nontrivial - especially since they change between versions. You'll end up making D wrapper functions which are no different to Java wrappers or Perl wrappers really.
  • by the_Speed_Bump ( 540796 ) on Monday April 19, 2004 @10:30AM (#8904045) Homepage
    The backend (code generator) for the reference compiler is closed source. However, the frontend is dual-licensed under the GPL or Artistic licenses, and is free in every sense of the word.

    David Friedman has already had success connecting this frontend to the GCC code generator, in fact: http://home.earthlink.net/~dvdfrdmn/d
  • by digitaldaemon ( 515710 ) on Monday April 19, 2004 @10:33AM (#8904079) Homepage
    No, it compiles natively.
    Walter Bright, who also wrote the first native C++ designed the language and wrote to compiler for it. The compiler shares the same backend as his C and C++ compiler.

    ManiaC++
  • ABA Games uses D (Score:2, Informative)

    by billcopc ( 196330 ) <vrillco@yahoo.com> on Monday April 19, 2004 @10:34AM (#8904090) Homepage
    ABA Games, that wacky psychedelic asian dude writes shoot-em-ups in D. I think the D is for Drugs.

    http://www.asahi-net.or.jp/~cs8k-cyu/index_e.htm l

  • by juhaz ( 110830 ) on Monday April 19, 2004 @10:41AM (#8904162) Homepage
    g++ gives me terrible headaches, what with refusing to compile code with throw statements

    What do you mean by that? G++ absolutely does support throw statements. How about an example of code snippet that doesn't work because of throw?

    Oh, and you're using 3.3, right? C++ has been moving so fast only recent compilers are any good...
  • by orthogonal ( 588627 ) on Monday April 19, 2004 @10:59AM (#8904367) Journal
    BOOM! And you reveal that you don't know what you're talking about. Circular references are irrelevant to any GC scheme more sophisticated than reference counting.

    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.
  • enumerated types (Score:2, Informative)

    by elbarrio ( 592330 ) on Monday April 19, 2004 @10:59AM (#8904375)
    The comparison list shows that Java doesn't have enumerated types. Thought it was worth mentioning that java will soon have enumerations in release 1.5:

    java 1.5 spec [sun.com]

  • by AArnott ( 751989 ) on Monday April 19, 2004 @11:01AM (#8904400) Homepage
    Whoever put the comparison sheet of D, Java, C#, C++, and C together needs to be more careful. It claims that C# has no inner classes. Which it currently has. Also the comparison sheet claims many things are unique to D, which in fact are supported by the C# 2.0 specification. "C# 2.0 isn't here yet" you say? Neither is D. In fact, the D spec is only at rev. 0.8x.
  • by at2000 ( 715252 ) * on Monday April 19, 2004 @11:31AM (#8904745)
    No! It is call-compatible only.
    D programs can import and link against C code and libraries, providing D with free access to a huge amount of pre-written code. Note, however, that D is not link-compatible with C++, so pure C wrappers are required to access C++ code in D.
  • Comment removed (Score:5, Informative)

    by account_deleted ( 4530225 ) on Monday April 19, 2004 @11:54AM (#8905036)
    Comment removed based on user account deletion
  • by be-fan ( 61476 ) on Monday April 19, 2004 @12:14PM (#8905350)
    My point was that to avoid the problem of circular references, the garbage collector does have to be more sophisticated
    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.
  • by cheide ( 731641 ) <cameron.heide@gmail.com> on Monday April 19, 2004 @12:22PM (#8905485)

    Oh! sure, nice, but then the problem is with resources allocated on those 3, 5 or 10 'skipped' levels during exception handling.

    Most resources *should* automatically free if they were allocated on the stack, wrapped in an std::auto_ptr, or a guard class whose destructor will do whatever's necessary.

    If one of those layers has a resource it knows has the potential to leak anyway, it can add its own exception handler, catch the exception on its way back, release the resource, and then rethrow the exception.

    Of course this is still the fundamental problem with languages like C++ -- it works great, *if* you have the discipline to do it properly in the first place...
  • Re:wow (Score:4, Informative)

    by llimllib ( 588506 ) on Monday April 19, 2004 @12:26PM (#8905552) Homepage
    D's only link-compatible with vanilla C, so you'd need to create a GTKD wrapper, or just use regular old gtk.
  • Re:wow (Score:3, Informative)

    by gunpowder ( 614638 ) on Monday April 19, 2004 @12:29PM (#8905590)
    No, I think he meant this. [fov120.com]
  • by devphil ( 51341 ) on Monday April 19, 2004 @12:32PM (#8905653) Homepage


    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.

  • The problem with C++ (Score:5, Informative)

    by Animats ( 122034 ) on Monday April 19, 2004 @12:55PM (#8906019) Homepage
    D is Walter Bright's improvement on C++. Bright wrote the original Zortech C++ compiler, which was one of the first real C++ compilers, as opposed to a front-end for a C compiler. D is really too similar to the other C++ variants to get much traction.

    C++ itself is undergoing a revision. But the plans for it aren't that good.

    The big problem with the C++ committee is that most of the members don't want to admit the language has major problems. Neither does Strostrup, who has written that only minor corrections are needed. If that was really true, we wouldn't need all those variants on C++ (Java, D, C#, Objective-C, Managed C++, etc.)

    The committee is dominated by people who like doing cool things with templates. Most of the attention is focused on new features for extending the language via templates. It's possible to coerce the C++ template system into running programs at compile time (see Blitz [oonumerics.org]). Painfully. LISP went down this dead end, where the language was taken over by people who wanted to extend the language with cool macros. (See the MIT Loop Macro. [cmu.edu]) We all know what happened to LISP.

    What isn't happening is any serious attempt to make C++ a safer language. C++ is the the only major language that provides abstraction without memory safety. That's why it causes so much trouble. C++ objects must be handled very carefully, or they break the memory model. This usually results in bad pointers or buffer overflows. Java, etc. are protected against that. This is the basic reason that writing C++ is hard.

    It's not fundamentally necessary to give up performance for memory safety. I've written a note on "strict mode" for C++ [animats.com], an attempt to deal with the problem. I'm proposing reference counts with compile-time optimization, rather than garbage collection. The model is close to that of Perl's runtime, which handles this well.

    Garbage collection doesn't really fit well to a language with destructors, because the destructors are called at more or less random times. Microsoft's Managed C++ does that, and the semantics of destructors are painful. With reference counts, destructor behavior is repeatable and predictable, so you can allocate resources (open files, windows) in constructors and have things work. The main problem with reference counts is overhead, but with compiler optimization support and a way to take a safe non-reference-counted pointer from a reference counted object, you can get the overhead way down and reference count updates out of almost all inner loops.

    C++ itself isn't that bad. The language could be fixed. But I don't see it happening. Microsoft has gone off in a different direction with C#. SGI, HP, DEC, Bell Labs, SCO, and Sun are defunct or in no position to drive standards any more.

    What C++ needs is some hardass in a position to slam a fist on the table and say "Fix it so our software doesn't crash all the time". It doesn't have one.

  • Amiga E (Score:2, Informative)

    by LentoMan ( 704115 ) on Monday April 19, 2004 @02:02PM (#8906929)
    There is already a programming language called E for Amiga:
    http://wouter.fov120.com/e/
  • by Anonymous Coward on Monday April 19, 2004 @02:11PM (#8907026)
    try this...
    object = NULL;
    System.gc();

    although you shouldn't really call System.gc yourself. Also, object = NULL would do the same thing as object.free() since you don't actually want to free the memory right now, but instead tell the JVM that it should be free'd in the future. Inline memory free'ing is only necessary in embedded apps that are written in C anyway. BTW, valgrind rocks. I used it to trim a version of Doom from 16MB to under 4 with all textures. This allowed me to get it running on very small hand held devicies.
  • by Chuck Messenger ( 320443 ) on Monday April 19, 2004 @02:58PM (#8907547)
    OK, I delved into D a bit more. It does look like a very interesting language, now that it has templates. Some comments, going down the cart (considering D in relation to C++):

    Function literals This is excellent. Function literals would make C++ a much better language. The STL cries out for them. While Java doesn't have function literals, it has something pretty close -- anonymous nested classes. But C++ has nothing very close. The best you can do is something like the Boost lamba library, which while impressive, it quite horrible. This feature makes D pretty interesting to me.

    I'd be interested to know what D has in terms of standard libraries -- something akin to the STL..?

    Dynamic closures Not sure exactly what this is, but I imagine it makes D into a fully-functional language. Sounds great! It makes me even more interested.

    Resizeable arrays Well, I don't think this claim stands up -- that C++ doesn't have resizeable arrays. After all, since D is a garbage-collected language, I'm guessing its arrays are on the heap, not the stack. C++ has resizeable heap arrays -- vector, etc.

    Arrays of bits Again, I take issue with C++ not having these. Check out Boost::dynamic_bitset.

    Built-in strings Once again -- no way. C++ certainly has built-in strings, in any meaningful sense of the word -- std::string.

    Array slicing I'd be intersted to see an example of how D's array slicing compares to C++'s interator-based programming. I'm not sure what's being talked about here, exactly.

    Array bounds checking There's really no meaningful way you can say C++ doesn't have array bounds checking. Come on! What C++ has, which might be much better than D, is switchable array bounds checking. You don't _have_ to check array bounds (e.g. for release builds), but it's trivial to add if you want it.

    Associative arrays Wrong! C++ certainly has associative arrays. They're quite excellent. See std::map and std::multimap. And of course, you can build any special sort of associative array you want -- say, a hash.

    This chart is completely biased against C++ -- quite unrealistic. Why not just stick to the _real_ benefits D has over C++, and not kick up alot of FUD? It only serves to make people like me (rightfully) skeptical.

    Strong typedefs OK, fine -- typedefs aren't strong in C++. But if you want something to be strong, make it a class/struct/enum. Why do typedef's need to be strong? What's really being said here is that D lacks a "type alias", which is what a C++ typedef is -- just a shorthand for another type. Does D have that?

    String switches Just syntactic sugar, although I admit it might be nice syntactic sugar.

    Multiple Inheritance An unfortunate deficiency of D. I find multiple inheritance to be quite useful. But D can't have everything -- that's OK. If this were D's only deficiency, it wouldn't be fatal to me, especially because...

    Interfaces ... interfaces get you _most_ of what's good about multiple inheritance. But not all.

    Dynamic class loading This is a nice thing about Java. Too bad D doesn't have it (but hardly a fatal problem, for me).

    Inner classes Seems like D's functional programming capabilities trump the lack of inner classes...

    Covariant return types Ummm -- what are these? C++ has them, so I must know what they are....

    Properties Syntactic sugar...?

    Inline assembler
    Direct access to hardware
    Direct native code gen Excellent. However, one reason I really like C++ is that there are toolchains for a huge variety of hardware. If there were a gcc front-end for D, that would go a long way to addressing this issue...

    Lightweight objects Meaning, stack-allocated objects?

    Explicit memory allocation control Does this mean D has _real_ destructors (unlike Java's pseudo-d

  • by Dawn Keyhotie ( 3145 ) on Monday April 19, 2004 @02:59PM (#8907563)
    To quote from the lead-in to your referenced documentation [vitanuova.com] by Kernighan:

    "Limbo is strongly typed, provides automatic garbage collection, supports only very restricted pointers, and compiles into machine-independent byte code for execution on a virtual machine."
    This pretty much disqualifies Limbo as a successor language to C. C is a systems programming language, not a byte-code interpreted play-toy.

    Cheers!

  • by mystran ( 545374 ) on Monday April 19, 2004 @03:06PM (#8907631)
    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.

    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.

  • by KagakuNinja ( 236659 ) on Monday April 19, 2004 @03:16PM (#8907728)
    To program effectively in both C and C++, you have to develop consistent rules, to keep you r code manageable. One such rule is, always pass smart pointers by reference; this avoids the unnecessary construction and destruction of a temporary. Of course, I almost never write functions that accept auto_ptrs as parameters. Conceptually, you don't to pass an auto_ptr to a function like you are doing.

    The purpose of the auto_ptr is to provide temporary ownership of an allocated object. I would have coded your example like this:
    int a(Thing *) {
    ...
    }

    int b(Thing *) {
    ...
    }

    int main(...) {
    auto_ptr<Thing> ptr(new Thing);

    a(ptr.get());
    b(ptr.get());
    }
  • by WalterBright ( 772667 ) on Monday April 19, 2004 @04:08PM (#8908360) Homepage
    D offers several ways to do allocation, gc is only one of them:
    • garbage collection
    • using C's malloc/free
    • stack allocation via alloca()
    • automatic stack allocation and cleanup (RAII technique)
    • static data
    • overloading new/delete on a per-class basis
    • writing one's own functions to allocate/release memory
  • by jareds ( 100340 ) on Monday April 19, 2004 @04:31PM (#8908599)

    Both Objective Caml [ocaml.org] and SML (using, say MLton [mlton.org]) can be compiled to ELF executables for the x86.

    Anyway, native-code compilation versus bytecode compilation isn't a property of a language, it's a property of an implementation. The GNU Compiler for Java [gnu.org] exists.

    These were pretty arbitrary examples: there are plenty of options for native code executables besides C/C++.

    I don't mean to slight D, though!

  • Re:wow (Score:4, Informative)

    by Jorkapp ( 684095 ) <jorkapp&hotmail,com> on Monday April 19, 2004 @05:35PM (#8909216)
    Wikipedia: B Programming Language [wikipedia.org]

    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.
  • by Zobeid ( 314469 ) on Monday April 19, 2004 @06:31PM (#8910098)
    You had a minor inaccuracy there. . . Objective C should not be listed as a "variant" on C++ or any kind of spinoff from it. It's a competitor. I'm not sure which one was invented first, but I remember clearly that both C++ and Objective C were introduced around the same time and both competed to be the widespread successor to C. C++ won that competition, though the reasons why are obscure to me. I rather like Objective C, and it's still the preferred language for application development on Mac OS X (that's a legacy from NeXT).
  • Join the D newsgroup (Score:1, Informative)

    by Anonymous Coward on Monday April 19, 2004 @10:06PM (#8912357)
    Hay anyone wanting to put forward some contructive critism join the D newsgroup(at news.digitalmars.com). Who knows you just may help *put the language back on track*.

    Negative additudes are wellcome, D needs feedback from all sectors. By negative additudes, I don't mean we want people to spoil the friendly nature of these group. So if you hate D, come to the group and explain exactly what you hate about it.

    Parhaps there's a solution to be found.

"Engineering without management is art." -- Jeff Johnson

Working...