Slashdot Mirror


Next Generation C++ In The Works

lamefrog writes: "Bjarne Stroustrup and other members of the C++ community recently met to discuss new work on the language for the first time post-ISO standard (C++0x) in an effort to keep the language moving, avoid fossilization and avoid being overtaken by proprietary extensions. Suggested new features center around the standard library and include support for multi-threading and simple platform-independent systems abstractions (handles, TCP/IP, memory maps etc...)" (Read more.)

"Most intriguing is a suggestion to include extended type information that will eliminate the need for IDLs and make it possible to generate standard bindings to external systems (COM, CORBA, SQL). Clearly Bjarne wants to position this as a platform-neutral, vendor-neutral, standardized alternative to the proprietary, vendor-supported languages that have emerged over the recent years. Audio MP3 and slides available on Dr. Dobb's TechNetCast." Thoughtfully, it's available to download as well (not just streaming), and accompanied by a transcript. Good listening.

479 comments

  1. Whatever happened to by Anonymous Coward · · Score: 1

    C#? (I pronounce it C-Hack)

    1. Re:Whatever happened to by questionlp · · Score: 1

      C# is the Microsoft .NET'd version of C/C++/Java/et al. Visual Studio .NET is still in beta and there probably won't be another beta release until sometime in the summer. I'm not sure when the final release is supposed to be out.

      I would personally program in Python than in C#, mostly when Active State is working on a Python.NET model/compiler/etc. for Visual Studio .NET (or 7.0).

    2. Re:Whatever happened to by questionlp · · Score: 1

      p-code... boy, that brings back memories of Visual Basic 4.0 and 5.0 :)

      If I wanted to a cross-platform soluton, I'm still sticking with Python (interpreted kind of like p-code but bytecode instead like Java)... it's nice and not nearly as messy as Java.

      I think .NET in general is more hype than substance, but that's just me... hehe

    3. Re:Whatever happened to by 1337+$14X0r · · Score: 1

      uh, I thought it was pronounced C-Sharp, a musical reference to the next level higher. I personally submit C/=0 as a name for MSFTs .nyet plan. It's a wierdo smiley and a blatant error (both very appropriate for Microsoft)

      --

      --- Sigs are dumb.

  2. Re:I hate to say this but, Stability... is good. by Anonymous Coward · · Score: 1
    And C was never broke.

    I disagree. ANSI C isn't broken, but look at early 80s C code. Look at an early version of C and tell it couldn't be improved upon. I dare you :)

  3. Re:Would you please by gseidman · · Score: 1
    Please put in the sockets and signals that Qt implement? Those are damn nice.

    Look at libsigc++ for a well-designed implementation of signals and slots which does not rely on a source code generator (moc) and catches various bugs at compile-time instead of runtime.

    Qt has the right idea, but its implementation involves unpleasant cruft and extra language keywords (emit, slots, signals, Q_OBJECT, etc.).

  4. Re:No kidding... by jandrese · · Score: 2

    It's not a bug, its a feature. Although the handling of less thans is less than ideal (it should just convert them), the adding of spaces to URLs is intentional. Before slashdot did that, there were some jerkoffs who liked to post comments with 10000 character long URLs that would cause most browsers to either choke or make you constantly scroll left and right to read the comments. The breaks in long lines (URLs are very long lines) prevent that from happening, although it does add some annoyance to copy-and-paste URLs (Hint: use the Anchor tag!)

    Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs.

    --

    I read the internet for the articles.
  5. Re:What about making it a little less bloated? by Trepidity · · Score: 2

    Umm, my major problem with C++ is execution time. I try and write as little as possible in C++, sticking mainly to C and Perl for anything which needs to execute quickly

    You're claiming Perl executes faster than C++? Bwahahaha.

  6. How does this help? by Have+Blue · · Score: 2

    By creating yet another language, they are just adding to the problem (of incompatible C/C++ derivatives). It would be better to pick one of the existing next-generation C languages and declare that the standard, or at least make the standard source-compatible with said language to ease transition.

    1. Re:How does this help? by stripes · · Score: 1

      No "it" was "Java", of corse C++ can do generics as well as the STL, the STL is just normal C++ code. (well better designed then most, but still...)

    2. Re:How does this help? by stripes · · Score: 2
      or even just non-trivially higher level than C++

      Well garbage collection alone is a pretty big step towards higher level. Now if it could just do generic algorithms as well as the STL....

    3. Re:How does this help? by rho · · Score: 5

      You moron -- that's no way to develop applications. What are you, a first year Fortran student?

      The proper way to develop software is to have long, pointless meetings where techies can show off their intelligence, marketeers can display their ignorance and managers can "lead".

      Then, everybody pisses around reading Slashdot while a few firebrands argue over what kind of versioning system to use: "CVS!" "RCVS!"

      When half of the estimated time has past, the programmers start screaming about the Mythical Man-Month and how marketing is full of shit, while reconfiguring the Cisco switch to cut latency for Quake deathmatches.

      Marketing then begins to sell the product to customers, promising to have asked-for features implemented "at beta".

      Two weeks before due date, the programmers work 22 hour days cobbling an application from stolen code from previous jobs, algorithms designed in a drunken stupor, and (apparently) one programmer bashing his face into the keyboard.

      This fresh, steaming turd gets pushed out the door to tumultuous disdain. Programmers blame marketing, marketing blames management, and the customers get told that it's Microsoft's fault.

      So keep your wacky ideas to yourself, okay rookie?


      "Beware by whom you are called sane."

      --
      Potato chips are a by-yourself food.
    4. Re:How does this help? by FFFish · · Score: 2

      It depends on how you define "best."

      If you mean fastest-executing, then you're correct.

      However, I mean "best" in terms of programmer productivity, code maintainability, and robustness. Low-level languages are not the best choice for achieving these goals.


      --

      --

      --
      Don't like it? Respond with words, not karma.
    5. Re:How does this help? by FFFish · · Score: 3

      Heck, by creating yet another C derivative language, they are just adding to the problem of inefficient, difficult-to-debug, difficult-to-maintain languages.

      IMO, the programmer community would, in many cases, be far, *far* better off writing their applications using a very high level language.

      This will allow them to spend *less* time creating the main code body, and *more* time debugging. Their applications will be less faulty.

      Then, using profiling, they can identify exactly those areas that need to be written using a low-level language for speed.

      Imagine: very high productivity, very high maintainability, very large reduction in bugs, and 96% or more of the performance!

      It's the intelligent way to work.

      --

      --

      --
      Don't like it? Respond with words, not karma.
    6. Re:How does this help? by Pig+Hogger · · Score: 2

      IMO, the programmer community would, in many cases, be far, *far* better off writing their applications using a very high level language.

      Like this one???

      Funny, however, how many machos wouldn't be caught dead programming with it???? Like if working with C was a sign of intelligence (must be those PHBs who insist on it).


      --

    7. Re:How does this help? by Shadowlion · · Score: 1

      Now if it could just do generic algorithms as well as the STL

      You can do generic algorithms in C++ right now - they just usually involve the STL to provide a generic, unified interface to arbitrary types of data.

      --

    8. Re:How does this help? by Surak · · Score: 2

      Ok, who are you and how long have you been working for my company?

      That was about the funniest damn thing I've ever read...hey, you're not like Scott Adams by any chance? :-)

    9. Re:How does this help? by GregWebb · · Score: 1

      Exactly! I've been saying this for years and it's really irritating to still see people using C/C++ as a general purpose language.

      It's overcomplicated, unfriendly and rather less readable than possible. No, I'm not a COBOL fan ;) but there is a happy medium.

      C and its descendents are a major cause of program unreliability. If we could only move to something else for general purpose coding, we might actually get code with less bugs due to silly details got wrong, which was then easier to effectively debug.

      --

      Greg

      (Inside a nuclear plant)
      Aaaarrrggh! Run! The canary has mutated!

    10. Re:How does this help? by GregWebb · · Score: 1

      I appreciate C doesn't worry about that sort of thing - we seemed to be having people arguing for making stuff really closely hardware linked, which is daft.

      The point, though, is that if I'm coding in C I still have to worry about stuff which should fall into the SEP field. I just don't need that power, and its presence slows down coding and introduces possible errors.

      --

      Greg

      (Inside a nuclear plant)
      Aaaarrrggh! Run! The canary has mutated!

    11. Re:How does this help? by GregWebb · · Score: 2

      I don't want to know what the hardware is, I shouldn't have to.

      If I'm writing an OS, a HAL, a driver or a compiler then the hardware is an issue. If I'm writing something really speed critical then I live with hardware as an issue. For anything else, it shouldn't matter one bit. That's the whole point of high level languages. I mean, honestly, when I'm writing a WP what does it matter what the endianness of the processor I happen to be compiling to today is? Or how many registers its got? Someone Else's Problem. Make it mine and I cause others for no good reason.

      --

      Greg

      (Inside a nuclear plant)
      Aaaarrrggh! Run! The canary has mutated!

    12. Re:How does this help? by Salamander · · Score: 2
      It's very hard to write good code in low-level languages.

      Hard? Yes. Impossible? No. Many people have to write in C because that's the only language supported in their environment (e.g. a kernel or RTOS). These are often systems where the requirements for reliability, maintainability, etc. are very high, and the quality tends - of necessity - to be correspondingly high. My C is more object-oriented than 90% of the code I've seen in languages designed for OOP, for example, and I'm sure I'm not the only person for whom that's true.

      Note that the previous author didn't say that the best code is *always* or even *usually* written in very low-level languages. He just said that it *often* is, and that's true.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    13. Re:How does this help? by Salamander · · Score: 2
      If you are coding an I/O intensive application, chances are that the scripting language with run about as fast as your tuned C or assembly. Your hard drive or your network card will usually hobble the most carefully tuned C or assembly

      What if you're coding the firmware for that hard drive, or the driver for that network card? Where's your scripting language then? That's why a lot of people use C, and that's the code to which I think the previous author was referring.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    14. Re:How does this help? by ttfkam · · Score: 1

      "The key is planning your code extensively, programming in a disciplined manner, and using assert() liberally, so your code is essentially "bug-free" (i.e. no "bugs", just design faults)."

      This applies to all languages. Why is C or assembly special in this case? The problem is many (most?) programmers do not plan ahead, are not disciplined, and don't use assert(). When confronted with this reality, it makes sense to have the language act as a safety net in exchange for some efficiency.

      If you are coding an I/O intensive application, chances are that the scripting language with run about as fast as your tuned C or assembly. Your hard drive or your network card will usually hobble the most carefully tuned C or assembly AND it will take much longer to write than the equivalent code in a scripting language.

      Premature optimization is the root of all evil.

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
    15. Re:How does this help? by ttfkam · · Score: 1

      "That means your new script may one day be the bane of somebody's database system, and they'll have to waste time rewriting your code"

      Once again, how is C somehow special in this case? If my script has a very specific purpose that affords no great speed disadvantage (2 seconds every hour or so), why are you rewriting it?

      If it is bad code, rewriting is a good idea. C is not immune to this statement either. If it is easy to read with an efficient algorithm, why does it automatically need to be rewritten?

      And precisely how much CPU time is being wasted here? If we think in terms of time == money (even in Free Software), the extra time spent in C as opposed to Perl (string manipulation comes to mind) might better be served by either (a) realizing that except for large-scale or time-sensitive (real-time) projects, C will not give you a sufficient return or (b) upgrading your computer. Hardware has been and will remain cheaper than people.

      That said, there are definitely times where C makes more sense. Apache ported to Perl might be an interesting exercise, but in the end a horrific goal. A C program written to be used once, like parsing a web server log (as long as there are no extenuating circumstances like multi-gigabyte sizes), would be time wasted. Perl was made for it and the extra speed that C affords is immaterial in this case.

      And finally, how are you wasting CPU cycles in the I/O and networking code case that I mentioned? If the device is still waiting for data (filling buffers et al), both a C program and a script will be waiting with an equal amount of CPU usage. In addition, most (all?) I/O and networking in modern scripting languages is written in a lower level language anyway (such as C). When the script is relatively small, you are basically running C with a thin wrapper.

      Algorithms always beat language wars. Get over it and use the right tool for the job.

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
    16. Re:How does this help? by Dwonis · · Score: 2
      IMO, the programmer community would, in many cases, be far, *far* better off writing their applications using a very high level language.

      This will allow them to spend *less* time creating the main code body, and *more* time debugging. Their applications will be less faulty.

      Actually, the best code is often written in very low-level languages, like C and assembly. The key is planning your code extensively, programming in a disciplined manner, and using assert() liberally, so your code is essentially "bug-free" (i.e. no "bugs", just design faults).
      ------

    17. Re:How does this help? by Dwonis · · Score: 2

      I define "best" as having all good qualities, including what you say.
      ------

    18. Re:How does this help? by Dwonis · · Score: 2
      I don't want to know what the hardware is; I shouldn't have to.

      That is the entire problem with today's programmers. That don't want to code blind, without knowing what they are coding for.

      Also, a lot of the things you mentioned you don't want to worry about can be transparent in C.
      ------

    19. Re:How does this help? by Dwonis · · Score: 2

      Because when you get into machine code, you only have a few registers to leave data in for the next function to see. It also makes handling your stack a lot easier (I think; can someone who does compiler design verify this?).
      ------

    20. Re:How does this help? by Dwonis · · Score: 2
      If you are coding an I/O intensive application, chances are that the scripting language with run about as fast as your tuned C or assembly. Your hard drive or your network card will usually hobble the most carefully tuned C or assembly AND it will take much longer to write than the equivalent code in a scripting language.

      That would make sense, except that today we have multitasking operating systems, which means you're wasting CPU time that could be used for other processes. Also, more and more, we are seeing code that used to be the frontend to something being moved into a backend. That means your new script may one day be the bane of somebody's database system, and they'll have to waste time rewriting your code, which is a shame (and a disgrace to the concept of free/open-source software.)
      ------

    21. Re:How does this help? by Dwonis · · Score: 2

      I recommend assert so that people use it more than one would want to for production code (due to runtime slowdowns). Besides, if people follow the other things I said (discipline, planning, discipline, etc (did I mention discipline?)), that will be a very minor issue.
      ------

    22. Re:How does this help? by jovlinger · · Score: 2

      A friend of mine once wondered why it seemed that functional programmers were more productive than others. He came to the conclusion that the cart was before the horse. Functional programming is unfortunately only popular in the hallowed halls of academia, and (yes generalising here) thus the people who were functional programmers thus tended to be more intelligent than your average code monkey.

      Case in point is that he wrote much of his garbage collector (by necessity) in C, and managed to produce some clear and consise code in a language that seems designed to thwart that aim.

      However, your post is correct in that it requires discipline to pull this off. The aforementioned code monkey has enough of that to fit in a box of matches without taking the matches out first. High level languages are no panacea: I've seen scheme code that is scary, and have, in flash of insanity, written Haskell that more resembled fortran than a proper language. However, they do make writing horrible code a bit more awkward while writing good code a bit less so.

    23. Re:How does this help? by HerbieStone · · Score: 1

      It's just like the dilbert comics. I'd like to take it on the sarcastic way and find it amusing...., but it's the reality! *sob*

    24. Re:How does this help? by fprintf · · Score: 1

      Gawd how I wish I had some mod points right now. This post has me in tears. :)

      --
      This post brought to you by your friendly neighborhood MBA.
    25. Re:How does this help? by Creepy · · Score: 1
      Having written some X-platform code, I'd be more than happy to see EITHER a library extension or additions to the main language, especially functionality many programmers now use - threads, for instance. I'd be even more happy if someone shoves it down Microsoft's throat. Microsoft is big on C++, but I doubt they'd take new extensions that only make it easier to make cross-platform coding since they lean heavily towards the proprietary side.

      For that matter, the Windows Native Thread library was the only library that wasn't easy to implement - even old macOS with coop multitasking was easier to write (the function pointer actually molds well to pthreads, which I used for UNIX, but I needed to toss in a timer to give up the thread). MacOS X has pthreads (yah!) and Windows NT sort of supports them, but NT seems to work better with it's own different model of Windows threads.

      That's just to implement a thread... and it sucked up about 4 days of time to get working at a very base level (creation, destruction, scheduling priority) on UNIX (Solaris and Linux), MacOS (pre X), Windows 98 and Win NT. Most of that time was learning the different thread models, not actually coding, but I had used pthreads before starting the project, so understood how they worked and what they did already. Had this been standardized, I could be done in 1 day, netting me 3 extra days for other work. Heck, just getting a few of the "semi-official libraries" standardized would help tremendously - so keep at it!

    26. Re:How does this help? by EzInKy · · Score: 1

      C can return as many values as you'd like in a struc...and assembly can return the value's in a struct and if speed is of essence, use the computers registers too. At some point, you get so "high level", that you forget what you are progamming for.

      --
      Time is what keeps everything from happening all at once.
    27. Re:How does this help? by jeremyp · · Score: 1

      Assert () is bad. Well, checking for possible error conditions and reporting them is good, obviously, but the ANSI assert is bad because you can turn it off for production code. This means your production code can behave differently from your debug code, particularly if your assert tests for conditions that never happen or are hard to set up in your debug environment but happen regularly in the production environment. This is particularly problematic for multi-threaded applications.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    28. Re:How does this help? by bellings · · Score: 2

      Two weeks before due date, the programmers work 22 hour days cobbling an application from... (apparently) one programmer bashing his face into the keyboard.

      Only ONE programmer where you work writes code that looks like that? You work in an extremely high quality shop, my friend.

      Of course, I work in a Perl shop. The reader is allowed to fill in his own joke here.

      --
      Slashdot is jumping the shark. I'm just driving the boat.
    29. Re:How does this help? by torokun · · Score: 1
      Garbage collection sucks my anal crevice. Does it feel so great to just forget about encapsulating memory management nicely within a class, and just spew it all over the system to let someone else clean it up for you? GC is a hack that destroys a major benefit of good encapsulation -- the ability to change your memory allocation without affecting users of your class's interface.

      Really... The only reason for it is that people are lazy and sloppy thinkers.

    30. Re:How does this help? by tpv · · Score: 1
      Actually I find that this method of code generation produces work that is well above average.

      Having only one such programmer is probably reducing their productivity.

      --

      --
      Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
    31. Re:How does this help? by Xentax · · Score: 1

      They're not creating a new language. They're working on the next revision of Standard (That's ANSI _AND_ ISO Standard) C++.

      --
      You shouldn't verb words.
    32. Re:How does this help? by Xentax · · Score: 1

      True. I didn't mean to imply that there was any real 'work' going on, only that what was being done was to _enhance_, not _replace_, standard C++.

      I was at the discussion at SD :)

      Xentax

      --
      You shouldn't verb words.
    33. Re:How does this help? by Spinality · · Score: 1

      No, Scott Adams get his ideas from guys like this. In truckloads. Daily. He freely admits that all his comics are now based on stories sent to him by his readers. -- tb3

      Well, plus his years of PacBell experience as a card-carrying nerd himself. He draws on a lot of his own battle scars -- otherwise he never could have become so funny.

      --
      -- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
    34. Re:How does this help? by Matthew+Austern · · Score: 1
      They're working on the next revision of Standard (That's ANSI _AND_ ISO Standard) C++.

      Actually, just to be picky: we are not working on the next revision of Standard C++. We are just beginning to think about working on the next revision of Standard C++. Many people on the C++ standardization committee believe it's time to start thinking about what the next revision should look like, but the committee has not officially started work on it and there are as yet no official plans for it to do so.

      There will be a standardization committee meeting next week, in Copenhagen, and there will be some informal discussions about this, with something like Bjarne's SD talk as a starting point. Formal discussions have not begun and have not yet been scheduled.

      There's an intermediate step between doing nothing and coming up with a whole new revision of the language: a technical report that describes some semi-official library extensions. (One obvious candidate would be hash_set and hash_map, which are now widely in use but which exist in at least three slightly different versions.)

      It's generally agreed that library extensions are more appropriate at this point than core language changes, so I think it's likely that we'll see that library extension TR before we see a new C++ standard.

    35. Re:How does this help? by tb3 · · Score: 1

      No, Scott Adams get his ideas from guys like this. In truckloads. Daily. He freely admits that all his comics are now based on stories sent to him by his readers.
      -----------------

      --

      www.lucernesys.comHorizon: Calendar-based personal finance

    36. Re:How does this help? by oodl · · Score: 1

      > Actually, the best code is often written
      > in very low-level languages, like C
      > and assembly

      False! It's very hard to write good code in low-level languages. Low-level languages just don't provide the proper constructs for organizing code clearly. For example, in C, functions can only return one value (at least directly). That's totally ridiculous. A general purpose language in the year 2001 should definitely allow multiple return values.

      How about memory management? In complicated systems, managing memory manually leads to messy code.

      How about exceptions? Exceptions make code cleaner. C doesn't even have exceptions, while the exception mechanisms in C++ and Java are lame compared to those in a language such as Dylan.

    37. Re:How does this help? by oodl · · Score: 1

      Why should you have to pack the items that you want to return into a struct? That's lame.

      C was okay considering the time period in which it was developed (late 60's)... but it's time to move onto more productive languages.

  7. Re:Who needs it... by Eccles · · Score: 1

    I don't use VC++ much, but I think I read (C/C++ UJ) that this is a preference that can be changed to put 'i' in the correct scope.

    You can do (hope I get this right)
    #define for if (0); else for
    in some core header file, and then your for statement variables will have the proper scope.

    Seems like it shouldn't have taken that much effort to fix the Windows headers to match the standard, though.

    --
    Ooh, a sarcasm detector. Oh, that's a real useful invention.
  8. Re:Who needs it... by Eccles · · Score: 1

    Your method will break anything like this one.

    It's supposed to. Your code (ignoring the HTML gobbling of <) is not legal under the ANSI/ISO C++ standard. Under it, variables declared in a for statement got out of scope at the end of the compound statement.

    --
    Ooh, a sarcasm detector. Oh, that's a real useful invention.
  9. Re:Something I've wanted for a decade... by pod · · Score: 1
    While I have no idea what you just wrote there, or even if it's valid, but this brings up a major issue:

    The C and C++ specs leave many conditions 'undefined'. That is to say, compiler writers may handle a given situation as they like (generate error, do the Right Thing, who knows?). This always boggled my mind... here you have a bunch of smart guys writing a complex document defining a language millions of people will use for the next few decades, they come up with problem situations and just shrug their shoulders? Undefined? Don't do this? WTF?!? They obviously though this could be a problem that would come up, so why no default behaviour?

    --
    "Hot lesbian witches! It's fucking genius!"
  10. Re:Something I've wanted for a decade... by pod · · Score: 1

    Yes, but then you have non-portable code. C specifically was designed for portability. So now you have code that relies on some implementation defined behaviour that may or may not be the same on other platorms, even using the same compiler. I understand the reasons for doing this somewhat, but things like a[i++] = i++ _should_ have precisely defined behaviour. Constricting the ++ operator might lead to inefficiencies on some architectures, but really, when half a dozen characters lead to undefined behariour there's a problem.

    --
    "Hot lesbian witches! It's fucking genius!"
  11. Visual C++ 6.0 frustrations by Per+Abrahamsen · · Score: 2

    Here is the problems I had when trying to compile code (that worked on GCC 2.95 and Borland 5.0) with Visual C++.

    - The compiler crashes if you look at it the worng way. Internal errors everywhere.

    - The for scope was wrong. Luckily, someone suggested a macro that would compensate for that.

    - Lots of silly arbitrary limits, for example debug symbols can at most be 255 chars. That is ok for C, but not for a mangled C++ template. There is a pragma that remove the warning, except that it doesn't work for static objects.

    On the other hand, their development environtment is nice, and their library beats GNU and Borland.

    Will 7.0 make me happy?

    1. Re:Visual C++ 6.0 frustrations by krlynch · · Score: 2

      and their library beats GNU and Borland.

      That's because they didn't have anything to do with writing it :-) Dinkumware provided most of their standard library, and went to impressive lengths to work around the issues in the compiler.

  12. Re:No kidding... by Per+Abrahamsen · · Score: 2

    > The C++ definition used to say the scope of
    > variable was the scope that surrounded the for
    > loop.

    That was many, many years ago.

  13. Re:No kidding... by Per+Abrahamsen · · Score: 2

    > The reason why it's not the default setting is obvious.

    GCC implement the "new" semantic, but still accept code that would be valid with the old semantic with a warning (by default).

  14. Workaround for broken for-scoping by Per+Abrahamsen · · Score: 2

    // Work around broken for-scoping
    #define for if(0);else for

  15. They will merge as much of C99 as practical by Per+Abrahamsen · · Score: 2

    I doubt you will have to fight for features already in C99, while Bjarne probably won't get his wish for a common C/C++ standard fullfiled, I assume the new C++ standard will adopt most of the C99 features. Even though the C standard commite didn't made the job easy. I.e. C99 has a complex keyword, giving trouble for the C++ complex template.

  16. They are called "class" by Per+Abrahamsen · · Score: 2

    Uses "class" to create new types.

    I like that this works:

    typedef double time;
    typedef double distance;
    typedef double speed;

    time hours = 2.0;
    distance miles = 30.0;
    speed mph = miles / hours; /* not an error! */

    1. Re:They are called "class" by Per+Abrahamsen · · Score: 2

      #1, basically, this is the "use class" again. class is the abstraction mechanism for creating new types, not typedef.

      #2, we are trying to get away from the preprocessor, not towards it.

    2. Re:They are called "class" by jeremyp · · Score: 1

      There are two ways around this.
      1. An operator overload for dividing distance by time:

      speed operator/ (distance d, time t)
      {
      return (speed) ((double) d / (double) t) ;
      }

      After all it's only your knowledge of physical laws that lets you know it's OK to divide distance by time. Is it meaningful to add a distance to a time? It'd be great to have a compiler that gave an error when you did something like this:

      mph =miles +hours ;

      2. Have an alternative to typedef that ignores the strong typing e.g.

      #define distance double

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  17. Re:A serious (rather unpopular) hope... by Per+Abrahamsen · · Score: 2

    > 1. Losing the pointless duplication of
    > declarations in .h files.

    Not necessarily a good thing. Redundance catches errors.

    > 2. Virtual methods can be determined by the
    > linker, so the programmer no longer needs to
    > specify virtual-ness at all.

    Definitely not a good thing, virtualness is important when reasoning about a class. After a call to a virtual function much more state is uncertain than after a call to a non-virtual call.

    > 4. Inlining and template instatiation can be
    > post poned until link given a sufficiently
    > sophisticated intermediate format. In fact the
    > compiler can inline any method or function.

    This has been the case for a long time, with gcc -repo or Sun CC.

    > 5. No more name mangling.

    The type information has to be represented somehow, name mangling is not really different from other means.

  18. Re:A serious (rather unpopular) hope... by Per+Abrahamsen · · Score: 2
    The only errors this catches are discrepancies in the header and source, which of course would be avoided by this feature.
    A discrepancy means one of the places is (likely to be) wrong compared to what was intended. If you eliminate one place, there is no a priori reason to assume it will be the wrong one that is eliminated. Redundancy in specifications thus helps catching errors, because you have to be wrong twice for the error to go uncatched. Same principle as parity checks.
    Virtualness is an implementation issue which is exposed in the base class because of linker limitations
    Virtualness have nothing to do with implementation, and everything to do with specification. When calling foo->bar (), the caller know excatly what the function will do if bar is non-virtual, and must assume anything can have changed if bar is virtual. This is important for writting robust code. Functions should be made virtual only after careful thought.

    This issue has been confused by some poor OOP language which doesn't have the ability to specify non-virtual function. These languages should not be used for robust software.

    However with sufficiently advanced linking technology, no mangling need be done at all. Its a kludge to get around old linkers.
    It simply doesn't matter. The same information must be represented, the form (a mangled string, or a struct) is simply an implementation detail.
  19. I hate to say this but, Stability... is good. by root · · Score: 2
    Why does the language have to change every few years. It just makes old code harder to compile down the road because there are n version of the language. Did we learn nothing form BASIC being pulled in 50 different directions? Quit screwing with the language and work on the standard libraries.

    How about creating <stdgui.h> ?

    A classic case of "If it ain't broke, don't fix it." And C was never broke. C++ is and remains a monstrosity of unneeded evil.

    1. Re:I hate to say this but, Stability... is good. by kevinank · · Score: 2

      C++ is pretty much a kitchen sink language, so I'm not terribly surprised to see that Stroustrop wants to add introspection, which is one of several features that Java has and C++ does not.

      Maybe he'll also standardize a garbage collector, a window toolkit, etc.

      Sigh. Most C++ compilers still don't handle Templates correctly which is only okay because most C++ programmers (myself included) don't use them correctly either.

      --
      LibBT: BitTorrent for C - small - fast - clean (Now Versio
    2. Re:I hate to say this but, Stability... is good. by kevinank · · Score: 2

      Getting code to compile is one thing. Getting your linker not to spew out 150 copies of the generated template class is quite another, and the pragmas required for doing so without hiding the implementation class vary from compiler to compiler (except MSVC which handles the problem in its linker.)

      Moreover, templated code is extremely annoying to debug.

      Despite its lack of type safety I prefer abstract base types (like void*) for container implementations rather than STL like type safe containers. The overhead of STL templates is getting a new copy of their whole btree algorithm for each new type you'd like to build a map from.

      --
      LibBT: BitTorrent for C - small - fast - clean (Now Versio
    3. Re:I hate to say this but, Stability... is good. by jeremyp · · Score: 1

      I regularly write code to be compiled with GCC and VC++ and provided you stick to ANSI standard stuff, I have not found any piece of code that (if correct) would not compile with both compilers *and* lead to the same behaviour in the resulting exe.

      gcc generally reports errors better e.g. if you get an unresovled function call, it'll tell you where in your source code you tried to make the function call.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    4. Re:I hate to say this but, Stability... is good. by jeremyp · · Score: 1

      But a default of private is better, so you need to introduce a new keyword to stop all your existing C code from breaking completely. Of course it'll break completely anyway because of the strong type checking in C++, but you could argue that the struct keyword is unnecessary (as Java programmers do) since a classic C struct is merely a class with all public members and no methods.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    5. Re:I hate to say this but, Stability... is good. by chainxor · · Score: 1

      I don't agree. C++ is a much cleaner language than C. Yes, it is bigger (Templates and OO), but it's not a monstrosity. Personally OO is indeed a good thing (and templates if you use them in a clever manner), especially when projects get big. Of course the programmers would need to have an understanding of OO concepts or else the code will just be mishmash of C and some weird use of C++ constructs all mixed like a plate of spaghetti.

    6. Re:I hate to say this but, Stability... is good. by chainxor · · Score: 1

      Personally I use MSVC 6++ compiler whenever I can, and templates works just fine there.
      I remember having some problems with GCC some time ago, but isn't that supposed to be fixed now?
      I don't about CodeWarrior's compiler - anyone?

    7. Re:I hate to say this but, Stability... is good. by DagSverre · · Score: 1

      Are you serious? MSVC 6 has the worst template support I've ever encountered on (modern) compilers. GCC does on the other hand allow you to do about everything in the standard with templates these days.

      Examples? Libsgic++ (ligsigc.sourceforge.net) had to be dumbed down and partially rewritten in the MSVC 6 port. I can give you an example right here as well (which I've encountered myself):

      template [class C, class T, T (C::*funcPtr)()]
      class someClass {};

      This code won't compile for me in VC, if anyone got it working please tell me how...I fear it can't be done though. If anyone is wondering, this example would be used like this:

      someClass[MyClass, int, &MyClass::GetSomeInt()] myVar;

      Meaning, it takes a class, a type, and a pointer to a function in the class returning that type. If you pass in the pointer in the constructor instead you loose four bytes of run-time memory just on this, which isn't crucial but merely irritating. (And the class would only be instantiated once for each different T anyway so no higher code size either).

      ([ and ] is supposed to be sharper, not feeling like writing HTML right now, sorry...)

    8. Re:I hate to say this but, Stability... is good. by gnuLNX · · Score: 1

      Well said. I have programmed in c/C++ for about 4 years now. It wasn't until I actually started using some C++ GUI toolkits that I realized that I wasn't really programming in C++. The toolkits forced an OO upon me and I realized the true power of OO programming once I took the time to learn how to think in OO terms. Just because you define a class doesn't mean that you have done anything OO. Most people that I know that critasize OO programming and C++ don't really know how to programm in C++, instead they are C programmers which is good n it's own right. But C programmers shouldn't put down C++ until they have taken the time to learn the language the way the language is meant to be used.

      --
      what?
  20. ``simple platform-independent abstractions''. by Kaz+Kylheku · · Score: 2

    The problem with these is that if you make them too simple, nobody will want to use them. If you make them too complex, they won't be widely implemented. And there isn't really a satisfactory middle ground either, it's more of a fine line. One missing little key feature can make an interface unsatisfactory, if not outright useless.

    There exist standard such abstractions for C programming, under the umbrella of POSIX and The Single UNIX Specification. These abstractions are not as widely implemented as, say, the standard C library! We are still not at the point where you can write POSIX code and expect it to work everywhere.

    Any interface that is going to be acceptable to a wide range of C++ vendors is going to have to be dumbed down and braindamaged beyond repair.
    For example, a standard C++ threading library probably won't be able to have useful POSIX behaviors in it because Microsoft would leave them unimplemented in future generations of Visual C++. So you will end up with some weak interface that caters to the lowest common denominator, and which programmers will soon learn to avoid.

    On the other end of the scale, you could end up with a situation in which the powerful, useful systems extensions are are an optional part of the C++ standard, and one that is only implemented properly by people who have a clue, over top of high quality operating systems. And so only developers targetting only these systems will be able to use the interface. Still, it's better than an interface that all programmers avoid.

    I suspect that for some time to come, the real tool for portability will be something that is already there: good old preprocessing directives that allow you to roll several similar programs into one. :)

    The ultimate solution to the portability problem is to actually have one operating system running everywhere. Portability is achieved with greater ease at the lowest levels, and doing it there provides the greatest leverage for everything else. Example: it's easier to have Linux running on some portable device and recompile existing programs for it, than to port applications to some exotic embedded operating system on the same device! This is particularly true because such devices are increasingly built around standard, advanced architectures that fit the model expected by an advanced operating system. The idea of using the same advanced OS for small and large computing is pretty much here now.

    Windows CE teaches us that it's not even enough to merely have a reimplementation of the same system call interface. Anyone who has had to port Win32 sofware to Windows CE will understand! If you port the actual kernel, that's a big difference, because you port every nuance of the behavior behind that interface. It's not possible to specify every such nuance in a document and have everyone implement it exactly, and it's hard to be certain to what extent an application depends on these nuances!

    Remember, when Thompson and Ritchie presented C and UNIX to the world circa 1974, it was the portability of the operating system that impressed the world. The portability of C programs rested on the retargettability of the C compiler and porting of the OS, not on writing in a standard language using standard interfaces! Porting C programs to different operating systems came later (and is not really all here yet, nearly thirty years later).

    This is what language standardization is really about: a bunch of conflicting big interests bent on preserving their piece of the pie. Nobody wants to come out and admit that there needs to be one *implementation* of one interface running everywhere, because that would mean giving up their proprietary operating systems and interfaces, whose incompatibilities they secretly cherish. Since nonportability of software is caused by secrecy driven by ego and greed, universal portability will only be achieved when we recognize the root causes and do something about them. Right now, with our programming language standardization efforts, we are accepting these causes as immutable givens, and working *around* them to create solutions that are incomplete and unsatisfactory when translated to action in the software development trenches.

    1. Re:``simple platform-independent abstractions''. by Ayende+Rahien · · Score: 1

      Not a single OS, a single platform, which all OS should implement.
      Frex, did you know that NT is 100% POSIX complient? (Giving MS a reason to have the threading support done well)

      Java was a good promise, but it's *way* too tied down to one language.
      Yes, you *can* compile other languages to byte code, that is not enough, you have to force your code into Java-like in order for this to work.

      I believe that .NET is a better solution, if it will be as good as I hope (multi lanuage, multi platform, openly speced), it might be just the thing that you are looking for.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  21. No1 Wish: try/finally by tjansen · · Score: 1

    My number one feature wish for C++: try/finally clauses, like in Java. While I rarely use them in Java, they would be REALLY useful in C++ and make dealing with exceptions much easier. I do not know how many times I have written:

    try {
    // allocate something
    }
    catch (...) {
    // free it
    return;
    }
    // free it, too

    This means lots of duplicated code (or many auto pointers and similar stuff) and many potential bugs.

    1. Re:No1 Wish: try/finally by tjansen · · Score: 2

      You can use a auto_ptr only if you have allocated something using new. If you malloc'd it, or used some (C) library that requires you to call a function to free the resources auto_ptr cannot help.

    2. Re:No1 Wish: try/finally by stripes · · Score: 2

      auto_ptr is less then 100 lines of code. You can take the one from and template it up a bit more to use any allocate/free functions you like. You can even get some counted versions from boost.

      finally may still be nice for some things, but following the "all resource allocation is object creation/all deallocation is destruction" design will eliminate 99% of those.

    3. Re:No1 Wish: try/finally by J.Random+Hacker · · Score: 1

      Well -- the other way to handle this is to use a class to manage the connection. Create a class to manage the DB connection, and have this class do the grunt work of creating or obtaining the DB connection. This can be done in the constructor or in some member function (more likely in the code you gave above). Also have the destructor close or return the connection. The class should also be able to handle the case where no connection is available correctly.

      If the instance is allocated on the stack, you'll get the connection cleaned up when you leave that scope. This does everything that the finally would have done, and the class will be usable in other locations -- a great help in the example you give, since the pattern is likely somewhat common in your app.

      This is a really old idea, btw -- it was mentioned in the first edition of "The C++ Programming Language", IIRC.

    4. Re:No1 Wish: try/finally by The_Messenger · · Score: 2
      But what if the resource you're trying to free isn't a pointer? What if it's, say, a database connection? I do this in Java all the time:
      try {
      // get database connection from pool
      // connection used for useful task
      } catch (WhateverException iExpect) {
      // error code
      } finally {
      // return connection to pool
      }
      I think that finally is a great keyword, and I think this is the best suggestion I've read here yet. I hope that someone on the standards body reads this!

      Some of you are saying that finally encourages bad design. Rather, I feel that instead, most C++ programmers don't use the try/catch mechanism to its full potential. Hacking in Java has actually made me a better C++ programmer.

      --

      --

      --
      I like to watch.

  22. Re:Would you please by stripes · · Score: 2
    Please put in the sockets and signals that Qt implement? Those are damn nice.

    I like the libsigc-- ones better, far more runtime checking, adaptors, and I think they are even faster. OSS license, and avail. on sourceforge. They are not GTK+ specific, even though it was originally designed for use there.

  23. Re:What about making it a little less bloated? by stripes · · Score: 2
    That's simply impossible. A C++ virtual function is an array index (into vtbl) followed by a call through a pointer

    Nope. It is an array index followed by a jump to that location which contains a jump to the new location. Or at least that is a common way to do it (it does double the size of the vtbl). That tends to make branch predictors happier...

    Now other then that one little edge, I did kind of forget the extra indirection, which does make the C++ call a bit slower, but compared to the cost of the pipeline bubble from doing a jump through a pointer, or for having the BTB miss (10 to 20 cycles) the extra two for the indirect (assuming a cache hit) is pretty minor.

    Oops. My bad.

  24. Re:Rationale Garbage Collection Explained -- sort by stripes · · Score: 2
    Properly implemented, GC has no impact on the classes interface, or even the lifetime of the objects.

    Only reference counting can destroy objects as quickly as explicit memory management. Reference counting is also the slowest GC, and frequently not even accepted as GC because they break in the presence of even trivially circular objects. So what most people would think of as good GC will extend the lifetime of objects somewhat (except when they fix a memory leak and radically reduce the lifetime of the object).

    If your destructor is important, use of auto_ptr or other "smart" pointers will be needed even in a GCed language. (don't get me wrong, I like GC, I just don't like overselling it)

  25. Re:What about making it a little less bloated? by stripes · · Score: 2
    That double indirection is a loader artifact, not really part of the language.

    It is independent of ld.so. Well actually it might be done for similar reasons. It use to always be an indirect jump (like in C, but with the vtbl indirection), but has been changed to a jump through a jump because that runs faster on many platforms.

    See the gcc C++ archives for details, or maybe you can find a comp.arch archive.

  26. Re:What about making it a little less bloated? by stripes · · Score: 2
    don't understand this. Is this because the processor assummes that any location you jump to is involitile? It seems that an indirect jump could be "predicted" just as well by assumming the contents of the pointed-to memory location is the same as last time and this would require no more circuitry than the jump-to-jump predictor.

    I'm not a CPU designer, but I hang out in comp.arch a lot. So take this with a grain of salt.

    Some CPUs sniff writes to areas covered by the i-cache, and will do a lot of work when they are detected. Assuming BTB targets must be in the i-cache (true on some CPUs) that provides a good way to catch changing tables of jumps, but not tables of jump addresses.

    No CPU I know of sniffs BTB source addresses. I think that is in part because BTBs became popular in micros well after self-modifying code became "evil".

    Many CPU's (pretty much everything other then the x86 -- and other really old things like the 390) require a (i-)cache invalidation between modifying code and executing that code. The cache invalidation will also invalidate the BTB. So the CPU can feel free to use the BTB to optimize a JMP-JMP sequence, but not to optimize a indirect jump.

    While I'm on the topic of CPUs, I think the POWER (incl PowerPC) has dedicated branch registers, and doing an indirect branch through them is quite fast, at least if the CPU has time to prefetch the targets, or they are in the i-cache. Except on the PowerAS where the branch registers aren't special, but the pipeline is so short (an amazing six cycles at 500+Mhz) pipeline stalls are cheep enough that they don't do target prediction, and only static branch prediction.

    Could a CPU make indirect branches as fast as JMP JMP branches? Sure, but I think it would slow down all data stores, or the all uses of the BTB, or both. It doesn't seem worth it with current language usage. Could C implement function pointers as JMP JMP? Sure, but that would make function pointers wider then normal pointers (or waste space in normal pointers).

    Does this make C++'s virtual function calls faster then C's? That is going to depend a lot on the CPU, and the usage patterns. I doubt they will be faster on a PowerPC, but they could be faster on a AMD K7, or the Intel P3 and P4, and they were for sure in one usage on the SPARC for me. Which is why I went down this rathole in the first place, to figure out how that could be.

  27. Re:What about making it a little less bloated? by stripes · · Score: 2
    I truly don't understand this. C always can tell the pointertype, because it is static. Or are you thinking about equivalent code in C?

    I was talking about the equiv code. Yes, C always knows the pointer type, or more accurately C assumes it knows the pointer type, and if it is wrong, the programmer (or user) will pay.

    The discussion is idiotic. Algorithms and design are what's crucial, not syntactic sugar. High-level languages just improves your efficiency by many orders of magnitudes (whatever that is).

    It is your right to think that. Personally I find it easier to bring people into the fold by convincing them to use the more powerful language, and it's cheeper features.

    Of corse the first time you look at code that finds the 95% percentile by doing sort, and replace it with nth_element converting a O(NlogN) algo into a O(N) algo and save days of runtime in a billing application, yes, they will buy the algo argument. One savings like that can make up for a lot of runtime ineffecency.

    However if you never get them to use C++, you will never get them to "just call nth_element". So I like to start by saying "Yo, if you micromanage C's runtime speed, you can do that in C++ too, and while your in there try templates, they'll make that micromanagment way simpler, go check out the STL too....". That tends to convert more people.

  28. Re:What about making it a little less bloated? by stripes · · Score: 2
    Pick ANY task.

    Mmap a large binary file, treat it as an array of int, sort it. Treat it as an array of char, sort it. Use the language provided library to do both sorts.

    Write a C and C++ program to accomplish the task.

    Done. The C++ STL version is a few lines shorter then the C qsort version.

    Pick any C and C++ compiler. You make the choice of which.

    The gcc provided with BSD/OS 4.2 x86, or the SPARC version. For both languages.

    The C code will finish first. Always.

    Odd, the C++ program seems to have been eight times faster. Oh, look now that the file is in the cache it is 14 times faster.

    You simply cannot argue with facts.

    What's the alternative, arguing without facts, as you have just done?

  29. Re:What about making it a little less bloated? by stripes · · Score: 2
    I think the point is that the tables of jumps do not change, and thus the icache is not invalidated. The table being talked about is the vtab for a given class and it is a constant.

    Exactly. The hidden costs the other poster was talking about don't exist.

    This jmp-to-jmp stuff is a way to fool the CPU cache and predictor circuitry into assumming the location is constant, because it figures that jmp instructions are constant. It does seem kind of annoying that it is worth doubling the table size (and thus halving how much fits in the cache) in order to get around a mistaken programming assumpition by the CPU designers.

    Well, it doesn't so much fool the CPU into thinking the location is constant as to actually inform it that the location is constant.

    I think it would be better for a CPU jump predictor to assumme *everything*, whether in instruction, read only, or read/write data, is constant. Modern C++ code typically accesses a given location many orders of magnitude more times than it modifies it!

    C++ isn't the only thing that runs on a CPU. It may well be a good idea to have a indirect jump that does allocate a BTB entry, or to have BTB entries allocated if the indirect address is on a read-only page (this may be hard to tell). Of corse one could only do this on a CPU that deals with the BTB entry being incorrect (most modern CPUs do, OOO machines can do it fairly trivially), otherwise you can get some odd problems.

  30. Re:What about making it a little less bloated? by stripes · · Score: 2
    You're so full of crap. Yes, those hidden costs do exist and must be paid *even though* the contents of the table are in fact effectively constant. That's the problem. You still have to invalidate the i-cache, you still have to forego VM-level optimizations, etc. because the values *could* change.

    Eh? The vtbl is stored in immutable code space (in most implementations), after all the vtbl is immutable. The only i-cache invalidate is done when the OS maps the page in the first time. I'm unaware of what VM optimizations are being forgone.

    You can bitch about the vtbl being immutable is a bad requirement, and prevents C++ from being as flexible as Ruby. But that is a different topic.

    So I say there are no hidden costs in how C++ implements this trick. You can argue that there are hidden costs in how the CPU thinks about i-space, but that is a very different argument.

    It does no such thing. Any CPU that makes such an assumption about the immutability of i-space could be considered broken.

    With the sole exception of the x86 all modern CPUs are broken? They all assume that i-space is very seldom altered, and that that altering can be quite costly. In fact even the modern x86 assumes that. The other CPUs require an i-cache invalidate, the x86 makes stores slower by snooping i-cache address, or they make the i-cache smaller, or both.

    That seems a little silly as i-space modification is rare, it wasn't even all that common when it was easy. The only place I can think of where it is all that useful is a low level graphics system, but that kind of code can be frequently be pre-expanded, or even more commonly hardware assist is used now anyway.

    I have written self modifying code (at least) three time in the last 20 years. I don't mind it being slightly harder now. Have you ever written any?

    That breakage can be worked around by having the VM system play nasty tricks with making i-space pages read-only etc., but the cost of having to cover for the CPU's deficiencies like that is much greater than the benefit.

    Or frequently at the "cost" of finding stray pointer usage much sooner.

    Try looking at the problem from a *system* standpoint for a change, instead of a myopic "how can a CPU designer avoid work" standpoint.

    From a system standpoint making self modifying code faster makes everything else slower. Is there really enough self modifying code to make that a good deal?

  31. Re:What about making it a little less bloated? by stripes · · Score: 2
    No, it's the same topic because it impacts the same solution.

    I thought the topic was whether the C++ double jump through a vtbl was better then a single indirect jump through the vtbl. C++ does not allow overloading of functions of a single object, it requires a new class for that. So C++ will not benefit from a writable vtbl.

    If the topic is something else, please let me know so I can either argue my point, or agree with yours.

    Please stop trying to redefine the topic to suit yourself.

    Well it was a reply to a C++ article, so I assumed we were discussing C++, and CPUs slipped in in relationship only to that. I admit I may be talking about a different topic then you though, but not to frustrate you, but because I was unaware you were discussing something else.

    "Seldom" is not equal to "never", and we were talking about the assumption that i-space would *never* change because that's the only assumption that would make the proposed solution seem reasonable.

    No CPU I know of has that assumption. All of them allow a i-space change, because all of them need to allow programs to be loaded in. Given the rarity of the changes many require something fairly expensive to be done after the change (like an i-cache flush, or on things like the MIPS a controlled flush of some of the lines).

    We're not talking about self-modifying code, as much as you seem to be hoping that the taint associated with that phrase will stick to anyone who disagrees with you. We're talking about mutable data in i-space, and about the nasty hack of using double jumps with the intermediate target in i-space to "trick" CPUs and make method dispatch a cycle or two faster without considering the effect of such a hack on the rest of the system.

    Ok, does that mean you think the vtbl is mutable? The vtbl is immutable. It is never changed. It is a constant. I don't even know any non-portable ways to change the vtbl.

    If C++ itself was changed in a way that needed mutable vtbls I expect the double jump through a vtbl would be changed back to an indirect jump and the vtbl moved to a writable area. But I'm not sure. It might be cheeper on some CPUs do do selective i-cache flushes (like on the CPUs that allow single cache lines to be invalidated).

    But you're almost right. Making this particular hack work faster makes the rest of the system slower. That's exactly the point. Congratulations on finally getting it.

    Are we talking about the way C++ uses the CPU? If so it doesn't make anything slower as it uses immutable i-space to hold immutable data (technically it is code I guess, but immutable none the less).

    If we are talking about the way CPUs make modifying i-space expensive, then I expect you are wrong, but it does depend on exactly what code you need to run. It is a big argument, and unless it is one you are interested in I'll leave it dormant.

    If we are talking about something else please do let me know.

  32. Re:What about making it a little less bloated? by stripes · · Score: 2
    I'm sure we could have a very interesting discussion about the relative merits of double jumps vs. indirect jumps if you'd cooperate, because you seem to know more than most /.ers about how CPUs work. However, as long as you're going to deny that these systemwide costs exist at all - things like false sharing, extra interprocessor communication in an SMP system to do TLB shootdowns, pollution of the BTB when the regular L1 cache is damn near as good - then that's not going to happen.

    Those things do exist (for the most part). C++ doesn't cause them though. C++ using the double jump doesn't make these problems any worse (except, arguably "pollution of the BTB..."). If you are not intrested in C++'s use of this feature and want to disscuss modifyable i-space in genneral, I'm fine with that.

    But could you let me know what the hell the topic is?

    Now of the costs that you listed, what do define "false sharing" as, and what does "pollution of the BTB when the regular L1 cache is damn near as good" mean?

    then that's not going to happen

    Well it won't happen unless we are both on the same topic. Care to let me know what the topic is?

    How disappointing.

    Pretty much, but you can change that.

  33. Re:What about making it a little less bloated? by stripes · · Score: 2
    Ahhh, but it does. On an architecture designed around the "i-space modification is rare" assumption, writing to a vtbl *even* at object-creation or class-loading time incurs a substantial overhead in exception handling

    The vtbl is not ever written to. On a unix system it is part of the ELF or a.out code area. The linker figures out how it looks, and it is not changed at runtime.

    It might be different for a dynamically linked library, but the normal C linked libs frequently (but not always) work that way. BSD/OS does the double JMP trick (at least on the x86), using a ld.so that it got from FreeBSD, which uses a ld.so borrowed from, or inspired by the Linux version. So there is a good chance all three systems do it the same way.

    Of corse dynamically linked C++ code is quite rare. Or at least using C++ libs dynamically, it is common for C++ code to use dynamic C libs. This has a lot to do with defcicencies in the ABI, and in template generation code.

    So for a static linked program the vtbl is never ever written. I'm not sure about dynamically linked ones, maybe I'll go check.

    This is different from the modifications that must occur at image-load time (including DSO-load time) because those have distinct boundaries and the OS can treat pages differently during that period than afterward. Maybe if parts of the C++ runtime were integrated into the OS loader this could be handled more efficiently, but that's a heinous idea for other reasons.

    For statically linked code it is the same as being done at image load time, because the vtbl is filled out at image load time (before that actually).

    For dynamically linked code it is also not all that different (I assume) because ld.so does similar things for the C code, and it also has minimal OS support (the mprotect(2) call, make the stub tables non-executable+writable, change them, make them executable+read-only).

    Similarly, the whole point of the double-jump seems to be to abuse the BTB for performance. I call it abuse because every method pointer that's stuffed into the BTB is one less BTB entry that can be used for *real* branches.

    That's an opinion based on whether you view it as a kludge or not. I view it as a real use of the BTB because I view the BTB's job a keeping the pipeline filled in the presence of branches.

    Some CPUs allocate BTB entries for normal JMP and JSR instructions. The AMD 29k did that, the BTB held an address and the actual instruction. Modern CPUs don't tend to do that because the pipeline is too long to be happy with just one instruction. Some modern CPUs still keep entries for all branch/JMP/JSRs, but the BTB has a "internal pointer" to the i-cache line. This is rare because it is only useful on CPUs where the i-cache lookup takes more then one cycle (otherwise the internal pointer is no win).

    CPUs like the HAL SPARC64 actually unfold i-space around control flow instructions, so the JMP-JMP would be replaced with the straight line code, no BTB would be allocated. I'm not sure about the P-IV's trace cache as I don't know if it is a true trace cache, or just shares the name.

    In any event I think using the BTB entry to make the JMP JMP faster is a great thing, it avoids a pipeline stall. If that means some other branches can't fit, well at least it got used in some places.

    However here I'm only arguing my opinion vs. yours. The right thing to try would be to convert from JMP JMP to a indirect JMP. If the indirect JMP is faster then you are right for that workload. If the JMP JMP is faster then I'm right for that workload. It's probably not all that hard to get gcc to produce either kind of code, so the big issue would be finding the right workload.

    Any ideas?

    very fast special-purpose cache; there's another cache - the L1 - right nearby that could also contain that same information

    The BTB is actually included in the L1 cache on some CPUs. At least one SPARC, and I think the AMD K7. The down side is they limit the number of jumps that can have a BTB entry per cache line. I guess the other down side is they make the L1 cache take more transistors per line, and possibly reduce it's size.

    So you save yourself a cycle on the method dispatch (if repeated) by using the BTB instead of the L1, in return for which you create a nice fat pipeline bubble for someone else when they hit a branch that would have fit in the BTB if not for your shenanigans. That's not a win, it's just shifting the load.

    Oh, it's more then a cycle in many CPUs. In fact of all the modern CPUs except the PowerAS it is a fair bit more then a cycle, if you read the PowerAS papers they make a big deal about it. I think the PowerAS is also known as the IBM North Star, it is the CPU in their more recent AS/400ish systems.

    I do agree that if the BTB entry for the JMP JMP pushes out an entry that would see at least as much use it is just shifting the load. Or worse if it pushes out an entry that is used more. A good BTB replacement algorithm can reduce the chances of that happening. A very large BTB (like the ones tied directly to the L1 cache) will also reduce the chances.

    On the other hand the BTB entry for the JMP JMP may push out a less often used entry, or no other entry at all. In those cases it is a win.

    The question is, does it win more then it loses? The true answer will depend on the CPU and the benchmark. I expect it to be a win though.

    I sincerely hope you're asking how false sharing applies to this particular situation, not what false sharing is, because if you meant the latter then you should be reading H&P instead of posting here.

    Yes, I'm asking how it applys here. I read H and P in '92. I know there is a new edition, but getting it is pretty far down on my reading list. It did actually make it onto my bookshelf and there have been 4 moves between then and now though.

    False sharing is an issue because a single cache line on a modern processor is likely to span multiple vtbl entries. Naive vtbl-patching code that does manual icache invalidation would therefore be likely to go through all that overhead multiple times.

    For a statically linked C++ program there is no vtbl patching. None. For a dynamically linked one I don't expect the costs to be different from the C version which has a similar table.

    ck. The only alternative would be to have the vtbl-patching code be *deeply* aware of the local machine's cache line size (i.e. not just hidden in some memory-munging library routines). Also ick. That kind of machine-specificity needs a reason, and there just doesn't seem to be much of one so far.

    Yeah but the assumption would probably be 16 bytes because that is a really really common number, and even if it happens to be only 50% or 25% of the cache line that is better then doing only a single address.

    Of corse that would be if there were any vtbl patching code, because there isn't any.

    The same as it has always been, Sparky: whether double jumps as an alternative to indirect junks are a reasonable or sucky idea.

    Independent of context?

    If you know that the target won't be altered you can get a very different answer then if you assume the target will be mutable. Or even a different answer on mutable but almost never changed vs mutable and changed frequently.

    The answer can also depend a lot on the CPU and other things, like is the main memory system high latency (like maybe remote on a NUMA) or low latency (like on a CPU with an integrated SDRAM or RDRAM controller).

    I expect it is the correct thing with a immutable target on most but not all CPUs.

    If you're having trouble making the connections between the issues we're discussing and that basic point, let me know and I'll dumb it down a little more for you.

    If you don't want to debate, don't debate. There is no need to stoop to insulting your debating partner.

  34. Re:What about making it a little less bloated? by stripes · · Score: 2
    If you think about it for a while, you'll realize that there are situations that the linker can't handle, and therefore there must be run-time patch-ups for at least those cases. You really should be more careful about using words like "never".

    So when do they change the vtbl? I could believe the debugger might do it, but I don't know if it does. The debugger also writes other normally non-writable areas, so I don't think that makes a big difference.

    I don't know any other times a statically linked C++ program would change the vtbl. I've been asserting that dynamically linked C++ programs aren't an interesting debate area because (a) I really haven't seen any, and (b) the C code ends up doing the same fixups, and (c) I don't really know when and how the fixups are done (they could be as each vtbl entry is used, or en mass), (d) many platforms that can dynamically link C can't do the same for C++, (e) I figured it was irrelevant because in a apples to apples the C code is just as bad.

    And I suppose those are the only OSes that matter, eh?

    No, but those are the only OSes in widespread use that I know how the dynamic linker works on. I also know how Multics did it, how Sprite did it, how SunOS 4.x did it, and a few research systems. I also know how the static linked shared objects on SCO and BSD/OS work.

    I didn't want to say "this is how dynamic linking always works", so I went with "it works this way on the OSes I know about".

    And do you suppose that mprotect is free? Or might this be one of those hidden costs whose existence you've been denying?

    No, that is a lot of overhead. However I was explaining exactly what ld.so does for C code, not C++ vtbls. For example on many systems a libc.so call to malloc will do a JMP JMP (or indirect jump), even though malloc is in libc.so, the call through the dynamic link table just in case a "more important" .so defines malloc.

    I don't know if these (C code!) JMP JMP sequences are better then an indirect jump. By extension I don't know if the same C++ shared object JMP JMPs are a good idea.

    You got that backwards. I view it as a kludge or not based on the effect it has, instead of assuming it's not a kludge and then trying to deny effects to back up my opinion. IMO if it slows down the system as a whole *or* if it makes code elsewhere significantly more complex to support it, it's a kludge.

    Well, I do believe the static linked C++ JMP JMPs don't slow the system down as a whole, and I don't think they make anything more complex with the possible exception of the linker.

    Yeah, and nobody ever got in any trouble by forgetting the difference between "really really common" and "universal for all time" right?

    Sure they did, I even hesitated to bring it up the first time. I just think there is a lot of code that assumes 16 byte lines, and because the lines of CPUs are currently multiples of 8 bytes (almost always multiples of 16) they tend not to get in too much trouble.

    I can think of cases where it would cause trouble. I can think of more cases where it would at the very least fail to be faster then code that ignores the cache line size. I assume it also pisses off CPU designers because there might be some win in designing 30 byte cache lines (or some other odd size), except all the code that assumes 16 byte lines screw it up (but code "just written" would run better).

    The right thing would be to run with a #define, or a const int, I was however making a cynical comment that 16 would get chosen, not a pronouncement that 16 ought to be the One True Answer there.

    When my debating partner is obstinately straying from the rules of debate, I actually do feel they deserve a little slap on the wrist. The crux of this whole debate is your statement (in cid#635):
    The hidden costs the other poster was talking about [me, in cid#595] don't exist

    What annoys me is not that the statement was made, but that it wasn't retracted the first time it was refuted. Instead, I've had to put up with your topic changes, buzzword storms, squishy definitions, and all manner of other evasions. Frankly, I don't appreciate the extra work. I wouldn't treat you like an errant debate pupil if you'd stop acting like one.

    Let's see, what were those costs I was denying existed?

    Manual cache invalidation isn't cheap. It requires a lot more interlocking within the MMU than a typical instruction, so you pay a penalty every time you create an object.
    Invalidating i-cache may blow away unrelated (but needed) instructions because of false sharing.
    The object-creation code is now messier and more system-dependent.
    Mixing instruction and data spaces precludes a whole class of VM-system optimization.

    Those I still say don't exist, because I still say the vtbl is not changed at runtime.

    Now I do admit that I hadn't thought about dynamically linked code the first time I made that statement. In fact I didn't think about it until about two posts ago. I still don't think dynamically linked code is relevant for reasons I stated at the top of the post.

    If we do include the dynamically linked code then of the costs you listed originally, the same ones I dismissed out of hand, the "Invalidating i-cache may blow away unrelated (but needed) instructions" is the only relevant cost. It is not payed on each object creation. Depending on how exactly ld.so works it may be payed only when the .so is mapped the first time, or it may be payed when the first call on that vtbl is made, or the first call through a specific entry of the vtbl is called. Even so the vtbl will be shared for all objects of the same class.

    To be pissy, the costs you asserted, and I denied don't exist, even for a dynamically linked object.

    Being less pissy, one of the four costs you asserted exists in a radically reduced form. If you include dynamically linked code (and I hadn't argued at the time that one shouldn't, in large part because I hadn't thought about dynamically linked code at all) then you have enough of a point that I should have said "3 of the four never ever happen, the last doesn't happen in practice, and even if it did it isn't per object create, but about as frequent as per class in a .so, or per virtual function per class in a .so, or maybe per .so".

    But I didn't realize at the time that there was a small part of the original statement that was true. You were (or seemed) fixated on the vtbl being modified all the damn time, and I was fixated on denying it.

    Maybe we would have gotten here sooner if you were civil, but I assure you we would not have gotten here later.

  35. Re:What about making it a little less bloated? by stripes · · Score: 2
    We would have gotten here even sooner if you hadn't been so uncivil as to sleaze all around the subject (and several others) instead of simply accepting that maybe the point about hidden costs was a valid one.

    Maybe it wasn't sleaze, maybe I didn't realize it was true.

    And I still don't think it is the least bit common.

  36. Re:What about making it a little less bloated? by stripes · · Score: 3
    Umm, my major problem with C++ is execution time. I try and write as little as possible in C++, sticking mainly to C and Perl for anything which needs to execute quickly.

    Some things in C++ are quite slow, but no slower then simulating them in C. Faster in many cases. The C++ STL sort function seems to be about an order of magnitude faster then C's qsort (operating on char, short, and int's).

    In fact the STL in general is quite fast, normally faster then the C equivalent (when one exists), definitely faster then what one would whip up in an hour.

    C++'s virtual functions are slow. Quite slow. But faster then C calling through a pointer. Sometimes insanely faster because the C++ compiler can actually tell what type the pointer will be at run time. C can almost never tell.

    If the only thing you care about is execution speed, use C++. Use the STL. Use C's I/O. Avoid virtual functions, except when you would have used a function pointer before.

    I'm going to ignore the bit where you think Perl makes faster code then C++ (I do admit it could in some cases, but not normally).

    This is not to say that I think C++ is a wonderful language. I rather dislike it. I love the STL. Everything else in C++ seems to have been done better elsewhere. Still the language has value, if only because of the wide availability.

  37. Re:What about making it a little less bloated? by stripes · · Score: 3

    That isn't surprising at all. The C runtime is very straight forward (except for setjump/longjump). It is pretty clear how things can/should be implemented. C++ does a lot more for you, and it is unclear how they might do it (either because it's hard to guess how anyone might do it, or it's just hard to guess how this one compiler does it).

    (the STL's "runtime complexity" requirements is a good start, but it is just big O, the constants can still kill you)

    I don't think you will find a higher level language then C with a simpler to guess performance model (unless the model is "everything written in Tcl is slow"). I mean for all Eiffel's wonderful features, or Modula-3's, I don't think looking at two functions and guessing which is faster is among them.

    I can't think of any high level language has a simpler runtime then C. That is both high complement, and damnation.

  38. Re:What about making it a little less bloated? by spitzak · · Score: 2

    I don't understand this. Is this because the processor assummes that any location you jump to is involitile? It seems that an indirect jump could be "predicted" just as well by assumming the contents of the pointed-to memory location is the same as last time and this would require no more circuitry than the jump-to-jump predictor.

  39. Re:What I really want to see... by spitzak · · Score: 2
    Hear, hear.

    The fact that I can't take some code and change a pointer to a reference (or back) without a huge amount of search & replace of . and -> is very annoying and often I end up leaving inefficient code as it was because of this.

    There is no reason for this distinction. There isn't even a reason in C ever since the very first version that remembered the type of variables.

    Probably more drastic, but I would like to see '.' usable everywhere '::' is. This means class and variables are in the same namespace, which is incomptable, but it would make the code much nicer to read.

  40. Re:Simplify, standardize and fix by spitzak · · Score: 2
    Oh dear...

    Shared libraries for functions like this are NOT efficient, despite all the hopes and dreams of morons. How big is the identifier that matches up the program with the shared library? I would not be suprised if it is 2 or 3 dozen times larger than the code (take a look at some mangled template names if you don't believe me).

    And you have just made this poor sap's program into another entry in DLL (or .so) hell. Now they have to "install" it in order for it to work. Wow, what great advanced in Comp Sci. Someday it will be totally impossible to run anything!

  41. Re:The only thing I want by spitzak · · Score: 2
    Why not do that?

    Besides the fact that you returned a reference to a temporary, a quick comparison of the size and readability of his example and your "solution" should make it pretty obvious why!

  42. Re:What about making it a little less bloated? by spitzak · · Score: 2
    I think the point is that the tables of jumps do not change, and thus the icache is not invalidated. The table being talked about is the vtab for a given class and it is a constant.

    It looks like the problem is that the CPU designers figured the reason that somebody would jump to *(ptr+offset) is because the entry at *(ptr+offset) changes. But C++ (and all other OO languages, I would think) that entry is a constant, and instead it is the ptr that changes to point at different (but still constant) tables.

    This jmp-to-jmp stuff is a way to fool the CPU cache and predictor circuitry into assumming the location is constant, because it figures that jmp instructions are constant. It does seem kind of annoying that it is worth doubling the table size (and thus halving how much fits in the cache) in order to get around a mistaken programming assumpition by the CPU designers.

    I think it would be better for a CPU jump predictor to assumme *everything*, whether in instruction, read only, or read/write data, is constant. Modern C++ code typically accesses a given location many orders of magnitude more times than it modifies it!

  43. Re:What I really want to see... by spitzak · · Score: 2

    Yes, reference and pointer are very much alike. That is why I want '->' and '.' to be the same, since having to change these back and forth is the only difference in most cases.

  44. Re:A serious (rather unpopular) hope... by PhilHibbs · · Score: 1

    That's just the most outlandish example I could think of, but there are many other platforms out there that would suffer, and for minimal benefit. The internal representation isn't important, it's the interchange representation that's the problem. A standard binary data exchange format, and efficient (i.e. platform-optimised) routines are what is needed.

  45. Re:A serious (rather unpopular) hope... by PhilHibbs · · Score: 2

    It's unpopular for good reasons. It would impose too great a burden on unusual platforms such as PDPs (IIRC) where the byte size is 36 bits. Having to mess around with the value before and after every integer operation would be a nightmare. Also, there is the endian problem, as others have mentioned. What I would like to see is a set of std:: functions for outputting binary data in specific formats such as little-endian 32 bit, big-endian 64 bit, etc.
    eg:

    std::binary_out<int,std::little_endian,32>( 12345 );

  46. Would like to see.... by squarooticus · · Score: 1

    (1) A(n optional) method "this()" that returns some pointer-like object to be used as the "this" variable in method calls. Guess what this would allow? No-in-place garbage collection. Imagine being able to move an object around in memory inside a callstack in which the object is being accessed.

    (2) Interface separation from inheritance, like "implements" in ML or Java. I would like to be able to specify an interface that a compliant class needs to follow to be passed as a parameter to my function, without requiring the author of that class to ever have heard of my function. This can't be done with inheritance, because the author of that class would need to have known about your interface (read: base class) in advance.

    Kyle

    --
    [ home ]
  47. Re:Java vs C++ by buysse · · Score: 1

    Or, maybe, House /implements/ Roof, Walls, and Foundation?

    All right, House is not a good example for interfaces. Never mind.

    --
    -30-
  48. Re:The only thing I want by CoffeeNowDammit · · Score: 1
    Um, why not just do:
    class QDstring { //"(very very) quick and dirty"
    unsigned int len_;
    char * buf_;
    public:
    QDstring(int, int) { /* etc. */ }
    ~QDstring(void){ /* not virtual, so don't use as a base class */ }
    const length(void) const{ return len_; }
    const char * contents(void) const {return buf_};
    };

    const QDstring & foo(void)
    {
    return QDstring(1,2);
    //I know, returning a temporary is bad,
    //but what the hell do you want in a post?
    }

    Or better yet, use the Standard string class..

    ".sig, .sig a .sog, .sig out loud, .sig out .strog"
    --

    ".sig, .sig a .sog, .sig out loud,
  49. Re:What about making it a little less bloated? by John+Whitley · · Score: 2
    except when you would have used a function pointer before.
    Actually, this highlights (from the perspective of an embedded programmer) one of the biggest problems I have with C++. Personally, I have no problems getting good performance using C++ code... but this requires (IMO) far too much knowledge of the C++ compiler implementation. C requires some implementation knowledge to use effectively (e.g. strings are null-terminated arrays of char, etc.)... but in C++ there is just too much implementation-specific crap irrelevant to the programmer-as-designer's life.
  50. Re:wish: strongly-typed typedefs? by BuzCory · · Score: 1

    You guys are just uisng the wrong language!

    It would be especially nice if these types were *not* considered, for the sake of signatures, type-identical to counterpart size-variant types, and if enums were also given a generic root type instead of being int in signature.

    I always wished that typedefs created new types, instead of behaving like wimpy macros.

    typedef int FOO;
    typedef int BAR;
    FOO f = 1;
    BAR b = 2;
    int i = 3;
    f = b; // ILLEGAL TYPE MISMATCH!
    b = i; // ILLEGAL TYPE MISMATCH!
    i = f; // ILLEGAL TYPE MISMATCH!

    How about this? (pardon the formatting, <pre> is not allowed.)

    type FOO is new integer ;
    type BAR is new integer ;

    function fiz( i : FOO ) return FOO ;
    function fiz( i : BAR ) return BAR ; -- Different, overloaded
    function fizzle( i : FOO ) return FOO ;
    function frazzle( f : FOO ; b : BAR ) return integer ;
    f : FOO := 1 ;
    b : BAR := 2 ;
    i : integer := 3 ;

    f := b; -- ILLEGAL TYPE MISMATCH!
    b := i; -- ILLEGAL TYPE MISMATCH!
    i := f; -- ILLEGAL TYPE MISMATCH!

    -- further:
    f := fiz( 5 ) ; -- first fix
    b := fiz( b ) ; -- second fiz
    f := fizzle( f ) ; -- legal
    b := fizzle( f ) ; -- ILLEGAL, TYPE MISMATCH
    f := fizzle( b ) ; -- ILLEGAL, TYPE MISMATCH
    i := frazzle( f, b ) ; -- All legal and proper
    i := frazzle( 7, b ) ; -- All legal and proper
    i := frazzle( f, 7 ) ; -- All legal and proper
    i := frazzle( 7, 7 ) ; -- All legal and proper
    i := frazzle( b, f ) ; -- ILLEGAL, 2 type mismatches
    -- (operands reversed).

    -- And so forth.

    -- All arithetic, comparison, indexing, operations are inherited.

    Each enumeration type is distinct (with its own namespace). Enumeration types may be used for indexing and loop control, but not for arithemtic.

    Sound good? For more info look here or here or here.

  51. Re:What I really want to see... by Y2K+is+bogus · · Score: 2

    Here's a question for you:

    How is the parser supposed to understand if myControl is a ** or if cntrlRect is a **?

    struct Control **p;

    struct Control {
    void **cntrlRect;
    };


    This technique is what you'd use for loading a module dynamically and resolving it's functions dynamically. The syntax is C because C++ is C with features builtin to hide the underlying "ugly" C implementation.

    The parser can't dereference the ->> at runtime precisely of the above structure layout; it's ambiguous, you need to do it longhand like C programmers have been doing for eons.

  52. Re:The only thing I want by szo · · Score: 1

    There is already some solution for this. See tuples here.

    Szo

    --
    Red Leader Standing By!
  53. listen ? "C# is J++ aka C.O.O.L." : "C# not C++" by Mongoose · · Score: 1

    C# isn't C it's the COM+ extention of what was the M$ lang 'COOL' that was 'j++' ( M$ basterd java ).

    Come on guys - I don't even use windows but 3 times a week and I know that. ;)

  54. C<>! & give it to Stepanov! by Szplug · · Score: 1

    I'd love to see Stepanov and a couple people of his choosing get together to work on his concept-based language. Either polish up & extend C++'s template handling, or better yet start something completely new.

    --
    Someday we'll all be negroes
  55. Re:My wish list. by artdodge · · Score: 2
    3) Eliminate pointer arithmetic.
    And ensure that the language is never used for any system-level project ever again, including the C++ standard library.
    Garbage collection ain't too popular with systems types either - if you don't want something any more, free it so someone else can use its resources. Either that or throw away the context (apache fork-n-die model) so you don't waste your time scrap-hunting.
    Maybe I'm just an old fart about disciplined programming. But then again, so is Linus, so I'm in good company. :-)
  56. Re:Language vs Library by artdodge · · Score: 2
    there's not much point in a language without its standard library
    Tell that to all the people out there who implement the C library mostly in C.

    Or kernels in C.

    Heck, what do stdin/stdout mean to an MFC application?

    You need some sort of support library. For a language to be useful, I would expect to be able to chuck the standard one out the window and replace it with one that suits the context I want to use the language in.

  57. Would you please by PD · · Score: 2

    Please put in the sockets and signals that Qt implement? Those are damn nice.

    And something else... figure out some way to make the error messages from templates more readable. Templates are extremely nice, but when you screw one up, finding your mistake involves parsing a line with 8000 characters. This one's probably more for compliler implementers, but if there's a clean way to help in the language, do it.

  58. Re:Java vs C++ by PureFiction · · Score: 2

    "Could you please list the advantages C++ has over Java?"

    How about the memory eating JVM for starters?

    The point is, the Java people will consider many aspects of the language as 'benifits!'. While the C++ people will see these as misplaced, ill implemented 'drawbacks!'.

    It's all about viewpoint...

  59. Re:wish: strongly-typed typedefs? by Pig+Hogger · · Score: 2

    Yes, but then do you have to redefine functions and operators for them? 'cause that would be a pain in the ass if I couldn't add or subtract my FOO's.

    Overload, dear, overload.


    --

  60. Re:wish: strongly-typed typedefs? by Pig+Hogger · · Score: 2

    Nah. The standard rules of C++ could be amended to deal with these new types. After all the +- operator already work on:
    char, short, int, long - all signed or unsigned and T* where T is a type.
    Other strongly typed languagesw such as Pascal already behave in this way, so it is possible to make it work.

    Isn't it funny that all the while C* programmers have been tripping over themselves and shooting themselves in the foot with C*'s easily obfuscated syntax, Pascal programmers have been able to enjoy extensions to the language that effectively cancelled all objections given against Pascal?

    So, you have a group of people still untangling their spaghetti-pointers and memory leaks, whilst the other have been concentrating on their *REAL* job, programming?


    --

  61. Re:What about making it a little less bloated? by FigWig · · Score: 1

    . The STL in particular is a beautful, high performance, library that damn near perfectly nails down the balance between power, flexability and ease of use.

    Don't forget the mind numbing syntax! The STL is nice and fast, but using it makes me yearn for the layers of casting that Java libraries have.

    --
    Scuttlemonkey is a troll
  62. Gripe, Moan, etc. by Conor6 · · Score: 1

    I've been programming for years. I taught myself C++ almost when it came out, back when it was so new, most people didn't understand why it was needed. It had almost no real features beyond the basic language stats.

    And really, I'm not sure how I feel about this constant revisioning. It seems to me like the compilers are following Gates' Law (every 18 months, speed of software halves). While some things are nice (namespaces, etc.), I'm not sure how I feel about templates, and all of the other more minor features. I mean, feature extension after feature extension, it's getting a little tiresome keeping up with it all.

    The upshot of this, of course, is that C compilers, which aren't following Gates' Law, are now faster than anything on modern processors.

    ~Conor (The Odd One)

    --
    Conor
    Programmer, Consultant, Geek, CTYer.
  63. Re:Something I've wanted for a decade... by Conor6 · · Score: 1

    It seems to me that the proper way to do this is to explicitly call the superclass version. It's slightly a pain, but I don't see how you'd miss doing anything by doing it that way, rather than what you describe.

    Though I am interested to hear what you'd like to do, under those specs... I can't think of too much that's that interesting. Mail me or something.


    ~Conor (The Odd One)

    --
    Conor
    Programmer, Consultant, Geek, CTYer.
  64. Re:Funny you should mention that. by Detritus · · Score: 2
    Wasn't C a descendant of BCPL?

    I used to have a BCPL programming manual, it looked like a primitive ancestor of C.

    --
    Mea navis aericumbens anguillis abundat
  65. Re:Simplify, standardize and fix by Detritus · · Score: 2
    And they need to ditch "implementation defined" behavior. Pick a behavior, and MANDATE it. Evaluate function arguments left to right, one at a time, and THEN call the function. Make a[i++]=i++ have a defined meaning. Make ints of less than 32 bits illegal. Heck, force standard bit sizes of the legacy types, and use int32, int64 for future code.

    Go use Java.

    The philosophy of C, and to some extent C++, is that the language does not hide the underlying machine architecture from the programmer. That is why there are all of those "implementation defined" bits in the language. They reflect reality, where not every CPU is a descendant of the VAX or 80386. The language has enough implementation dependent slop to allow its efficient implementation on a wide variety of architectures. The language also gives compiler writers some freedom in how to evaluate and optimize expressions, layout data structures and pass parameters to functions.

    Computers with 32-bit pointers/integers and 8-bit characters will not be around forever. They will eventually be replaced by newer architectures, perhaps with 64-bit integers, 128-bit pointers and 32-bit characters.

    --
    Mea navis aericumbens anguillis abundat
  66. Re:A serious (rather unpopular) hope... by sholden · · Score: 1
    It is pretty easy to do this using templates and coming up with something like:

    integral i32; integral i128;

    or integral_at_least which would give you a 64-bit integer or whatever is fastest and at least that size for any given architecture.

    Download boost and have all that and more...

  67. Re:What I really want to see... by flanker · · Score: 1
    You don't have function pointers in your example so I'm not sure I understand your question. If you want to do compile-time checking on function pointers you can do something like:

    typedef int (*MyLibFunctionProcType)(int param1);

    #define FakeLibFunctionCall \ (*((MyLibFunctionProcType)(funcPtr)))

    //in your code
    int retval = FakeLibFunctionCall(7);

    This is a pretty standard way for building plug-in frameworks in C-based languages that has been around for awhile.

    --
    Left shift 1 for e-mail...
  68. Re:Delphi by Requiem · · Score: 1

    Well, other than the fact that neither C, C++, or Java have the issues that Pascal does.

    Delphi is an implementation of Object Pascal.

    Look, I don't mind Pascal, and I love OO, but Object Pascal is really a beast to behold.

  69. Re:Delphi by Requiem · · Score: 1

    I find that while there are nice things about C++, it is too cumbersome a language for me to use effectively. That's why I prefer languages like Java and Python - my coding time is much faster in that language, and I don't have to think about things like pointers, memory, leaks, etc.

    Admittedly, I haven't used any implementation of Object Pascal a lot, but I haven't really liked what I tried. Pascal is best suited as an introductory procedural language.

  70. Re:C-Sharp? by afc · · Score: 1
    ...If you've ever had to watch The Sound Of Music you'll know what "do" represents :-).

    A female deer? Sorry, couldn't resist :-P
    --

    --
    Information wants to be beer, or something like that.
  71. Let me guess... by Black+Perl · · Score: 1

    ...they're gonna call it C##

    --
    bp
  72. Re:C++ Frustrations by Octorian · · Score: 1

    Some of the commercial UNIX compilers are actually pretty good. I've been happy in my experiences with MipsPro lately. I've also heard SunPro is good, but I don't know about the "standards" side... same with IBM's xlc. On the other hand, "xlc" is one of the few compilers that actually DOES CATCH that missing semicolon without farting on itself. :)

  73. Proprietary Extensions by Roy+Ward · · Score: 1

    > ... an effort to keep the language moving, avoid fossilization and avoid being overtaken by proprietary extensions.

    You mean keep the compiler writers so busy scrambling to keep up with the new standard that they don't have any _time_ to work on proprietary extensions?

  74. My wish list. by HiThere · · Score: 2

    1) Simplify syntax.
    2) Eliminate type casting. Require user specified conversion functions (standard types included with standard library, of course).
    3) Eliminate pointer arithmetic.
    4) Range types.
    5) Standard garbage collection inclusion.
    6) Persistant storage. Preferable by a directly included B+Tree database.
    7) B+Tree database as a part of the standard library.
    8) Foreign Function Interfaces (not just to C, but to, O, Fortran, Python, Ruby, OCaML, Ada, Eiffel ... all the standard suspects).


    Caution: Now approaching the (technological) singularity.

    --

    I think we've pushed this "anyone can grow up to be president" thing too far.
    1. Re:My wish list. by BoP2 · · Score: 1

      1) Simplify syntax. How? What part? 2) Eliminate type casting. Require user specified conversion functions (standard types included with standard library, of course). This is for C compatibility. If you don't like it, don't use it. :-) 3) Eliminate pointer arithmetic. There are some uses for this in the standard library. If you don't like it, don't use it. :-) 4) Range types. Might be slightly useful. 5) Standard garbage collection inclusion. I believe the committee didn't feel that garbage collection was ready for standardization. It is also not wanted by some users, like real-time embedded systems. If you really need one, you can add a 3rd party collector. 6) Persistant storage. Preferable by a directly included B+Tree database. This would *require* external storage for all implementations. Do you want a hard disk in your VCR? 7) B+Tree database as a part of the standard library. The problem is that the standard library is *required* for every compliant implementation. You can't require database support for embedded controllers... 8) Foreign Function Interfaces (not just to C, but to, O, Fortran, Python, Ruby, OCaML, Ada, Eiffel ... all the standard suspects). See 7!

  75. Re:Time to move on by geophile · · Score: 5

    Get in line, sonny. They're still coming out with new versions of Ada, COBOL and FORTRAN.

  76. Re:What about making it a little less bloated? by TeknoDragon · · Score: 2

    if you're writing C++ that's slower than Perl you're doing something wrong. I challenge you to support any statement to the contrary.

    Sure, Perl has built in facillities that can do some common stuff very quickly, but if you used the same algorithms in C++ it would almost certainly execute faster.

  77. Re:A serious (rather unpopular) hope... by rw2 · · Score: 2
    The reason it's unpopular is because it would require a performance hit for no significant gain.

    The header climits tells you what the range available is in a platform independent manner. If you think you will not be able to control that your program be compiled on a 32 bit platform then check out INT_MAX and make sure its big enough for what you want to do.

    I can't comment on the C99 standard and what they think the gains would be from such a scheme. Though I wonder if those are really fixed bit width types? Can you talk more about that?

    --
    Poliglut

  78. Re:Something I've wanted for a decade... by Surak · · Score: 2

    Say screw it and write in Object Pascal?

  79. C++, I think by cpeterso · · Score: 1

    .

  80. wish: strongly-typed typedefs? by cpeterso · · Score: 2

    It would be especially nice if these types were *not* considered, for the sake of signatures, type-identical to counterpart size-variant types, and if enums were also given a generic root type instead of being int in signature.

    I always wished that typedefs created new types, instead of behaving like wimpy macros.


    typedef int FOO;
    typedef int BAR;
    FOO f = 1;
    BAR b = 2;
    int i = 3;
    f = b; // ILLEGAL TYPE MISMATCH!
    b = i; // ILLEGAL TYPE MISMATCH!
    i = f; // ILLEGAL TYPE MISMATCH!


    1. Re:wish: strongly-typed typedefs? by cpeterso · · Score: 2

      Of course, you could use something like:


      typedef struct { int _opaque; } time_t;


      and then pass time_t structs by value, assuming that copying a struct with just one int is no more expensive than just copying an int...?

      or like Windows, declare pointers to non-existant structs, like: typedef struct __HWND* HWND.

    2. Re:wish: strongly-typed typedefs? by Black+Parrot · · Score: 2

      > I always wished that typedefs created new types, instead of behaving like wimpy macros.

      Maybe you should consider Ada, which does this and most of the other things people are wishing for everywhere in the responses to this article.

      Don't let ESR's lame and factually incorrect entry in his jargon file put you off.

      --

      --
      Sheesh, evil *and* a jerk. -- Jade
    3. Re:wish: strongly-typed typedefs? by Steeltoe · · Score: 1

      Still didn't answer his question. He would have to overload gazillion functions all over. This is a general problem in C++ as a high level language.

      - Steeltoe

    4. Re:wish: strongly-typed typedefs? by Steeltoe · · Score: 1

      Well, this is just IMHO. I learned Pascal first, but turned to C++ after that. Pascal was not low-level enough at that time. Now it's not high-level enough, and I use Ruby. Pascal is a fine language, though I've never really liked all the syntax.

      - Steeltoe

    5. Re:wish: strongly-typed typedefs? by jeremyp · · Score: 1

      Nah. The standard rules of C++ could be amended to deal with these new types. After all the +- operator already work on:

      char, short, int, long - all signed or unsigned and T* where T is a type.

      Other strongly typed languagesw such as Pascal already behave in this way, so it is possible to make it work.

      The great thing is, you could override the standard C++ operators to change their behaviour for your types e.g. throw an exception if your addition overflows on int16.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    6. Re:wish: strongly-typed typedefs? by zaius · · Score: 2

      Yes, but then do you have to redefine functions and operators for them? 'cause that would be a pain in the ass if I couldn't add or subtract my FOO's.

    7. Re:wish: strongly-typed typedefs? by tpv · · Score: 1
      Kinda.

      The things that typedefs do now, are useful.
      For things like templated classes or function pointers, the current typedef is a very useful feature.

      But I too would like to be able to define new primitive types more simply.
      A time_t is not an int, or long, or whatever. It's just an integral type that ultimately has the same internal representation as one of the basic types.

      A new construct such as
      class FOO<int> ;
      would do me fine.

      --

      --
      Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
  81. Re:A serious (rather unpopular) hope... by ChadN · · Score: 1

    When Mozilla was started, this was sound advice (for portability sake). By the end of this year, it will be bad advice (in general). Use of templates (and STL) will be strongly favored for portability, speed, programmer man hours saved, etc.

    --
    "It's overkill, of course. But you can never have too much overkill." - Anonymous Slashdot Coward
  82. Re:I think Bjarne is right about the state of C++ by cruelworld · · Score: 1

    Tee Heee...random moderators keep modding this down....then some other moderator comes along and mod's it up..

    Ah....Signal 11 would be proud.

  83. Re:C++ Frustrations by echristo · · Score: 1

    Of course, if you look at how long time it took for standardization last time now would probably be a good time to start.

    -eric

  84. Stroustrup coming to Columbia on Thursday by philgross · · Score: 1
    Bjarne Stroustrup is speaking at Columbia University in New York City on Thursday, April 26th. His talk is at 7:30pm in Schermerhorn Hall. See our ACM page for details.

    Admission is free and all are welcome. Pose your questions to the man himself...

    1. Re:Stroustrup coming to Columbia on Thursday by philgross · · Score: 1

      His announced topic is "multi-paradigm programming in C++". You can read more about what he means by multi-paradigm programming on his excellent web page and FAQ -- Phil Gross

    2. Re:Stroustrup coming to Columbia on Thursday by jameswu1 · · Score: 1

      What's the topic of the talk?

      ~James

  85. Re:*Poof* You have generic programming - now what? by SuperKendall · · Score: 1

    But the point under discussion *is* the claim that Java cannot support generic programming techniques - some people use that argument to say that the Java peg cannot fit well into *any* shape of hole, which is just as incorrect as saying that it can do anything.

    I just want to find out for myself where they feel limited by Java when trying to program in a generic manner, as I myself have not felt that limitation. Other people pick up on that argument and then dismiss Java out of hand without even knowing why they would want support for generic programming. I'm just trying to stop the FUD.

    I agree with your point that for some things, you simply will not be able to use Java and for others Java is a very good choice. I just tend to think the range of problems where you can use Java is wider than most people think it is. In fact many of the examples you listed could very well be done in Java, but I won't get into that here!

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  86. Re:Java flaws by SuperKendall · · Score: 2

    a) It's tied to a VM.

    Not really. There are plenty of companies who have made systems that compile Java code into an executable... however that's been a niche market because most people are quite happy running Java code in VM's. Furthermore, the great thing is that Java is not tied to a specific VM so much as a family of VM's. Don't like your current VM? Swap in one that works better for you (unless you are running iPlanet, GRRRRR)

    b) Its frameworks for GUI development try to be a least common denominator at the expense of running well on any given platform.

    Totally off base. Rather, Swing is a "greatest common denominator" tagential system. If you use it carefully it works quite well just about anywhere - I wrote a fairly large MDI app all in Swing that was targeted to P166's with 32MB of memory!! It wasn't incredibly fast there, but then again on a P450 is was as fast as any of my other apps.

    Swing was meant to be a GUI framework done right, and for the most part I think they've succeeded. It won't really be practical to write consumer apps that use Swing though until OS'es ship with a system to share Java execution and library space.

    c) Its not a standard until Sun submits it to a real standards setting body. Until then its just as proprietary (in my mind) as Visual Basic, etc.

    On the other hand, only MS make a VB compiler and runtime. Look at the plethora of Java VM's and compilers... If it looks like a rose and smells like a rose and the DNA profiles come back saying "rose", then even if the tag says it's a dandelion it's probably a rose.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  87. *Poof* You have generic programming - now what? by SuperKendall · · Score: 2

    Let's say they add some features to the Java to provide support for genericism.

    What are you going to use it for that you can't do now in Java? I'm curious because I really haven't seen any examples given that I couldn't code in Java, and I feel like I use a number of fairly genericly oriented techniques when programming in Java. Perhaps I would be happier still if some extension made it into the language, but I don't feel very hampered at the moment.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:*Poof* You have generic programming - now what? by karb · · Score: 1
      The point isn't that there are things you can't do in one language and not in another. Java and C++ are both very capable languages. Anything present in only one language could be simulated in the other. You may be irritated at one language (java can't pass methods), but you can simulate that in some way (use the strategy pattern).

      The point is that if I sit down tonight and write a video game, I just can't get the performance out of java that I can get out of C++. If I want to deploy a large web application, my best bet is probably using servlets. Writing a kernel? C++ (or C). etc.

      In the grand scheme of things, it really doesn't matter that java can't (blank) or that C++ is based on C. A circle's smooth, but you can't fit it in the square hole.

      --

      Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone

    2. Re:*Poof* You have generic programming - now what? by TheSunborn · · Score: 1

      General typesafe containers.

      The ability to store simply types(int) and so on in a container.

      Are the most obvious, but there are more.

  88. Collections by SuperKendall · · Score: 2

    The STL is more powerful than the Java Collections package in the same sense as an F1 racer is more powerful than an Audi TT. For just about any real use you have, the TT is more practical and fun to use.

    I think the Collections package strikes the perfect balance between a set of libraries that has a lot of power and a set of libraries that just about anyone can fine useful at some level. The Collections package takes care of about 99% of your collection needs on a day-to-day (or even yearly) basis, with a great and extremley usable interface packed with features. Syncronize or make collections read-only on the fly! Sort by internal or custom external comparitors! Easy to use Sets and TreeSets with an AVL tree you don't have to code by hand!

    Plus, all that and if you want you can download the whole shebang in a tiny (I think about 48k, but it might be larger) jar file if you need to use it in a 1.x VM.

    On top of that, I'm really not sure there's anything you can do in STL that can't be done with a little (or possibly no) effort in Java. Post examples, I'd be happy to see 'em.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  89. A few counterarguments by SuperKendall · · Score: 2

    I can see general typesafe containers as an argument, in that any time you use a container you know the contents will be what you expect them to be.

    But then again you could easily approximate that in Java by providing List, Map, and Collection wrappers that would make sure anything added to a particular collection would be of an appropriate type. You could wrap the overlays around any collection. Just as with templates you need to specify a type that will be held you could do the same with collections if you really cared.

    Then again, it works out that pretty much anywhere you have a collection you're going to know what's going in and what's going out. I don't think I've run into a problem yet where it mattered that the container was not type safe.

    A rougher approximation for the second item (storing simple types) is of course using the wrapper objects like Int(), and I'll be the first to admit that's a bit of a pain. However, I don't see where that's an argument against Java supporting genericism so much as an argument about how types are handled in the language (and as a great fan of Scheme I'd love to see simple types be objects as well). I don't think it's a really strong argument as in most real cases you'd be dealing with objects, and the wrapper classes are good enough.

    If I had to work with lots of collections of ints or longs or whatever, I'd probably just slightly extend a few interfaces like List and Iterator to make use of the standard collections yet have simple access to simple types. Other operations like sorting and so forth would work on the contents transparently just like any other container, and I could still pass the containers around without knowing what they held.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  90. What 3.8 *ACTUALLY* says is... by HenryFlower · · Score: 3

    that an implementation of STL (the MS implementation, one presumes) at the time the book was written was immature. The above post makes it seem as though Kernighan and Pike were frothing in their denunciation of C++.

  91. Re:C++ Frustrations by IkeTo · · Score: 1

    Try g++ 3.0 pre-release. It's standard libraries are much more standard compliant.

  92. Re:C++ Frustrations by BeanThere · · Score: 2

    "I switched from GNU C++ to Visual C++ in 1996 (change of jobs) and found that VC++ 5.0 was lot closer to the standard"

    Thats odd, as I remember it the C++ standard wasn't finalised until around 1998. Can you really blame major compiler vendors for not having up-to-the-minute support on a moving target?

    I do remember VC 5 had a number of problems with STL in particular, and we still have problems with the compiler in VC 6, even with the latest SP (random errors regarding DEBUG_NEW in MFC apps that disappear when you try compile again, as well as internal compiler errors) .. but overall our experiences have been pretty good with it.

    -----

  93. Re:C++ Frustrations by BeanThere · · Score: 2

    Yes I do actually.

    When configured properly, they cut compile times quite dramatically (funnily enough, when misconfigured (e.g. if the "use precompiled headers through" edit box is empty instead of containing a filename), they slow down compile times dramatically). I experimented with this stuff very recently actually, managed to get a "rebuild all" down from 6 minutes to 3 minutes 45 seconds, for a project of just over 100000 lines of code, in 7 or 8 projects.

    -----

  94. What about garbage collection? by jonathanclark · · Score: 1

    I didn't see/hear any discussion on garbage collection. Anyone know what they think about this? That is my main reason for wanting to use Java or C-sharp.

    1. Re:What about garbage collection? by jonathanclark · · Score: 2

      I'm aware of that garbage collector (I use it for a number of projects), but it is has a number of limitation because it doesn't have any support from the compiler. That collector for example, knows nothing about your data structures so it has to assume everything could be a pointer forcing it to scan the entire heap. This is not practical for real-time application where GC needs to be done incrementally. Yes, the xerox collector can run experimentally in incremental mode using page protection - but this makes it hard to debug on many platforms and though I have not tested the speed, I suspect it has a fairly dramatic performance hit if you application accesses a lot of data. Also hardware page protection is not available on all platforms (DOS, game consoles, embedded systems, etc).

      Right now if you want fast incremental GC you have to make you own smart pointers and do reference counting for all global roots. It would be nice to see compilers with reference and resource management builtin so you don't have to make everything look like template hell.

      Also it's a misnomer that GC adds more overhead in terms of speed. Applications written to properly use GC spend less time copying/freeing objects than their non-GC counterparts so on average a GCed program with a good collector will have better performance. Not to mention I recall a study showing that c++ programmers spend some 50% of their time dealing with allocation/deallocation and a large percentage of bugs are related to memory leaks and premature frees. On average GC makes your program go faster and it almost always speeds up your development (which is more important these days).

      I've written a few garbage collectors myself using smart pointers to track global roots and then I use thread-suspension during collection to deal with currency issues. It would be nice to see something like this standardized and supported by the compiler and support libraries (i.e. enumurable counting pointers and thread suspension). It could be toggled on/off by class so that there is 0 overhead if you choice to not use it.

    2. Re:What about garbage collection? by Animats · · Score: 2
      It's time to do something about C++'s unsafe memory allocation. All the later languages (Perl, Java, Python, C#, etc.) have safe memory allocation. But conservative garbage collection for C++ presents a number of problems. The worst one is that it results in destructors being called at ill-defined times. C++ destructors weren't designed for that, and calling them from GC has a good chance of introducing new, nonrepeatable bugs. Even Hans Boehm, who introduced the idea at PARC, isn't that enthusiastic about it any more.

      It's also possible to write code that creates pointers a conservative GC won't find. "Numerical Recipes in C" does this in its storage allocator, which creates offset arrays so they can index from 1. ("Numerical Recipies in C" is actually "Numerical Recipes in FORTRAN" transliterated to C, as comparing the two books makes very clear.)

      Reference counting, with compiler support to optimize out much of the count updates, looks more promising for C++. "Smart pointers" have been around for years, but without language and compiler support, the overhead is annoying.

      Weak pointers (the Perl kind, not the Java kind) can be used to avoid the circular linking problem. "Backlinks" should be weak pointers. It's possible to introduce restrictions that force an "ownership tree" of data, so that it's unambiguous which pointers should be strong and which should be weak. But that may be too restrictive for C++.

      I've been writing up something on "Strict C++". The general idea is like "strict mode" for Perl; it's optional, there are more restrictions, and it's safer. If the whole program is in "strict mode", you're guaranteed pointer safety (no buffer overflows, no dangling pointers, no memory leaks.) The restrictions are less restrictive than those of "Safe C++" (another PARC project).

      Now that we have the STL, and it's in widespread use, it's more reasonable to do this than it was a few years back. Much of the safety can be encapsulated. The general idea is that you pass references to collections around, not raw pointers. On collections themselves, you use iterators. Iterator arithmetic can be made safe, (there are STL implementations that check in debug mode), and with code hoisting in the optimizer, much of the checking can be safely removed during compilation. Pointer arithmetic on non-iterator pointers would be prohibited in strict mode. With one big exception.

      Part of this is a "great compromise": "const" pointers to objects that don't contain pointers don't have to be safe. This allows the use of "const char*", classic "printf", but not "sprintf" or "scanf", which write an argument whose length they cannot verify. You can read junk, but can't write it. Provided you can turn a memory access hardware trap ("Bus Error" to UNIX people) from a bad access into a C++ exception, this is safe enough for practical purposes. We can't get too religious about this or programmers won't go for it.

      If this catches on, programs written in it won't have buffer overflow vulnerabilities. That's enough reason to do it. Not everything needs to be in "strict mode", but important programs should be.

    3. Re:What about garbage collection? by robert-porter · · Score: 1

      You can run a garbage collector if you want. If you want GC'ed C or C++ look here ftp://parcftp.xerox.com/pub/gc/gc.html. C++ was made for system intensive stuff, a garbage collector is overhead(then again leaking memory is overhead).

    4. Re:What about garbage collection? by Ayende+Rahien · · Score: 1

      I think that you might want to take a look on C++.NET, especially managed code, which seems to have many of the stuff that you want.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  95. What about making it a little less bloated? by AntiFreeze · · Score: 2
    Umm, my major problem with C++ is execution time. I try and write as little as possible in C++, sticking mainly to C and Perl for anything which needs to execute quickly.

    C++'s fallback is that it is a bloated language with too many frivolous constructs. For anyone who doesn't believe me, take a look at section 3.8 of The Practice of Programming by Kernighan and Pike. Repeating them is a waste of space and my time (and you might as well pick up the book and read the whole thing while you're at it =]).

    Therefore, I think that the best thing (well, at least an important thing) to do with the next incarnation of C++ is to move a lot of the bloated architecture into external libraries, so that what is necessary can easily be loaded, and so that execution time would speed up incredibly. Of course, I'm not saying this is easy to do or even really possible, I'm just saying that it should probably be looked at pretty carefully.

    ---

    --

    ---
    "Of course, that's just my opinion. I could be wrong." --Dennis Miller

    1. Re:What about making it a little less bloated? by Salamander · · Score: 2
      Many CPU's (pretty much everything other then the x86 -- and other really old things like the 390) require a (i-)cache invalidation between modifying code and executing that code. The cache invalidation will also invalidate the BTB. So the CPU can feel free to use the BTB to optimize a JMP-JMP sequence, but not to optimize a indirect jump.

      That seems like a classic example of not counting all the costs. The double jump might in and of itself be less expensive than an indirect jump, but there are hidden costs involved:

      • Manual cache invalidation isn't cheap. It requires a lot more interlocking within the MMU than a typical instruction, so you pay a penalty every time you create an object.
      • Invalidating i-cache may blow away unrelated (but needed) instructions because of false sharing.
      • The object-creation code is now messier and more system-dependent.
      • Mixing instruction and data spaces precludes a whole class of VM-system optimizations.

      When you do count up all the costs, using double jumps is a tremendously stupid idea. The double jump itself might be faster than an indirect jump, but that's outweighed by the overall negative effect on the system as a whole.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    2. Re:What about making it a little less bloated? by Salamander · · Score: 2
      Exactly. The hidden costs the other poster was talking about don't exist.

      You're so full of crap. Yes, those hidden costs do exist and must be paid *even though* the contents of the table are in fact effectively constant. That's the problem. You still have to invalidate the i-cache, you still have to forego VM-level optimizations, etc. because the values *could* change.

      Well, it doesn't so much fool the CPU into thinking the location is constant as to actually inform it that the location is constant.

      It does no such thing. Any CPU that makes such an assumption about the immutability of i-space could be considered broken. That breakage can be worked around by having the VM system play nasty tricks with making i-space pages read-only etc., but the cost of having to cover for the CPU's deficiencies like that is much greater than the benefit. Try looking at the problem from a *system* standpoint for a change, instead of a myopic "how can a CPU designer avoid work" standpoint.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    3. Re:What about making it a little less bloated? by Salamander · · Score: 2
      You can bitch about the vtbl being immutable is a bad requirement, and prevents C++ from being as flexible as Ruby. But that is a different topic.

      No, it's the same topic because it impacts the same solution.

      You can argue that there are hidden costs in how the CPU thinks about i-space, but that is a very different argument.

      No, it's the same argument because it impacts the same solution. Please stop trying to redefine the topic to suit yourself.

      With the sole exception of the x86 all modern CPUs are broken? They all assume that i-space is very seldom altered

      "Seldom" is not equal to "never", and we were talking about the assumption that i-space would *never* change because that's the only assumption that would make the proposed solution seem reasonable.

      From a system standpoint making self modifying code faster makes everything else slower.

      We're not talking about self-modifying code, as much as you seem to be hoping that the taint associated with that phrase will stick to anyone who disagrees with you. We're talking about mutable data in i-space, and about the nasty hack of using double jumps with the intermediate target in i-space to "trick" CPUs and make method dispatch a cycle or two faster without considering the effect of such a hack on the rest of the system.

      But you're almost right. Making this particular hack work faster makes the rest of the system slower. That's exactly the point. Congratulations on finally getting it.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    4. Re:What about making it a little less bloated? by Salamander · · Score: 2

      I'm sure we could have a very interesting discussion about the relative merits of double jumps vs. indirect jumps if you'd cooperate, because you seem to know more than most /.ers about how CPUs work. However, as long as you're going to deny that these systemwide costs exist at all - things like false sharing, extra interprocessor communication in an SMP system to do TLB shootdowns, pollution of the BTB when the regular L1 cache is damn near as good - then that's not going to happen. How disappointing.

      You are the weakest link. Goodbye.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    5. Re:What about making it a little less bloated? by Salamander · · Score: 2
      C++ using the double jump doesn't make these problems any worse

      Ahhh, but it does. On an architecture designed around the "i-space modification is rare" assumption, writing to a vtbl *even* at object-creation or class-loading time incurs a substantial overhead in exception handling, VM activity, the aforementioned cross-processor interrupts, etc. This is different from the modifications that must occur at image-load time (including DSO-load time) because those have distinct boundaries and the OS can treat pages differently during that period than afterward. Maybe if parts of the C++ runtime were integrated into the OS loader this could be handled more efficiently, but that's a heinous idea for other reasons.

      Similarly, the whole point of the double-jump seems to be to abuse the BTB for performance. I call it abuse because every method pointer that's stuffed into the BTB is one less BTB entry that can be used for *real* branches. Also, the BTB is just a small, very fast special-purpose cache; there's another cache - the L1 - right nearby that could also contain that same information. So you save yourself a cycle on the method dispatch (if repeated) by using the BTB instead of the L1, in return for which you create a nice fat pipeline bubble for someone else when they hit a branch that would have fit in the BTB if not for your shenanigans. That's not a win, it's just shifting the load.

      what do define "false sharing" as

      I sincerely hope you're asking how false sharing applies to this particular situation, not what false sharing is, because if you meant the latter then you should be reading H&P instead of posting here. False sharing is an issue because a single cache line on a modern processor is likely to span multiple vtbl entries. Naive vtbl-patching code that does manual icache invalidation would therefore be likely to go through all that overhead multiple times. Ick. The only alternative would be to have the vtbl-patching code be *deeply* aware of the local machine's cache line size (i.e. not just hidden in some memory-munging library routines). Also ick. That kind of machine-specificity needs a reason, and there just doesn't seem to be much of one so far.

      Care to let me know what the topic is?

      The same as it has always been, Sparky: whether double jumps as an alternative to indirect junks are a reasonable or sucky idea. If you're having trouble making the connections between the issues we're discussing and that basic point, let me know and I'll dumb it down a little more for you.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    6. Re:What about making it a little less bloated? by Salamander · · Score: 2
      The vtbl is not ever written to. On a unix system it is part of the ELF or a.out code area. The linker figures out how it looks, and it is not changed at runtime.

      If you think about it for a while, you'll realize that there are situations that the linker can't handle, and therefore there must be run-time patch-ups for at least those cases. You really should be more careful about using words like "never".

      using a ld.so that it got from FreeBSD, which uses a ld.so borrowed from, or inspired by the Linux version

      And I suppose those are the only OSes that matter, eh?

      ld.so does similar things for the C code, and it also has minimal OS support (the mprotect(2) call, make the stub tables non-executable+writable, change them, make them executable+read-only)

      And do you suppose that mprotect is free? Or might this be one of those hidden costs whose existence you've been denying?

      That's an opinion based on whether you view it as a kludge or not.

      You got that backwards. I view it as a kludge or not based on the effect it has, instead of assuming it's not a kludge and then trying to deny effects to back up my opinion. IMO if it slows down the system as a whole *or* if it makes code elsewhere significantly more complex to support it, it's a kludge.

      The right thing to try would be to convert from JMP JMP to a indirect JMP. If the indirect JMP is faster then you are right for that workload. If the JMP JMP is faster then I'm right for that workload

      Not quite. The whole point here is that it's not sufficient to compile a C++ program and run it and compare the timings. It's also important to factor in the overall performance, maintainability, and other costs of making that program run faster and supporting the hacks that it uses. Remember what I said about hidden costs, or shifting load?

      Yeah but the assumption would probably be 16 bytes because that is a really really common number

      Yeah, and nobody ever got in any trouble by forgetting the difference between "really really common" and "universal for all time" right?

      There is no need to stoop to insulting your debating partner.

      When my debating partner is obstinately straying from the rules of debate, I actually do feel they deserve a little slap on the wrist. The crux of this whole debate is your statement (in cid#635):

      The hidden costs the other poster was talking about [me, in cid#595] don't exist.

      What annoys me is not that the statement was made, but that it wasn't retracted the first time it was refuted. Instead, I've had to put up with your topic changes, buzzword storms, squishy definitions, and all manner of other evasions. Frankly, I don't appreciate the extra work. I wouldn't treat you like an errant debate pupil if you'd stop acting like one.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    7. Re:What about making it a little less bloated? by Salamander · · Score: 2
      Maybe we would have gotten here sooner if you were civil

      We would have gotten here even sooner if you hadn't been so uncivil as to sleaze all around the subject (and several others) instead of simply accepting that maybe the point about hidden costs was a valid one.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    8. Re:What about making it a little less bloated? by UnknownSoldier · · Score: 2

      > but look at BeOS. Unless I've been misinformed, (and I'm sure someone will let me know) isn't BeOS written almost entirely in C++?

      The BeOS kernel was NOT written in C++. The GUI was.
      (I can dig up archived messages on Be development if you want proof.)

      The reason BeOS boots in 5 seconds, is because it doesn't have to support all that legacy crap. :-) (Of course it doesnt' support a whole lot else, unfortunately ;-(

      *hopeing BeOS will go Open Source someday*

    9. Re:What about making it a little less bloated? by Temporal · · Score: 1

      I was talking about virtual vs. non-virtual. Inline methods are a whole different matter. Yes, inline functions are much much much faster than virtual or even non-virtual (but non-inline) functions.

      ------

    10. Re:What about making it a little less bloated? by Temporal · · Score: 2
      C++'s virtual functions are slow. Quite slow.

      That's a common myth. If you actually run some tests, you may be surprised to find that a virtual function is hardly slower than a non-virtual function. I did some such tests myself recently, and was stunned by this discovery. And yes, I did make sure that the compiler wasn't optimizing out the virtual call.

      Other sources say that a virtual call take about as long as four assignment ops. Almost anything that you might want to call through a virtual function will take at least an order of magnitude more time than that. Thus, the time taken by the virtual call itself is irrelevant.

      While I'm at it, I'd like to point out something about efficiency -- poor performance is almost always caused by bad design, not the language of implementation.

      For instance, trying to represent a text document in a text editor by using one large string (char* or STL string) is likely to cause problems, since you potentially need to allocate a new block of memory the size of the document and copy the text to the new block every time a change is made.

      Another example, in the case of 3D graphics, would be a design where you attempt to store a triangle mesh in a linked list rather than a static array. I've seen people do this! The result is that they have to make at least one OpenGL call *per triangle* rather than per mesh, which increases the time complexity of the algorithm enormously. The author of said software tried to solve his performance problems with little tweaks like using lookup tables for sin and cos. Needless to say, it didn't help much. (Of course, his lookup tables were actually slower since they were not implemented as inline functions, but that's beside the point.)

      ------

    11. Re:What about making it a little less bloated? by rubberducky · · Score: 1
      C++'s virtual functions are slow. Quite slow. But faster then C calling through a pointer.

      I am not sure if this is true. To figure out the correct type for a virtual function, the compiler must performa a variable type analysis. The liklihood that your vta analysis will figure out the correct type is no better than the probability that a points-to analysis will figure out the points-to relationship for the function pointer in C.

      Therefore, when you are lucky (ie. vta succeeds), you are (on average) as fast as C. When you are unlucky, you are way slower than C (think about table lookups for the appropriate virtual functions).

    12. Re:What about making it a little less bloated? by Steeltoe · · Score: 1

      "Sometimes insanely faster because the C++ compiler can actually tell what type the pointer will be at run time. C can almost never tell."

      I truly don't understand this. C always can tell the pointertype, because it is static. Or are you thinking about equivalent code in C? I thought the myths about virtual functions had died long ago. It's just like the argument with Java being faster than C. Yes, it can be when you allow for optimizing out "stupid" coding.

      The discussion is idiotic. Algorithms and design are what's crucial, not syntactic sugar. High-level languages just improves your efficiency by many orders of magnitudes (whatever that is).

      - Steeltoe

    13. Re:What about making it a little less bloated? by Steeltoe · · Score: 1

      Yeah, you never really want to forget those C/C++ skills. It can be crucial to a successful- or a mediocre system. Right tool for the right job and all that. Too bad you have to spend months to convince managers.

      Btw, you can discuss whatever you like regardless of what I say ;-)

      - Steeltoe

    14. Re:What about making it a little less bloated? by clem.dickey · · Score: 1

      In Stroustrup's other appearance at SD 2001 West he presented some numerical code (matrix manipulation, etc.) beat C on the tested compilers. One one compiler it also beat Fortran.

      The trick is popularizing the idioms he used so that you don't have to be Stroustrup to understand them.

    15. Re:What about making it a little less bloated? by PerlGeek · · Score: 1

      Now, I like Perl and all, but how can that be, as Perl is written in either C or C++?

    16. Re:What about making it a little less bloated? by torokun · · Score: 1
      OOP != Slow

      There are a lot of principles at work in good OOP, and they don't have to involve run-time polymorphism, or huge class hierarchies to be OO.

      I'll agree that it takes a lot of experience to use C++ correctly and efficiently, but I've got to say, I love it because of the things you can do, and because of it's efficiency.

      There are tons of ways to write mad-fast C++, and still use good object oriented design -- you just have to know how. Use simulated dynamic binding. Use const references. Use initialization lists. Use inline functions properly. Overload new and delete to do faster allocation. Use the STL properly. Avoid temporaries. Use expression templates. Use templates a lot. Use more templates. .....

      Of course, you have to learn how all these things work together to write good C++ code, while being efficient at the same time, but isn't that what we programmers do? ;)

      Don't knock C++ for speed until you've made it fucking fly. Cause you can, if you know the language.

    17. Re:What about making it a little less bloated? by invi · · Score: 1
      Other sources say that a virtual call take about as long as four assignment ops. Almost anything that you might want to call through a virtual function will take at least an order of magnitude more time than that. Thus, the time taken by the virtual call itself is irrelevant.

      You are missing the point here: if the method is not virtual, the compiler may choose to inline small methods (get()- and set()-methods), in which case the method invocation is basically free.

      If the method is virtual and you call it through a pointer (like this, even if used implicitly), the compiler has no choice but to generate code which considers the vtable which is an indirection and therefore takes more time.

      Simulating the same behaviour in plain C would probably use the same amount of execution speed, even though making your code more complicated and harder to maintain.

      Remo

    18. Re:What about making it a little less bloated? by Xentax · · Score: 1

      No offense, but if your C++ code is going more than, say, 10% slower than equivalent code in C, you're not writing good code. Write the functionality first, then (and this part is important), OPTIMIZE. Profile, and then improve the places where you're spending the most time.
      If you believe you have optimized the code, look at build/link options, you may be able to improve there. Explicit vs. implicit vs. static template instantiation, etc.

      Xentax

      --
      You shouldn't verb words.
    19. Re:What about making it a little less bloated? by limejuice · · Score: 1

      I keep hearing people say C++ is bloated, citing Netscape as an example. Certainly Netscape is the king of bloatware, but look at BeOS. Unless I've been misinformed, (and I'm sure someone will let me know) isn't BeOS written almost entirely in C++? Yet BeOS is lightning quick on my Pentium 133 with only 64 megs of memory. Perhaps the slowness is a result of the programmer or the compiler, and not the language itself?
      --

      --
      Daniel J. Kelly
    20. Re:What about making it a little less bloated? by ralphbecket · · Score: 1

      Mercury (a pure, fast, functional/logic programming langauge) has a very simple performance model for the basic language. Some of the higher level aspects of the language, such as typeclasses and higher order code, have less obvious models, but as soon as the optimizer is turned on in any language you lose the simple performance model. That said, you can do much more in the way of optimization with a pure, referentially transparent language than you can with imperative stuff like C and (ugh...) C++.

    21. Re:What about making it a little less bloated? by pkesel · · Score: 1

      C++ is a tool that takes some knowledge and experience to get right. First, you MUST know your compiler and how to make it work properly. One little compiler flag can make a huge difference. Secondly, if you're looking for speed, know your design and just how many constructors you're using. If you're constantly dynamically creating something that's several levels down the class hierarchy, expect some time to create those things. If you don't need all that construction or can't live with the costs, change your design. Thirdly, as someone else suggested, know your algorithms. That means know the mathematical complexity of what you're doing, and watch your call stack depth, and the value parameters in each item in the stack.

      I promise you that the guy who picked up a Perl of Java book and was a whiz kid in a couple weeks won't find as much mastery in the same time with C++. He might have something that works, but I bet it won't work as well as it could.

      --
      - Sig this!
    22. Re:What about making it a little less bloated? by Mr.+Fred+Smoothie · · Score: 1
      Wow. If your Perl code runs faster than your C++ you are either an amazing Perl programmer, or need to learn a little more about C++ (like how to use references for argument passing, etc).

      The whole design principle behind all of the so called 'bloated' features in C++ was that you don't pay for them if you don't use them. Don't want the overhead of exceptions or RTTI? Don't use them. I have found this to be the case with most of the features. Even the cost of the features one does use has been consistently decreasing in many or most implementations as compilers improve (e.g. -fnew-abi in g++). There is more work to be done there, but serious, dedicated people are working on it, and it is but a matter of time until many of these issues are for the most part resolved.

      --

    23. Re:What about making it a little less bloated? by vidarh · · Score: 2
      The overhead for calling a virtual function in C++ is only looking it up in the vtable of the object. To emulate C++ virtual functions in C, just as a C++ compiler will implement it, you could do as follows:

      You add a "void * vtable" to your struct, fill it in with a pointer to a struct of pointers to functions related to the real "class" of your struct. Then you call the functions like this: yourob->vtable[some_function_offset]()

      Your overhead shouldn't be more than two indexed array lookups over that of a normal function call.

    24. Re:What about making it a little less bloated? by Gsus2 · · Score: 1

      Lookup tables were good when memory was faster than the processor. Nowdays they should be avoided. The cache isn't doing much help when you lookup random values either.

    25. Re:What about making it a little less bloated? by Flying+Headless+Goku · · Score: 2

      No offense, but if you are following "good OOP practices", using lots of classes and virtual functions, and generally taking advantage of the features of C++, you can expect your C++ code to run much more than 10% slower than C code.

      C++ OOP wreaks havoc on pipelines and cache (using C++ as "better C" is, of course, just like using C). Expect 50% slowdown and be prepared for worse (when your own code is actually doing the work -- when your own code just tells libraries what to do, it barely matters what you are writing in; you could use Python or TCL and it wouldn't make a big dent in the performance).

      Running it through the profiler and looking for bottlenecks won't do you much good when the bottleneck is your general architecture.
      --

      --
    26. Re:What about making it a little less bloated? by haruharaharu · · Score: 1

      How else are you going to call a function, except through a pointer? You can't inline everything.

      --
      Reboot macht Frei.
    27. Re:What about making it a little less bloated? by hfuzz · · Score: 1

      Make sure your optimization settings are set to max. The difference between optimized and unoptimized C++ code can be huge. In general, if your code doesnt run as fast as C code, your code is crap. Forget the "10%-overhead is ok" or "templates are slow" shit. Its wrong. C++ does what C does and goes miles beyond. If your perl-code is faster than your c++ code youd probably refrain from posting on ./ and do a little more coding work.

    28. Re:What about making it a little less bloated? by BoP2 · · Score: 1

      Ok, so have a look at Bjarne Stroustrups paper "Learning Standard C++ as a new language"

      Learning

      where he shows some cases where C++ is *way* faster than plain old C.

  96. Re:The Right Tool for the Job by madmaxx · · Score: 1

    | Oh, I have my criticisms of C++: A new standard
    | is a mistake when no on produces a fully-ISO
    | compliant compiler today. The STL is an ugly
    | mess designed by committee; I'd like to see
    | restricted template arguments, inheritable
    | enums, and a few other new ideas.

    the stl wasn't designed by committee, but by stepanov ... and is one of the most brilliant designs i've seen to date.

    --
    mx
  97. Re:C++ Frustrations by GreenK · · Score: 1

    No kidding.... Look at how w3c was handled... yeah there are standards, but it's hard to get people to follow them correctly. I'm still waiting and waiting for cool things like MathML to get put in to at least ONE popular browser (been hoping for mozilla for how many years?). Remember how long we have held onto COBOL FORTRAN and PL/I? Standards create stability but they allow things to stagnate. I think a new standard is a good thing because it will push people away from the antiquated one we have now. (yeah you may disagree, but people have been using extentions and fragmenting the space for too long...time to regroup)

    OT: wow, It's been a while since I last posted, an I hadn't realized that my user number is considerably low for how many people are here now.. :-) Good to see so many opinions!

  98. Time to move on by miahrogers · · Score: 1

    I think they should stop and concider when it's time to move on. My grandmother coded in C for Bell Labs (ok I'm 15, but still). While C/C++ are still great languages, in the future (ie: when these things finally get around to being fully supported in most compilers) processors will be about 8 times faster (expecting moores law at 1.5 years and 4-5 years until these are supported).

    There are many great scripting languages with much more concise structuring than C and C++, and even things like variable-types could possibly be eliminated (perhaps build a virtual machine into the kernel that will handle the programs). Anyways they should think before wasting the time to add onto the language, get it standardized, get it implemented, and getting everyone to learn it.

    1. Re:Time to move on by miahrogers · · Score: 1

      And C is implemented in itself. "How'd they do that?" you ask. They wrote a bootstrap compiler in some other language that can create binaries (like assembler), and then they used that bootstrap compiler to compile a compiler written in the native language (being C in this example).

      Connect the dots

    2. Re:Time to move on by miahrogers · · Score: 1

      Yeah, but (hopefully) the ideal langauge of tommorow will run as native machine code, or at least be capable of it. You could structure programs so that sometimes they could require types, and other times not. Requiring types would be nice for really big and structured code.

      Anyways there are ways of doing it, and it would be nice to have both a "medium level" language which is easier to write than C++ (cleaner, well thought out, proper OO) than another mutant of C/C++.

    3. Re:Time to move on by divec · · Score: 1
      C can [be compiled down to native machine code] because it's a simple abstraction from assembler. C++ can be distilled to C code. How would you do this with Perl, for example, where you may not know what kind of data you'll be dealing with until runtime.

      Here's a question: Is there a theoretical CompSci way of making a distinction between compilable and non-compilable languages like this? I tried to think of one but it proved harder than I expected. For example, I could make a "perl compiler" that creates an executable which is simply perl.exe followed by the actual script. Sure, this "shouldn't" count, but I can't see a rigourous way of making the definition stick.

      --

      perl -e 'fork||print for split//,"hahahaha"'

    4. Re:Time to move on by KewlPC · · Score: 1

      Umm... sticks and stones?
      C may be an old language, but it is still useful:
      -C statements translate directly into assembly language
      -Generated code is fast and efficient
      -No OO crap getting in the way of C
      -If you need/want OO, use C++ instead
      -If you're writing an OS, C and assembly are the only realistic options

      C'mon guys, it may not be the newest, flashiest language, but C is still a viable programming language (especially for OS kernel programming). Hell, the Linux kernel is written in C (like there's somebody on Slashdot who didn't know that)

    5. Re:Time to move on by Dancin_Santa · · Score: 1

      Gosh, and what language would those scripting languages be implemented in?

      I believe this is the same question that Creationists use to debate the Big Bang...

      Dancin Santa

    6. Re:Time to move on by Dancin_Santa · · Score: 1

      Sure, but can you create a language as runtime dependent as *insert scripting language here* that can be compiled down to native machine code? C can because it's a simple abstraction from assembler. C++ can be distilled to C code. How would you do this with Perl, for example, where you may not know what kind of data you'll be dealing with until runtime. You could build a runtime (like perl.exe) that could do the runtime translations but your compiled code couldn't be run as-is without that runtime.

      Dancin Santa

    7. Re:Time to move on by nick-less · · Score: 1
      Sure, but can you create a language as runtime dependent as *insert scripting language here* that can be compiled down to native machine code? C can because it's a simple abstraction from assembler. C++ can be distilled to C code. How would you do this with Perl, for example, where you may not know what kind of data you'll be dealing with until runtime. You could build a runtime (like perl.exe) that could do the runtime translations but your compiled code couldn't be run as-is without that runtime.
      I dont think so, you can compile *insert scripting language here* to machine code; sure it would be a little bit harder to write a compiler for a language like perl, php or visual basic, but not that hard, and you wont gain that much speed, because the libraries and buildin functions where written in C anyway...
    8. Re:Time to move on by nick-less · · Score: 1
      Hell, the Linux kernel is written in C (like there's somebody on Slashdot who didn't know that)
      Which is a piece of crap, anybody knows that you should better use a Microkernel instead ;-)
    9. Re:Time to move on by Ayende+Rahien · · Score: 1

      I don't think so, you can take a program in english, and compile it. (Okay, by hand at the moment, but one day... my computer will core dump because I used or instead of and/or when I told it what to do :) )

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    10. Re:Time to move on by Ayende+Rahien · · Score: 1

      As a note, last Ada version was on 95, when OO was added to the language. I don't think it needs to be changed any time soon.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    11. Re:Time to move on by oodl · · Score: 1

      Dylan is a very well designed object-oriented dynamic language with 2 solid implementations. One implementation compiles directy to machine code, and the other compiles to C code as an intermediate. Dylan has many advanced features, including optional typing.

      It's hard to believe it's the year 2001 and many computer have 256 Mb of RAM, but many programmers are still programming with sticks and stones (C, C++).

  99. Extended type information = Reflection by descubes · · Score: 1
    The extended type information would be quite welcome... if it extends to the C++ code itself and allows full reflection to be implemented in C++. And I doubt they will ever go that far.

    See Mozart to see what I mean.

    By the way, if you believe that we can improve over C++, come and help me implement LX... In my very biased opinion, this language is insanely better than C++. It is also one of the least successful Open Source projects in existence :-)

    --
    -- Did you try Tao3D? http://tao3d.sourceforge.net
  100. Re:A serious (rather unpopular) hope... by descubes · · Score: 1

    You can't be serious with C++. I've tried (see my bio if you have any doubt ;-) You should rather consider one of the many C-- in existence. Some tidbits:

    C-- is a subset of all ambiguous constructs which could be removed from any C++ extension without impact on general code quality. This naturally include all standard C and C++ constructs.

    All new features range from "useless" to "potentially disastrous". The C-- reserved words that fall in the last category do not contain an asterisk (*).

    The current implementation (V21.13) is a post-processor written in FORTRAN. It handles errors generated by the C compiler and interpolates with the C-- source code to create an MS-DOS batch file, which more or less does the same thing as what your C-- program intended to do, only slower. This implementations makes it easy to port the C-- compiler, provided there is a FORTRAN compiler, a C compiler and an MS-DOS batch file interpreter. IBM PC/DOS version is currently in beta test.

    OK, I wrote all that crap a long time ago, and it shows a bit... But I may have been one of the first ones to propose comments ending in \\ (for left-handed people), a C++ compatible implementation of comefrom, function inheritance, #try .. #catch (to try and compile something), and a few others niceties. Too bad I did not finish it, I still had a lot of work to do on short long, dereferencing of float, dodecadecimal numbers, probabilistic switch, etc.

    --
    -- Did you try Tao3D? http://tao3d.sourceforge.net
  101. Re:About time by ttfkam · · Score: 1

    Correction: The STL is equivalent to (most of) java.util, (part of) java.io, and java.lang.String. They are not equivalent. What the original poster was mentioning was the loss of java.net, java.awt, java.sql, javax.swing, java.rmi, java.lang, etc.

    Assertion: You need to talk to a database.
    Question: What is the official C++ method of talking to databases?
    Answer: There is none.

    Assertion: You need to write a graphical user interface.
    Question: What is the official C++ method of implementing a graphical user interface?
    Answer: There is none.

    Assertion: You need to write a distributed (multi-system) program.
    Question: What is the official C++ method of implementing a distributed program?
    Answer: CORBA? But which ORB?

    Assertion: You need to write a multi-threaded application.
    Question: What is the official C++ method of using threads and handling semaphores/mutexes?
    Answer: There is none.

    The biggest advantage Java has over C++ is its standard library. Period.

    The biggest advantages of C++ over Java (IMHO) are memory usage and parametric (compile-time) polymorphism w/ templates.

    Universal themes regardless of language? Premature optimization is the root of all evil. Efficiency of design/algorithm will almost always win over choice of language (BASIC can be faster than C given different algorithms).

    Use what works for you. Use the language that best fits the problem. Let's stop the language wars and get some work done.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  102. Re:About time by ttfkam · · Score: 1

    javax.servlet and java.rmi ARE in fact merely libraries (packages in Java-speak). The only thing that makes them "integrated" are their inclusion in rt.jar.

    EJB is simply an umbrella term for RMI, JDBC, JavaBeans and JNDI with some convenience classes/interfaces.

    Don't get me wrong. They are wonderfully useful and reasons for me to love working with Java, but they are not intrinsic to the syntax of the language any more than the STL is intrinsic to C++. They actually are merely "libraries."

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  103. Re:They should break from the C model entirely... by ttfkam · · Score: 1

    Already been done. It's called Smalltalk. And one of the reasons it did not take off was the fact that everyone already knew C (or a C-like language).

    There is a reason that C++ has curly braces for scoping, parentheses for parameter lists and square brackets for array syntax.

    There is a reason that Java has curly braces for scoping, parentheses for parameter lists and square brackets for array syntax.

    There is a reason that Perl has curly braces for scoping, parentheses for parameter lists and square brackets for array syntax.

    There is a reason that ECMAScript has curly braces for scoping, parentheses for parameter lists and square brackets for array syntax.

    I sense a pattern here...

    There is also a profound resistance to OO thoery in the C language camp that I still can't quite understand, but that is another story...

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  104. Re:Simplify, standardize and fix by ttfkam · · Score: 1

    Hunh? I hate to break it to you, but unsigned int and int are two different types. The only similarity they have is their size in memory. It's counter-intuituve to you because apparently you had false assumptions. Do not blame the language for this.

    If your function were as follows (warning! useless template feature approaching!)

    template <class T>
    void swap (T& x, T& y){
    T a;
    a=x;
    x=y;
    y=a;
    }

    and you did this:

    unsigned int a=1, b=2;

    swap(a, b);

    a and b are swapped, which is correct!

    A little forethought with the design (and I stress "little") and we find, as you did, that there are two copies of our functions in the binary. Oh no! I've lost maybe half a kilobyte on my hard drive! Look at that extreme bloat! Whatever shall my 27GB drive do? A thousand of these programs and I'll have lost close to one megabyte! Oh wait! No... If I put this function into a library like I should do for all of my heavily reused code segments, I've still only lost half of a kilobyte of position independant code AND shared libraries offset the memory footprint increase.

    The waste for a single instance is far from substantial. The waste from multiple instances is far from substantial. The waste from multiple references to an instance in a shared library is so insubstantial, it is laughable.

    Worry about your overall algorithms before fretting too much over this. There's a reason we don't freak out over our programs fitting into (less than) 128KB of memory and taking up less space than is available on a cassette tape.

    Premature optimization is the root of all evil.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  105. Re:Simplify, standardize and fix by ttfkam · · Score: 1

    Oops! Totally forgot the last part of your curious position.

    a[i++]=i++;

    Hmmm... This is quite a problem. You're right in that it is quite ambiguous and implementation dependant. Let's try an alternative shall we?

    a[i] = i;
    i += 2;

    - or -

    ++i; // no temporary
    a[i] = i;
    ++i;

    - or -

    i += 2;
    a[i] = i;

    Yet another thing I cannot seem to grok: why do coders get so obsessed about saving a line of text in source (which is supposed to be readable by humans by the way!) when the code output by the compiler is EXACTLY the same for all intents and purposes. In fact, by avoiding temporaries (you did know that "i++" causes a temporary variable to be created right?), it might be 0.0001 seconds faster (woohoo!). The important difference being that the first example is ambiguous to read even if there were a defined behavior. All of the others on the other and are completely clear to anyone regardless of their experience level provided they've have done any rudimentary programming.

    Optimize your code, not your source.

    16 bit ints are completely justified on a 16 bit CPU. If you think that's weird, you should check out the systems that have 36 bit ints (yes, they exist). Not only are some ints less than 32 bits, some aren't even powers of two.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  106. Re:No kidding... by ttfkam · · Score: 1

    According to ISO 98 C++, your example should scope "i" to the loop. Don't blame the language for limitations in the compiler.

    It's like blaming the authors of the U.S. Constitution because some representative in Congress tries to establish a law which contradicts the Constitution.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  107. Re:Language evolution by ttfkam · · Score: 2

    "I think it is interesting that after less than a decade, C++ is being labeled as fossilizing. While its parent C is still very vital."

    1) C++ was first released twenty years ago.
    2) C++ is not fossilizing (where is your data that people aren't using C++ anymore?) The STL, a relatively new construct (less than ten years old), is being used more and more. How is that fossilization?
    3) If C is so vital, then why are people flocking to Java and scripting languages?

    C has its uses. C++ has its uses. Language X has its uses.

    On the other hand, I agree with you that if Java adopts generic idioms and assertions, my reasons for using C++ will decrease dramatically. However, since we are talking about hypothetical futures, if C++ gains an easy to use garbage collector and unified thread and socket library, my reasons for using Java will decrease dramatically.

    Languages are immaterial. Concepts are important. Use whatever language best describes the concept you are trying to present.

    --

    - I don't need to go outside, my CRT tan'll do me just fine.
  108. Re:A serious (rather unpopular) hope... by gkatsi · · Score: 1

    It is pretty easy to do this using templates and coming up with something like:

    integral&lt 32 &gt i32;
    integral&lt 128 &gt i128;

    or integral_at_least&lt 35 &gt which would give you a 64-bit integer or whatever is fastest and at least that size for any given architecture.

    All you have to do is provide specializations for some of the bit sizes and define the others as recursive templates.

    This does not have to be part of the compiler, just the standard library.

    As for the having-different-signatures part, it is of no use, as far as I can see. The only reason to do that is to maintain binary compatibility in the face of changing type sizes. But this can't happen within the same architecture, so all you need is source compatibility. Besides, as another poster mentioned, it is a major incovenience for users of your code (users as in programmers that use your code).

  109. Language vs Library by bmacy · · Score: 1

    I really hate this... there *is* a difference between a Language and a Library. C++ is a Language and STL is a Template Library (I won't go into my loathing of the STL as anything other than a compiler test suite). I really wish they'd stop putting this stuff in the Language spec. Make an ANSI C++ Standard Library Set spec.

    Like in Java... it's a Language, a set of Libraries, and a Virtual Machine.

    Brian Macy

    1. Re:Language vs Library by DevNull+Ogre · · Score: 1

      It's not unreasonable to have a standard library as part of the language spec. I see your point about word usage, but what good is [insert favorite language here] without its standard library? Do you really want a C without printf? C++ without cout?

      Since there's not much point in a language without its standard library, why bother separating the specs?

  110. Things I'd miss about Java (re C++) by bigbird · · Score: 1

    Many other reasonable answers include such things as garbage collection, checked exceptions, portability of binaries ...

    1. Re:Things I'd miss about Java (re C++) by The_Messenger · · Score: 1
      I'd actually prefer to have explicit memory conrol, which is why I plan to look at C# despite its inherent evil-ness. :-) Checked expections can be a good thing, but I would prefer the ability to turn them off.

      But binary portability simply rules. I didn't think I would be so keen on it until the first time I developed a project completely on NT and then moved it to AIX without recompiling. It's not all it's supposed to be, especially with non-Sun JVMs, and so I encourage recompilation for production server applications, but in general it kicks ass.

      --

      --

      --
      I like to watch.

  111. Re:No kidding... by damyan · · Score: 1

    The /Zc:forscope option tells the Visual C++ compiler to follow the standard C++ definition for the scope of variables declared in a for loop.

    Is this true? We've been getting desperately annoyed trying to write code that runs on both VC and gcc by this. Unfortunately I can find no reference to this in the docs anywhere. Can anyone confirm this?

  112. C++ needs an implementation standard. by Jason+Pollock · · Score: 1

    What I would like to see is an implementation standard for C++.

    At least some way that I could link C++ code generated by GCC with others, such as Sun Forte. We use GCC for platform independence, but we are continually having to write stupid little C function wrappers around classes to get around all of the linking issues.

    Then I might be able to do some code re-use at more than just the source level.

    Jason Pollock
    1. Re:C++ needs an implementation standard. by Jason+Pollock · · Score: 1

      I realise that, but there isn't anything keeping them from saying that if you adhere to the standard, use this implementation, then you will interoperate. Other languages are able to work this way. Java does, C forces everyone to because they have to link in system libraries.

      Different revisions of the standard could still change the name mangling to force link failure, but if you are both on the same revision, I would expect it to work.

      If the system libraries were implemented in C++, don't you think we would have an implementation standard? Yep, me too. :)

      Can you tell that this is currently a major beef with me? :) I'm having to write two hunks of C code, passing void *'s around because I can't link two libraries together, and I don't have the source code for the Forte one.

      Jason Pollock
    2. Re:C++ needs an implementation standard. by captredballs · · Score: 2


      FYI

      gcc, and possibly other compilers, actually do this on purpose. Since the c++ standard is not stable (ie they are already changing it again), they use the different versions of name mangling to keep folks from compiling wrong versions of C++ libraries together.

      So that standard would be great and all, but it might just be the next thing changing ;-)

      --

      I suppose I'm not too threatening, presently, but wait till I start Nautilus
    3. Re:C++ needs an implementation standard. by Matthew+Austern · · Score: 1
      What I would like to see is an implementation standard for C++

      What you're looking for is called an ABI (application binary interface). And, of course, what you really need isn't an ABI, but an ABI for each platform you care about. Since you mention Sun Forte, for example, you probably care about an ABI for Sparc/Solaris.

      Some ABIs already exist; they're usually defined by platform vendors. Sun, for example, has published its C++ ABI.

      There's currently a multi-vendor effort to write a C++ ABI for Unix (various flavors, including Linux, Solaris, HPUX, and IRIX) running on Intel's new IA-64 architecture. The work is almost complete. The ABI is necessarily quite complicated, of course.

      I don't see that this can ever be something that the C++ standardization committee can deal with, since an ABI has to involve a lot of very specific platform issues. (Which register you use for passing which argument, etc.)

  113. How do you pronounce the new standard? by puppetluva · · Score: 1

    It looks a lot like it would be pronounced like "cocks" because no-one is going to go through
    the trouble of saying "cee-plus-plus-oh-ex".

    They need to change that. . .

  114. Re:C-Sharp? by divec · · Score: 1
    IANA Musician, but I seem to remember from my ancient days of playing violin that C-sharp is equivalent to D-flat.

    That's true, unless you're playing very pedantically; at any rate it's true enough to make it funny :-) Interestingly enough, "C#" is abbreviated as "dos" in Catalan, as in do-sharp, according to the docs for my local copy of Lilypond. (If you've ever had to watch The Sound Of Music you'll know what "do" represents :-).

    --

    perl -e 'fork||print for split//,"hahahaha"'

  115. Re:Something I've wanted for a decade... by Hard_Code · · Score: 1

    Bravo!

    --

    It's 10 PM. Do you know if you're un-American?
  116. Is it just me by QuantumG · · Score: 1

    or does this story have a blue border? WTF?

    --
    How we know is more important than what we know.
    1. Re:Is it just me by QuantumG · · Score: 1

      I would prefer it if every story posted by Tim was in blood red, so I can imagine that I am slowly stabbing him to death.

      --
      How we know is more important than what we know.
    2. Re:Is it just me by questionlp · · Score: 1

      I think the color scheme for the programming section is blue, where as the Apache section is purple and funny yellow/green.

    3. Re:Is it just me by mellonhead · · Score: 1

      You are correct. At first I thought it was my monitor. It's a nice change though...

    4. Re:Is it just me by Joe+Hardy+(_yoda) · · Score: 1

      I think the color scheme for the programming section is blue, where as the Apache section is purple and funny yellow/green.

      ... and 'Ask Slashdot' is dark grey with some cool drop shadows

      --
      -- No, no gems to be found in this sig.
  117. Re:Is it just me (there is an easier way, y'know) by QuantumG · · Score: 2

    yes, if I close my eyes the world will go away. Having a fuckwit writing news means there is one less competent person writing news which means I, and others who can recognise a dickhead, miss out.

    --
    How we know is more important than what we know.
  118. g++ 3.0 is ALMOST FINISHED! by devphil · · Score: 2
    g++ comes close, but still enough annoyances to be, well, annoying

    Got a few spare CPU cycles? Help us test the 3.0 prereleases. You can download freshly-built and working RPMs from http://www.codesourcery.com/gcc-snapshots/ and run your favorite C++ through it.

    The C++ library has been completely rewritten. It wasn't stable enough for 2.95 (or RH's 2.96), and since then it has depended upon recent changes in the compiler itself, so it didn't get included in 2.95.3. Someone else on this page was complaining that "even g++ doesn't have fully-templated iostreams like the standard says," but the new library always has. (It just hasn't been turned on by default in any existing gcc release, is all.)

    There are other changes as well. Some really cool ones are already in the tree but won't be included in 3.0; we decided to wait until 3.1 for major user-visible features. The big (IMHO) change for 3.0 is the vendor-neutral ABI for C++ that will let you link code compiled from different compilers.

    When will it be released? Sooner, if you help.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  119. Rationale Garbage Collection Explained -- sort of. by J.Random+Hacker · · Score: 1

    Geez -- I haven't often seen such ignorance displayed with such force. You really ought to consider doing some reading on GC as a topic, and not rely on (I'm guessing :) experience with one really bad implementation.

    Properly implemented, GC has no impact on the classes interface, or even the lifetime of the objects. What it does accomplish is to allow the designer to concentrate on the problem semantics and ignore object lifetimes. There are real problems where this is a serious issue, and where you cannot design the problem away without implementing reference counting or some other poor cousin of GC. Semantic nets, and related AI type problems tend to have this characteristic.

    And no -- sloppy thinking does not result in GC, it results in Windows applications.

    The problem with getting a proper implementation is that GC would like to know the types of things in much more detail than the compiler ordinarily makes known to the runtime system. If all obects had RTTI type information, then GC is much easier to implement in a clear and correct way. If the standard prescribed hooks allowing implementations to provide GC, then we'd have it when we need it without lots of extraneous effort. G++ has one such facility.

    hope this educates you a little :)

  120. Re:Bolt-ons are not the same as "new and improved" by J.Random+Hacker · · Score: 1

    You presume too much. To my way of thinking, Java has some serious flaws that could have been avoided. Others have mentioned VM and the lack of independent standards -- I'm not so concerned about those.

    What bothers me about Java are these two things:

    (1) The thread primitives are not primitive enough. Per Brinch Hanson and C.A.R. Hoare demonstrated the minimum requirements for correct threading 30 years ago (IIRC) - the library implementation in Java leaves open some very hard to track down race conditions (Note that the fact that you have not seen the problem only means that you have not triggered the problem).

    (2) Interfaces cannot contain code, so cannot provide behaviour. Multiple inheritance is prohibited (Yes MI is hard to get right, but sometimes it *is* the right tool for the job, with all alternatives being inferior). This leads to duplication of what should be common code.

    Language design is really hard to get right, so there can be no guarantee of continued progress. Some new ideas will turn out to be really bad ideas. We have to try things out and see how they work in practice. I'm fairly certain that every language will be less than perfect because of the cognitive distance between how humans think and how computers work. What makes a programming wizard so amazingly productive is (imho) a well trained mind, and the ability to *really* focus on a single task.

  121. What is a non-compilable language? no such thing. by J.Random+Hacker · · Score: 1

    All useful languages that I am familiar with are also equivalent to some Turing machine. You can always write a transformation to a Turing machine description (not that it would be *easy* -- they don't call it the Turing-tar-pit for no reason :). In turn, you can always write a transformation from a turing machine description to a common processor type machine (loosing infinite tapes in the process, but that is no real loss, since the original program has that same limit).

    So -- I contend that you can compile *any* computer language that you can interpret. The only question that remains is whether compilation is useful for the language in question.

  122. Re:Rationale Garbage Collection Explained -- sort by J.Random+Hacker · · Score: 1

    Well, you are right that I was digging at Windows. I've been astonished at certain types of thinking about program construction that is directly attributable to exposure to Windows and/or MFC. (I usually refer to that thinking as Windows/MFC-induced brain damage) It seems to me that the sloppy thinking occured when those interfaces were constructed (I don't imagine that they were designed....), but the effects carry forward to anyone who learns to program by being exposed to them.

    But that was not the point of my post, really. I just like take every opportunity to point out the flaws of the MFC/Windows programming model. ;-)

    You can use GC to cover up design flaws, just as you can misuse any feature of any language. The mere presence of GC in a design does not indicate sloppy thinking. It might. Or -- the presence of GC might indicate that the objects modeled have such indeterminate lifetimes that GC is the best solution to managing them. Before you rant on *that* being a result of sloppy thinking, consider the semantic nets I mentioned above -- they deal with real world data that is changing over time, and it is not clear when a node is no longer useful untill the last reference is lost or dropped. If the semantic net is multi-type, you might have a serious problem keeping up with the reference management, particularly when there are multiple referents, and no clear hierarchy. GC expresses memory management well under these circumstances.

    I'm not saying that GC is the only solution here -- clearly reference counting would work, but it tends to obscure the code and has limitations (e.g. circular structures). IMHO, GC is the best engineering solution to that type of memory management problem.

    Adding GC as an *option* to the language just gives me another useful tool. Your tool box can never be too full.

  123. Re:Bolt-ons are not the same as "new and improved" by Dwonis · · Score: 2

    Irregardless, he has a point. :-)
    ------

  124. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    No there are plenty more areas that warrant a gripe.

    The lack of an alternative to #include and 30+ year old linking technology sticks out in my mind as something that impacts both programmer and execution time. Fixing this would allow:

    1. Losing the pointless duplication of declarations in .h files. In fact, you would not need .h files anymore except for backwards compatibility. 'Course you'd lose the ability to make a header file do different things based on defined symbols, but that would be an advance IMHO.

    2. Virtual methods can be determined by the linker, so the programmer no longer needs to specify virtual-ness at all.

    3. Virtual methods can be implemented by binary decision trees instead of jump tables. This speeds execution on pipelined CPUs. They can also be inlined when there are few overloads.

    4. Inlining and template instatiation can be post poned until link given a sufficiently sophisticated intermediate format. In fact the compiler can inline any method or function.

    5. No more name mangling.

    6. Faster compiles -> no need to parse the same M header files N times for N files, once compiled, the intermediate format defines the interface to a module. Basically this is essentially global precompiled headers.

    Could this be done and keep backwards compatability? I don't know, and I wouldn't care. I would personally convert all 5000+ of my companies C++ modules just for the performance benefit and future time saved.

  125. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    Wow, so smug, and yet so wrong. Rather than explain in excruciating detail how narrow minded your response was, or possibly how poor or incomplete your education is, I'll forgo all that nastiness and help you out.

    Headers are a kludge leftover from C++' C ancestory. They allow all sorts of nasty tricks, but generally are considered the simplest way to accomplish independent compilation units. A more complicated, but much more efficient and less error-prone way to do this is to devise a language in which you can annotate the methods, types, etc that you wish to be part of the interface for a unit. When the compiler compiles the unit source, a compact description of the unit's interface is stored _somewhere_ in your build environment. When you need to use the interface of another module, your compiler goes into that module's description and pulls out the information it needs without doing any parsing whatsoever. I would imagine you would get compilation speeds in excess of a simple language like C using this technique.
    For a library supplier, they can use a simple tool to generate documentation from the source.

    As for virtual methods, this is an implementation detail that really does not need to exposed in the language if it could optionally use better linker/object technology. The language implementation can decide which methods need to be virtual itself through global analysis at or before linkage. For any given method, it must be virtual if any derived class overloads it. Since current linker/object technology is incapable of maintaining this kind of information and some code generation would be required at linkage, a more flexible object code format and linking technology would need to be created, but we are talking about a new version of C++, aren't we?

    Note that once you have the list of methods which overload a method, you can implement that method using a decision tree, each branch of which contains the code for the derived class. This avoids the pipeline stalls that you get with vptr virtual dispatch, which I might note is essentially forced upon the compiler writer because of inadequate linker technology.

    All sorts of interestings things become possible and lots of C++ frustrations fall away when the antiquated C linkage mechanism is done away with. But I fear it is too radical a change or it can't be done in a backwards compatible way. So I'm not holding my breath.

  126. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    Not necessarily a good thing. Redundance catches errors.

    The only errors this catches are discrepancies in the header and source, which of course would be avoided by this feature.

    Definitely not a good thing, virtualness is important when reasoning about a class. After a call to a virtual function much more state is uncertain than after a call to a non-virtual call

    I disagree. Virtual-ness is an implementation issue which is exposed in the base class because of linker limitations. There should however be an overload keyword for methods in the derived class to make the intent clear and avoid erronous overloading, as well as a way to keep base methods from being overloaded intentionally.

    The type information has to be represented somehow, name mangling is not really different from other means.

    However with sufficiently advanced linking technology, no mangling need be done at all. Its a kludge to get around old linkers.

    I don't seriously think the C++ committee would make any of these changes a reality, but I can dream. More likely a new high performance language will be created soon. There are so many issues in C++ due to its heritage, any new language with similiar (or greater) performance, features and a C-ish feel would be instantly popular, and probably take away both Java and C++ "market share" very quickly. It's an opportunity waiting to happen.

  127. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1


    This ignores the idea that you want to be able to explicitly tell the compiler which functions should be allowed to be "virtualized." How would that work out if the compiler auto figured out which functions should be virtual? Would you replace virtual with a "no_virtual"

    I think a keyword like "final" on a base method that you don't want to be overloaded, and a "overload" keyword on the method in the derived class would do what you want ( to avoid erronous overloading). With these kinds of changes, a new language would probably be required as it wouldn't be particularly backwards compatible.

    Small Eiffel does some of this. Not that I advocate Eiffel per se. See:

    http://smalleiffel.loria.fr/papers/papers.html

  128. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    point 1: Class designers often do not know which methods will need to be overridden in derived classes, thus if they are kind they declare any usefully overridable method virtual. Now, dispite the C++ mythos of paying only for what you ask for, all clients of that class must now pay for the virtual table overhead even if nothing in their _particular_ application requires overloading of some of the virtual methods.

    point 2: Only public/protected functions that are not marked to be un-overloadable would require this special processing. Most of the code generation could still be done at compile-time, but you'd have to allow for some flexibility w/respect to code layout and additional (small amounts) of code at final link. You definitely could not use existing object file formats.

    Dynamic libraries are a difficulty with this scheme, but could be done by falling back to vptr tables for the classes that are exposted by the library.

    point 3: As for virtual methods, a jump through a data table is more expensive because no speculative execution can be performed. This is true even for implementations that put jump instruction in the table. The pipeline is stalled until the vptr of the object is fetched. By contrast, even if the id of an object has not been fetched, decision trees can be speculatively executed, at least for small orders of overloading. Thus by the time the id is fetched, the correct code will most likely already be in the pipeline.

  129. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    That would be extremely bad programming practice (making everything virtual). I would argue that a class designer that doesn't know which of his methods will need to be overridden in derived classes is either lazy or doesn't really know what they are designing.

    This is just the nature of reusable software. If you design a library class with a method that does something useful by default, but want to make it replacable or extendible, in C++ you have to make it virtual, independent of whether or not it actually gets overrided or extended in a particular program.

    Virtual method calls are less efficient than direct calls because of the following factors:

    1. The vtable base has to be loaded from the object. There is no getting around this unless you've already got it in a register. If you are in a method of the same class, or you already called a virtual method of the object, you probably have it already in a register, otherwise you need to load it. A decision tree implementation also has this overhead.
    2. Until this value is loaded in some form, there is no way to look ahead in the instruction stream-> the indirect calls are dependent on the vtable address. And yes there are multiple possibilities for the instruction stream, and they all depend on the vptr of the object being called. If there were not the case, a direct call could be used.
    3. If the vtable is implemented by an array of function pointers, you've got another load to do before you can start filling the pipeline again. If it's an array of jumps, you're incurring only an extra instruction overhead.
    4. The fact that the vtable, the functions themselves and the original code are usually at different address neighborhoods, you incur more stress on the CPU caches. This is statistical stress, which may not be a problem with any particular call, but overall more cache misses happen, on average, and in general.
    5. It is impossible for compilers to inline virtual methods without global analysis, which is generally precluded from the use of dated linking techniques. This inability precludes an easy solution to #4
    6. The previously mentioned need to make all methods that _might_ be overloaded virtual, especially for library code which is difficult for end users to modify.

    In short, C++ vtable-based virtual methods incur at least one more instruction to be executed, probably a pipeline stall, can't be inlined, and cause more cache stress.

  130. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    In Eiffel, every method CAN be polymorphic (I dunno if there is an option like "final") If the compiler can determine that a method has no overloaders, this case is is optimized (at least in reasonable implementations) as a direct call without you having to worry about it. This is the ideal, IMHO.

  131. Re:A serious (rather unpopular) hope... by eric17 · · Score: 1

    Redundancy is useless if it is mere copy/paste duplication with some minor editting. I can't imagine anyone dismissing Java because it lacks this division, on the contrary, it saves time, and given simple tools for extracting interfaces, does not have any drawbacks.

    virtualness:
    I don't disagree that thought must be given to the design of the base class, however, I don't believe a language should penalize you for allowing overloading on a method even if the method is not overloaded by any class in your link unit. Whether or not overloading is allowed by default is a matter in which I no particularly strong opinion, although I believe that C++'s default of non-virtual is mainly due to the inability to avoid the penalty in almost all implementations.

  132. No kidding... by Keeper · · Score: 2

    Nothing annoys me more than the "for (int i=0; iblah; i++)" scope bug (int i should be within the scope of the for loop, not the block of code containing the for loop).

    Equally annoying is attempting to do something with templates that cause the compiler to freak out and crash. Once that happens you have to Clean everything and rebuild from scratch, after removing what caused the compiler to freak out (it corrupts files when it crashes like that).

    Current VC support for templates is patchy at best. *sigh*

    1. Re:No kidding... by Keeper · · Score: 2

      No, I'm bitching that Visual Studio DOESN'T scope i to the loop. It's annoying as hell (because as you said, it should).

    2. Re:No kidding... by pallex · · Score: 1

      Nothing annoys me more than the `post as plain old text if you like, but i`ll strip out less than signs, add spaces to url`s` bug in the SlashCode....will this ever be fixed?

    3. Re:No kidding... by igrek · · Score: 1
      The /Zc:forscope option tells the Visual C++ compiler to follow the standard C++ definition for the scope of variables declared in a for loop.

      The reason why it's not the default setting is obvious. Think about the code written before the 98 C++ standard. The C++ definition used to say the scope of variable was the scope that surrounded the for loop. If you change this rule, some code will not compile, at best. AFAIR, windows header files require the "old" C++ convention, so VC supports it by default.

    4. Re:No kidding... by igrek · · Score: 1

      Oops... Sorry, I didn't mention that /Zc:forscope option works only in the new VC++ 7.0. See the article in the Visual C++ journal.

    5. Re:No kidding... by Ayende+Rahien · · Score: 1

      This should solve it:

      {
      for (int i=0;i100;i++){
      //do stuff
      }
      }
      That will work correctly on VC & GCC.
      Or, you can use /Za:forscope

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  133. Re:A serious (rather unpopular) hope... by Keeper · · Score: 2

    While having those types defined would be nice, don't fool yourself into thinking that having them would solve a lot of porting problems. Bit ordering is an annoying problem that tends to bite you in the ass when you don't want it too. Especially if your apps go between Intel & non-Intel CPUs.

  134. WARNING by Keeper · · Score: 2

    The /Za flag turns off a lot more than just the for loop scoping "feature." User beware.

  135. Re:Java flaws by pnatural · · Score: 1

    c) Its not a standard until Sun submits it to a real standards setting body. Until then its just as proprietary (in my mind) as Visual Basic, etc.

    actually, it should be proprietary in the minds of everyone... the little TM (trademark) gives it away!

  136. Re:Funny you should mention that. by barracg8 · · Score: 2
    As an even less useful piece of information, I believe C's precursor ("B") got its name from the place it was developed - Bell labs.

    G.

  137. More on the subject... by Ungrounded+Lightning · · Score: 2

    Actually, the behavior he is describing is what is actually implemented in most cases.

    During the base class constructor, the virtual function table pointer is initialized to point to the base class table, thus when the user written ctor code is called any virtual function ref will be to the base class ctor.

    When the next level of inheritance's ctor is called, the VTPTR will be initialized to the derived class VTBL, and so any virtual will go to the virtual class.

    During destruction, the process is reversed.

    All that is needed is to formalize this behavior.


    Close.

    First: Though the usual implementation is via a vtable pointer, the spec speaks in terms of what virtual function is entered, rather than in terms of when the vtable pointer is stored, so that compilers are not constrained to use a vtable implementation.

    Second: The current spec defines the behavior of calls during the constructors and destructors of the classes, but leaves open the behavior during the construction and destruction, and other initialization if any, of the member objects.

    In terms of "storing a vtable pointer" the current standards allow the compiler to store the derived-class vtable pointer either before or after the member object constructors are called and/or other member initialization is done (or even at some arbitrary point during such initialization). I claim it should be tightly specified to be stored AFTER all other initialization (including any other automaticly-generated code) and immediately BEFORE the execution of the first line of the body of the constructor.

    Similarly, it allows the base-class vtable pointer to be stored before the member DEstructors are called, after, or during. I claim it should be stored immediately AFTER the execution of the last line of the body of the destructor, BEFORE any member destruction or other automatically-generated code.

    In the general form, the reasoning is as follows:

    Member constructors (and other member initialization) are peers with base class constructors: They constitute the creation of pieces of the object, which are to be finished parts before the object is constructed from them. First they are constructed and initialzed. Once that is done the class' own constructor assembles them inito a composite object and initializes that composite object.

    Until the pieces of the object are completed the object is just a collection of pieces. It is only during the execution of the body of the constructor that the collection progresses from a pile of parts to a unified, operational, component.

    So calling the derived-class overriding of a virtual function before the derived-class constructor is executing is a mistake. It calls a function of an object that does not yet exist, rather than the corresponding function of the component piece, which DOES exist and IS initialized.

    During the execution of the constructor, the author of the derived class can take whatever care is necessary to use only the features of the object whose underpinnings are properly initialized. While the member objects are being constructed the author of the derived class has no such opportunity.

    On destruction the issues are similar. While the derived-class has had a chance to initialize, some of the underpinnings for the virtual functions may need to be torn down on finzliation. Calling a virtual function after its support structure is torn down is also an error.

    Writing a code generator to store the vtable pointer at the proper moment during construction is trivial. Writing one to store it at the proper moment on destruction is slightly harder: The base class and derived class might be separately compiled, so either the base class must export its vtable pointer for the derived class destructor to store or the derived class must generate its own equivalent vtable.

    My definiton means that virtual function calls in initialization expressions get the base-class overriding. But that's not a problem for two reasons: It's currently not specified, and the author can specify the overriding he wants by using the :: scope-resolution operator.

    Now, there is a problem related to this that I'd like to see addressed:

    Consider a base class which exists to allow an object to attach to a list and have a virtual method called in response to events sent to that list. It is up to the derived class to overload a virtual function to handle those events.


    This is exactly one of the reasons we wanted this definiton.

    Now, ideally I'd like the base class to connect to the list in the ctor, and disconnect in the dtor. However, it is not safe to connect to the list until the object is fully constructed, as an asynchronous event may cause the virtual method to be called before the object is constructed. Equally, I want the object off the list before the dtor is called for the same reason.

    What I'd like to have would be an additional two methods. The first would be called immediately after the ctor, the second immediately before the dtor. Thus, these calls have at their disposal the whole, fully constructed object, with all virtual methods intact and ready to go.

    In the case of global objects or static objects, the compiler would generate a second list of function calls, to be called after the init code has iterated through all the static constructors (and another to be called before iterating over all static destructors).


    With the definition I'm proposing you have a solution available, and it doesn't require two overridings of the function. Consider:

    First: Create a construction-progress member variable, and initialize it to the "no progress yet" state. This variable is thus initialized before the vtable pointer is changed, and it will persist after destruction.

    Second: The vtable pointer is changed - but any of your virtual functions that need construction that isn't complete can check the state variable, and do what is appropriate for the current level of construction. (This is probably making a call to the base-class version of the function and returning the restut.)

    Third: As construction progresses through stages that enable various virtual member function behavior, the constructor updates the state variable, "turning on" the fully-constructed behavior, or any intermediate-step behavior, as necessary.

    By the time the object is fully-constructed and the constructor exits, the full behavior of the member functions is manefest. The teardown sequence proceeds similarly, but in reverse.

    If you like you can implement the "state variable" as a set of "pointer-to-function" variables, to eliminate the explicit tests at the start of the member functions. The "real" virtual member function would be something like:

    foo(args) { return (*this->current_foo)(args) }

    It's not quite as execution-time efficient as your double vtable pointer store, but it gives you arbitrarily fine control without extra compiler mechanism.

    Having done a fair bit of multithreaded C++, I am of the opinion that, if they are going to standardize on a threading library, they are going to need this sort of hook.

    Check.

    Though originally intended to handle non-multithreaded cases (such as the non-polically-correct examples of garbage collector pointer-walks and error-exceptions during construction), this scheme is also adequate to support correct behavior in multithreaded code.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  138. Something I've wanted for a decade... by Ungrounded+Lightning · · Score: 5
    The C++ standards deliberately leave something open which I think should be defined in a particular way.

    Suppose:

    you are constructing an instance of a derived class

    one of its base classes has "published" a pointer to the partially-constructed instance

    the class has a virtual member funciton

    the member function is overridden by this class

    the class also has a member variable of a class type with construction

    the constructor of the member variable (or something it calls) finds the published pointer and calls the virtual member function.

    What happens?

    My claim is that such a call SHOULD be legal and SHOULD call the BASE CLASS version of the member function. Similarly, during the execution of the DEsctuctors of the member variables you should also get the BASE CLASS version of the member function. You should get the derived class version exactly from the beginning of the execution of the first line of the body of the constructor through the end of the execution of the last line of the body of the desctuctor.

    The reasoning is too involved to go into here. Suffice it to say that:

    It's a consistent generalization of the philosophy of the C++ constructon-destructon semantics (and of the way that the C++ semantics differs from those of Objective C and Smalltalk.)

    It's an compiler implementation that is allowed by all the levels of C++ standardization.

    There's a LOT of neat stuff you can do with this guarantee that you can't do without it.

    There are a lot more opportunities for programming error if your compiler doesn't work this way. (Not to mention the issue of code that works find with a compiler that does it one way but breaks when run through a compiler that does it a different way.)

    The original C++ work didn't specify the behavior in question. The first ANSI standard explicitly left it open. The revised ANSI standard not only explicitly left it open but said "don't do that". B-(

    At the time I first proposed it (about 10 years ago) we looked into a sample of the compilers on the market. There are four binary combinations of member constructor/destructor and base/derived version of member function, of which I claim one is "right" and the other three "wrong":

    Cfront and the Cfront-derived C++ compilers tested (Sun, SGI) got it "wrong" one way.

    The three IBM PC compilers tested got it "wrong" a second way.

    Gnu G++ got it "wrong" the third way.

    so standardizing on this semantics wouldn't favor any particular vendor's existing product.

    IMHO this somewhat obscure issue is one of the major impediments to C++ achieving its potential as an object-oriented language, and it is unfortunate that is wasn't "fixed" in one of the previous standards.

    Perhaps there's one more chance here.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
    1. Re:Something I've wanted for a decade... by wowbagger · · Score: 2

      Actually, the behavior he is describing is what is actually implemented in most cases.

      During the base class constructor, the virtual function table pointer is initialized to point to the base class table, thus when the user written ctor code is called any virtual function ref will be to the base class ctor.

      When the next level of inheritance's ctor is called, the VTPTR will be initialized to the derived class VTBL, and so any virtual will go to the virtual class.

      During destruction, the process is reversed.

      All that is needed is to formalize this behavior.

      Now, there is a problem related to this that I'd like to see addressed:

      Consider a base class which exists to allow an object to attach to a list and have a virtual method called in response to events sent to that list. It is up to the derived class to overload a virtual function to handle those events.

      Now, ideally I'd like the base class to connect to the list in the ctor, and disconnect in the dtor. However, it is not safe to connect to the list until the object is fully constructed, as an asynchronous event may cause the virtual method to be called before the object is constructed. Equally, I want the object off the list before the dtor is called for the same reason.

      What I'd like to have would be an additional two methods. The first would be called immediately after the ctor, the second immediately before the dtor. Thus, these calls have at their disposal the whole, fully constructed object, with all virtual methods intact and ready to go.

      In the case of global objects or static objects, the compiler would generate a second list of function calls, to be called after the init code has iterated through all the static constructors (and another to be called before iterating over all static destructors).

      In the case of auto objects or dynamic objects, the call would be made after the object was constructed.

      This solves not only the above problem, but also it helps to solve the problem of circular dependances in construction ( a needs b to construct, b needs c, c needs a). The best way to avoid this design error is to do as little in the ctor as possible, and push the heavy lifting off to a second function. This method gives you that second function.

      Having done a fair bit of multithreaded C++, I am of the opinion that, if they are going to standardize on a threading library, they are going to need this sort of hook.

    2. Re:Something I've wanted for a decade... by Steeltoe · · Score: 1

      Every behaviour you define constricts the language. It becomes a feature people will use and rely on, no matter how obscure. So you better get them right the first time. That's a hell of a difficult job to get everyone to agree on.

      3-12 years ago I would have sided with the C++ folks. In the "name of efficiency", the behaviour should be unexpected. To allow fast and optimized compilation.

      Now I program in Ruby. I don't see the need for raw speed anymore, but short and well-designed programs. I tried that doing C++ but it always got ugly and slightly buggy. SDL is nice and powerful, but ugly as well. I'm not going to say one language is better than the other though, just that I'm tired of C++, and I like Ruby alot now. They are two different tools for the job though.

      The funny thing is that Ruby lacks even more compilation constraints than C++. However, it doesn't crash very often (did dump core once on me). Unit tests does wonders for languages like Ruby. I've yet to get rid of every single mistake in C++, while concentrating on making improvements and generalizations.

      What they should have done with C++, is not have any undefined behaviour crap. People DO rely on these, because it "works" and not everyone reads all the standards. Just until they change compilers. I agree with you now.

      - Steeltoe

    3. Re:Something I've wanted for a decade... by ebbe11 · · Score: 1
      As far as I can see, this boils down to:
      • During construction you want a call to virtual function using a pointer of type base class to the object being constructed to go to the base class version of the function.
      • During normal runtime you will (of course) want the same call to go to the derived class version of the function.
      So for all calls to virtual functions using a pointer to the object, the program must check whether it is constructing of the object that is pointed to. Depending on the outcome of this test it will then either call a function found using the type of the pointer or use the object's vtable.

      Maybe you could do some neat stuff if this was legal. But will two different behaviours for the same call make C++ programs easier to understand?

      I think not.

      --

      My opinion? See above.
    4. Re:Something I've wanted for a decade... by LionKimbro · · Score: 3

      Suppose:

      • you are constructing an instance of a derived class that is part of the system dependent side of a bridge
      • the other side of the bridge is called by a mediator instance
      • the mediator class has virtual functions
      • the instantiation of the mediator class makes a system call to create a thread that runs on the other side of the bridge
      • the instantiation in the first instance is allocating but is not initialized
      • the bus component on one side of the bridge is calling a lambda function that is created on the other side
      • the lambda function was created by manipulating a string in memory and casting it to a function call
      • but the lambda depends on instantiation data
      • the mediator passed some data to the thread
      • there are no semaphors

      It's 4:00am.

      What do you do? What do you do !!

    5. Re:Something I've wanted for a decade... by hding · · Score: 1

      I think this may be true of many languages. I'm not familiar with the C/C++ standards, but the Common Lisp standard also leaves many things undefined. There are reasons for doing this (I think there was some discussion of this recently in comp.lang.lisp, if you'd like to check.) There may be more than one reasonable thing to do; instead of forcing one behavior, it is then left up to the implementation. It may be desired to give implementers some room for experimentation in order to discover what the best thing to do is for inclusion into a later standard. Sometimes it legitimately doesn't matter. Sometimes the committee simply couldn't reach an agreement on what to do.

      The best solution (at least in the case of Common Lisp) is to read the standard, not to use things which depend on undefined behavior without very careful consideration and understanding of the potential consequences, and to complain very loudly at one's vendor whenever the standard is not being followed properly.

    6. Re:Something I've wanted for a decade... by hding · · Score: 1

      Yes, you will write unportable code if you deviate from the standard, which is one of the consequences I suggest that one weigh before doing it.

      As far as your example goes, it's clearly one of the canonical examples of undefined behavior in C/C++, but what is a logical way to resolve it, and what consequences does that have for the language as a whole? Is a solution for this (which may involve considerable added complexity - I don't know, but presumably any solution will affect a general class of situations and not just this one particular one) worth enough compared to simply leaving it unspecified and requiring another line of code to force the programmer to more explicitly declare his intent? Again, I don't know - you'd have to ask someone who knows a lot more about language design and implementation (and C/C++'s in particular) than me. :-)

  139. What I like to see by ffatTony · · Score: 1

    It will be great when C++ has many of the rich data types java does. I'm certainly looking forward to it, but I'm sure I'll still write everything in C anyway.

  140. Official conformance suite by sconeu · · Score: 2

    They should annoint a conformance suite, so that things like VC6 won't be able to claim "standards conformance", when they don't even handle exception specifications properly.

    --
    General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    1. Re:Official conformance suite by sconeu · · Score: 2

      The KB specifically states that prototype exception specs, i.e.

      int f() throw x, y, z; // I may have the syntax messed up

      doesn't work and will generate a warning.

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    2. Re:Official conformance suite by dondiego · · Score: 1

      Last time I looked, MS makes no claim of standards conformance... I'd love to see a link to some sort of document where they do claim compliance...

    3. Re:Official conformance suite by The_Messenger · · Score: 2
      The latest issue of CUJ has an very interesting comparison of the standards-conformance of popular C++ compilers and libraries. Microsoft actually scored pretty high, which isn't bad considering that their compiler's base is three years old. VC++.net should solve most of these problems, while introducing twice as many more, no doubt. :-)

      --

      --

      --
      I like to watch.

  141. Re:Bolt-ons are not the same as "new and improved" by karb · · Score: 1
    Java isn't really trying to be 'better' than C++. It doesn't really support generic programming, for one. I'm sure there are others, but I'm not much of a language lawyer.

    It isn't usually a good idea to compare languages so narrowly (better/worse) outside of a specific domain. It gets unneedlessly emotional when both are the obvious best choice for different domains.

    Also, lousy syntax isn't usually a problem. Consider that COBOL and Perl have two of the Worst Syntaxes In The World.

    While your 'new' illustration has value, cars are far too easy to produce. We seem to get maybe four or five useful new programming languages a decade. There's a reason. It takes a lot of work and hassle for a language to mature. You can learn from the mistakes of the past, but there are still plenty of new mistakes to be made.

    --

    Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone

  142. Re:Bolt-ons are not the same as "new and improved" by karb · · Score: 2
    unneedlessly emotional

    I don't know what that means.

    --

    Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone

  143. Errata by UnknownSoldier · · Score: 1

    Forgot some ops too

    o) ~ would be the new XOR op.
    e.g.
    a = b ~ c; // a = b XOR c
    a ~= b; // a = a XOR b

    o) ! would be used for binary not as well as logical not.
    e.g.
    a = !a; // a = NOT a

    Errata:
    The fixed point should read:
    fix &lt 8,8 &gt fix &lt 8,24 &gt

    And the static cast should read
    static_cast &lt int * &gt (pC)

    P.S.
    Hey /. how come I can't edit my comments? :)

  144. C^2 - the next gen of C++ by UnknownSoldier · · Score: 3

    I've been thinking about how to make C++ better in my spare time for the last year or so.

    (Unfortunately my notes are at home, so this isn't the full feature set)

    Here are some comments I'd love feedback on.

    o) New operators:

    ^ would be the standard math power operator. The compiler would optimize ^2 the much it does now with *2.

    @ would be the pointer derefence op. (Allows you to search for where pointers are being used)

    ?= (replacement for ==, since it is WAY to easy to get = and == mixed up)

    $ is also another operator for users.

    o) STANDARDIZED and PORTABLE types
    NO MORE "long long" crap.

    int8, int 16, int32, int64, int128 (signed int's)
    real32, real64, real80 (floating point)
    fix (fixed-point)
    char8 (8-bit ascii)
    char16 (unicode-16)
    char32 (unicode-32)

    int would be the "native" integer type for the cpu.
    float would be the "native" floating type for the cpu.

    o) New keyboards

    "func" would preface all functions/methods. (helps the compiler out, and lets editors be able to expand/collapse functions easier)

    "macro" would force the function to be inlined.

    "include" is part of the language. No longer needs that ugly pre-processor hack.

    o) Cleaner Syntax - CONSISTENT reading of right to left.

    Pointers would bind LEFT (instead of right in C/C++)

    i.e. Pointer to a function

    The old C++ way: new (int (*[10])()) // array 10 pointers to function returning int

    Easier C^2 way: new func int() * [10] // array of pointers to func.

    e.g.
    func int () * pFunc; // pointer to func, no more stupid parenthesis matching

    o) C style implicit () casts gone. Only C++ style casts. (Allows for searching of casts)

    e.g.
    C++ way:
    char *pC;
    int *pI = (int*)(pC);
    *pI = 3;

    C^2 way:
    int *pI = static_cast(pC);
    @pI = 3;

    o) standard way to turn OFF implicit up-casting

    o) Binary constants. (We have decimal, octal, and hex. Where's the binary notation??)

    Preface numbers with "Zero Z"
    e.g.
    const int mask = 0z0110100010; // 0x1A2

    o) "typedef" and "alias" would be extended.
    typedef would make a NEW type. (Compiler wouldn't throw away the newnames)
    alias would behave like the old typedefs currently

    Maybe it's time to download gcc 3 ;-)

    *shrugs*

  145. Re:How about by captredballs · · Score: 1

    Seperate namespaces can be very usefull when you are using more than one third party tool and THEIR code, not yours, have common object/method names.

    Don't get me wrong, I hate C++ and its sillier "features", but namespaces are one of the few goodun's.

    --

    I suppose I'm not too threatening, presently, but wait till I start Nautilus
  146. Re:About time by captredballs · · Score: 1


    One reason that Java doesn't have genericity (templates) is because the VM spec cannot change to include it without breaking backwards compatibility. Or something like that. Look for OOPSLA conference papers from '99 and you'll find something. From what I remember there is an interesting read, if a little mathematical.

    One thing I MUCH prefer over Java is that there is a single memory management scheme for object references. None of this on-the-stack vs passed-by-refernce vs newed-and-passed-by-pointer vs passed-by-reference-from-a-newed-array business going on. You only have "its a reference and it may be nill".

    I have to work with code that uses 4 or 5 third party libraries. Dealing with the different object allocation schemes at the same time is a real pain in the ass, especially because it's also CORBA based and we have to deal with inter-process allocation and deallocation also.

    blather blather blather

    --

    I suppose I'm not too threatening, presently, but wait till I start Nautilus
  147. Re:C++0x standard??? by dimator · · Score: 2

    Damn, you beat me to it.

    --

    --
    python -c "x='python -c %sx=%s; print x%%(chr(34),repr(x),chr(34))%s'; print x%(chr(34),repr(x),chr(34))"
  148. Re:C++ Frustrations by Baki · · Score: 1

    Two years ago I used SunPRO with STL, and I didn't found any deviation from the standard. Everything worked as expected (unlike g++, which was useless for C++ back then).

  149. Re:Java flaws by Heutchy · · Score: 1

    Java flaws?

    Co-variant arrays.

  150. The key is the Standard Lib by selectspec · · Score: 2

    I would hope that any changes to the standard will focus on the C++ Standard Lib and not so much on language semmantics/features. The C++ library is in need of some serious features. While I recognize why they had to stop and finish, the work is losing ground to more complete libraries in other languages. The STL needs to be completed, and dare I say, some of the implementation should even be standardized. Certainly, the interfaces should be standardized. My God, lets make hash tables official, and pick an implementation. Also, the iostream libs need to be expanded to include asynchronous I/O, more usable streambuffers etc. Also, the standard needs to officially ditch strstream and replace it with string_stream. As for threading, well Posix has pretty good threads, although events could be wrapped up a bit neater (like dare I say in win32). As for handles and such, it would be in the C spirit, as the standard C lib has things like FILE and such.

    --

    Someone you trust is one of us.

  151. Re:C++ Frustrations by selectspec · · Score: 3

    Yes, mdev 7.0 is probably one of the most compliant C++ compilers out there. It is one of the few linkers than handles template-objectfile redundancy propperly without tedious pragma's and bizzare typedefs in cpp files. Also, the msdev implementation of STL and IOStreams is to the letter of the standard with full template iostreams (unlike g++ non-template IOStreams). However, msdev's implementation includes nothing that is not in the standard (like hashtables), except auto_ptr. All in all, Microsoft has embraced C++ big time (MFC and especially ATL). Frankly their devotion to that sad ancient religion, hasn't helped them conjour up the stolen data plans nor given them clairvoyance enough to learn the location of the rebels hidden fort...kha..cc.cka..aaak.

    --

    Someone you trust is one of us.

  152. Re:Judge language by thickness of its first book. by daniell · · Score: 2
    I've got 3 things to say.
    1. Objective C is what C++ should have been.
    2. Java is entirely unusable; due mostly to a very poorly laid out framework of utility classes. The language on its own would be okayish. Show me a scanf [int main{int i; scanf("%d",&i); exit(i);}] in java. Not as elegent is it?
    3. Java isn't just a language; its a framework of utility classes plus a bytecode virtual machine runtime environment, originally intended to produce good bytecode for embeded applications and now used mostly to make cross platform GUI apps.
  153. Java flaws by SideshowBob · · Score: 1

    a) Its tied to a VM.

    b) Its frameworks for GUI development try to be a least common denominator at the expense of running well on any given platform.

    c) Its not a standard until Sun submits it to a real standards setting body. Until then its just as proprietary (in my mind) as Visual Basic, etc.

    Just my 2 cents

    1. Re:Java flaws by pdoubleya · · Score: 1

      I work with Java on a daily basis. Some comments: 1) it's extremely portable with no recompilation. At one point I was coding in Microsoft J++ (without using MS extensions) and was able to copy my class files to a Sun server, where they ran with no problem. This was on a multi-tier app with a complex browser applet (using Netscape applet classes), over a CORBA layer, to a relational database. pretty amazing 2) Personally, I think Sun has done an excellent job of keeping Java standard across implementations, and at regulating APIs. Across the board, it takes me a few hours to learn a new API from Sun (and from most anyone else) because the style is so uniform. I think that's a plus. 3) I use Java in programming for businesses, which biases me greatly, I assume. For that purpose, it's excellent all-around. I can worry more about solving the problems and needs of the business, and not worry about (too many) platform-specific details. just my thoughts.

      --
      "I honestly would vote libertarian if their candidates weren't usually total cooks."--slashdot poster
  154. Holy smokes my head hurts! by fprintf · · Score: 1

    Wow, so this is what interests you people. No wonder us MBAs can't relate at all! I tried writing a simple C++ program and thought I did alright, but all the stuff you guys are talking about just goes way over my head. Good thing I dropped out of CompSci and became a business type guy - I couldn't hang for sure.

    --
    This post brought to you by your friendly neighborhood MBA.
  155. Don't use it, don't pay for it by astrophysics · · Score: 2

    I'm glad to see he still beleives that users who don't use a feature shouldn't suffer a performance hit for it being part of the language.

    As long as that's adhered to, I imagine I'll keep using C* for the forseeable future. If they add things that cause a performance hit for everybody, I and the scientific community will probably stick with an older version, even once it's obcure. Just look at how much Fortran 77 is still being used!

    Personally, I really like the fact that I can write one section of code in a very generic OO manner, but then have the inner loop essentially in C. I try to get the advantages of C++ while avoiding the performance pitfalls in the most time critical parts of my scientific codes.

  156. already did. by holzp · · Score: 1

    its called java.
    nothing shall exist 'twixt c and java.
    'cept python. mayhaps.

  157. one suggestion by holzp · · Score: 2

    call it (c + 2), get rid of all those horrible side effects!

  158. Re:A serious (rather unpopular) hope... by gid-foo · · Score: 1

    As for virtual methods, this is an implementation detail that really does not need to exposed in the language if it could optionally use better linker/object technology. The language implementation can decide which methods need to be virtual itself through global analysis at or before linkage.
    This ignores the idea that you want to be able to explicitly tell the compiler which functions should be allowed to be "virtualized." How would that work out if the compiler auto figured out which functions should be virtual? Would you replace virtual with a "no_virtual" specifier? Changing explicit virtual declaration to an explicitly not virtual declaration?
    I'd be interested to see the pro's and cons of decision tree versus v-table. Any good links?

  159. Re:Judge language by thickness of its first book. by naasking · · Score: 1

    int* pi = malloc(sizeof(int));
    That's an illegal C++ statement!


    It's technically not legal in C either, but compilers accept it since they assume they know what the programmer meant.

    int* pi = (int*)malloc(sizeof(int));

    Now, that C++-version is legal C, but it is *poorly written* C code. Any C programmer worth his salt would frown on a program littered with such statements.


    What are you talking about? That's perfect code. You should always cast your return values to the approriate type. It enforces type checking. Doing otherwise can be dangerous. Anyone not doing it should be immediately shot. Perhaps you should check out the Ten Commandments for C Programmers. Specifically, commandment 3 and 4. Malloc is a library function which returns a (void *). That is an illegal pointer to dereference, modify or use in any meaningful way. You have to cast it to use it.

    Most modern compilers often just do it for you, but assuming a compiler will do it for you reduces portability. Also, subtle bugs can appear since the compiler has to interpret what you meant. This case is pretty clear what the intention is, but more complicates situations are sure to come up where the compiler will guess wrong and you'll be sitting there scratching your head wondering why your program is segfaulting.

    -----
    "Goose... Geese... Moose... MOOSE!?!?!"

  160. Re:Judge language by thickness of its first book. by naasking · · Score: 1

    In ANSI C you are always allowed to assign void* to another pointer type. In fact, that is what void* is for. Adding a cast buys nothing.

    Adding a cast provides consistency, clarity, good style and correctness. The compiler may not care, but it will sometimes misinterpret what you mean, and your programming colleagues will thank you for being clear in your code.

    Moreover, adding a cast can disguise the fact that you've forgotten to #include stdlib.h. If you forget to include this header (which has the prototype for malloc), then the compiler will assume that malloc returns an int.

    How often does that happen? You're telling me that I should always program in bad style for the odd time I might forget to include stdlib.h? I've forgotten to do it before, and that kind of mistake is always immediately obvious. And if you do it often enough for it to be a major problem, I suggest actually paying attention to what you're doing. I'm not flaming here, but honestly, that's like forgetting how to add 5 and 6. There might be the odd time you get it wrong, but it only takes a moment to realize your mistake. If you're consistently adding 5 and 6 wrong, then you might want to go back to grade 2.

    Normally, this would fail to compile when you try to assign it to a pointer. But if you have included the cast, your program will compile and silently mix integers and pointers. This will work on a machine where pointers really do have the same physical representation as ints, but will fail elsewhere. Thus, not only is the cast not needed, it actually makes your program more prone to portability bugs.

    I think that saying 'programming according to the language standard reduces portability' is a ridiculous statement. But I just noticed a possible source of misunderstanding between us. It's in the line:

    int* pi = (int*)malloc(sizeof(int));

    Which I said was correct. It is NOT correct even with the cast. It's valid, but not correct. That statement is requesting an int and assigning it to a pointer. That should read:

    int* pi = (int*)malloc(sizeof(int *));
    or
    int pi = (int)malloc(sizeof(int));

    Which ever he meant. Those are correct statements. The first was an oversight on my part. Perhaps that's what you meant about decreasing portability due to differing implementations of (void *) and int? (in which case I would agree with you because it's bad programming)

    The fact that the previous, incorrect statement would be legal in C++ worries me even more. Perhaps the original poster mistyped?

    -----
    "Goose... Geese... Moose... MOOSE!?!?!"

  161. Re:Judge language by thickness of its first book. by naasking · · Score: 1

    Huh? As I read it, the original line is quite correct: malloc a chunk the size of an int, treat the return pointer as a pointer to int, and store that pointer as 'pi.'

    *sigh* I'm studying for exams, and my brain hurts. Forgive my mistake. You and I(in my original post) are correct...

    -----
    "Goose... Geese... Moose... MOOSE!?!?!"

  162. Re:Judge language by thickness of its first book. by naasking · · Score: 1
    It could be argued that the former is easier to read, since it is cleaner.

    Cleaner does not always mean clearer. I don't find your way clearer at all. Let's propose a hypothetical(yet common) situation. C requires you to declare all variable at the beginning of any block. You declare an 'int *p;' at the start of your function. About twenty or so lines down, you're tracing through some deeply nested some 'if' statement or some loop. In an average program, you'd normally have quite a few things to keep an eye on. You may have some structures with their own members being read, swapped, deleted, looping variables, etc., then all of a sudden you come across the following line:

    p = malloc(sizeof(int));

    Since C is so versatile(sometimes painfully so), I can only hope but wonder at what the person who wrote the code intended. What is p? I'd have to go back up to the declaration to make sure it's an (int *) and make sure it is what I think it is, and not some other funky magic the programmer was attempting.

    Proper casting encourages good style and (more) correct programming because it forces you to think about what you're doing instead of blindly throwing pointers around(which, if you've ever done any C programming, you know is an easy trap to fall into). Seeing code that casts everything properly shows me that the person put a little more thought into their code. I'd more readily trust that kind of code.

    I'm not suggesting it happens often. I was just pointing out a potential drawback to casting the return value of malloc, in addition to the fact that it accomplishes nothing.

    I know you were trying to say it was a drawback. In my opinion, you're example was pointless. It's like saying you need the proper sequence of steps to start a car, and if you don't follow them the car won't start. That's just the way the world works, and you won't find anything that doesn't have it's tradeoffs and drawbacks. Your example was just a nitpick.

    The standard says that the casts are unneccessary.

    If the standard said that casts were unnecessary, there would be no built-in type checking in compilers. Also, it would be impossible to convert between types such as int(32-bit in GCC) and chars(8 bit). Alot of common code would be completely invalidated without casting. In short, no, casting is quite necessary.

    If you have included stdlib.h, this code is correct, with or without the cast.

    No, it's not correct(in that it won't do what you expect it do), but it is valid code.

    Btw, I just looked in my copy of K&R2 and noticed that they cast the return value of malloc. Their influence over what is considered good C style is (rightfully, IMO) powerful. Then again, K&R also allow their hello world program to fall out of main() without returning a value...

    Since you have the K&R2 book, perhaps you should check out page 142, near the bottom(just before that code snippet), quoted here for convenience:
    The question of the type declaration for a function like malloc is a vexing one for any language that takes type-checking seriously. In C, the proper method is to declare that malloc returns a pointer to void, then explicitly coerce the pointer into the desired type with a cast.
    The only reason that you can use the allocated memory without casting is because compilers cast it for you. Unfortunately, this leads people to believe that you don't have to cast things since they believe the compiler will handle it for them. But like I've said before, the compiler will not always be right in guessing what you meant and then you'll just be left scratching your head wondering what's wrong.

    As for the hello world program, it seems they only do it for the first chapter. I'm sure they were just trying to concentrate on getting some key points across and not have to explain every niddling little detail to a beginner.

    -----
    "Goose... Geese... Moose... MOOSE!?!?!"
  163. Re:A serious (rather unpopular) hope... by Steeltoe · · Score: 1

    What guarantees do you have that this be a 16-bit unsigned integer. Unsigned yes, but 16-bits? Guarantees? I've never seen any.

    Besides, try 32-bits or 64-bits.. They're more useful anyways.

    - Steeltoe

  164. Java vs C++ by cafelatte · · Score: 1

    A couple of months ago, I decided to learn Java instead of C++. These are the reasons why I wanted to use Java instead of C++:

    1) It was platform independent. I wanted to be able to create programs that didn't discriminate on the platform being used. Mac users and windows users should also be able to use any GNU GPL program that I write. Sometimes people can't choose their platforms. (Like me at work!)

    2) It's more advanced in features than C++. It does the memory allocation and dellocation by itself. With a JIT (Just In Time) compiler, the code is as efficient as C++ programs so I've heard.

    The only reason not to use Java is that it's proprietry. That bothers me but not that much because Sun is IMO a trustworthy owner and I believe they will keep the Java technology innovative. I would like Java to become a standard.

    1. Re:Java vs C++ by cafelatte · · Score: 1

      Java is NOT more advanced in features then C++. I don't know where you heard this, or what kind of weed you were smoking when you came to this conclusion.

      While I'm reading a book on Java ("Java 2": The Complete Reference, by Osbourne publishers) the author frequently makes comments on how Java differes from C++ in case a C++ programmer is reading. Every difference is an improvement. Could you please list the advantages C++ has over Java?

    2. Re:Java vs C++ by cafelatte · · Score: 1

      Thanks for your comment. I found your argument compelling. Damn, looks like I chose the wrong language to learn! I'll still stick with Java for now though. I want to program a few simple games and want to be able to give it to all the windows-only people I know and not hastle over writing portable C++ code and recompiling for each platform. I should learn C++ too since almost all GNU GPL code out there is in C/C++ and GCC is an awsome compiler. What the hell, I'll buy a book on C++!

    3. Re:Java vs C++ by earache · · Score: 1
      Java is NOT more advanced in features then C++. I don't know where you heard this, or what kind of weed you were smoking when you came to this conclusion.

      The code is also not as efficient, although in some cases it might come close, but I doubt overall that is a very valid claim.

      C++ is plenty platform independent if you use the right libraries and write your code in a generic enough manner. I can compile an app for win32, linux w/gnome or kde, beos and QNX with our in-house libs with little to no adjustments. There are plenty of third party toolkits that will let you do the same and I can gaurantee you the responsiveness of your user interface, the majority of your backend processing is going to smoke anything you come up with in Java.

    4. Re:Java vs C++ by vsync64 · · Score: 1
      Lack of multiple inheritance is not a big deal in practice

      YahahahahahahahaHAAHAHAHAHAHA!!!!

      Good one.

      --

      --
      TO BUY A NEW CAR WOULD MAKE YOU SEXUALLY ATTRACTIVE.
    5. Re:Java vs C++ by vsync64 · · Score: 2
      While I'm reading a book on Java ("Java 2": The Complete Reference, by Osbourne publishers) the author frequently makes comments on how Java differes from C++ in case a C++ programmer is reading. Every difference is an improvement.

      No, they claim every difference is an improvement. That's a good book -- I own it -- but their advocacy often crosses the line of sanity.

      Like when they defend the whole single inheritance fiasco. They use the example of a House and how you'd want to make it inherit Foundation, Walls, and Roof. Makes sense, right? But then they say to make Walls extend Foundation, and Roof extend Walls, and House extend Roof. Um, a roof isn't a wall. It shouldn't have wall-specific methods.

      Java does have some things going for it. It's a neat little platform for applets and set-top boxes. But it is vastly overused in settings for which it is painfully unsuited (like Web servers). And certain pathetic hacks to get around the confinements of Java (such as using "interfaces" to pretend for a second that Java can almost simulate multiple inheritance, but wretchedly) just cause more spaghetti code, pain, and suffering.

      Try a real object system sometime. You'll like it.

      --

      --
      TO BUY A NEW CAR WOULD MAKE YOU SEXUALLY ATTRACTIVE.
    6. Re:Java vs C++ by jo42 · · Score: 2
      > Could you please list the advantages C++ has over Java?

      You can write operating systems and real applications in C/C++.

    7. Re:Java vs C++ by Glock27 · · Score: 1
      Java does have some things going for it. It's a neat little platform for applets and set-top boxes. But it is vastly overused in settings for which it is painfully unsuited (like Web servers). And certain pathetic hacks to get around the confinements of Java (such as using "interfaces" to pretend for a second that Java can almost simulate multiple inheritance, but wretchedly) just cause more spaghetti code, pain, and suffering.

      Java is pretty well suited to large scale programming. Lack of multiple inheritance is not a big deal in practice...heck Smalltalk (touted as the end-all OO language by its aficionados) doesn't even have interfaces, only straight single inheritance.

      Current Java implementations are very competitive with (and often better) than C++ performance. See the "Binaries vs. Bytecodes" article at Ace's Hardware for one example. Yes, Java uses a lot of memory...but memory is CHEAP! Why do we really need 64 bit desktop chips? ;-)

      Also don't forget that gcc 3.0 will have a traditional (ahead of time) Java compiler for those memory-tight embedded applications.

      In the meantime, my company is distributing several scientific Java apps, and supporting them on Windows, Linux and soon MacOS X. Sweeeeet!

      186,282 mi/h...not just a good idea, its the law!

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
  165. Re:A serious (rather unpopular) hope... by pfingst · · Score: 1
    12345 - That's amazing, I have the same combination on my luggage!

    Mark

  166. Re:Language evolution by catseye_95051 · · Score: 2

    vi
    :s,JAVA,C++,g
    :s,JVM,Vtable,g

    Note that it now reads like something I read 8 years ago.

    LMFAO

    Every age has its luddites.

  167. Re:Language evolution by catseye_95051 · · Score: 2

    roflol

  168. Re:C++ Frustrations by clem.dickey · · Score: 1

    From comments made at the meeting, it appears that Visual C++ 7.0 will be significantly better. Stroustrup said that he didn't even try programming on one popular implementation (I don't think he said Visual C++, but it was implied) until the latest drop, in which he said things now work correctly. If nothing else, the for loop scope is correct. :-)

    I switched from GNU C++ to Visual C++ in 1996 (change of jobs) and found that VC++ 5.0 was lot closer to the standard in the areas I cared about (library, since they used Dinkumware) than was g++. For the base language, especially templates and catching incorrect constructs, I found Microsoft and gnu both pretty dreadful.

    The April 2001 C/C++ Users Journal has some results from conformance testing. There are conformant compilers, and then there are popular compilers.

  169. Re:C++ Frustrations by clem.dickey · · Score: 1

    Thats odd, as I remember it the C++ standard wasn't finalised until around 1998

    Right. I should have said "Draft Standard." But I don't think the template stuff matched any specification. My most memorable g++ bug was that member initialization occurred in the order members appeared in the initializer list, not the order of declaration.

    As for Microsoft, their compiler - when it worked at all - tended to produce correct code. YMMV.

  170. Re:C++ Frustrations by PerlGeek · · Score: 1

    All your compilers are belong to us!

  171. Re:What I really want to see... by eu4ik · · Score: 1

    Why not use operator overloading? Overloading operator -> for a Handle class (probably a template class) fixes that problem quite cleanly. It also makes porting to other platforms easier (and let's face it, Mac handles were a hack dating back to the 128K days). I always wanted to do that when I was programming on the Mac, but at the time there wasn't a good C++ compiler available.

  172. Re:C++ Frustrations by codemonkey_uk · · Score: 2

    And what about partial specialisation of templates?

    Thats not in, is it?

    Oh, and FWIW, auto_ptr *is* part of the standard.


    Thad

    --

    Thad

  173. Article On Bjarne's Ideas For Future C++ by Carnage4Life · · Score: 2

    Bjarne Stroustrup recently had an interview with LinuxWorld where he outlined his plans for the future of C++. Here's an in article that analyzes and contemplates the ramifications of these changes.

    Don't expect these changes anytime soon though. From recent ACCU meetings it seems that most of the C++ standard from 1997 still hasn't been implemented now let alone new libraries that are yet to be designed. The soonest I see any of Bjarne's ideas being usable by developers and standardized is 2005 if the rate of compiler and library development continues at the current rate.

    --

    1. Re:Article On Bjarne's Ideas For Future C++ by bstroustrup · · Score: 2
      Please note that the main trust of my presentation was

      (1) no major changes to the language

      (2) major extensions to the standard library

      Clearly we can/will get some major discussions/fights over the definition of "major" in (1). My examples of possible minor extensions

      (compatible changes) included: - allow list<vector<int>> (without a space between the >>s

      - allow template typedefs

      - explitly acknowledge that GC is a valid optional implemenation technique

      - make lookup for functions and function objects identical

      Most such changes will be compatible and technical. I'm posting the slides from my talk on my FAQ.

      Please note that the purpose of talking about the future now is to have sufficient time for a serious and constructive debate before the standard comes up for revision - not to create a rush of changes for tomorrow. Also note that these are my ideas, not (yet:-) committee policy.

      --
      - Bjarne Bjarne Stroustrup, http://www.research.att.com/~bs
  174. Re:More standard librarys would be nice... by Trepalium · · Score: 1
    I think that would be a bad idea. Every OS has different semantics on how it implements the user interface, and elements of the user interface. I doubt you want the programming language to dictate the user interface, just as you wouldn't want the language to dictate the operating system. In fact, I think that C++'s standard library is too big already. Looking at "The C++ Programming Language" by Bjarne Stroustrup, it weighs in at close to 1,000 pages, whereas something like The "C Programming Language" by Brian W. Kernighan and Dennis M. Ritchie is a mere 250 pages.

    File system structure technology matured years ago, so it's quite easy to integrate such things into a standard library, but user interfaces are completely different -- many of them, including the Microsoft Windows user interface, are still rapidly evolving today. Any attempt to try to standardize them would more than likely backfire, since every UI would have different constraints and features. Who's to say which ones are correct and which ones are not?

    --
    I used up all my sick days, so I'm calling in dead.
  175. Re:Funny you should mention that. by The_Messenger · · Score: 1
    It will be "D". Otherwise our resumes will seem to have stuttering problems. "Experienced P-programmers..."

    --

    --

    --
    I like to watch.

  176. Re:A serious (rather unpopular) hope... by The_Messenger · · Score: 2
    Thanks for posting those links. I've about to evaluate some C++ auto-documentation software, and I'm definitely going to check those out.

    I've often thought, however, that it would be really great to have a direct C++ port of Javadoc. I use Java as much as I use C++, and I've really come to like Javadoc.

    • Javadoc-umentation tends to be more accurate, because since the documentation is in the source code, programmers have less of an excuse to make undocumented source changes.
    • Javadoc shows you sub- and superclasses automatically, which makes both development and maintainence of others' code much faster.
    • Finally, it creates shiny PHB-friendly webpages for your department intranet with no extra work. :-)
    I've heard that Javadoc can actually be coaxed to work with C++ code, but I've yet to play with this.

    --

    --

    --
    I like to watch.

  177. Re:About time by The_Messenger · · Score: 2
    Java can specifiy standards for GUI, et cetera, because it only runs on one platform, the Sun-certified JVM of your choice. Doing the same for C++ would require a standard operating system and architecture. Hey, let's start an OS flame war... :-)

    C++ could possibly include standard libraries for threading, but that would require too much cooperation between competing OS vendors, would require a shite-load of work, and in the end the hackers would end up using faster OS-native schemes anyway. They could also possibly add some standard ODBC stuff, but since ADO is now preferable on Microsoft platforms, it might not be worth the effort.

    Lack of a standard C++ distributed object model sucks. Really bad. But to add something WRT that to the standard, they'd have to design their own, to avoid showing bias towards a vendor. So we'll continue to use CORBA on UNIX and DCOM on NT.

    I feel that the committee needs to reevaluate its scope before going forward. If they add too much to the standard library, C++ will end up being just like Java, in that everyone always does things the same way, and that the control of entire industries will be in the hands of a single group of people. Some would see that as a good thing, but not me.

    Windows is the "standard" operating system for most people, but on Slashdot, the use of alternative systems is encouraged. I feel this is a good thing because it adds variety and a Darwinian heterogeneity to life. It doesn't make developer's lives any easier -- do you think game developers are happy about the prospect that in the future they'll have to write for Linux in addition to Windows? The only solution is a standard cross-platform solution (why, I think Sun has one!), which puts us at the mercy of either a Evil Bad Corporation or a stagnant standards body.

    Which is best? Freedom, choice, and the endless complexity associated with it? Or bondage, lack of choice, and the ability to relax and not worry? C++ has always seemed to be about the former -- it's not simple, but it lets you do whatever the hell you want. The latter is the domain of proprietary corporate languages such as Delphi, VB, and Java. There's not necessarily anything wrong with either camp, but I think that it's too late in the game for C++ to change direction.

    --

    --

    --
    I like to watch.

  178. Re:About time by The_Messenger · · Score: 2
    Those are environmental features which are enabled by the standard library. You're excactly the kind of raving, ignorant fucknut newbie that I wouldn't hire, and I doubt the original poster would either. He knows what he's talking about, and you don't. Verrrrry simple, young one.

    --

    --

    --
    I like to watch.

  179. Re:About time by The_Messenger · · Score: 2
    Lack of non-blocking IO is one of the biggest complaints about Java's standard library, and it's one of the top requested features on the JDC. Have hope -- assertions are another top-requested feature, and they're already in the Merlin (JDK 1.4) early builds. I'm not sure about non-blocking IO, but Sun seems to generally listen to its developers, even if it is hesitant to add new features between JDK releases.

    Merlin will be very cool... a logging API, the new JDBC libraries, all sorts of cool stuff.

    Sun markets this as a good language for server tasks?
    Yeah, on $500k+ Sun boxes. If you're app doesn't scale then buy a bigger box. :-)

    --

    --

    --
    I like to watch.

  180. Re:Hint MOD THIS UP by earache · · Score: 1

    :)

  181. MS C++ by garoush · · Score: 1

    Wait a minute. A large number of /. readers are complaining about MS C++? Why should we care if it is good or bad or if it is out of date or not? We are Linux users are we not or am I hearing that the majority of us are using MS C++ which means you must be developing for M$. Please tell me this is not the case. Ok. :-)
    ---------------
    Sig
    abbr.

    --

    Karma stuck at 50? Add 2-5 inches.. err.. 2-5x Karmas Count to your pen1es.. err.. Karma all naturally and private
  182. Here's another word by jorbettis · · Score: 1

    Troll.

    --

    Jordan Bettis

    ``Wherever you go, there's another stupid sigfile quote.''
  183. Actually, It came from BCPL by jorbettis · · Score: 1

    BCPL is the language frome which B was begot.

    Larry Wall talked about it in a speech once (might have been Postmodern) where he joked that the replacement to C should be called P, Going through the letters of BCPL.

    So, in 2090, then, we should be programming in L.

    --

    Jordan Bettis

    ``Wherever you go, there's another stupid sigfile quote.''
  184. Something I've wanted to say for a decade... by rmstar · · Score: 1
    What do you do? What do you do !!

    You open a new window in your editor & write a C program. Then you remember how nice life was before fascist pedantic arseholes decided to take over the world.

    C++ is disgusting.

    rmstar

    1. Re:Something I've wanted to say for a decade... by LionKimbro · · Score: 1

      Agreed.

  185. Re:One Word by EzInKy · · Score: 1

    Wow....C# is the one word answer??? You are implying that the language is going to be OPEN for everyone to use, and the source available on every platform then so that security flaws could be inspected by everybody? If that is true, it really would be the answer, wouldn't it?

    --
    Time is what keeps everything from happening all at once.
  186. Conservation of Tree Consumption by jejones · · Score: 1
    Years ago, Computer Shopper magazine was a hulking 900+ page monthly slab of dead tree, and C++ books were only a few hundred pages. Now Computer Shopper barely tops 200 pages, and introductory C++ books run around 1200 to 1500 pages. Coincidence? I think not.

    Seriously, couldn't some work be devoted to finding that small language that is supposedly screaming to get out of C++?

  187. Microsoft "managed code" by Animats · · Score: 2
    Sigh. That only works with the .NET execution engine, which is roughly comparable to a Java JVM. Worse,
    "When the compiler sees a destructor it generates a Finalizer() method, so that when the last object reference is released it is added to the finalizer queue. The Finalizer() method will call the destructor. Finalizers are discouraged for performance issues and because you cannot guarantee when the clean up code will be called."

    That's equivalent to Java finalizers, not C++ destructors. Different and less predictable semantics.

  188. 32bit bytes Re:take another hit by StandardDeviant · · Score: 2

    Yeah, becuase it splits evenly into two 16-bit values. This was good for LISP (which was along with Fortran pretty much the only game in town as far as high level languages go at the time (we're talking PDP's here) from what I've heard), as the "low moby" (is that the right term? the "low" half of the 36-bit byte) could hold 16 bits of data, and the "high moby" could hold a 16 bit pointer to the rest of a list structure. The two correspond to car and cdr respectively, I think. I don't hack LISP, so please forgive me if I've gotten that backwards.
    --
    News for geeks in Austin: www.geekaustin.org

  189. Re:A serious (rather unpopular) hope... by StandardDeviant · · Score: 2

    Take a gander doxygen (http://www.stack.nl/~dimitri/doxygen/) or doc++ (http://www.zib.de/Visual/software/doc++/).

    They're both like JavaDoc for other languages such as C/C++ supporting HTML, LaTeX, etc. as output formats. Good docs (esp. for OO projects) are important, and these two tools let you make them pretty easily. Yeah, more time consuming than // or /* ... */ but you get more for your effort too...


    --
    News for geeks in Austin: www.geekaustin.org
  190. Want to compile Java to native exe? by yerricde · · Score: 2

    a user interface, cross-plattform like swing, as fast like it should be... and most stuff java has, without the need for the virtual machine ..

    You might want to take a look at GCJ if you want to compile Java language code into native binaries. GCJ's class libraries implement most of Java 2's APIs (RMI and AWT are not finished; volunteers are welcome to help).

    --
    Will I retire or break 10K?
  191. Re:Simplify, standardize and fix by e-Motion · · Score: 1
    I'd say templates and temporaries should go.

    Let's take the following function

    void swap(int& x, int& y) {
    int a;
    a=x;
    x=y;
    y=a;
    }

    Now do this:

    unsigned int a=1, b=2;

    swap(a, b)

    a and b remain with 1 and 2, which is wrong!

    Why?

    Because when they are cast they get put into temporaries, and the reference now acts like a call by value (the temporary is changed, but NOT copied back - the changes are lost)

    Correct me if I'm wrong, but this sounds like a problem with the compiler. Temporaries should be considered const. You should only be able to implicitly cast an unsigned int to a temporary int if the reference in the argument list is a const reference. I tried your program on my compiler, and it barked at me.

  192. Re:Funny you should mention that. by e-Motion · · Score: 1

    As an even less useful piece of information, I believe C's precursor ("B") got its name from the place it was developed - Bell labs.

    A useless piece of information, mainly because it's incorrect. C came from B. Where did B come from? A? It actually came from "BCPL" (Basic Combined Programming Language). So what is the next programming language going to be called? D or P? =)

    Perhaps the dillemma means we are forever doomed to use names like C++, C#, etc.

  193. Re:I'm sorry... by igrek · · Score: 2
    Let's see:

    -In C, I can be assured of minimal compiler overhead/bloat

    What makes you think that C++ is bloated? I used to work on some realtime systems, and don't think the code was bloated. We used assembler inserts in the internal loops and always checked the machine code generated. We didn't use STL, or RTTI or other new stuff, though.

    -In C, I can use modules/libraries that were written in assembly language without having to worry about name-mangling or things like that

    You can have the same in C++

    -With C, I don't have to search through a class-browser to find a function that I need

    I don't see a big difference between finding a function and finding a method. If you can leave without code browsers in C, you will not need them in C++. Function overloading makes life more difficult, though; you're right here.

    -I can actually use C to write an operating system

    Well, we all know some operating system written in C++, but I would not touch it ;)

    It's not like I'm advocating C++. I personally see some big problems with C++ and its OOP. But your list of problems is definitely not something I experienced, and I've been working with C++ since the end of 80-s.

  194. Re:Judge language by thickness of its first book. by jeremyp · · Score: 1

    That's probably one of the areas in which C++ is better than C. C++ is strongly typed (it has to be or overloading wouldn't work) and therefore errors like this will always get picked up whether you include stdlib.h or not.

    Having said that, if you use the -Wall switch on gcc the error of not including a prototype will be picked up (as a warning).

    Personnally, I'm in favour of putting the cast in because it makes the programmer think about the return type of malloc. I have seen too many errors similar to:

    char c ;
    c = malloc (sizeof (char)) ;

    which gives an error if you have included stdlib but not if you haven't.

    I guess the fundamental problem is that the whole error checking of C is inadequate and that is one of the few problems I have with that language.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  195. Re:C# a dead-born language ? by jeremyp · · Score: 1

    I think that's a good point (some paragraphs would have helped). M$ seems to be constantly revising the environment that programmers for Windows have to deal with. Can you remember DDE, replaced by OLE, replaced by COM (the same thing really) replaced by whatever .Net is going to use? Can you remember ODBC replaced by ADO or is it Ole DB or something? Now according to the latest MSDN journal, MAPI is obsolete. Just think of all those MAPI based applications that have got to be rewritten. They also had a go at their socket API to make it more M$ like and slightly less BSD socket like.

    A cynic would say that M$ does it to keep the revenue flow of it's MCSE department healthy. Or maybe to keep it's competitors one step behind.

    BTW has anybody noticed, that even in POT mode the HTML paragraph tags still get interpreted as HTML.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  196. Re:Rationale Garbage Collection Explained -- sort by jeremyp · · Score: 1

    Geez -- I haven't often seen such ignorance displayed with such force.

    And no -- sloppy thinking does not result in GC, it results in Windows applications.

    I haven't often seen such ignorance.... In what way does sloppy thinking result in Windows programs? I think this is just a snide dig at Windows programmers born from sloppy thinking.

    Anyway I think GC hides sloppy programming and given that most programmers, even the ones who have been programming in C for 20 years are sloppy programmers, GC is probably a good thing. It means we might get some code that works properly.

    BTW about 18 months ago I saw a demo of Veritas' Cluster services with an admin console written entirely in Java. Veritas were prepared to admit at the time it had a memory leak, so garbage collection is not a panacaea.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  197. Re:A serious (rather unpopular) hope... by jeremyp · · Score: 1

    Yeah, I'd like:

    typedef unsigned short int uint16 ;

    uint16 i ;
    unsigned short int j ;

    i = j ;

    should throw up a compiler error or warning.

    That also means you could overload functions differently for unint16 and unsigned short int. and enums etc.

    I completely agree with this. Obviously, you can use a cast if you really do want to assign one type to the other.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  198. Re:C++0x standard??? by darvs · · Score: 1

    How about C+=2 ?

  199. Re:Who needs it... by baxissimo · · Score: 1

    They'll probably get it working on Macintosh, seeing as how that's the only other platform they currently deliver apps on.

  200. Re:Who needs it... by baxissimo · · Score: 1
    Really? On what are you basing that? You must be talking about the next version since with 6.0 silly stuff like

    for(int i=0; i<10;i++);

    still puts the i in the wrong scope according to the standard. And don't get me started on the template non-conformance issues.

    I hope you're right though. It would be so nice to have a compiler from MS that is decently standard compliant.

  201. Multi methods? by relinquish · · Score: 2

    When will we see a mainstream language implementing multimethods (as in CLOS for example)?

    --
    Relinquish
  202. 2 (Windoze) platforms by Frank+T.+Lofaro+Jr. · · Score: 1

    Yeah, Windows CE on hand-helds and Windows XP on PCs will be the 2 platforms.

    --
    Just because it CAN be done, doesn't mean it should!
  203. Simplify, standardize and fix by Frank+T.+Lofaro+Jr. · · Score: 2

    I'd say templates and temporaries should go.

    Let's take the following function

    void swap(int& x, int& y) {
    int a;
    a=x;
    x=y;
    y=a;
    }

    Now do this:

    unsigned int a=1, b=2;

    swap(a, b)

    a and b remain with 1 and 2, which is wrong!

    Why?

    Because when they are cast they get put into temporaries, and the reference now acts like a call by value (the temporary is changed, but NOT copied back - the changes are lost)

    I tested it and confirmed the counter-intuitive bad behavior.

    Okay, so let's use a template for it to avoid the "deadly" casting, and instantiate int, int and unsigned int, unsigned int versions.

    I tested this two. 2 different copies of IDENTICAL machine code.

    Not much waste, but for big functions, the waste becomes substantial.

    Templates are a hack.
    Making the user worry about temporaries is a hack.
    (The value should get copied BACK if it is call by reference. And it needs to handle the aliased reference case, e.g. a function that takes 2 references that is called as foo(a, a) and declared as foo(int& x, int& y) should have changes in x reflected immediately in y and vice versa).

    And they need to ditch "implementation defined" behavior. Pick a behavior, and MANDATE it. Evaluate function arguments left to right, one at a time, and THEN call the function. Make a[i++]=i++ have a defined meaning. Make ints of less than 32 bits illegal. Heck, force standard bit sizes of the legacy types, and use int32, int64 for future code.

    Those are just some ideas.

    This is not meant to be a troll, you have to admit ambigity in the language is bad, and 16 bit ints are an abomination...

    --
    Just because it CAN be done, doesn't mean it should!
  204. sigh by Laplace · · Score: 1
    I like the current C++ standard. It is very expressive and powerful. Just look at the amazing things that have been developed using templates, like the Blitz++ library . Having said that, it's very frustrating to have so many compilers (read, none that I know of) that support the entire standard. By doing this, Stroutrup et. al. are simple going to create a new divide for vendors (including the FSF ) to play catchup with.

    Their goals of avoiding stagnation and fossilisation are admirable, but as an active developer (and student) of C++, I find this to be counterproductive. Thinking about new constructs and definitions is always a good goal; redefining the standard that can hardly be considered standard if divisive and stupid.

    Just my $0.02.

    --
    The middle mind speaks!
  205. Re:C++ Frustrations by torokun · · Score: 1
    Yes, the .NET compiler is supposed to be better, but I know that in VC++ 6.0, there's still a problem with the constructors of the containers...

    You can't initialize a vector, etc, with any iterators you want, because although the constructor is supposed to be templated to accept any iterator types, it isn't -- it only takes iterators for that container currently.... I hope this is fixed in 7.0 too.

  206. Re:A serious (rather unpopular) hope... by torokun · · Score: 1
    Actually, I think you've hit on a crucial point, and we're really gonna see some trouble when we all move to 64bit systems...

    I was thinking about this earlier today, and I think that what's really needed is a language that forces you to define your types before you can write any code. It should force you to define them in a simple language describing the number of bits, signedness, etc... Then, your compiler could just tell you whether your processor could support your spec or not, and you could just change the spec when you switched platforms, or got new functionality in a processor.

  207. Re:Bolt-ons are not the same as "new and improved" by torokun · · Score: 1


    Java gives me Diarrhea.

  208. Re:Rationale Garbage Collection Explained -- sort by torokun · · Score: 2
    Ok.... I was referring to GC as applied to an entire language, like in Java. I have absolutely no problem agreeing that in some cases, as in semantic nets, using a GC-sort-of-algorithm to perform memory management can be the best solution.

    I do have a problem with the application of GC to an entire language... I believe that the applications that would seem to require a GC-like algorithm are very rare in commercial software, (as you mentioned, more prevalent in AI)...

    Maybe C++ could make it easier to do GC on specific classes, but I really don't like a language that doesn't let you encapsulate the details of memory management within a class...

  209. One Word by cd_Csc · · Score: 1

    C#

    1. Re:One Word by mizhi · · Score: 1

      Wait, you mean the language the Microsoft is prostituting around? Like hell I'm going to let them tie me to a platform with that crap.

      --
      Humorless sig goes here.
    2. Re:One Word by mike260 · · Score: 1

      That's not one word.

    3. Re:One Word by diamondc · · Score: 1
      ahhh!

      you messed it up.. it's.. we'll ALL b-flat
      from the Goonies of course :D

      --
      "I keep looking in the want-ads under 'revolutionary' but there don't seem to be any listings.. "
    4. Re:One Word by anshil · · Score: 1

      As C#'s name might suggest it is a successor or familar to c, that's wrong.

      To my opinion in most facts c# is java in a good disquise, I think c# has been chosen, since that name does it's job as best to masquarade what technology is in, and it did well having a lot of people to believe it's a c(+ü) famliar, what it's not.

      C is a language running nativly and orginally developed and optimized for OSes and OS-close applications. However has spread in a far wider area.

      Java and C# run in a virtual machine, with it's virtual registers and such, having the application not to worry about details like what registers you cpu has or such.

      I personally still think java stands before c#, as the java .class specifications are open, java runs very well on non-windows systems, where the internal .net specs are kept secret, and also you're loosing cross-platform.

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    5. Re:One Word by anshil · · Score: 1

      Hmm, what's IL?

      I donnot know if it is also able to also nativly compile, but it has it's basis on a VM, just like in example VB is doing also, a lot of people not beeing aware of that. (What do you think vbrun.dll is for? It's the VM for VB applications...) Howver also the specs of the VB VM are secret/non-open. I know the the newer versions have an ability to do also native builds, however the normal VB applications and when using the debugger it starts up in a VM.

      --

      --
      Karma 50, and all I got was this lousy T-Shirt.
    6. Re:One Word by Ayende+Rahien · · Score: 1

      C# doesn't require a virtual machine, it should be compiled to IL, which is then compiled to native binary.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    7. Re:One Word by Ayende+Rahien · · Score: 1

      C# was submitted to EMCA, it's going through the standards as you read it.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    8. Re:One Word by Ayende+Rahien · · Score: 1

      Speaking about platform independent, both MS and OSS are supposed to be working on porting .NET (and hence C#) to other OS.
      If they want to get EMCA approved standards, they *have* to do it on at least two platforms.
      And here is one link to OSS CLI & .NET, which will gives you C# as well.

      http://sourceforge.net/projects/open-net/

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    9. Re:One Word by Ayende+Rahien · · Score: 1

      Here are a couple more:

      http://sourceforge.net/projects/ocsdnet/
      http://sourceforge.net/projects/opencsharp/

      Non seem very active at the moment, though.
      However, the entire C# specification can be downloaded (for free) from MS' site, so it can't be *too* hard to do it.
      The main problem, I think, is that C# doesn't really have a library system, such as C++, it has all the .NET for this, so you have to implement .NET, which is not fully done, let alone published, yet.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    10. Re:One Word by Ayende+Rahien · · Score: 1

      IL == Intermediate Language.
      I know that VB uses P-Code (not exactly VM, though).

      IL is when you don't compile to native code, it's higher level than Java Byte Code, frex, it then gets compile by a JIT or another compiler to native code. This allows you to sub-class with different languages, among other neat stuff.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    11. Re:One Word by beelzebubu · · Score: 1

      *Ugh*

      C# is a proprietary non-standard patented and copyrighted format by MS. The standard of C# is, although the name suggest differently (C...), to be compiled for cross-platform interpretation, like java bytecode.

      C/C++/C-NextGen(tm) is supposed to be a free, simple, well-thought-over platform-independent standard programming library which you compile on systems to get system-specific executable binary code.

      This is all so opposite. I cannot see how anyone can even think of C# when you're thinking of C... Java in a linux kernel, how odd can we get? (I know it's possible, I just don't want it - the performance decrease is simply to high)

      *Ugh*

      I don't see why we should make UI extensions, graphical extensions, system-specific extensions in a beautiful yet difficult-to-understand code such as C. Programming is not for weenies or newbies, _real_ programming is for people who know what they're doing. So let the newbies use C# when it's ready because it says M$-something, let the professional newbies use java since their company wants it and let the _real_ programmers use C, C++ or C-NextGen(tm).
      I am actually hoping for something more than a basic layer for connecting to other languages like SQL. The problem would then be that companies still blame the layer to be too "plain" and not specific enough and would still make an own implementation which would be incompatible with that of others. I know the C-language developers will know better than this. And they will surely know better than to include UIs, that is something for third party libraries. They are usually system- or at least environment-dependent anyway.

      Go C!

  210. What I really want to see... by AshPattern · · Score: 1
    Ever since I started programming on the Mac in C/C++, I've wanted a modification to the language to multiply-dereference structure elements by adding greater-than signs. This is (or was) really important on the Macintosh, since a double-pointer was a stable system convention (called handles). I don't need this as much, now, but it'd still be nice for a few pointer-manipulation tricks.

    With the language the way it was, I had to do something like:

    (**myControl).cntrlRect
    or
    (*myControl)->cntrlRect
    both of which are insanely ugly. I think it would be far better to have something like:
    myControl->>cntrlRect

    I post this in hopes that someone on the committee will read this!

    1. Re:What I really want to see... by tim_maroney · · Score: 1
      Or better yet, get rid of the distinction between -> and . since in practice the compiler can always determine when a . needs to be changed to a -> or deeper dereference. The distinction between the operators is just an error trap.

      Tim

    2. Re:What I really want to see... by tim_maroney · · Score: 1
      Except that sometimes you want to pass a pointer around, and not the data to which the pointer points... even if it's already a reference deep.

      Maybe I'm missing something, but I don't see how those goals are in conflict. I'm not saying get rid of pointers; I'm just saying there's no reason to have separate operators for a field of a pointer, a field of a reference, and a field of a pointer to a pointer. The dot operator could easily do all of those.

      Tim

    3. Re:What I really want to see... by Dancin_Santa · · Score: 1

      Would you also have

      (myControl->>cntrlRectptr)->x;

      Looks like hell. But that's just my opinion.

      Dancin Santa

    4. Re:What I really want to see... by Ayende+Rahien · · Score: 1

      Isn't refernce and pointer one and the same?

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  211. Re:About time by partingshot · · Score: 1

    > what they would miss most if forced to use C++
    > instead of Java

    wow, harsh. what if they said "nothing"?
    remember, someone at sun wrote your fancy
    java library in c.

    --
    Anonymous posts are filtered.
  212. Re:A serious (rather unpopular) hope... by Brand+X · · Score: 2

    Not precisely. I want it to be a different type. That just makes it an alias for an unsigned short... which means you can't have a unique signature for a function with a unsigned int16 as an argument, as opposed to an unsigned short int.

    --
    -- Still waiting for the Nike endorsement
  213. Re:A serious (rather unpopular) hope... by Brand+X · · Score: 2

    Tell me about it. I've got a program here that does client/server interactions with mixed binary data streams, and I have to runtime identify the data type and handle the byte-swapping for conversion. Unfortunately, the protocols were developed for an Intel platform, and are not inet ordered (bigendian). But... shrug ...you go after what you can, when you can. Self-ordering types would be... problematic... for optimal processing.

    --
    -- Still waiting for the Nike endorsement
  214. Re:A serious (rather unpopular) hope... by Brand+X · · Score: 2
    Yeah, I'd like:

    typedef unsigned short int uint16 ;

    uint16 i ;
    unsigned short int j ;

    i = j ;

    should throw up a compiler error or warning.

    That also means you could overload functions differently for unint16 and unsigned short int. and enums etc.

    I completely agree with this. Obviously, you can use a cast if you really do want to assign one type to the other.


    Yes. But it shouldn't use the same keyword... How about:

    typegen unsigned short int uint16;
    typedef unsigned short int Uint16;
    unsigned short int foo = 1;
    Uint16 bar = foo;
    // OK, same type.
    uint16 baz = foo; // Warning, need cast conversion
    --
    -- Still waiting for the Nike endorsement
  215. A serious (rather unpopular) hope... by Brand+X · · Score: 5

    As a programmer who often works on massively cross platform C++ server and client applications, a lot of these proposals (distributed processing, standard thread libraries) are nice, but there's one major gripe with the language under all platforms: the lack of standard sized types. What I mean is, integral types in parallel to the short int, int, long int, long long int (C99 standardized, not C++) etc, with names like int8, int16, int32, int64, int128... allowing portability without meticulous work in wrapping and handling functions, outside libs, autoconf scripts, etc. It would be especially nice if these types were *not* considered, for the sake of signatures, type-identical to counterpart size-variant types, and if enums were also given a generic root type instead of being int in signature (eg, operator(ClassName&, enum) ) and a variant size integral type defined to the size of a pointer were included. Just some thoughts from a person who has to extensively use the language.

    --
    -- Still waiting for the Nike endorsement
    1. Re:A serious (rather unpopular) hope... by Ars-Fartsica · · Score: 2
      Headers are for other programmers, so they know the interface they are to use when programming with that module, WITHOUT laying bare the sum total of the module's source code. Very necessary if you're in the business of selling precompiled libraries you don't want copied.

      Yet Java trivially gets around this problem - y ou can see the signatures and even formatted odcumentation for a module without seeing the implementation...and all without header files.

    2. Re:A serious (rather unpopular) hope... by swilcox · · Score: 1

      how about:
      typedef unsigned short int u16
      that is one of the reasons it is there you know...

    3. Re:A serious (rather unpopular) hope... by AstynaxX · · Score: 2

      1. Losing the pointless duplication of declarations in .h files. In fact, you would not need .h files anymore except for backwards compatibility. 'Course you'd lose the ability to make a header file do different things based on defined symbols, but that would be an advance IMHO. Someone must not have been paying atttention in their OOP and OOD classes. Headers are for other programmers, so they know the interface they are to use when programming with that module, WITHOUT laying bare the sum total of the module's source code. Very necessary if you're in the business of selling precompiled libraries you don't want copied. They also do serve a compiler function, but that could be removed to speed things up as you've stated. 2. Virtual methods can be determined by the linker, so the programmer no longer needs to specify virtual-ness at all. Again, back to class for you! Imagien, if you will, a VERY sensitive public function in a class, it manipulates the private member variables in a low level manner, and ALL or at least MOST of the other functions count on it to do so. Now imagine fscking with that function by letting Joe Random Coder make it virtual at will. Frightening thoughts. I hate to be so blunt, this isn't meant as a flame, per se, but a little research into the reasoning can go a long way with some of these things.

      -={(Astynax)}=-

      --
      -={(Astynax)}=-
      "Darkness beyond Twilight"
    4. Re:A serious (rather unpopular) hope... by Courageous · · Score: 1

      It would be especially nice if these types were *not* considered, for the sake of signatures, type-identical to counterpart size-variant types
      --------
      Ah yes. Don't I *wish*. If I declare something
      int32u, I want it to fail if someone offers an
      "unsigned long". I want a different signature to
      be treated as a different type.

      C//

    5. Re:A serious (rather unpopular) hope... by mr+crypto · · Score: 1

      Hear hear! No programmer can confidently write a large program and expects it to compile and run on a variety of platforms. My $0.02 - standards are not enough. We need a program that enforces the standard and says definitively whether or not something is valid C++. I've seen too many tables showing "to what degree" a compiler is standard. Look at the Mozilla portability guide http://www.mozilla.org/hacking/portable-cpp.html which starts with "Don't use C++ templates."

    6. Re:A serious (rather unpopular) hope... by Tech187 · · Score: 1

      I think he wants a .h file containing those defintions to be standard, not to have to drag in his own defintions everywhere he codes.

    7. Re:A serious (rather unpopular) hope... by haruharaharu · · Score: 1

      That works very well if you can control the format of the output. C++ doesn't

      --
      Reboot macht Frei.
  216. Re:About time by Ars-Fartsica · · Score: 2
    As a senior developer in a Java shop, one of the things I often ask interviewees is what they would miss most if forced to use C++ instead of Java. Anyone who answers anything other than 'the libraries' gets a big black mark next to their name in my book.

    Well, there is a large body of libraries available through the STL and through third-party vendors such as RogueWave. Admittedly this isn't an out-of-the-box solution, but there it is. Added to which, the STL is a much more meaningful implementation of extensible libraries.

  217. My kingdom for a garbage collector by bataras · · Score: 1

    When I grow up, I want a garbage collector to come take away all the crap I'm too lazy (or incompetent?) to clean up myself....

  218. Re:Who needs it... by SnapShot · · Score: 1

    I don't use VC++ much, but I think I read (C/C++ UJ) that this is a preference that can be changed to put 'i' in the correct scope. The reason it defaults the way it does is so it doesn't break the various windows headers.

    --
    Waltz, nymph, for quick jigs vex Bud.
  219. Re:How about by SnapShot · · Score: 1

    Look at some of the things that C99 added to C for a similar tack, IMHO, that the next generation of C++ (C+=2) should take.

    I like the idea of "long long". Perhaps defined as a twice the size of the current compiler's "long" type. Currently, this would allow a 64 bit type for use desktop programmers (128 bit for those of you that get the fancy workstations). Stop the madness before "huge int" becomes the standard.

    The beauty of the STL is that it doesn't involve anything that couldnt be implemented on any system. Adding things like multi-threading, any sort of GUI support, or anything else that can't be generalized to work identically on all platforms seems to be a mistake.

    --
    Waltz, nymph, for quick jigs vex Bud.
  220. Re:How about by SnapShot · · Score: 1

    Namespaces have been a god send for the work I've been doing. I've had to write a lot of simple data structures to add high-speed functionality through DLL's to an interpreted scripting language (RadBuilder -- which is actually kind of fun, when was the last time you actually got paid to implement a binary search tree instead of just using some library version?)

    Anyway, I can use whatever names I want for my classes and functions since I can wrap the whole thing in a namespace and not worry about conflict. I can call a function "sort" instead of "radbuilder_dll_sort" and not worry that there is a name conflict with some other library I've included.

    It doesn't make programming mindless... it's just another tool (one that works for me).

    --
    Waltz, nymph, for quick jigs vex Bud.
  221. Re:Judge language by thickness of its first book. by dark_panda · · Score: 2

    As of the latest standard, I believe there are 37 keywords with the addition of inline, _Bool, _Complex, _Imaginary, and restrict. K&R C had 31 keywords vs. ANSI's 32 -- ANSI added volatile, signed and const and dropped asm and fortran.

    At least, I think that's how it went... it's somewhat blurry now, I haven't used C in a long time...

    J

  222. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  223. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  224. Way off topic, but... by AaronStJ · · Score: 1

    Where did the cool poweder blue color scheme come from? I really like it. For that matter, why is it that pages tend to have different color schemes? Normally it's the plain green, but sometimes there is tht red scheme that, imo, look prettty bad.

    This blue is really cool, though. Very soothing.

    --
    Stupid like a fox!
  225. Re:C++ Frustrations by Osram · · Score: 1

    I do remember VC 5 had a number of problems with STL in particular, and we still have problems with the compiler in VC 6, even with the latest SP (random errors regarding DEBUG_NEW in MFC apps that disappear when you try compile again, as well as internal compiler errors)

    Do you have precompiled headers on?

  226. Re:C++ Frustrations by HereTheDogIsBuried · · Score: 1

    MathML is already in Mozilla, and it works pretty good from the bits that I've seen, unfortunately, Mozilla is probably not a popular browser.

  227. Just because... by ChaoticCoyote · · Score: 2

    ...very few people can fly a Space Shuttle doesn't mean we shouldn't have spacecraft.

    Some of us are big boys, and we can handle C++ just fine, thank you.


    --
    Scott Robert Ladd
    Master of Complexity
    Destroyer of Order and Chaos

  228. The Right Tool for the Job by ChaoticCoyote · · Score: 2

    I'm a rather eclectic fellow when it comes to programming languages. Since the mid-70s, I've written code in (chronological order) MBASIC, Z80 assembler, FORTRAN, COBOL, 8080 assembler, C, Pascal, Modula-2, Prolog, C++, Java, and Python. I've dabbled in many more languages.

    Specialization is for ants, as Heinlein said.

    Where is it written that every program must be written in one "true" language? I won't hire one-trick wonders; give me a programmer who knows a couple of programming languages, who shows me they can adapt and think, and I'll give 'em an office...

    Programming isn't about syntax -- the essence of software development is design and algorithms. Each language brings a different perspective to the table, and a wise engineer uses the right tool for the job.

    My current commercial project wraps a portable, high-performance engine (C++) in component architectures (COM, JavaBeans) for server-side (Java) and standalone (C++, Visual Basic, Java) applications; we have several utilities written in Python. The C++ is for performance (Java and Python can't cut it, believe me), the Python for quick development, and the Java for network-oriented "stuff".

    C++ is a power tool that shouldn't be given to inexperienced or undisciplined programmers. What makes C++ powerful is that it isn't an object-oriented programming language -- C++ is a multiparadigmic language providing the tools I need to build code in the best way for a given task. Is it perfect? No. Is it a dmaned fine tool? Yes.

    Oh, I have my criticisms of C++: A new standard is a mistake when no on produces a fully-ISO compliant compiler today. The STL is an ugly mess designed by committee; I'd like to see restricted template arguments, inheritable enums, and a few other new ideas. But overall, C++ is a damned fine tool, if used by a professional in an intelligent fashion.

    --
    Scott Robert Ladd
    Master of Complexity
    Destroyer of Order and Chaos

  229. Not quite... by ChaoticCoyote · · Score: 2

    ...since what's in the ISO/ANSI/IEC standard is substantially different from what Stepanov and company invented as the original STL.

    Compare the standard containers library, as implemented by ISO/ANSI/IEC, to Stepanov's original STL, and you'll find a rather large set of differences. The C++ Standard Library is a corruption of Stepanov's fine work...

    I continue to use the original STL in many projects, avoiding the ugly, often poorly-implemented mess that stems from Chapter 23 of the standard.


    --
    Scott Robert Ladd
    Master of Complexity
    Destroyer of Order and Chaos

  230. no by 4what4 · · Score: 1

    no one

  231. Re:C++ Frustrations by arnald · · Score: 1

    Nope; in fact, it's a shit browser.

    --
    arnald
  232. Re:Who needs it... by Xentax · · Score: 1

    C# is proprietary. C# will probably NEVER run on anything but windows. C# will exhibit no better performance than Java. C++ is and will continue to be the language of choice for complex applications with performance constraints. There's 3 reasons C++ will still be around, and thus is worth improving. I was at the Conference this article is about. I heard Bjarne's speech, and I also attended an 8-hour tutorial on C# (by Stan Lippman, if anyone's wondering). I can see where C# will have some utility (rapid GUI development for the Windows platform, mainly), but it won't be replacing C++ for most of the situations where C++ is currently the best choice.

    Xentax

    --
    You shouldn't verb words.
  233. Re:C++ Frustrations by Xentax · · Score: 1

    To give the answer the forum speakers gave, they just finished NOT doing anything for a few years, to give the compiler groups time to catch up. They don't want to wait any longer.

    Xentax

    --
    You shouldn't verb words.
  234. Give me a hand here by prelelat · · Score: 1

    This is just a question but what would all the benifits would there be from a new C++ language I know that there should be lots but I don't know what they all are so would people please enliten me?

  235. Re:Bolt-ons are not the same as "new and improved" by JebOfTheForest · · Score: 1
    the Sun Java Community Process folks are working on the genericity issue right now. It's fairly high-priority I think. Hopefully, there solution won't be as complex as C++, so that it will get properly implemented by more than one compiler in my lifetime.

    jeb.

  236. Re:Bolt-ons are not the same as "new and improved" by JebOfTheForest · · Score: 1
    FOA, as far as "powerfulness" goes, I'm sure it'll ultimately be functionally equivalent, it's just that some things will be nastier to do than others.

    If by "powerful", you mean if it complicates the definition of the system by 1000% to make it 10% easier to do something you want to do less than 1% of the time, than I would agree. Java is often less "powerful" than C++. But the compilers for it actually compile the whole language.

    jeb.

  237. Re:Delphi by DarkEdgeX · · Score: 1

    Nah, object oriented Pascal is nice. I still use C++ though because it allows operators to be overloaded, something Delphi (Object Pascal) still lacks.. there are other minor differences, but at work I use Delphi and at home and whenever else possible I use C++.

    --
    All I know about Bush is I had a good job when Clinton was president.
  238. Re:Delphi by DarkEdgeX · · Score: 1
    Admittedly, I haven't used any implementation of Object Pascal a lot, but I haven't really liked what I tried. Pascal is best suited as an introductory procedural language.

    It also has it's place in business though, and in Europe it has a much larger following (specifically Borland's implementations of Pascal-- Borland Pascal and Borland Delphi). You're right though, as a training language it's a step above Basic and shares enough similarities with C and C++ that anyone migrating from Pascal should be able to catch on quickly.

    About Java though, while it's nice to have garbage collection and be able to avoid memory leaks, I just don't see Java being a C/C++ killer. Garbage collection just seems like a step beyond exception handling (alloc a pointer, 'try' to operate on it, then free the memory in a 'finally' handler), and another way of bloating the CPU resources used by an application. (In other words, a step backwards.)

    Java works for web technologies, but I don't see it taking the place of common application development.

    --
    All I know about Bush is I had a good job when Clinton was president.
  239. Re:C-Sharp? by Spinality · · Score: 1

    On instruments like the violin or in voice, Db should be slightly higher than C#. -- Cpk71

    You're opening a whole can of worms here! There are many who disagree violently with this assertion, maintaining that mean-tone tuning or any other deviation from equal temperment is a hopeless throwback to the seventeenth century. Certainly, if you play in a symphony or an ensemble in which equal temperment instruments participate, you'd better play/sing tempered fifths. Easley Blackwood was famous for berating string sections on this point.

    Of course, if playing Irish fiddle tunes or singing madrigals, you're quite right -- use those pretty-sounding perfect intervals. But if you're playing Beethoven, Hindemith, or Thelonious Monk I'd stick to the tempered scale.

    ROFL, didn't expect this conversation in this thread.

    - What's bimodal and brown? A chocolate-covered flip-flop.

    --
    -- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
  240. Re:Judge language by thickness of its first book. by Spinality · · Score: 1

    naasking said: int* pi = (int*)malloc(sizeof(int)); ...is NOT correct even with the cast. It's valid, but not correct. That statement is requesting an int and assigning it to a pointer. That should read:
    int* pi = (int*)malloc(sizeof(int *));
    or
    int pi = (int)malloc(sizeof(int));

    Huh? As I read it, the original line is quite correct: malloc a chunk the size of an int, treat the return pointer as a pointer to int, and store that pointer as 'pi.' The result is a pointer to an int-size value. Your two examples do something quite different. The first mallocs a chunk the size of a pointer, and makes 'pi' point to it (yet 'pi' is defined as a pointer to int, not a pointer to a pointer). The second mallocs a chunk the size of an int, treats the address as an int, and stores it on the stack. Neither of these seem to be the desired result.

    Try rereading these. I don't think I skipped my coffee this morning.

    - What's bimodal and brown? A chocolate-covered flip-flop.

    --
    -- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
  241. Hint by Mr.+Polite · · Score: 2

    It's called Delphi
    ---

    --
    "Watch these suckers jump when I get Administrator."
  242. Funny you should mention that. by AFCArchvile · · Score: 1
    from the they-could-call-it-b-minus dept.

    Back when it was still being designed, the version of C before the final standard was called "B". Pretty useless factoid, but interesting.

    --
    "Ancillary does not mean you get to rule the world." --U.S. Circuit Judge Harry Edwards, speaking to the FCC's lawyer
    1. Re:Funny you should mention that. by Ayende+Rahien · · Score: 1

      Not much farther, we will have C? (for AI) C$ (to replace COBOL) C! (mathematics) C+=4 (for the latest, hottest hype around).

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  243. Bolt-ons are not the same as "new and improved" by KarmaBlackballed · · Score: 2

    C++ was an innovation that extended C into object territory that it was never designed to handle.

    Take the best Ferarri from 1966. Best of breed for its time. Nice looking too. Race it against the best of breed from this year. Do whatever you want to that 1966 Ferarri, it will never be as good as a new a fresh design.

    Java syntax is an improvement over the convoluted syntax that is C++. Deal with it. Its creators would have to be less than top-notch considering they could see all the bad things in C++ and avoid them.


    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~ the real world is much simpler ~~

    --

    --- -- - -
    Give me LIBERTY, or give me a check.
    1. Re:Bolt-ons are not the same as "new and improved" by AKAImBatman · · Score: 1

      (2) Interfaces cannot contain code, so cannot provide behaviour.

      Use abstract classes. Abstract classes allow you to define part of the behavior, while requiring that the extending class complete any behavior marked as abstract.

      Multiple inheritance is prohibited. This leads to duplication of what should be common code.

      Yes, it is. I have not yet had a problem with that either. As for common code, that's silly. You should define some other library of common code and reuse it. MI is not a requirement and is generally more trouble than it's worth.

    2. Re:Bolt-ons are not the same as "new and improved" by leviramsey · · Score: 1

      I myself find Java code to be more convoluted than C++. When I see lines with more than 4 casts, I scream!

  244. Re:I think Bjarne is right about the state of C++ by rabtech · · Score: 2

    Did the moderators not bother to click the link and see that it goes to a GOATSE.CX-esque picture? Somebody mod that down please... the post is a junk post to trick people into clicking the link.

    I fear that no one reads the moderator guidelines anymore.
    -------
    -- russ

    "You want people to think logically? ACK! Turn in your UID, you traitor!"

    --
    Natural != (nontoxic || beneficial)
  245. Re:Judge language by thickness of its first book. by Evil+Grinn · · Score: 1
    Malloc is a library function which returns a (void *). That is an illegal pointer to dereference, modify or use in any meaningful way. You have to cast it to use it.

    Actually, in ANSI C there are very good reasons not to cast the return value of malloc.

    In ANSI C you are always allowed to assign void* to another pointer type. In fact, that is what void* is for. Adding a cast buys nothing.

    Moreover, adding a cast can disguise the fact that you've forgotten to #include stdlib.h. If you forget to include this header (which has the prototype for malloc), then the compiler will assume that malloc returns an int. Normally, this would fail to compile when you try to assign it to a pointer. But if you have included the cast, your program will compile and silently mix integers and pointers. This will work on a machine where pointers really do have the same physical representation as ints, but will fail elsewhere. Thus, not only is the cast not needed, it actually makes your program more prone to portability bugs.

  246. Re:Judge language by thickness of its first book. by Evil+Grinn · · Score: 1
    Adding a cast provides consistency, clarity, good style and correctness.

    How much does it really add? Is

    char *pointer = malloc(SOME_SIZE);
    really any harder to read than
    char *pointer = (char*) malloc(SOME_SIZE);
    ? It could be argued that the former is easier to read, since it is cleaner.

    And if you do it often enough for it to be a major problem, I suggest actually paying attention to what you're doing.

    I'm not suggesting it happens often. I was just pointing out a potential drawback to casting the return value of malloc, in addition to the fact that it accomplishes nothing.

    I think that saying 'programming according to the language standard reduces portability' is a ridiculous statement.

    The standard says that the casts are unneccessary.

    int* pi = (int*)malloc(sizeof(int));

    If you have included stdlib.h, this code is correct, with or without the cast.

    If you have not included the header, the cast won't save you.

    Btw, I just looked in my copy of K&R2 and noticed that they cast the return value of malloc. Their influence over what is considered good C style is (rightfully, IMO) powerful. Then again, K&R also allow their hello world program to fall out of main() without returning a value...

    I suspect that most uses of casting malloc's return value are really just holdovers from pre-ANSI compilers and pre-ANSI lint utilities.

  247. Re:How about by mike260 · · Score: 1

    I seem to recal a Bjarne Stroustrup quote along the lines of: "I think there's a smaller, cleaner language inside C++ trying to get out", and I definitely agree (assuming I'm haven't got it wrong and am totally misquoting him). Everyone I know has picked their subset and is wary of going outside it.

  248. Re:C++ Frustrations by mike260 · · Score: 1

    Have you tried the Intel compiler?

  249. Re:How about by mike260 · · Score: 1

    I think you seem to recall incorrectly then
    Well, someone said it about something. In my imagination, if nowhere else.

  250. Re:C++ Frustrations by bertok · · Score: 1

    Yes, mdev 7.0 is probably one of the most compliant C++ compilers out there.

    It's not. AFAIK, most other popular C++ compilers are better. I've used Visual Studio .NET 7 for a while now, and it hasn't improved much over 6. The standard library is a little more compliant, but only in a few places. The compiler itself still doesn't support all the standardized features. The following list is taken from the VS.NET help file:

    Standard Compliance Issues in Visual C++

    • 2.11 Alternative Keyword Representations
      The alternate forms of the following keywords are not available: and, and_eq, bitand, bitor, compl, not, not_eq, or, or_eq, xor, xor_eq
    • 3.4.2 Argument-dependent Name Lookup
      Argument-dependent name lookup, also known as Koenig lookup, is supported for operators but not for other member functions...
    • 6.4 Scope of a Name Declaration in a Selection Statement
      A name introduced in a selection statement should be in scope for the remainder of the selection scope...
    • 10.3 Covariant Return Types
      Covariant return types are not supported...
    • 14 export Keyword on a Template
      The export keyword is not supported on templates...
    • 14.5.2 Out-of-Class Template Definitions
      Class and template members must be declared and defined within the class or template...
    • 14.5.4 Class Template Partial Specialization
      Class template partial specialization is not supported by the Visual C++ compiler...
    • 14.5.5.2 Partial Ordering of Function Templates
      Partial ordering of function templates is not supported...
    • 14.8.1 Explicit Template Argument Specification
      Visual C++ does not deduce template arguments for function templates; that is, all template parameters must be used in function arguments or return type...
    • 15 Function try Blocks
      Function try blocks are not supported...
    • 15.4 Function Exception Specifiers
      Function exception specifiers other than throw() are parsed but not used.
    • 18.6.4 uncaught_exception Returns true
      As can be seen in the Visual C++ source file, uncaught.cpp, uncaught_exception returns false.
  251. Re:C++ Frustrations by spongebob · · Score: 1

    I too have heard that VC++ 7.0 is much better. I wonder why people still have time to generally bash things without specifying the scope of their problems set. If someone was saying that for "generic" usage that VC++ sucks, I refuse to listen. I need to know when it sucks and why. I am not saying that VC++ is a holy grail by any means, but let me know where it gives you beef. These comments are like saying Java is only 5% slower than native code. Ok, maybe this is true, but the important question stands: Is it only 5% slower in applications I might use. Anything else is just generic and useless.

  252. They should break from the C model entirely... by wrinkledshirt · · Score: 1

    Random thoughts...

    I think they'd have a chance at creating a good language if they followed Java's lead.

    [[Insert cries of outrage]]

    No, seriously. Java's got some knocks on it but the main problems are verbosity of code and the way it gets implemented (virtual machines, HTML converters, general slowness, etc.). If the new language were built in the same abstract way that Java is, you'd get a decent OO language with none of the ugly memory management techniques that a C coder has to go through. I'll still probably code in C, just because I like it and don't need objects for what I do and the speed is nice, but I think that for the average programmer, messing around with mallocs instead of "new" and arrays of chars instead of a string class is a real pain-in-the-butt price to pay for performance. I know these (strings and "new") are both aspects of C++ right now, but you've still got backwards compatibility (if you can call it that) with C and that means a bunch of confusion (ie: a bunch of C-string functions that don't work all that well with C++ strings, etc.). It's a huge mess to sort through, with C techniques available on the one hand and C++ techniques available on the other. And it's not like I've ever seen a C++ textbook aimed at beginners that didn't teach C fundamentals at the beginning. The overlap is practically assumed and accepted, and I think that's bad for the language.

    I think if they went for simpler and more cleaned up, they'd make the language a lot more attractive. I don't think they should model it on C++, myself.

    Although, I do have to admit that the time might be better spent working towards improving the supporting libraries with C++. One of the nice benefits of C++ is that, even though it can be a pain in the ass to build appropriate foundation classes, ones that get built nicely are a DREAM to work with. Of course, that's a language-irrelevent issue...

    --

    --------
    Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...

    1. Re:They should break from the C model entirely... by wrinkledshirt · · Score: 1

      There is also a profound resistance to OO thoery in the C language camp that I still can't quite understand, but that is another story...

      Probably because we understand that the difference between y = foo(mystruct, x) and y = myclass.foo(x) is pretty darned academic.

      Better get the asbestos suits out...

      --

      --------
      Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...

    2. Re:They should break from the C model entirely... by Ayende+Rahien · · Score: 1

      What about this, then?
      int a;
      float b;
      char c = foo(a);
      c = foo(b);
      Unless I missed something, C can't handle polymorphism, encapsulation, and several other basic OO or even OB programming.

      (Talking about straight C here, Objective C is an unknown beast to me)

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  253. the next C++ by mr+crypto · · Score: 1

    Could the next version of C++ make Purify less important? The fact that this product line exists indicates a C++ usability problem.

  254. Re:C-Sharp? by FrostedChaos · · Score: 1
    >I sometimes wonder if it's probably easier to
    >express our software musically than in C++.

    excellent idea.

    Windows 98: BUUUUUUUUUUUUUUUUUURRRRRRRRPPP
    Visual Basic: [EXTREMELY LOUD FART]
    Quake III: [toilet flushing]

    --
    "Any connection between your reality and mine is purely coincidental." -Slashdot
  255. Polish Construction by vodoolady · · Score: 1
    It's an annoying and weird problem. I'm not really keen on the idea of switching the method handler around for the special case of construction. You've really got two phases: phase one is the trad C++ make-my-memory-useful phase, and phase two is the 'stuff you always need to do with me every time I'm created' phase.

    The subtle difference is that phase one gets an incomplete base class, while phase two gets the finished object, and hence virtual method calls in the base class get passed to the derived class handler.

  256. Sug: KILL INCLUDE FILES!!! by vodoolady · · Score: 1

    What a stupid stupid way to import stuff: gotta protect the whole thing with #ifdefs, think about forward declarations, urg

  257. Actually... by AKAImBatman · · Score: 1

    ...he's exactly the type I would hire. He seems to at least attempt to understand what he's talking about, and isn't afraid to speak his mind. Now his immaturaty is showing through, but at least I can work with that. I'd take a dozen of guys like this over a couple hundred programmers with no drive. You must have one hellva time finding programmers. Oh, and to jsse himself, if you read this feel free to email me your resume. I would be more than happy to discuss Java employment with you. And no, I'm not a recruiter or a manager. But I am the lead programmer for my company and do make the recommendations for who gets hired and who doesn't.

  258. Re:g++ should be the standard C++ compiler by smittyoneeach · · Score: 1
    I have no business speaking above my skill level, but here I go, anyway:

    The number of differing Application Binary Interfaces with a significant user base can't be terribly high. Why not a template parameter for the compiler to target the different platforms? I suppose some linker interface trickery would degrade performance.

    Reading Mr. Stroustrup's February response on /., he seems disinclined to endorse anyone's ABI. Can the discussion be obviated?

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  259. I'm sorry... by KewlPC · · Score: 1
    ...but am I the only C programmer who didn't move on to C++, despite the fact that I had more than one oportunity?

    Let's see:
    -In C, I can be assured of minimal compiler overhead/bloat
    -In C, I can use modules/libraries that were written in assembly language without having to worry about name-mangling or things like that
    -C has none of this namespace nonsense
    -With C, I don't have to search through a class-browser to find a function that I need
    -C has no function (sorry, method :/) overloading, and thus no name-mangling
    -I can actually use C to write an operating system

    I could go on all night, but I think I've made my point as far as that goes.

    People often tell me of C++'s advantages over C, but all those "advantages" make me think of is code bloat and unwanted speed reductions.

    1. Re:I'm sorry... by Ayende+Rahien · · Score: 1

      The kernel is C, though.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  260. Re:The tremendous limitations of Java by CustomDesigned · · Score: 1
    We use both C++ and Java. Java for "high level" stuff and stuff where we want *binary* platform independence (where "just recompile" is not acceptable).
    1. Ctor/Dtor. First of all, Ctors *are* guarranteed in Java. Dtor is mostly needed for memory management in C++ - which is not needed in Java. When dealing with external resources, it is no harder to remember to call "g.dispose()" everywhere than it is to remember to "delete p". C++ garbage collectors don't call dtors either (and for good reason).
    2. Multithreading. This is a library issue - and newer Java library classes *don't* synchronize unless you ask for it. How 'bout some of those older C/C++ libraries that aren't thread safe at all (e.g. returning values in static memory!)
    3. Generic types. Gotta agree with you there. Hopefully, GJ will be standardized soon.
    4. Operator overloading. Agreed, but I haven't missed it as much as generic types. Probably because I haven't tried to do any scientific code in Java. Right tool for the job and all that. (Go Fortran!) This is a language issue, and several free Java extensions offer operator overloading.
    5. Explicit allocation. You absolutely do *not* want this in Java. For the high level code Java is intended for, eliminating memory corruption as a source of bugs is *critical*. It is also critical for sandbox execution of untrusted code - something C++ doesn't have a clue about. Yes, custom memory management can be faster, but using the C++ default of malloc/free in generally not any faster. Right tool for the Job.
    6. Support for plain functions. Java has had plain functions since 1.0. They are called 'static' methods. Have you actually used Java?
    In short, while C++ is good for small to medium projects which are perfomance sensitive, it is unsuitable for large or security sensitive projects because of memory corruption which grows exponentially with project size.

    C/C++ is especially unsuitable for security sensitive applications such as nameservers, web servers, mail transfer agents. Because of the pervasive use of the wrong language for these servers, the most common exploit by far is overflowing some buffer to overwrite the stack with native code.

    The bottom line is, neither language can substitute for the other in all applications.

  261. Re:About time by jsse · · Score: 1

    As a senior developer in a Java shop, one of the things I often ask interviewees is what they would miss most if forced to use C++ instead of Java. Anyone who answers anything other than 'the libraries' gets a big black mark next to their name in my book.

    It's you who deserves a big black mark on your face. Java beans achieves the concept of reusability, as they can be created and redistributed like blackboxes - it's especially important to commercial and enterprise usage. Take a look at some java factories like Flashlines, they sell individual java beans which can be used on any platforms and any development environment. EJB, Servlet, and RMI etc. are hardly merely 'libraries', they are integrated parts of Java, and you just can't ignore their importance. A Java app developed on personal java 1.1 can run on any mobile devices compliant with this jvm, without recompilation.

    I really doubt someone with such an insight and knowledge in Java could be a senior developer in a Java shop...or you are simply a troll?

  262. Re:About time by jsse · · Score: 1

    javax.servlet and java.rmi ARE in fact merely libraries (packages in Java-speak). The only thing that makes them "integrated" are their inclusion in rt.jar.

    Ever heard of terms like rmic, rmiregistry, EJB-containers? Are they a java libraries?

    EJB is simply an umbrella term for RMI, JDBC, JavaBeans and JNDI with some convenience classes/interfaces.

    Should I comment on your pure imagination on EJB? Nah, RTFM yourself!!

    Damn, fell into another troll's trap again....

  263. How about standardising c- - as well by os2fan · · Score: 1
    One could include in the standard, some sort of macro language c-- that would allow the use of much of the same headers.

    This means that you could write and test source codes in shell batches without the need to compile, and then when ready, compile, or that the same interface is used by shell scripts and program applications.

    More importantly, it means that the same knowledge and tools can be applied to writing both scripts and code, and if c-- is more forgiving, like CEnvi used to be, a good way to learn and explore c in a meaningful way. {ps} it probably is, but I have not upgraded to vers 4, since there is no OS/2 support :) {/ps}

    --
    OS/2 - because choice is a terrible thing to waste.
  264. C-Sharp? by Fromeo · · Score: 1

    IANA Musician, but I seem to remember from my ancient days of playing violin that C-sharp is equivalent to D-flat. Which also seems to be an appropriate description.

    1. Re:C-Sharp? by Cpk71 · · Score: 1
      This is true only on an equal-temperament instrument like a piano. On instruments like the violin or in voice, Db should be slightly higher than C#. Also, in classical composition, they're "logically" different even if they have the same pitch value. For instance, the minor 7th of the key of C is a Bb, but the major third of the key of F# is A#. Even though A# and Bb are the "same" on the piano, melodies arranged around Bb as a minor seventh are going to sound VERY different from those arranged around A# as a major third!

      What this has to do with C++ is unclear, but I sometimes wonder if it's probably easier to express our software musically than in C++.

  265. lazy coders by ironfroggy · · Score: 1

    Low level coding IS best.. for the final binary. Yes, it is a little tougher. Yes, it is more work for the programmers. Yes, it does take more time and more thinking on our part. But, does this matter? No. Our goal should be to produce the best binaries we can. The fastest and smallest binaries we can! Sacrafice your own time and brain power for a good binary, thats what matters. Take the hard road and reach the better paradise.

  266. Other wish-list items for a standard library ++ by nigels · · Score: 1

    Time, Date, Timezone and calendar handling
    Universal constants (PI, e, etc)
    Unit Conversion
    I think that multiple return values is also a useful, and nice idea -


    int, int foo()
    {
    ...
    return x,y;
    }

  267. C++ Negativity by nigels · · Score: 2

    With all the negativity going on here at Slashdot in relation to C++, it makes me wonder if slashdot has been infected with dot com web scripting try- hards, and the real hacker crowd has migrated elsewhere.

    My 0.01 (Australian cents arn't worth much) is that C++ would benefit from perhaps a few minor enhancements to the language, and certainly a major expansion of the standard library. Things that come to mind - multi-threading, networking, TCP/IP protocols, optional garbage collection, various smart pointers in addition to auto_ptr. I'd also like to see some HTML/XML oriented functionality as part of the standard library. A serious math and vector calculus library would be useful for graphics programming.

    I don't think it would be desirable or necessary to change things in a way that substantially breaks existing code.

    It would certainly be nice to have some of Java's tricks in a standardised form, and to decrease dependence on vendor specific 3rd party libraries.

    It's understandable that 15 year old programmers are more interested in Java-style padded-cell programming, but out here in research/commercial land, we've got existing code bases to consider - and Java just isn't that big enough an advantage to justify large, time consuming porting efforts.

    Make Java an ISO standard, and it could be taken half seriously. C++ is my bread and butter, and I won't be relying on Microsoft or Sun to improve my primary development environment. Roll on, C++0x!

  268. How about by Dancin_Santa · · Score: 1

    How about trimming the C++ language back a couple of years? How about then adding these "features" as libraries? How about NOT making the language any more complicated than it needs to be.

    Seriously, look at C for an example of a language that wasn't the ultimate solution to every problem, but ended up being so useful that it is used for just about every problem.

    Dancin Santa

    1. Re:How about by Dancin_Santa · · Score: 1

      It's obvious that C++ can be used without resorting to all the various features that it provides. Its design allows for it to be coded as "a better C" to full-fledged C++ and all points in between. However, once unwanted 'features' begin intruding into code, I begin to have a problem.

      Obviously, and this has been talked about to death, is namespaces. The idea is good, but is it really necessary? Are people really naming functions printf()? In fact, it is practices like renaming library functions that lead to unmanageable code (does this printf belong in the std namespace or the MyIO namespace?).

      Now I get to write using namespace std; at the beginning of all my programs. Wow, that's a huge improvement! Thanks C++ standards!

      Dancin Santa

    2. Re:How about by Dancin_Santa · · Score: 1

      But if your functions like "sort" belong to templatized classes, in what way are namespaces necessary?

      Dancin Santa

  269. Re:Who needs it... by Dancin_Santa · · Score: 1

    Sounds better than ++C++.

    Dancin Santa

  270. Re:thank you for your input. by Dancin_Santa · · Score: 1

    You're welcome AC.

  271. How about less? by AnotherBlackHat · · Score: 1

    ...in an effort to keep the language moving, avoid fossilization and avoid being overtaken by proprietary extensions. Suggested new features center around the standard library and include support for multi-threading and simple platform-independent systems abstractions (handles, TCP/IP, memory maps etc...)"
    Yeah, wouldn't it be terrible if the language remained static - then people could spend less time learning it and more time using it. Or horrors, imagine if somebody actually suggested that was already too much bloat in the language and we ought to work on /reducing/ the feature set to make it easier to learn, and more portable (and probably faster.)
    Just look at all the damage RISC did - it took years for the industry to overcome the prejudice against bloated, high gate count chips caused by low cost, ultra fast processors.

    Instead of thinking about what they can add to the language, maybe they should talk about what can be removed from it.

  272. How about less? by AnotherBlackHat · · Score: 1

    ...in an effort to keep the language moving, avoid fossilization and avoid being overtaken by proprietary extensions. Suggested new features center around the standard library and include support for multi-threading and simple platform-independent systems abstractions (handles, TCP/IP, memory maps etc...)"
    Yeah, wouldn't it be terrible if the language remained static - then people could spend less time learning it and more time using it. Or horrors, imagine if somebody actually suggested that was already too much bloat in the language and we ought to work on /reducing/ the feature set to make it easier to learn, and more portable (and probably faster.)
    Just look at all the damage RISC did - it took years for the industry to overcome the prejudice against bloated, high gate count chips caused by low cost, ultra fast processors.

    Instead of thinking about what they can add to the language, maybe they should talk about what can be removed from it.

  273. What About... by Popocatepetl · · Score: 1

    ...learning how to use what we have more efficiently? I guess programming languages have become better over time - I guess. Except C is still very fast (I didn't expect it to get slower, BTW) and Java is difficult to deal with when it comes to things like not echoing characters obtained from the keyboard to the console. You can always go lower level if you want.

    I think, insofar as programming languages are concerned, we should stop creating new puzzles to figure out and solve the ones we have. This is all a lot of opinion, though.

  274. Re:Judge language by thickness of its first book. by Curien · · Score: 2

    35 keywords to the language. 35! That's it.
    I agree... that's quite an accomplishment. C is a much smaller language than C++. Small is often desireable, but smaller != better.

    There are too many ways to do the same thing.
    You like C, but you complain of too many ways to do the same thing in C++?

    The language was released while still being developed.
    And C wasn't? There's K&R C. There's K&R2 C. There's C90. There's C90 with the 95 addendum. Now there's also C99.

    "Every C program is a C++ program"?
    No one has *ever* said that (no one who knew what they were talking about anyway). A simple case is the C statement:
    int* pi = malloc(sizeof(int));

    That's an illegal C++ statement! In C++, it would look like:

    int* pi = (int*)malloc(sizeof(int));

    (Please forgive my lack of new-style cast and my lack of namespace specification). Now, that C++-version is legal C, but it is *poorly written* C code. Any C programmer worth his salt would frown on a program littered with such statements.

    What *has* been said (accurately) is that all the C programs appearing in K&R2 were checked not with a C compiler, but with a C++ compiler.

    C is a good language. I happen to prefer C++.
    ________

    --
    It's always a long day... 86400 doesn't fit into a short.
  275. c+java=? by anshil · · Score: 1

    I've developed for both c(++) and java.

    I find c++ not satisfying, especially when compared to java language structure.

    However java didn't provide me the speed i wanted to have, nor did I want to be forced to garbadge collection.

    As I guess already several have before, I came out starting developing my own object oriented language, trying to merge c(++) and java the way I think it should be, the compiler at the actually translates to nice plain c code.

    http://dtone.sourceforge.net

    Well, I'm the only develeper and user of that language, however having quite some fun with it :) (Just keeping hoping that one day the lonlyness vanishes, and some other might enthusiated as well :)

    --

    --
    Karma 50, and all I got was this lousy T-Shirt.
  276. About time by Mr.+Fred+Smoothie · · Score: 1
    At the risk of starting a language flame war, I think that C++ is the best of the low-level languages. I think that the two things which have really given it a bad rap are 1) lack of really high quality implementations, and 2) anemic standard libraries.

    g++ has come a long way toward addressing the first (at least on those platforms that g++ supports well). This will hopefully address the latter.

    As a senior developer in a Java shop, one of the things I often ask interviewees is what they would miss most if forced to use C++ instead of Java. Anyone who answers anything other than 'the libraries' gets a big black mark next to their name in my book. This is really the only area where I think Java has a real advantage (not just a marketing advantage) over C++. If the latter language were to get decent standard abstractions for things like networking and and multi-threading (and the ever-increasing plethora of Java extensions), it would be much more attractive.

    Of course, because of the nature of standards comittees, Java will likely have genericity and direct management of memory before this new standards process actually produces anything <sigh>. Thus I'll have to program in this crappy language for the forseeable future. Oh well.

    --

    1. Re:About time by Mr.+Fred+Smoothie · · Score: 1
      What librraries are you referring to ?
      <references to several third-party libraries snipped>

      To quote myself: "If the latter language were to get decent standard abstractions ..."

      --

    2. Re:About time by Ayende+Rahien · · Score: 1

      As a note, CORBA is nearly dead, AFAIK.
      And since COM is an open standard (is DCOM, too?) which is used by non-Windows applications, I think that DCOM is a preferable alternative.
      GUI shouldn't be standard, I think, too different between platforms to get it right in one library.
      What I *really* want is to have more abstracted OS stuff, other than I/O.

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
  277. Re:C++ Frustrations by latchup · · Score: 1

    If the comitee was waiting for some compiler implementors to catch up, i think we wouldn't be able to use new standards before they outdate. The problem is not that compiler vendors do bad in implementing basic constructs, rather than there are hordes of programmers and companies, that implement new constructs on their own, resulting in a big mess of basically equivalent but incompatible proprietary extensions. It's not only nessecary to do things like that in order to "save" the language from practical extinction, but to clear up the mess that evolved from everyone implementing missing features.

  278. More standard librarys would be nice... by nick-less · · Score: 1

    a user interface, cross-plattform like swing, as fast like it should be... and most stuff java has, without the need for the virtual machine ..

  279. Wishlist... by shic · · Score: 1
    I'd like to avoid the holy-debate regarding weather or not C++ is a good language - I use it because it is well suited to many of the programs I wish to write... A well-written C++ program exhibits reasonable performance, and judiciously applying the available language features make for reasonably clear programs. There are better languages when comparing C++ against others, but being a ubiquitous C derivative makes it a good compromise for some projects (most notably server side service implementations). That said, there are many facets of C++ which I find infuriating, many of which could be easily resolved at the language level... The top 5 on my personal wish list include:

    1) Standardised ordinals - signed and unsigned - of known platform independent sizes - maybe we could have something like int8, int16, int32, int64, nat8, nat16, nat32 and nat64?
    2) A mechanism by which overflow can be detected when performing arithmetic on numbers (particularly for ordinals above)
    3) Run-time polymorphism - not only would this satisfy language zealots who claim it's impossible to implement the identity operation as a compiled C++ function - but would also make it possible to easily implement more flexible containers.
    4) A type system to constrain template instantiations. When I template a class with another, I want to be explicit about what behaviours my template parameter type should support, and to have this aspect of my program statically verified.
    5) An improved scheme for enumerations whereby new enumerated types can be easily inherited from existing ones.

    I've other things I could moan about, but I don't want to see C++ done an injustice - it performs well with many real problems, and I would like to see it developed in such a way as to eliminate as many of its idiosyncrasies as possible.

  280. Re:Who needs it... by robert-porter · · Score: 1

    C# will be standardized by the EMCA, to do this they need to have it run on at least 2 different platforms. I'm sure MS is evil and stuff, but spreading FUD about them is not good.

  281. Re:C++ Frustrations by Ayende+Rahien · · Score: 1

    I think that templates are fixed, I know that MFC are finished, design wise, the only updates will be bug fixes.
    They plan something new, which will be fully template based, which mean that they either have to go OS or fix the compiler.
    Guess what will they do?

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  282. C++ Wish List by Ayende+Rahien · · Score: 1

    I want Ada's style way to create and limit new types.
    Frex, in Ada, you can do this:
    Week is new integer 1..7;
    (This create a new type, named Week, which is an integer that can only accept values between 1 to 7)
    And the compiler will take care of making sure that the value is within viable range.

    Compare this to C++'s way of doing it:
    typedef Week int;
    (Week is a new name for int)

    This saves me the time checking what the variable contains, and actually make Week a new type.
    Here is how I would like it to be:

    create /* new reserved word, I'm afraid */ {
    week ( int (1-7) );// I don't care how you spesify ranges
    //only operators allowed, not functions
    };

    Yes, I *know* I can do it with a class, it's not the same.
    Ada also allows you to specify the size of the type you create (16,32,64,whatever) saving the need to check on each platform & compiler what size the basic stuff is.

    I think my method is more readable than Ada's way, at least to C's people.

    Borrowing from Ada is not a bad idea at *all*, IMO.
    I like C++ better than Ada, though, Ada's OO approach is a little strange, and it's syntax can drive me crazy sometimes.

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  283. Re:Nested Namespaces ? by Ayende+Rahien · · Score: 1

    Not if I've to use the :: operator.
    I *hate* this one.
    What is wrong with "." operator double duty, as it does in Java?

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  284. Re:Who needs it... by Ayende+Rahien · · Score: 1

    for (int i=0;i10;i++){
    //do stuff
    }
    for (i=0;i45;i++){
    //do some more stuff
    }

    Your method will break anything like this one.

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  285. Re:Who needs it... by Ayende+Rahien · · Score: 1

    There is a compiler switch in VC6 that fixes this, but it's off by default because some core header files in windows needs it.

    The standard changed, it's not VC's fault.

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  286. Re:Who needs it... by Ayende+Rahien · · Score: 1

    The *new* standard, several years ago, you were perfectly okay doing it.

    --

    --
    Two witches watched two watches.
    Which witch watched which watch?
  287. C++ Frustrations by ryants · · Score: 4
    Why are they talking about new stuff when old, standardised stuff doesn't even work yet? (I'm looking at you, MS Visual Crap++)

    That's one of the most annoying and frustrating things about C++... it isn't implemented properly and effeciently anywhere yet (g++ comes close, but still enough annoyances to be, well, annoying).

    Ryan T. Sammartino

    --

    Ryan T. Sammartino
    "Ancora imparo"

  288. Namespaces - I use a lot... by doubtme · · Score: 1

    Actually, I use namespaces a lot, mainly for logically seperating different modules of a program (timing, input, sound, graphics etc etc). True, I could do this another way - directorys or name prefixes perhaps, but namespaces is a lot more elegant in my opinion, and errors can be caught at compile time, rather than link time which leads to much more helpful error messages. JM2C

    --

    There's no $$$ in 'team'...
    www..--..net - for incisive, w
  289. The only thing I want by BinaryC · · Score: 1

    I've always wanted to do this:
    (int, int) foo (){
    return (1, 2);
    }
    void bar(){
    (a, b) = foo();
    }

    You could return both a string, and the length of the string at the same time (without having to do the sheisty bar = foo(&returnValue))

    --
    Ne Quid Nimis - All things in moderation
  290. Re:Language evolution by arturo_1 · · Score: 1

    C++ has never being a great language: 1) It's type system is a failure (same as pascal), incoherent and misconcepted design. Real and usefull type systems can be found in ML languages that can found almost errors at compiling stage. C++ and a lot of others are really UNSAFE programming languages. 2) No Garbage Colector. (more memory mistakes) 3) Bloated and useless declarations and syntax. Most C++ programmers only use a subset of the language. 4) Too low level (as Java and pascal) to be reliable in large proyects. 5) Low productivity, a large debugging and testing effort. 6) Low level of expresiveness and abstraction. The programmer waste a lot of time dealing with irrelevant stuffs. My conclusion: It is very difficult to C++ to evolve to a BIG language as the basement is poor. Also in the OO arena are much better languages as Dylan (not Java). Better still functional languages of the ML family as OCaml from (INRIA) also with OO support that reach quasi C++ speed and superior memory perfomance, 5-10 times more productive than C++ or Java.

    --
    Arturo Borquez
  291. I don't get it... by Flying+Headless+Goku · · Score: 2

    ...why am I drooling and breaking out in a cold sweat at the same time?

    abstraction -- overhead -- efficiency -- complexity -- standardization -- divergent implementations -- progress -- stagnation
    EAAARRGH! [head explodes]

    I can honestly say that this fills me with nothing but the purest ambivalence.
    --

    --
  292. post-ISO by Flying+Headless+Goku · · Score: 2

    Thanks to the recent success of distributed SETI data processing, we can finally move beyond mere ISO standardization to GSO standardization.

    The main problem will be translating everything into '''d''k'pogi, as per Galactic Standards Organization regulations.
    --

    --
  293. Finally! by eliz · · Score: 1

    A real language for real computers! This is the best news I've read on Slashdot for quite a while!!!

  294. Where can one get the C/C++ ISO standard? by Phunky+Monkey · · Score: 1

    Been looking around for the official ISO white paper for some time. Anyone know where it can be found? I'm looking for the end-all be-all reference to the language so I can settle all of the "no you can't" vs. "yes you can" disputes about the office/school.
    -------------------------

    --
    -------------------------
    It is the monkied monkey that monkies with another monkey's monkey. Monkey.
  295. Nested Namespaces ? by DeepMind · · Score: 1

    What about re-packaging the STL (and the extensions) with nested namespaces, like packages in Java (eg, std::sql::oracle::query) ? It may make the reading clearer, and could lead to better programming.

  296. New Language by drizuid · · Score: 1

    What about Microsoft's up and coming C# language that is supposedly arriving with .NET What effect will this have on any other programming languages? In my school, DeVRY Tech, they use Microsoft visual c++ and visual basic, i think they will continue to use whatever microsoft puts out..

  297. Language evolution by Darth.NET · · Score: 1

    Programming languanges evolve in different ways due in large part to the style and personality of their authors, owners or shepherds. Sometimes this happens "in committee," (Ada, PL/1, and C,) sometimes thru benevolent dictatorship (Java, C#) and sometimes it's organized anarchy (Perl, Python.) But there are common threads. A language escapes from its origins and begins to mature in the field. Many users (programmers) become adherents and start to demand updgrades. Different vendors fork the base to attract more followers than their competitors. Disgruntled users demand A STANDARD! Proposals for new features are submitted, debated and then assessed by public review. Much ado is made over backward compatibility. Finally a version # is stamped. Lather, Rinse, Repeat. These cycles taper off and eventually the language survives into old age or becomes extinct.
    What is critical is its adaptability to changing environments. Faster, smaller systems. Larger systems. More memory, less memory. More communications (network), and distibuted systems. Languages evolve to do more in this more diverse arena, but the better languages don't just get bigger, they refine, adapt and avoid asteroidal impacts. They exist in many ecological niches simultaneously. Consider Java and Perl in this regard. Java: J2SE, J2EE, and J2ME. Perl: Sys admin scripting, CGI-BIN and even real time video editing.
    I think it is interesting that after less than a decade, C++ is being labeled as fossilizing. While its parent C is still very vital. I feel this is because the effort to bolt on object orientation on a proceedural language core resulted in too many compromises and patches (multiple inheritance, const-ness etc.) Java, on the other hand, is evolving to pickup the best from C++ (assertions, generic programming.) Maybe it is time to let the horse expire.

  298. Delphi by mpaine · · Score: 1

    Take C, mix in C++ and sprinkle a bit of Java.. result, DELPHI..

  299. The futur of C++ by jeje · · Score: 1

    is just called Ada 95 !!! Good compilers available, real time oriented, security oriented...

  300. Re:What about....... by jeje · · Score: 2

    Just a few work about the language Naming : this is Ada and not ADA ! This is not an acronym, but named after Lady Ada, the first known programmer.

  301. Bjarne Stroustrup speaking in NYC by Daniel+Starin · · Score: 2

    Bjarne Stroustrup is speaking at Columbia University

    ACM @ Columbia Univeristy welcomes all ACM members and interested persons:
    April 26th, 2001

    JAVA BYTES

    OK, maybe not, but there are certainly alternatives. Far and away the
    most popular programming language in the world today is C++. Unlike many
    modern inventions, C++ has one clear creator: Bjarne Stroustrup.

    On April 26th, he's coming to speak at Columbia, thanks to Columbias ACM
    chapter with the support of the Department of Computer Science. This is a
    rare chance to hear one of the major figures in both computer science and
    the information economy speak about his creation.

    The topic will be C++ itself, and thus should be of particular interest to
    dedicated Java types, as C++ is the primary programming language of the
    "real world." Used a Microsoft product lately, either operating system or
    application? Written in C++. Played a computer game? Used any retail
    software whatsoever? Ditto. Tens of billions of dollars worth of
    software written in C++ are sold every year.

    So anyway, come and listen to the guy who wrote the worlds main
    programming language talk about programming. The talk will be aimed at
    intermediate-level computer science undergraduates. We promise that your
    mind will be stretched.

    Please go to our site: http://www.cs.columbia.edu/acm for directions to
    the lecture hall at Columbia U. where the talk will be taking place.
    Columbia U. itself is located at 116th and Broadway.

    -- ACM @ Columbia U.

  302. Re:Thanks Bjarne, but PLEASE LET IT DIE by BoP2 · · Score: 1

    Bjarne, C++ is without a doubt the masterwork of language design, but we just aren't up to it. Mastering C++ in all its beauty is simply beyond 99% of the programmers out there, even among those who have mastered the pointerish issues of C and the OO issues of Smalltalk independently. Its just too hard.

    For you maybe, but those of us who are not trying to write C and Smalltalk programs in C++ really like it. Powerful and flexible often means that it takes a while to get used to it. Generally it is also worth the effort.

    Keep up the good work Bjarne! :-)