Thread: Who needs C++

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    141

    Who needs C++

    I don't really like C++ although I've done my share of object oriented programming. My target languages for that, however, have been Java, D and even python. I do far more programming in C however, because I write a lot of numeric, math oriented software. C has a lot of limitations of course in terms of rapid prototyping, memory management and a lack of modern language constructs. C++, however, IMHO, suffers by being overly complex, difficult to understand and often the execution model, how it actually get's translated to machine code and what the actual program control structure is, is highly obfuscated. (Just watching all the crap that gets called behind the scenes for simple memory management is an eye opener.)

    So what are the real alternatives to a serious programmer who doesn't want to use C++, but likes the efficiency of C? After playing around with various development models I have come to find that the paradigm used in gaming development these days is quite powerful. The low level, number crunching code is written in C or even assembler and the high level logic and configuration logic is often left to an embedded scripting language such as lua. Lua is particularly nice for this, since it is easy to understand, powerful, reasonably fast, good for managing configuration tables (for which it was originally designed) and easily embedded since it is a modest size pure ANSI C program. Moreover with automatic interfacing tools such as SWIG, it's particular easy to marry the two languages.
    http://www.swig.org/

    For desktop applications I've also used Haskell as the high level language since it's actually quite efficient, and thus only requires the most low level number crunching to be performed in C and it has a nice C interface (though it has a terrible learning curve for those coming from C like languages.). So my question is, is this two language model, a scripting language + C, competitive with development in C++? Since I'm not a C++ programmer per se, I can't really compare the two approaches. I know a lot of this depends on the development environment as well, and perhaps that's where the strength of C++ really lies.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by SevenThunders View Post
    So what are the real alternatives to a serious programmer who doesn't want to use C++, but likes the efficiency of C?
    Hold your nose and do C++ anyway?

    I don't have a lot of languages under my belt and resisted C++ for a great length of time. But it does what it says, and over time that tends to win out.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by Dave_Sinkula View Post
    Hold your nose and do C++ anyway?

    I don't have a lot of languages under my belt and resisted C++ for a great length of time. But it does what it says, and over time that tends to win out.
    Fair enough. It's pretty easy to get into trouble reinventing the wheel. I just always hold out hope for something better. The cute thing about embedding lua is that you can still claim that your code is 100% ANSI C. That lua stuff is well, just some configuration text files, that's all. (I tried to sell this idea to at least 1 manager a while ago.)

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    As you said, D...

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by zacs7 View Post
    As you said, D...

    D is compelling. A native debugger would help however. I've also managed to mess myself up pretty badly in D because it's just too darn powerful. I went crazy with templates and mixins to try to achieve generic programming and wound up with something I couldn't debug if my life depended on it. It was one of those complex, self-referential tree like data structures, with a bunch of extra metrics hanging around to do some interesting optimizations. I ended up rewriting it in C and simplifying the algorithm a bit. The C has been unpleasant, but the debugging quite a bit more pleasant.

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    M$ needs C++ , in fact their kernel contains a lot of C++ (70% or something)
    has been unpleasant, but the debugging quite a bit more pleasant.
    Anyway, I dislike C++ and have just stuck with C (after moving from C++ back to C). However I find a growing number of opensource projects are in C++, especially games or GUIs. But I find C does everything I want it to (sometimes inline asm is required, but hey!). So in conclusion to my ramblings, your looking for a language other than C++?

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by zacs7 View Post
    M$ needs C++ , in fact their kernel contains a lot of C++ (70% or something)
    has been unpleasant, but the debugging quite a bit more pleasant.
    Anyway, I dislike C++ and have just stuck with C (after moving from C++ back to C). However I find a growing number of opensource projects are in C++, especially games or GUIs. But I find C does everything I want it to (sometimes inline asm is required, but hey!). So in conclusion to my ramblings, your looking for a language other than C++?
    I'm looking for an efficient programming paradigm. I include C, since it's hard to argue with the existing C infrastructure. (ie sell it to your boss or your client or your customer etc.) I have heard lots of hype about other languages and how productive they are, from lisp, eiffel, smalltalk and the various functional programming languages, but they tend to have a somewhat smaller user base and support group and they face a lot of resistance from people who hire software engineers (e.g. M$). It is a heck of a lot easier to do most programming tasks in Python, for example than it is in C. My experience with a scripting language targeting scientific programmers (Matlab) is that it is nearly a factor of 10 times faster to develop in Matlab than C (and it's probably 10 times slower to run!). The reason is due to a lot of built in specialized libraries, a lot of concise high level abstractions, immediate feedback from the interpreter without the compile and run cycle needed in C and the availability of a garbage collector to do your memory management.

    Well I'd like that kind of productivity as well as having the performance. That's why a mixed paradigm can get me part of the way there. Do the high level stuff in lua or python or Haskell et. al. and just use C when I need to optimize. It has worked for me on a couple of large projects.

    D is kind of interesting in that it's performance is competitive with C, it has just as many libraries as C does and a few more (it can call C libraries directly) and it has garbage collection. What it lacks is an interpreter and a debugger. Interestingly there are C interpreters, with Ch probably being the most highly developed. It's actually pretty productive if you know your C and has a garbage collector I believe. It's fatal flaw is that it has a horribly complicated binary interface to compiled C code and C libraries. Some attempt has been made to automate this, but it falls short I'm afraid.

    There is also the Hans Boehm garbage collector, written in C. Using that makes coding in C quite a bit easier, however there are potential issues for real time applications and as of yet there are no 64 bit versions for windows.

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318

    Question WTF!

    Ewww, what kind of a life form would revert back to C from C++, when you actually have a choice?

    No references - Eeek!
    No operator overloading - Egad!
    No exceptions - Oh teh noes!
    No templates - Oh crap!
    No RAII - OMFG!
    No std library - AAARGH!
    I can't take it any more ... Somebody make this madness stop!

    Seriously, who wants to go back to the dark ages?!


    Yes D is beginning to look quite attractive... Someone just needs to write a nice IDE and debugger like MSVC++.
    Or Delphi FTW!

  9. #9
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by iMalc View Post
    Ewww, what kind of a life form would revert back to C from C++, when you actually have a choice?

    No references - Eeek!
    We have pointers. Just as functional, although slightly less convenient from a syntactic standpoint.

    No operator overloading - Egad!
    It's not object oriented -- this is just the way it is.

    No exceptions - Oh teh noes!
    We have setjmp/longjmp.

    No templates - Oh crap!
    Macros can be used quite creatively.

    No RAII - OMFG!
    Why not? Specify the interface however you want.

    No std library - AAARGH!
    WHAT? No standard library in C? That's purely insane.

    Seriously, who wants to go back to the dark ages?!
    If you can't write functional code without the features of C++, that's a deficiency of your skills, not the language you use. You should be able to make the machine do what you want regardless of the language forced on you.

  10. #10
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Me thinks your a Windows programmer then?

    For starters I was doing a lot of kernel recompiling at the time, it's nothing to do with the dark ages.

    There are plenty of D IDEs (no dedicated ones I know of however).

    Where do you think the C++ standard library came from...? cstdio, cstdlib... the list goes on.

  11. #11
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by iMalc View Post
    Ewww, what kind of a life form would revert back to C from C++, when you actually have a choice?

    No references - Eeek!
    No operator overloading - Egad!
    No exceptions - Oh teh noes!
    No templates - Oh crap!
    No RAII - OMFG!
    No std library - AAARGH!
    I can't take it any more ... Somebody make this madness stop!

    Seriously, who wants to go back to the dark ages?!


    Yes D is beginning to look quite attractive... Someone just needs to write a nice IDE and debugger like MSVC++.
    Or Delphi FTW!
    It's kind of funny but, I'd actually prefer to program in a good macro assembler than in C. It's just that assembly isn't portable. The performance and the complete control you have over the machine is quite compelling. Higher level constructs are possible with a good library (e.g. http://webster.cs.ucr.edu/AsmTools/HLA/index.html)

    I also prefer programming at the complete other end of the spectrum, in python, ruby or in a functional programming language like Haskell. In Haskell there are abstractions that you could only dream about in C++ or even D. Class types, high order functions, currying and parameterized types are quite a bit more powerful and expressive than object orientation, but that's a whole other debate topic.

  12. #12
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by SevenThunders View Post
    I also prefer programming at the complete other end of the spectrum, in python, ruby or in a functional programming language like Haskell. In Haskell there are abstractions that you could only dream about in C++ or even D. Class types, high order functions, currying and parameterized types are quite a bit more powerful and expressive than object orientation, but that's a whole other debate topic.
    Why do we have to debate it at all? It's all just programming. If you love Python, more power to you -- it's my favorite language, and having programmed in C for over 15 years, that's saying a lot. But it's just a programming language for crying out loud...

  13. #13
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Some people just haven't seen the light...
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  14. #14
    Registered User
    Join Date
    Apr 2007
    Posts
    141
    Quote Originally Posted by brewbuck View Post
    Why do we have to debate it at all? It's all just programming. If you love Python, more power to you -- it's my favorite language, and having programmed in C for over 15 years, that's saying a lot. But it's just a programming language for crying out loud...

    For me I just want to find out what works for other folks. How are they productive? Is there a way to do this stuff better and faster? It's a legitimate question and not necessarily just a matter of opinion. There have been some studies done which justify your use of Python as a way to improve productivity and correctness. I've had the pleasure in recent years of working on an unbelievably complex system that delivers broadband wireless internet to the home. There were plenty of difficult signal processing, hardware, DSP and other issues to overcome. But what was consistently the schedule drag and highest risk component of the whole project? The multi-million line control software, MAC layer and above, that ran the system. Moreover the software sucked up the most man years, even though initially we thought our design was really about featuring our cool algorithms and systems engineering smarts.

  15. #15
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by SevenThunders View Post
    But what was consistently the schedule drag and highest risk component of the whole project? The multi-million line control software, MAC layer and above, that ran the system. Moreover the software sucked up the most man years, even though initially we thought our design was really about featuring our cool algorithms and systems engineering smarts.
    Sounds like you guys have some serious maintenance issues. Look, I don't want to denigrate your abilities or anything, but most code sucks. The language has much less to do with it than the programmers working on the project.

Popular pages Recent additions subscribe to a feed