Another esbo thread hijack trying to start a flame war

This is a discussion on Another esbo thread hijack trying to start a flame war within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by behzad_shabani thank you, I don't need C based text editor, I want to write a C++ class ...

  1. #1
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794

    Another esbo thread hijack trying to start a flame war

    Quote Originally Posted by behzad_shabani View Post
    thank you, I don't need C based text editor, I want to write a C++ class based text editor.

    I have a question. how could I get a line into a std::string variable?
    C++ is really C 'under the bonnet'

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    Quote Originally Posted by esbo
    C++ is really C 'under the bonnet'
    No, it is not. At least for now, C++ is not a true superset of C, and neither are C++ programs compiled to C programs (even though the first C++ compiler actually did that).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by laserlight View Post
    No, it is not. At least for now, C++ is not a true superset of C, and neither are C++ programs compiled to C programs (even though the first C++ compiler actually did that).
    Well C produces assembler code as does C++ at the end of the day.
    Anything in C++ can be inplemented in C, it might take a few more lines, and C++ will
    do some of the work and 'syntax checking'.

    I certaintly C++ *could be* C 'under the bonnet'. Yes once you have your first C++
    compiler written you can write more complilers in C++. It's not likely you would write it
    from assembler anyway.

    I think my program actually use a lot of C++ concepts, but I had to implement them in C.
    A window might be a class for example. I had different types, fixed size, display only etc..
    but they were all based upon one multipurpose window, with usually functionality taken away. Of course I have to do the checking if I am going to modify a display only window
    not the compiler. I just don't try to modify it, that's all.
    Some of it is actualy like Basic too. For example you can add strings I believe eg, S1+S2+S3 which is basically a strcat and a strcpy.

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,667
    I think you're putting the focus on the wrong element (how C++ is compiled) rather than accepting that C programs are treated differently by C++ compilers. Use a C99 feature, and compiled as C++, your program could fail to compile. Even if you don't use C99 stuff (or by some miracle C99 stuff is proffered by your C++ compiler vendor), you have to wrestle with C++'s type system to get it compilable. You can't even do

    p = malloc( size );
    without a complaint.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    Quote Originally Posted by esbo
    Well C produces assembler code as does C++ at the end of the day.
    Anything in C++ can be inplemented in C, it might take a few more lines, and C++ will
    do some of the work and 'syntax checking'.
    In this case, it would be more important to consider that C programs, if they are not already valid C++ programs, can be modified to become valid C++ programs, since behzad_shabani intends to write a C++ program but you have a C program that does something similiar.

    However, I do not see how this makes C++ "really C 'under the bonnet'".

    Quote Originally Posted by esbo
    I think my program actually use a lot of C++ concepts, but I had to implement them in C.
    It may then be better to give behzad_shabani ideas on the design rather than the implementation of the program.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    2,027
    I think the main point of comparison is that C++ is a generic object oriented language, whereas C is imperative/procedural. As a result of this the process of designing programs in these two languages is drastically different.

    Now sure, you can write procedural programs in C++, and you can contort C into supporting object oriented and generic programming, but that not how people generally use the languages.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Quote Originally Posted by esbo View Post
    I think my program actually use a lot of C++ concepts, but I had to implement them in C.
    So why not use C++, where it's available in native form, instead of trying to hack into C?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,231
    At least for now, C++ is not a true superset of C, and neither are C++ programs compiled to C programs (even though the first C++ compiler actually did that).
    A few compilers still compile C++ to C. (The version of Comeau I have does this. An embedded compiler, which doesn't support templates, I use does this.)

    Anything in C++ can be inplemented in C, it might take a few more lines, and C++ will do some of the work and 'syntax checking'.
    If you don't consider static polymorphism in all its glory then you are only comparing a subset of C++ to C.

    The C macro processor simply isn't capable of all the same feats as templates. (As the C++ template mechanism isn't capable of all the same feats as macros.)

    Your "can be implemented in C" may as well be "can be implemented in $(language)".
    Your "few more lines" may as well be "infinitely many".

    For all the work you would have to perform manually your "C++ is really C 'under the bonnet'" may as well be "C++ is really assembler 'under the bonnet'".

    So while the statement may be true, it is meaningless.

    Soma

  9. #9
    Registered User
    Join Date
    Apr 2006
    Posts
    2,027
    Quote Originally Posted by phantomotap View Post
    The C macro processor simply isn't capable of all the same feats as templates. (As the C++ template mechanism isn't capable of all the same feats as macros.)
    The only template feat I can think of than can't be done with macro's is recursive templates.

    You probably need to explicitly declare every instance and do away with type safety. And debugging would be virtually impossible. But In principle I submit it could be done.

    Not that anyone should every try to do such a thing.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,302
    I just had the idea yesterday of porting std::vector to C. At first I thought that you'd simply need to pass the vector as a parameter rather than it being the this pointer. But there's WAY more to it than that. "A few more lines" just wont cut it. You've got to also provide to the vector a function that performs each of construction, copy-construction, copy-assignment, destruction. You've got to give it the size of the object contained, and get the type in there somehow too, probably via macros. The syntax will look awful due to no operator overloading, and overall, nobody is going to want to use it.

    It'd be like saying that you could clean a large mansion's floor with a toothbrush. Well no actually, you can't. First it'd take more than one toothbrush, and second, before you get half of it done, the other half has gotten dirty again.

    C really cannot do what C++ can do. Therefore C++ is much much more than C.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  11. #11
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    To be honest with you C++ comes across to me as a lot of mumbo jumbo and waffle that I don't need to write a program. There is nothing there I need nor want.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by esbo View Post
    To be honest with you C++ comes across to me as a lot of mumbo jumbo and waffle that I don't need to write a program. There is nothing there I need nor want.
    And you are obviously not interested in writing large, maintainable and reliable software.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    How come?
    What makes C++ so special from C?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    To be honest with you C++ comes across to me as a lot of mumbo jumbo and waffle that I don't need to write a program. There is nothing there I need nor want.
    Are you really that clueless?

  15. #15
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,231
    The only template feat I can think of than can't be done with macro's is recursive templates.
    O_o

    This rules out recursive templates, mutually recursive templates, nested templates, and determinism through template expansion.

    So... yea... saying that macros are capable of everything templates can do except what they can't do isn't particularly useful.

    To be honest with you C++ comes across to me as a lot of mumbo jumbo and waffle that I don't need to write a program. There is nothing there I need nor want.
    O_o

    So? It is your problem if you want to stay with C. That doesn't mean that C++ is "C under the hood". If you didn't have this ridiculous and naive opinion you might wish to use C++.

    Soma

Page 1 of 5 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple thread object model (my first post)
    By Codeplug in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2004, 10:34 PM
  2. Replies: 2
    Last Post: 04-12-2004, 01:37 AM
  3. Closing thread handles from within
    By Sang-drax in forum Windows Programming
    Replies: 6
    Last Post: 09-26-2003, 12:18 PM
  4. How to make a thread sleep or std::recv timeout?
    By BrianK in forum Linux Programming
    Replies: 3
    Last Post: 02-26-2003, 09:27 PM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 01:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21