Slashdot Mirror


The D Programming Language, Version 1.0

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.
For those with a C/C++ background, D offers:
  • native code speed
  • extremely fast compilation times
  • garbage collection (although you can manage your own memory if you want)
  • OOP - by reference only, easy initialization, always virtual
  • cleaner template metaprogramming syntax, more powerful templates, as well
  • built-in dynamic and associative arrays, array slicing
  • versioning (no preprocessor madness)
  • link-compatibility with C
  • nested functions
  • class delegates / function pointers
  • module system
For those with a C#/Java background (a shorter list, but one with big wins):
  • similar syntax
  • No virtual machine or interpreter
  • built-in unit testing and design-by-contract
These two comparison sheets can go into more depth on how D stacks up against other languages.

From D's creator:
For me, it's hard to pinpoint any particular feature or two. It's the combination of features that makes the cake, not the sugar, flour or baking powder. So,
  1. My programs come together faster and have fewer bugs.
  2. Once written, the programs are easier to modify.
  3. I can do (1) and (2) without giving up performance.
Get your compilers and start hacking D!
  • DMD (Digital Mars reference compiler, Windows & Linux, x86)
  • GDC (GCC front-end)

80 of 570 comments (clear)

  1. This won't work... by PurifyYourMind · · Score: 5, Funny

    ...it's just another version race. D may have won for now, but someone out there is already working on the E programming language. ;-)

    1. Re:This won't work... by 0racle · · Score: 3, Funny

      Now, after F do we get G or 10?

      --
      "I use a Mac because I'm just better than you are."
    2. Re:This won't work... by jlarocco · · Score: 4, Insightful
      Why do we need yet another programming language?

      Exactly. There's already Fortran and COBOL, everything else is superfluous.

      Seriously though, why don't we need another programming language? It's not like we only get a finite number of them. We're not going to run out of space or anything.

      If it doesn't interest you, don't use it.

    3. Re:This won't work... by 0racle · · Score: 2, Insightful

      Did you say the same thing when Python or Ruby were created? People do things in different ways, different languages end up with their strengths and weaknesses that way. So until there is a perfect language that is all things to everyone, yes there is always a need for another language.

      --
      "I use a Mac because I'm just better than you are."
    4. Re:This won't work... by TERdON · · Score: 4, Informative
      Now, after F do we get G or 10?


      Either it'll be called 10, or H. G, has already been taken, not only once, but twice.

      For your reference (kudos goes to Wikipedia), the following single letter (sometimes including some additional nonalphabetic characters) have also been implemented:

      A+ A++ B C C-- C++ C# D E F F# G (now known as Deesel) G J J# J++ K L M4 Q R S S2 T X10

      So - that only leaves you the letters H, I, N, O, P (sic!), U, V, W, Y and Z if you don't want to have a name clash with another programming language. Technically, M and X are followed by numbers in the previous examples, so you could argue for them as well, and even A (as it has a plus behind the letter)

      I'm mostly surprised that noone has thought of a (P)rogramming language. :)
      --
      I have a really elegant proof for Fermat's last theorem. If this sig was only a bit longer...
    5. Re:This won't work... by TheRaven64 · · Score: 3, Interesting

      UTF-32 does, indeed, do that. It is quite a good way of working internally. You can do things with UTF-32 much more efficiently than with UTF-16 or UTF-8 (e.g. searching for a character just requires you to compare each 32-bit value to the target, without having to check it isn't a special character that is the first in an escape sequence). Most modern processors come with a vector unit that can handle vectors of 32-bit integers, so if you have to handle large quantities of text you can speed certain things up even more by running streaming calculation on the vector unit.

      --
      I am TheRaven on Soylent News
    6. Re:This won't work... by Zerathdune · · Score: 2, Informative

      actually, B was a modification of BCPL, not A (to my knowledge there was never a language called A.) BCPL was an enhancement of CPL.

      --
      No single raindrop believes that it is responsible for the storm.
    7. Re:This won't work... by LunarCrisis · · Score: 3, Informative
      Though I agree with you for the most part (finding the nth character in a UTF-8 string is unnecessarily long), this is wrong:

      searching for a character just requires you to compare each 32-bit value to the target, without having to check it isn't a special character that is the first in an escape sequence UTF-8 was designed so that no complete set of bytes representing a character occurs as a substring of any other. This makes the search problem into a simple search for a string inside another string. The searching routine doesn't even need to know whether or not it's a UTF-8 string or not, just as long as it doesn't mangle the last bit.
      --
      Mr. Period: Nine is the one that's right by ten!
      Nine: One day I will kill him. Then, I will be Ten.
    8. Re:This won't work... by sacrilicious · · Score: 4, Funny
      So - that only leaves you the letters H, I, N, O, P (sic!), U, V, W, Y and Z

      I hope someone creates an "O" language. That way, interface bindings for it could be called "O-interfaces", or "O-faces" for short. So when you create a nifty library for the language, publishing it could be known as "showing the world your O-face".

      --
      - First they ignore you, then they laugh at you, then ???, then profit.
    9. Re:This won't work... by TERdON · · Score: 2, Insightful

      wasteful with western languages

      I'm not sure which ones you are referring to, except of course English.

      Swedish has ÅÄÖ. Norwegian has ÅÆØ, and so does Danish. Finnish has Ä and Ö. German has ÄÖÜ and ß. French has even more weird characters, including Ç. Spanish has Ñ, Ü and accents, and the list goes on. For really weird characters, check Polish. :) I don't doubt that a few of these are codable in pure ASCII, but for the rest of us, we're happy to be out of the code page choosing problems.

      --
      I have a really elegant proof for Fermat's last theorem. If this sig was only a bit longer...
    10. Re:This won't work... by Randolpho · · Score: 2, Interesting

      Fortran does actually have some very useful features not found in c or most other languages, especially when doing vector processing; it would be in your best interest to (*gasp*) learn the language rather than run f2c. Also, I would remind you that you compiled c and fortran are link-compatible, so you could create a function-interface specification that would allow you and your curmudgeon to work together, rather than cross-purposes.

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    11. Re:This won't work... by Creepy · · Score: 2, Informative

      wow - you missed a couple of C dialects, most certainly because they extended the letter name with a word

      Objective-C and the best programming language in existence, C-Intercal (yeah, yeah - you whitespace lovers can bite me).

      I can't believe you don't know this - it's common knowledge that the letter 'P' was skipped because back in the early 80s Wordstar would use control-P to purge your document with no confirmation screen as opposed to Wordperfect's print, so there was an extreme hatred for the letter from people that used Wordstar at work or school and Wordperfect at home (practically everyone not using Cut-N-Paste on an Apple ][, which was, pretty much everyone). It was such a powerful effect that it practically destroyed the Pascal programming language and its .p extensions and nearly killed the Macintosh, which had standardized on Pascal for its operating system. The stigma of the letter has faded, but many old timers would never use a programming language called P.

  2. D is surprisingly good. by FishWithAHammer · · Score: 3, Informative

    I'm looking at using it via GDC for my next project. For people who use C/C++ regularly, this is something you ought to look into.

    It's not a toy language. If you're a C++ programmer, you'll be almost immediately functional in the language. And you can call C and C++ libraries seamlessly. It's pretty sweet.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
    1. Re:D is surprisingly good. by matrixise · · Score: 5, Informative

      from http://digitalmars.com/d/interfaceToC.html

      D does not provide an interface to C++. Since D, however, interfaces directly to C, it can interface directly to C++ code if it is declared as having C linkage.

      D class objects are incompatible with C++ class objects.

    2. Re:D is surprisingly good. by Brandybuck · · Score: 2, Informative

      And you can call C and C++ libraries seamlessly.

      Really? Not according to their FAQ. C yes. C++ no. Otherwise I would be in the process of switching over as we speak.

      --
      Don't blame me, I didn't vote for either of them!
    3. Re:D is surprisingly good. by Geoffreyerffoeg · · Score: 2, Insightful

      If you don't know pointers, then you don't know how the machine works. I would never use a doctor that didn't know how my body worked.

      Yes, but last time I went to the doctor he didn't grab a hand pump and start pushing my blood around.

      And when was the last time C let you manually push items onto the stack?

    4. Re:D is surprisingly good. by eluusive · · Score: 3, Informative
  3. Weird writeup: by Per+Abrahamsen · · Score: 3, Insightful

    From the compared to C/C++ list:

            * native code speed

    As opposed to C/C++.

            * extremely fast compilation times

    Point granted (compared with most C++ compilers).

            * garbage collection (although you can manage your own memory if you want)

    Point granted, even though C and C++ arguably have optional garbage collection as well (if you link to the right library).

            * OOP - by reference only, easy initialization, always virtual

    Only value semantic? Meyer had to accept that value semantic was useful, and add it to Eiffel eventually, and C# added it over Java.

    And no way to specify that a function will always be the one specific. Good luck doing any kind of reasoning there.

    Bragging about missing features, that are essential to many tasks.

            * cleaner template metaprogramming syntax, more powerful templates, as well

    *More* powerful templates? The usual complaint is that C++ templates are too powerful (a Turing-equivalent compile time language).

            * built-in dynamic and associative arrays, array slicing

    Not exactly a recommendation that the core language apparently is so weak that these can't be put into libraries.

            * versioning (no preprocessor madness)

    I'm guessing he meant variants here, the preprocessor is often used for variants, rarely for versioning.

            * link-compatibility with C

    Which C and C++ of course lacks?

            * nested functions

    Point.

            * class delegates / function pointers

    Obviously both C and C++ have function pointers.

            * module system

    More preprecessor replacement here.

    The C#/Java list:

            * similar syntax

    But totally different from C++?

            * No virtual machine or interpreter

    You can compile Java and C# to native code as well, so this is just another case of bragging about a missing feature.

            * built-in unit testing and design-by-contract

    I'm a C++ programmer, and this is by far the most interesting aspect of the D language (and of Eiffel before that). Don't know why it should be in the Java/C# list.

    1. Re:Weird writeup: by 91degrees · · Score: 3, Informative

      Couple of points:

      * native code speed

      I think this is a response to criticisms from C programmers about most modern languages, rather than a benefit over C.

      Not exactly a recommendation that the core language apparently is so weak that these can't be put into libraries.

      Some of this is useful enough to be built in. stl and the like are pretty handy but sometimes it feels a bit of a kludge. Plus, built-in allows better optimistations for specific cases.

      Obviously both C and C++ have function pointers.

      Yes, and the syntax is horrible. D makes this a lot nicer.

    2. Re:Weird writeup: by donglekey · · Score: 2, Interesting

      This strikes me as the thoughts of someone who hasn't given D a good look. I have been using it recently and it is phenomenal. It is a breath of fresh air. It is not that it has many of these features over C/C++, it is that it cleans out the enormous amounts of headache inducing things about these languages while retaining what Java/C# lose. Native code speeds. No VM. Trivial Integration with C.

    3. Re:Weird writeup: by arkanes · · Score: 2, Insightful

      It's worth pointing out that the lack of core strings and vectors means that every C++ library more than 5 years old has it's own implementation of them, which means hooking libraries together means you get to waste time, memory, and performance on shuffling between almost identical string and array implementations. Multiple implementations of things like strings and basic vectors is a weakness, not a strength. The ability to provide specialized implementations of these is a strength, and D has that.

  4. java native code compilation by Nutty_Irishman · · Score: 2, Informative

    All other considerations aside, runtime speed really should be a justification as a bonus to Java. Java isn't that much slower if you actually take the time to compile it to native code first. Using something like a JIT compiler http://en.wikipedia.org/wiki/Just-in-time_compilat ion can greatly increase the speed of your code and put it close in line with C++. I would certainly consider D if both 1 and 2 were better than Java.

    1. Re:java native code compilation by Decaff · · Score: 4, Informative

      Java isn't that much slower if you actually take the time to compile it to native code first. Using something like a JIT compiler http://en.wikipedia.org/wiki/Just-in-time_compilat ion can greatly increase the speed of your code and put it close in line with C++.

      This is a bit of an old myth. Almost all Java is run as native code these days, even on VMs, and is mostly pretty close to C++ speed. Benchmarks that show Java as significantly slower than C++ usually result from not allowing the VM enough time to perform native code translation of time-critical code. Java has moved away from JIT compilation (as against the later optimisation of HotSpot) because it led to long start-up times - you had to wait for code to be compiled to native before it ran. Now Java usually starts up as interpreted, with the translation to native code happening later on, in the background.

      Where C, C++ and D win out over Java in terms of performance is when you need programs that have to start up fast, run fast, but only for short periods (a few seconds).

  5. Re:Erm how is this better.. by Nasarius · · Score: 2, Insightful

    Try using .NET for systems programming. Or projects (I've made several thousand dollars from one so far) that must be portable to NT4, 2K/XP without requiring your clients to install extra junk on every computer, etc. Contrary to what Microsoft may want you to believe, .NET is not the solution to all the world's problems.

    --
    LOAD "SIG",8,1
  6. Re:Erm how is this better.. by TheGavster · · Score: 2, Informative

    What, exactly, is the benefit of the .Net VM? There is only one full implementation of .Net (the MS one), and it runs on a single platform (Windows on x86). You might as well build native x86 code linked against Windows libraries for all the portability you have. And even if you're going to bother implementing the VM across a bunch of platforms, why not implement a standard library across a bunch of platforms and link native executables against that?

    --
    "Because Science" is one step from "Because old book". Try "Because of my experiment testing my falsifiable assertion".
  7. Currently learning D by kihjin · · Score: 5, Informative
    Note: I've been programming in C/C++ for four years.

    I took it upon myself to learn D not more than a few weeks ago. A classmate introduced me to the language last spring.

    While I'm still learning D, it has some notable features:

    • auto keyword for inferred type declaration
    • lazy keyword for evaluation
    • delegates are like function pointers, but cooler. Literal statements can be passed as variables, and aren't evaluated until the delegate is called.
    • scope(exit|failure|success), specify a block of exit code
    • in/out/inout function keywords, offer readable code for determining what a parameter in a function is designed for.
    • get/set methods automatically become a property (accessed like a public variable)
    • foreach, foreach_reverse, container iteration
    • with statement, C++'s using on a object-level

    Of course one may argue that none of this is necessary and could be made independent of the language itself. My belief is that would increase the complexity of coding in D.

    If you're interested in D you should visit http://www.dsource.org/. There are some interesting projects such as Derelict (collection of C game bindings) and Bud (make and SCons replacement).
    --
    This slashdot-related signature is a stub. You can help kihjin by expanding it.
    1. Re:Currently learning D by Mr.Radar · · Score: 2, Informative

      The compiler generates header files from source files with the -H option. It can decide what code is necessary and what code isn't.

      As for mixins, you can get the full scoop and some simple examples in the language spec, specifically the portion on Mixins.

      --
      What if this signature were clever?
  8. It looks like a step down by Anonymous Coward · · Score: 4, Funny

    After working so hard to get from C to C++, I don't see why I would settle for D. My next programming language is going to be B- or better.

    1. Re:It looks like a step down by 4D6963 · · Score: 2, Funny

      After working so hard to get from C to C++, I don't see why I would settle for D

      I'd gladly have my girlfriend to go from C to D, but I admit there's nothing I would love more than DD.

      Edit : yeah I know, quit telling me that I must be a liar, I don't have a girlfriend, WHO CARES?!?
      Edit #2 : What? You can't edit your comments on Slashdot? So how am I doing that, jerk?

      --
      You just got troll'd!
  9. Re:Another 'Toy' Programming Language by nacturation · · Score: 4, Funny

    I'll stick to languages that have at least a professional following, in use by real software engineers (that is, engineers who can legally call themselves engineers), not the run of the mill code monkeys. I'm dying to know... do you mean Fortran or Lisp?
    --
    Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
  10. Do we really need another D infomercial? by Anonymous+Brave+Guy · · Score: 3, Insightful

    I'm sure D is a lovely language, but it just seems like another incremental change over C++, like Java and C# before it, and like both of those languages what it's lost and the opportunities it misses are as telling as the little tweaks it makes to improve things.

    No-one has yet been successful, IMHO, in developing a really good industrial programming language. Those that make it tend to be pragmatic, practical tools like C and Perl and FORTRAN and COBOL. To be sure, each of these has many widely-acknowledged weaknesses, but the overall balance between those weaknesses and what you could get done using the language was right.

    I can increasingly see why some well-known programming language designers shy away from feature comparison ticklists. I think it's because as soon as you go down this route, you bias the comparison so much that it's meaningless. For example, consider the first checklist cited in the Slashdot write-up. (I note in passing that this is a wiki, and may change before you read this.) Here are some of the "yes or no" (almost) categories:

    Templates or executable macros No difference in expressive power is acknowledged between LISP macros and C++ templates. Thread synchronization primitives With no reference to how expressive they are, and how powerful the idioms supported by them? This one is really telling, IMHO, because I don't believe the future lies in classical thread sync and locking primitives. The whole approach is just too prone to deadlocks and race conditions to withstand the heavily parallel future that multicore chips are starting to bring into the mainstream. When you have ideas like pure function programming languages, operating in a world without side-effects where explicit locking isn't necessary, or interesting ideas for inter-thread communication such as those in Erlang, another variation on built-in pthreads just isn't worth much. Enumeration So again, we acknowledge no difference between simple and low-level enumerations such as those in C, and concepts such as disjunctive types and pattern-matching that are very powerful, remarkably elegant, and mainstream in certain families of programming language. Again, this is just papering over a gap, where other languages operate on an entirely different level. Long double floating point (80bit) This is just desperation. Pretty much no-one uses 80-bit floating point arithmetic IME (and yes, I do work in the field). The portability hazards and lack of true support from almost every mainstream architecture make them almost irrelevant, except perhaps for a few very small niches. Lexical Closures Another telling omission: the power of all those neat functional programming features is dramatically reduced when you can't construct functions on-the-fly.

    On top of all of this, the feature lists invariably gloss over some less concrete things that are nevertheless very important to systems programming languages. How portable is D? How many production-quality implementations are available? Is the language standardised or under the control of a single, commercial body? How much backing is there behind the language in the commercial development space; do others write libraries specifically for this language, or is it reduced to using C-style interfaces at the lowest levels anyway, and what impact does this have on the usefulness of features like DBC, exceptions, and so on? Does the language have an active hobbyist/volunteer community supporting it?

    I could go on, but I don't want this post to disappear into the oblivion any more than it already will. Although I'm deliberately focussing on criticising in this post, as I often do with D, I keep an open mind and will happily engage in debate with others, or even be proved wrong by people who have found D to have compelling advantages. So go ahead, D advocates, start your counter-arguments here...

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Do we really need another D infomercial? by stevenj · · Score: 2, Insightful
      Long double floating point (80bit) — This is just desperation. Pretty much no-one uses 80-bit floating point arithmetic IME (and yes, I do work in the field). The portability hazards and lack of true support from almost every mainstream architecture make them almost irrelevant, except perhaps for a few very small niches.

      Um, considering that the vast majority of the world's floating-point hardware is x86 and supports extended precision, saying that it lacks "true support from almost every mainstream architecture" is comical.

      (I agree that relatively few numerical applications need extended precision on a regular basis, but it is awfully useful on occasion. A very simple use is to assess the impact of roundoff error on a double-precision program: by far the easiest way is to increase the precision and see how much the answer changes, but this requires a floating-point type with greater than double precision. Yes, you could drop in an arbitrary-precision type, but this may be too slow in a large computation.)

      In any case, D's claim to this feature is a bit odd, since every x86 C/C++ compiler worth its salt already compiles long double to extended precision.

      --
      If a thing is not diminished by being shared, it is not rightly owned if it is only owned & not shared. S. Augustine
    2. Re:Do we really need another D infomercial? by Anonymous+Brave+Guy · · Score: 2, Interesting

      Ironically, I consider most of the C++ to D examples there to be flaws in D.

      Supplying predefined comparison operators is all very well, but what if a class doesn't support the concept of equality? Alternatively, suppose it supports only equality and not ordering, or vice versa? How do I do that in a natural way, with a single comparison function to define?

      The whole concept of relying on scoped variables completely misses a major advantage of RAII, which is that in the common usage, you can't forget anything (a delete, finally or in this case scope) and inadvertently skip the destructor. Requiring some special keywords to get this behaviour is just horrible.

      The construction/initialisation semantics just seem a mess. You've either introduced some hideous inefficiency and semantic problems (everything is default-initialised and then reassigned afterwards in the constructor if necessary) or you've introduced a horrible loophole (constructors can start messing around with uninitialised data, for example by calling another member function, before the class invariants are properly set up). The latter is even worse than the analogous loophole in C++.

      This sort of thing is exactly my big beef with D, and the reason I doubt I will ever seriously consider it for a non-trivial project in its current form. It's going for style over substance, PR hype over effectiveness. It does away with a few controversial things in C++, but some of its underlying models are simply broken, and as I illustrated elsewhere, its improvements in other areas are far from state-of-the-art.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:Do we really need another D infomercial? by Anonymous+Brave+Guy · · Score: 2, Interesting

      Um, considering that the vast majority of the world's floating-point hardware is x86 and supports extended precision, saying that it lacks "true support from almost every mainstream architecture" is comical.

      Not really. Take a look at the performance, addressing modes, and so on. The support for 80-bit on Intel boxes is not the same as the support for 64-bit, at least in practical terms.

      Also, while the vast majority of the world's FP hardware may indeed run on x86 (I don't know), I would suggest that at least a very significant minority of the software that actually requires high-precision floating point work still runs on workstations which may well be based on other architectures.

      No-one wishes this were not so more than me, I promise you: I write high-performance, high-precision mathematical libraries for a living, and minor differences in behaviour across platforms or where precision has been lost are the bane of my working life.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:Do we really need another D infomercial? by WalterBright · · Score: 2, Interesting
      In any case, D's claim to this feature is a bit odd, since every x86 C/C++ compiler worth its salt already compiles long double to extended precision.

      VC++ doesn't. Java doesn't. C# doesn't. Python doesn't. Ruby doesn't. 80 bit floating point is highly useful, and it's about time it was required for languages on FPUs that support it.

    5. Re:Do we really need another D infomercial? by metamatic · · Score: 3, Interesting
      So the only way to represent the concept of a class with an ordering but no equality is to have a run-time failure every time someone tries to compare them for equality?

      What do you think a programming language should do when I try to compare two things that can't be compared for equality?

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    6. Re:Do we really need another D infomercial? by Agronomist+Cowherd · · Score: 2

      It should give a compile time error, of course. Run-time exceptions that pop-up in little used code paths are evil.

      --
      -DwS
    7. Re:Do we really need another D infomercial? by WalterBright · · Score: 2, Insightful

      VC++ is one of the most widely used C++ compilers. The fact that it does not support 80 bit long doubles has apparently convinced a lot of people that such precision is unnecessary - and this wrong idea tends to propagate into other languages, since language designers are rarely familiar with numerical analysis.

      The C++ Standard allows this to happen with C++ compilers. It's about time, however, that modern languages have decent, proper support for numerical analysis, and that means requiring the support of the full precision of the underlying hardware. D aims to fully support numerical analysis needs.

      If other languages refuse to do so, well, that's another reason why there is a need for D.

  11. Lazy Questions by Quantam · · Score: 2, Informative

    Looking at the comparison lists, D looks pretty nice. It has a lot of features that I'd consider switching languages for (from C++), but any such language would have to have a few particular properties (due to the kinds of things I program):
    1. Must be able to disable garbage collection and manage allocation explicitly
    2. Must be able to allocate classes on the stack
    3. Must minimize use of exceptions in the standard library (in other words, exceptions must only be used for exceptional cases)

    Java fails all of them, if I recall correctly (I don't know that much about Java, actually). C# fails 2 and 3. It looks like you can disable garbage collection in D, but in the comparison list I didn't see mention of 2 or 3. Does anybody know, off the top of their head?

    --
    You have tried to support your argument with faulty reasoning! Go directly to jail; do not pass Go, do not collect $200!
    1. Re:Lazy Questions by TheRaven64 · · Score: 2

      2. Must be able to allocate classes on the stack

      This is a really, really strange requirement. Why would you need to be able to do this in a language? In a high-level language, memory allocation is abstracted away from you so you don't need to worry about it. A decent JVM, for example, creates pools for frequently allocated and de-allocated objects so that they have a much lower cost than heap-allocation of C++ objects.

      Objective-C, for another example, follows the Smalltalk model of putting as little in the language and as much in the libraries as possible. When you +alloc an Objective-C object, it actually calls the +allocWithZone: method with the default zone for that object type. If you want to create and destroy objects quickly, you can create a special zone for them, allocate a big block of memory all at once, and then use that. This approach was used heavily by NeXT, who wrote a windowing system, device drivers, and a suite of applications that ran quite happily on a 25MHz Motorola 68K chip.

      It basically sounds like you're saying 'I want to use a language that is exactly the same as C++, but isn't C++.' My advice to you is learn Lisp, Smalltalk, Erlang and Haskell, and then evaluate languages. It doesn't sound like you are sufficiently comfortable with different programming models to be able to comfortably switch languages to one that is actually different.

      --
      I am TheRaven on Soylent News
  12. Re:GC, No Vm or performance hit by Nasarius · · Score: 3, Informative
    garbage collection ... No virtual machine How do they square that particular circle?
    It's really not that difficult. Hans Boehm wrote a garbage collector for C/C++ years ago, which happens to be the same one that the Digital Mars implementation of D uses.
    --
    LOAD "SIG",8,1
  13. Re:GC, No Vm or performance hit by Anonymous+Brave+Guy · · Score: 4, Informative

    garbage collection ... No virtual machine ... How do they square that particular circle?

    The same way as countless other programming languages have in the past, I imagine. Why do you think garbage collection requires running your code under a VM?

    Just In Time Compilation in C# or Java has "Native code speed", in fact it goes one better - since the compilation happens at a later time, more processor or other specific optimisations can be made.

    Of course, you're overlooking all the overhead of monitoring the code long enough to determine which on-the-fly optimisations are worth performing, and of compiling the code itself, neither of which is trivial.

    GC has a lot to do with the perceived slowness.

    True, though of course it's not without overheads. Almost all of the Big Claims(TM) made by GC advocates in these discussions come with a catch: state-of-the-art GC method number 17 has a lower amortised cost of memory recovery than explicitly freeing it C-style!*

    * But only if your system contains 10x as much memory as the program will ever need anyway.

    This is traditionally followed by a wisecrack about how memory is cheap, followed by three enlightened posters pointing out the stupidity of that argument for multiple reasons. :-)

    Isn't it disingenuous to tout both "native code speed" and "garbage collection"?

    That depends a lot on context. If you really have a system where the overheads of GC are trivial but all the advantages are present, it seems a fair claim. It's just not likely to be universally true, and representing it as such would indeed be disingenuous.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  14. The feature-checklist school of software design... by stevenj · · Score: 4, Insightful
    ...is obviously the birthplace of D. Heavens, it's the union of C++ (already a nightmarishly huge language), C99, and C#, along with dozens of other features halfway borrowed from functional languages and other inspirations. More features must be better, never mind that the language becomes insanely complicated! (Next they'll be throwing in the Fortran 2000 standard.)

    My feeling is that languages shouldn't try to satisfy all possible needs. Rather, we should have small and clean languages, use the right tool for each job, and combine code libraries from different languages when needed. (I regularly use 3-6 languages in a single project and my life is much happier for it.)

    (Legacy support is critically important too, but it is vastly better to provide legacy support by providing ways to call older languages, especially the lingua franca of C, rather than demanding that the new language be a superset of the old. I still call numerical libraries written in pre-1970 Fortran, but that doesn't mean I have to write my code in a Fortran derivative.)

    --
    If a thing is not diminished by being shared, it is not rightly owned if it is only owned & not shared. S. Augustine
  15. Re:GC, No Vm or performance hit by scoonbutt · · Score: 2, Informative

    Garbage collection has no requirement for using a virtual machine. They usually show up together, but there's no technical requirement.

  16. Python and D by MightyMooquack · · Score: 4, Interesting

    One area I see D being useful in is integration with Python. Writing to the raw Python/C API is cumbersome. (Managing reference counts is tedious.) Boost.Python is difficult to build and slow to compile. I've written a library for D called Pyd, whose purpose is not entirely unlike Boost.Python's.

    Pyd is easy to use. It provides its own extension to Python's distutils. Usually, you just need to make sure the D compiler is on your PATH, write a setup.py file, and run python setup.py build.

    "Hello world" in Pyd looks something like this (and I apologize for the lack of indentation):

    import pyd.pyd;
    import std.stdio;

    void hello_func() {
    writefln("Hello, world!");
    }

    extern (C) void PydMain() {
    def!(hello_func);
    module_init();
    }
  17. Re:Erm how is this better.. by Heembo · · Score: 2, Informative

    In .NET it's called a Common Runtime Library, running MSLI code. (That sentence is analogous to "the Java Virtual Machine runs Bytecode"

    The big win in .NET is that there is built-in administrator controllable security (even pub/priv key security) between the CRL (or vm to you) and the internal .NET framework. In fact, there are several administrative controllable hooks built into the .NET framework that we just do not see in Java and Ruby and the others. This is the feature that separates .NET from the rest, and the rest of these frameworks are working to catch up. All modern languages are or should be moving into this direction. I predict that in 5 years the ONLY way you will be able to code to the WinOS is via the secure API that is .NET. (Assuming your programmers and admin teams understand .NET very well!)

    .NET is horrible at scaling (less you got a big hardware budget), so I see .NET all over the DoD and internal sites, but not so much for full-in internet sites where Java is winning in the top 10 (example, MySpace is a Java app).

    --
    Horns are really just a broken halo.
  18. Is anyone ... by compandsci · · Score: 2, Funny

    ... actually going to use this? I think I'll wait for D++

  19. IDE D's Language Features by trimbo · · Score: 2, Funny

    I just can't see why I'd want to switch to a language that has no IDE support and is evolutionary to C# or C++. I hardly have to look at documentation for APIs anymore because I can just use Visual Studio's autocompletion to figure things out.

  20. Re:GC, No Vm or performance hit by StrawberryFrog · · Score: 2, Interesting

    If I read that FAQ right, it is possible that "integer or other random data be misinterpreted as a pointer by the collector" since given the nature of C - no VM, the difference between a pointer and an int is at best a gentleman's agreement - anything in memory *could* be a pointer. Well, I suppose it works if he says so. But it certainly isn't pretty.

    --

    My Karma: ran over your Dogma
    StrawberryFrog

  21. Re:Because the ones we have suck? by TheRaven64 · · Score: 3, Informative
    There is no such thing as an interpreted language. There are languages, and there are interpreters and compilers. Lisp, for example, can be both interpreted and compiled (Scheme is usually interpreted and Common Lisp is usually compiled, but there are exceptions). Tcc can both compile and interpret C code. Java can be compiled by something like gcj or interpreted by a JVM. If you compile Java you lose some of the features; the JVM bytecode format is designed so that it is easy for automated tools to reason about. At load-time, the JVM will parse the class files and check that they do not violate the Java security model; this is theoretically possible with compiled code, but much harder.

    The Squeak runtime for Smalltalk is written in Smalltalk. There is a smallish subset of Smalltalk used to write the basic functionality, which is compiled to native code. This then supports the whole language. The same model is, I believe, used for JNode, an operating system written in Java...

    --
    I am TheRaven on Soylent News
  22. Re:Because the ones we have suck? by jyoull · · Score: 2, Interesting
    There is no such thing as an interpreted language. There are languages, and there are interpreters and compilers.


    Are you really well acquainted with gcj? I'm sorry, but I don't get how the end result or even the stuff going into it (and the required inputs, like making some explicit calls that would never be required in Java) can be called Java anymore.

    the point I didn't make well was that when a language has been designed to execute inside a containing environment (the JRE or whatever facsimile thereof) you can't just up and erase that... without emulating all the stuff that was supposed to be alive in that environment. Taking a look at the gcj's to-do list and all the stuff that isn't yet supported should be enough to show you not only that this is not a trivial task, but to suggest that perhaps it's not a useful task, and I say that knowing that people have worked very hard on the project.

    Maybe it makes sense for some resource-constrained settings like embedded systems, but there i've used Java straight up, satisfactorily. Granted, these are not life-critical systems I've built, but rather than compiling Java - or trying to - the better answer is to use a more appropriate language in those circumstances.
  23. Keeping It Simple by rumblin'rabbit · · Score: 2, Insightful
    Amen. Here's a quote from the article:

    Special attention is given to the needs of quality assurance, documentation, management, portability and reliability.
    So where is the word simplicity in all of this? Anybody that has learned to use C++ really well has, to my mind, earned the equivalent of a Master's degree. This makes C++ a brilliant failure. So to learn D will we require the equivalent of a PhD?


    Good designers make things both simpler and more powerful. They improve the product as much through subtraction as addition. Instead we get this...

    and Walter has continued to add more and more features.
    Bloody hell.
    1. Re:Keeping It Simple by DropArk · · Score: 2, Interesting

      So where is the word simplicity in all of this? Anybody that has learned to use C++ really well has, to my mind, earned the equivalent of a Master's degree. This makes C++ a brilliant failure. So to learn D will we require the equivalent of a PhD? No. Definitely not. Compared to C++, Java, and C#, the D programming language syntax is clean and simple. Sure there are exceptions (the 'static' keyword is way too overloaded) but there aren't many of them. I'm guessing you haven't actually tried to use D on any non-simple problem yet. But if you have and still claim it lacks simplicity, I'd be very interested in knowing your exact and specific findings.

      Good designers make things both simpler and more powerful. They improve the product as much through subtraction as addition. Instead we get this...

      and Walter has continued to add more and more features.
      Bloody hell. I'm sure you know that many things that are simple to use are also complex under-the-hood. In order to make D simple to use, some very complex concepts have been implemented. Also, reducing syntax is not the same as increasing the simple-to-use factor. If you take a look at the Forth programming language, its syntax and keyword usage is extremely simple. And yet it is often called a write-only language.
  24. Shouldn't it be called 'P'? by aegl · · Score: 2, Informative

    BCPL was one of the sources of inspiration for the programming language 'B', and its successor 'C'. Next in the series ought to be 'P'.

  25. EVERY Language Sucks by JoeCommodore · · Score: 2, Funny

    I mean, like, I try to write this program, and like, the language does ONLY what I tell it to, not what I really want. That really sucks.

    Can't someone write up some stuff that understands proper english? Geez.

    --
    "Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
    1. Re:EVERY Language Sucks by istartedi · · Score: 2, Funny

      %ecc posting.english -o test
      warning 1: ``like" is superfluous teen speak, construct discarded.
      warning 1: ``and like" is superfluous teen speak, construct discarded.
      warning 3: ``english" assumed to be ``English".
      warning 3: ``Geez" undefined. Linking against null action function.
      % ./test
      The poster's meaning is that he tries to write a program.
      We have established that ``That" really sucks, and we are
      assuming that ``That" is the poster's act of writing a program.
      Can't someone write up some stuff that understands proper english (Y/N):
      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  26. should be possible to write os in python by vyvepe · · Score: 2, Informative
    How many OS'es are written in Python? Neither Java, ruby, perl nor python attempt be appropriate languages for writing OS'es. This doesn't make them good or bad. Other factors might.

    It might be possible to write OS in those loanguages. MS is trying to do it in C#. The project name is Singularity. But I agree that OS in not the target domain :)

  27. object oriented by elmartinos · · Score: 2, Insightful
    From TFA:
    // Object Oriented Programming
    CmdLin cl = new CmdLin(argc, argv);

    Why do they always insist on this bad syntax? Why can't they write
    CmdLin cl = CmdLin.new(argc, argv);
    This way you can think of CmdLin as an object, new is just a method that returns a new instance. Voila, one keyword removed, and much cleaner syntax. This would not even offend the Java people because they can have the same syntax with a static method.

  28. Re:More old junk repackaged to look new by rbarreira · · Score: 2, Insightful

    Hey hey, calm down. Are you sitting now? Ok, read:

    Programming languages are to intended to be used by humans.

    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  29. Re:Because the ones we have suck? by thephotoman · · Score: 4, Funny

    Wait...C++ without the bullshit? That takes away all of C++!

    --
    Haec merda tauri est. Ceterum censeo Carthaginem esse delendam.
  30. Re:It's right there in your post by hao2lian · · Score: 2, Informative

    Shoehorning his adjectives doesn't change the facts: .NET is damn fast. Perhaps not "I need to raytrace downtown Manhattan." fast, but certainly fast for web services, desktop applications, mobile apps, and Windows PowerShell. Heck, it even beat out a C++ app where low-level usually succeeds--lifting big data structures--until Raymond Chen wrote his own allocator.

    http://blogs.msdn.com/ricom/archive/2005/05/19/420 158.aspx

    --
    Pelé!
  31. Re:GC, No Vm or performance hit by rbarreira · · Score: 2, Interesting

    Here is something that I found about this. Not very good news for conservative garbage collection, I say...

    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  32. Comparison to Objective-C? by Jimithing+DMB · · Score: 4, Interesting

    I noticed that a comparison to Objective-C is quite conspicuously absent from the list of languages compared to D. Why is it missing? Granted D seems to be a much greater change to C than Objective-C is but I can't help but thinking that one of the main attractions to D seems to be its heap-based garbage-collected object system. You can already get the object runtime with Objective-C. If you use GNU you can even have Boehm GC (which is apparently the GC that D uses). If you use Apple you will have to wait for Leopard to get GC. Another new Objective-C feature is the ability to use full C++ objects as instance variables in your Objective-C classes and do the right thing with initializing (calling the default no-argument constructor upon alloc).

    On top of that, Objective-C actually includes tons of reflection information. Although Objective-C has protocols which are roughly equivalent to Java/C# interfaces they are almost completely unnecessary. In Objective-C one can query at runtime whether a method is implemented or not and if so call it. So whereas in Java you'd do this:

    if(anObject instanceof MyInterface) ((MyInterface)anObject)->doSomething();

    in Objective-C you can do this:

    if([anObject respondsToSelector:@selector(doSomething)]) [anObject doSomething];

    The difference being that in the Java case you have to declare MyInterface as containing the one doSomething() method and inform java that your object extends MyInterface whereas in Objective-C you merely need to provide a doSomething method on your object.

    Basically that means that in Objective-C every single method effectively becomes an interface. You would not believe how useful this is once you realize it. Note that at runtime there is ZERO difference. In both the Java and Objective-C cases the object is being checked to see if it implements something. Same with C++ if you use dynamic_cast<>()

    Granted every language has its niche and I'm sure D will find its. Objective-C's niche is definitely GUI programming. The ample reflection information allows for easy implementations of archiving (serialization) and most importantly key-value coding and the related action methods pattern. It's a pretty damn cool thing when your RAD tool simply outputs archived objects that refer to methods to be called upon certain actions simply by name.

  33. Re:I have a problem with GC in a systems language. by WalterBright · · Score: 2, Informative
    I have a problem with GC in a systems language... specifically, using GC means that your functions will not necessarily run in bounded time.

    malloc (and friends) don't run in bounded time, either.

    For a lot of uses, particularly in user space, this is not a problem, but if you were to kick of GC in an interrupt handler or trap handler, or a number of other places, this would make it impossible for you to implement code that was guaranteed to take at most a maximum number of CPU cycles.

    You cannot use malloc or new in those circumstances either. The correct way to do it is to preallocate all data needed for the interrupt service routine or real time critical section.

    The upshot of this is that so long as it's possible for someone to write a driver that ends up running in your kernel, and which depends on GC functionality to not leak memory, it will be impossible for an OS written in that language to support hard real time.

    Hard real time programming uses preallocated or static allocated data, not malloc or new (or GC).

    I have to say that GC is marginally useful for systems work only if you can run it on a system that doesn't need GC -- so that you can get a read out of where and how you are leaking memory, fix the problem, and then disable GC before you ship. In other words, it's a great diagnostic, but only if you can run both GC and non-GC at the same time, and only if you explicitly scope your allocations (i.e. act like you are not running in a GC'e lanuage in the first place).

    I used to think that, too, until I was forced into working with a GC. I've changed my mind.

    In other words, the intent of GC is to make programmers not have to know where their scope boundaries are, and you _must_ know this for systems programming tasks. So it doesn't deliver on its promise in a systems context, though it could be a helpful diagnostic for developers.

    All I can suggest is try using a GC for a project. My jawboning won't change your mind, but experience might.

  34. Missing the point by pammon · · Score: 4, Insightful
    The largest problem with C++ is its complexity, which causes the language to fragment into partially intersecting sublanguages representing each programmer's comfort zone. D does not address this problem; in fact, it makes it much worse. Example? C++ has seventy some keywords, but D has more than ninety. Another example? See if you can guess what this means in D:


    0XA1_2_C35_4_5_6_5P6_Li

    Give up? Why, it's an imaginary real. Yes, you read that right. Oh, and I specified it in hexadecimal, just to prove I can. And I threw in some underscores because you're allowed to do that too. Have you guessed what an imaginary real is yet? This is supposed to be the "simpler C/C++ replacement."

    A good language strives to find a few constructs that solve multiple problems. A bad language takes the kitchen sink approach. C and C++ are not good languages, but wide deployment and support make them useful anyways. D does not have that, but the designers do have the luxury of learning from the mistakes of the past. So what the hell is their excuse?

    1. Re:Missing the point by donglekey · · Score: 2, Insightful

      A good language strives to find a few constructs that solve multiple problems.

      D does this. You are looking past the dozens of examples where D has cleaned up problems that have been plaguing programmers for years to grasp at a chance to make a piece of code as messy as possible. Maybe you are comfortable working with C/C++ and don't want to deal with another language. I am not comfortable dealing with all the fucked up C and C++ out there. I have worked with D and it is exciting and refreshing. It is much cleaner and you either know it already or need to look harder.

  35. OOP languages are slow by bluefoxlucid · · Score: 2, Interesting

    CPUs put a lot of stock in branch prediction; due to the nature of OOP languages like C++, Objective-C (I like this one), and D, this doesn't work. The way virtuals and class inheritence works, functions are necessarily dealt with as pointers; the function is pointed to by pointing to a master class object, basically. Here's a C reconstruction:

    struct myClass_members {
    struct myClass_members *(*alloc)(); // constructor
    void (*destroy)(struct myClass *); // destructor
    int (*my_member)(); // member function
    };

    struct myClass { // Data
    struct myClass_members *call; // Pointer to a list of members as above
    int my_value; // an integer value
    };

    What you do is initialize a constant myClass_members (called myClass_Object here) with a bunch of pointers to static functions in one source file; then call myClass_Object->alloc to create a new one (we'll call it my_inst). Then do my_inst->call->my_member() to call the member, and similarly my_inst->call->destroy(my_inst) to deallocate the class.

    Basically, OOP languages like C++ and Java use this methodology, but it's obscured through friendly syntax. What we can expose from the above is:

    1. When class members change, structs change. This causes binary incompatibility between different versions of libraries. The exception is Objective-C, which looks up members based on their name in a hash table generated at run-time
    2. The addresses of branches (specifically CALL to call a function) are indirect (yes, in Obj-C too); this means that you can replace the class with another class that has the same structure but different functions being pointed at. It also means that the CPU can't do branch prediction, which hurts pipelining and intelligent CPU caching, causing pretty big slow-downs.

    The whole "native execution speed" thing is bunk. Script languages are executed on a native bytecode interpreter, or JIT'd to native. The amount of work that goes into the execution is what you care about; as well as the utilization of the CPU's most powerful facilities. You can only justify OOP languages by saying that either A) the majority of the work doesn't involve making calls to other class members, and thus won't be hurt by this; or B) CPU speed doesn't matter. I hate argument (B); (A) I can accept, barely enough to tip my hat to you for having good software engineering sense.

  36. Re:I have a problem with GC in a systems language. by Animats · · Score: 3, Interesting

    I wasn't happy about that either. Garbage collection in a language with destructors leads to wierd semantics, which is why Microsoft's "Managed C++" is a nightmare. I corresponded a bit with Walter Bright in the early days of D, but didn't press the issue.

    What seems to work in practice is reference counting. GC gets most of the academic attention, but Perl and Python are both basically reference counted, and the result seems to be that programmers in those languages can ignore memory allocation. Java programmers have to pay a bit more attention, worrying about when GC will run and when finalizers will be called. Reference counting is deterministic; the same thing will happen every time, so timing is repeatable. That's not true of GC.

    There are two basic problems with reference counts - overhead and cycles. Overhead can be dealt with by hoisting reference count updates out of loops at compile time, so that you're not frantically updating reference counts within an inner loop. Hoisting (along with common subexpression elimination), by the way, is also the answer to subscript checking overhead.

    Cycles are a more serious problem. Conceptually, the answer is strong and weak pointers (in the Perl sense, not the Java sense), which allows the programmer to express things like trees. (Links towards the leaves should be strong pointers; back pointers towards the head should be weak pointers.)

    In practice, cycles aren't a serious problem, because they're generated by design errors and tend to happen in normal program operation, so they show up early in testing as memory leaks. Dangling pointers, on the other hand, tend to show up in error cases, which is why they survive testing to become delivered bugs.

    Ideally, you'd like to detect cycles at the moment they're created, at least for debug purposes. This is quite possible, although there's substantial overhead.

    Attempts to retrofit reference counting to C++ via templates have been made, but they are never airtight. To get anything done, raw pointers have to leak out, which makes the reference counting scheme very brittle.

  37. Re:Erm how is this better.. by TheGavster · · Score: 2, Insightful

    Sodding lot of good that does if the vendor of the VM is only going to build for Windows.

    --
    "Because Science" is one step from "Because old book". Try "Because of my experiment testing my falsifiable assertion".
  38. Re:The feature-checklist school of software design by Anonymous+Brave+Guy · · Score: 2, Interesting

    Perhaps accidentally, you've just hit on one feature of programming language designs that I think does justify a new compiler front-end: ease of parsing for use with tools. Parsing the current monsters like C++ and Perl is so awkward and error-prone that few tools even get simple things like syntax highlighting 100% right (and the performance of those that do is... less than stellar). I imagine most of us are more interested in the underlying semantics of programming languages than in the specific syntax anyway, so can't we use a grammar that is easy to parse effectively, and then have tools from syntax highlighters to source code navigation to refactoring working quickly and reliably for a change?

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  39. Re:GC, No Vm or performance hit by fish+waffle · · Score: 2, Interesting
    The real problem might be false negatives: memory containing garbage not getting freed due to something appearing to point at it, without actually being a pointer?

    In theory yes, but in practice not very much; conservative gc works very well in most cases. The main drawbacks are:
    • No guarantee that any given bit of memory is collected. As mentioned in practice it's not typically much of an issue, but if you're developing a critical application riding close to the memory limit this may be a concern.
    • Memory fragmentation can be a problem for some long running programs.

  40. Re:GC, No Vm or performance hit by WalterBright · · Score: 2, Informative
    Hans Boehm wrote a garbage collector for C/C++ years ago, which happens to be the same one that the Digital Mars implementation of D uses.

    While Hans Boehm has written an excellent GC, it has no relationship with D's GC. The complete source to D's GC (which is written 100% in D) comes with D, and you can check it out for yourself.

  41. Re:This won't work... D Strings by Anonymous Coward · · Score: 3, Informative

    While D strings are mostly implemented as character arrays, it works quite differently than C. Here are some notable differences:

    - D arrays are bounds checked. No accidental buffer overflows here.
    - D arrays are dynamic, you can resize them and concatenate them together.
    - D strings are D arrays, so they get the above bonuses.
    - D has distinct 'char', 'byte', and 'ubyte' types. char[] != ubyte[]. When you use foreach to iterate over a char[]/string, it will expand each codepoint (or whatever they are called) to a dchar (which is a 32 bit character) for you. ubyte and byte are used for plain-old-data, instead of the unfortunate C char.
    - Garbage collection frees you from worrying about where the strings go. No accidental memory leaks here.

    There is also a nice alternative to the plain old strings called dstring, which gives you even more benefits of d's arrays like indexing and slicing (you can safely leave foreach alone with it). http://www.dprogramming.com/dstring.php

    I've used both D strings and C strings, and D's strings just felt so much better.

  42. Re:Because the ones we have suck? by donglekey · · Score: 2, Informative

    D is garbage collected, has no vm, enables access to assembly language, access to direct memory management, and has trivial access to C libraries.

    Those techniques are definitely good if they work for what you are doing, and believe me I have wanted them to work for me, but the reality is that D enables things that those approaches don't have while retaining the ability to work and not worry about the language getting in your way.

  43. Re:Erm how is this better.. by JamesNK · · Score: 2, Informative

    Actually MySpace runs on .NET - Handling 1.5 Billion Page Views Per Day Using ASP.NET 2.0

    Apparently the move to ASP.NET went quite well with CPU usage dropping from 85% to 27% according to that post.

  44. The H programming language by Joseph_Daniel_Zukige · · Score: 2, Funny

    would be popular in Japan, I'm sure.

    Especially among teenagers and otaku. (And geeks who think that otaku is equivalent to geek.)

  45. GDC source is not 64-bit clean by The_Dougster · · Score: 2, Informative

    I've been messing around for a couple hours now trying to compile gdc against gcc-4.0.3 in Gentoo amd64 and it's just not happening. I ran into an issue where it had a int and size_t mismatch, an undefined cpu symbols macro, and after hacking these the build died complaining it thought that I was cross-compiling gcc.

    I've given up for now. Maybe if D hits the 1.0 magic number somebody will fix it for 64-bit systems and add it to portage. Oh well, I would have liked to start playing with D but I guess I'll just have to wait.

    --
    Clickety Click ...
    1. Re:GDC source is not 64-bit clean by The_Dougster · · Score: 2, Interesting

      See http://dsource.org/projects/gentoo/wiki/LaymanSetu p for a portage overlay that includes DMD-bin. You have to edit the layman configuration and disable warnings about missing fields, but it works fine after that.

      I tried it, and it added the package, but it is masked by missing keyword. Besides, I don't want to install dmd, which is the 32bit compiler from digital mars, I'd rather have the gcc addon gdc built into my existing 64bit compiler system. I currently don't have the 32bit emulation libs installed, and I don't plan on installing them either. I have a pretty cool system going that is 64bit clean and runs like my own personal supercomputer. I'm into engineering, science, and mathematics programming, so I really like the free extra precision with 64bit and sse3 not to mention the extra cpu registers.

      I might try and compile D (gdc) into /usr/local/gcc-4.0 again just to see if I can get it to work, but it is obvious that some patches need to get sent upstream for the amd64 platform. I'm not sure how best to implement the patches, but I would think that it should be done using autotools, and that config.h mechanism.

      --
      Clickety Click ...
  46. Stack allocation by igomaniac · · Score: 2, Informative

    Deciding how to allocate an object you create would better be left to the compiler. It's not a hard analysis to do to make sure the reference to an object never escapes a particular (possibly recursive) function call, and in that case the object can be allocated on the stack. Leaving this decision to the compiler makes sure that if someone changes the code you're calling so it suddenly starts to keep references to the objects that you've allocated on the stack and are passing in, it won't break. In big C/C++ programs, this kind of error is quite common since it takes a lot of time to track down all callers to a function you're modifying and understand their allocation patterns. Tracking down errors like this can be extremely time consuming and programming languages that allow these errors are in my opinion wasting valuable programmer time that could be spent optimising code instead.

    --

    The interactive way to Go -- http://www.playgo.to/iwtg/en/
  47. Re:GC, No Vm or performance hit by discord5 · · Score: 2, Funny
    This is traditionally followed by a wisecrack about how memory is cheap, followed by three enlightened posters pointing out the stupidity of that argument for multiple reasons. :-)

    Let me help you with this :

    Ha! Memory is cheap!
    So was your mother last night.

    Dad?

    Meh, karma to burn...