Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: DaveP on January 25, 2003, 02:23:08 PM

Title: Anti C++ sentiment?
Post by: DaveP on January 25, 2003, 02:23:08 PM
Folks

I have noticed a disturbing increase in the number of items I have read which dismiss C++ out of hand for esosteric reasons.

I guess this comes from the fact that most system programming interfaces are inherently procedural but probably also for the fact that if you do not understand the underlying semantics of C++ ( e.g. when to use virtual, what a copy constructor does ) then you are swimming in a very very big pond.

I happen to like many languages and have no particular C++ bent ( although pretty experienced and classified as "expert" by the skills board at my company - but then so is the vending machine repair guy ) but what exactly is it that people don't like?

I was told that the "MorphOS community hate C++" which seemed a bizzarre statement so can someone confirm/deny any particular clustering of anti-C++ sentiment there?

I get told a lot that Java is superior to C++ which I find amusing given how much of Java is implemented in C++ and is in fact a "crippled" C++ with a garbage collection thread ( easy to implement in C++ even if you don't implement smart/auto-pointers )?

What is behind the phobic reaction or am I seeing more there than I need to?

To me C++ is a fine language, it is a language for creating further dialects of C++ as much as for creating tools.

Thoughts? Comments or just so much philosophical bollards?
Title: Re: Anti C++ sentiment?
Post by: Darken on January 25, 2003, 03:11:50 PM
That's so strange to read in 2003 that people still don't like C++ and prefer C.

Several years ago, I used to program in C only, and had silly  misconceptions about C++. I thought it was a super high level hidding everything to the programmer and I used to hate it.

Well,  now I do know how to code in C++, and I just have to say that I love this language. The "C++" is a real good name : C language, but with cool extensions which let you design stuff more easilly. And I can't put up with C anymore  :-D

It's so great to maintain a clean  object oriented program coded in C++.  BeOS and some other OS projects show a  very good C++ programing interface. Reading code made for those OS is a real pleasure.

I think the "anti C++" statement just come from people who don't really know C++ (just as me when I used to know C only). Moreover most people around me who used to code in C only and who learnt C++, just can't come back to C anymore.
Title: Re: Anti C++ sentiment?
Post by: iamaboringperson on January 25, 2003, 03:13:04 PM
i love C++!

Quote
What is behind the phobic reaction or am I seeing more there than I need to?

probably the steep learning curve.
possibly also the feer it might be less efficient than C, i once thought that until i read some book on c++ efficiency or a c++ faq or somthing, could be because of its seemingly highrachical design
perhaps also people arent used to thinking OO, procedual is easy, but for some OO is bit daugnting?

in relation to the amiga, i feel that i dont use C++ so often because there is no native amigaos support for it, if there was somthing a bit more like borland C++ builder, i would definently use it more!
amigaos includes etc... need to be re-done in a C++ OOP way... that would definently get more support
 :-)
Title: Re: Anti C++ sentiment?
Post by: DaveP on January 25, 2003, 03:39:03 PM
"probably the steep learning curve."

Thats true, but people can learn a useful subset
like they tend to do with other languages.

I mean obvious concepts are:

BASIC
types and variables
conditionals and loops
i/o
structures

MEDIUM
class
constructor
destructor
methods
instance variables

Even without data-hiding inheritance, references, polymorphism you have a powerful structure there to get going with.

Anyway the first AmigaBOOK for publication is ready and we are submitting it to Addison Wesley Monday!


Whats the subject? C++ for Amiga Users.




Title: Re: Anti C++ sentiment?
Post by: iamaboringperson on January 25, 2003, 03:44:32 PM
Quote
Anyway the first AmigaBOOK for publication is ready and we are submitting it to Addison Wesley Monday!

what, an actual hardcopy book!
wow! if i found a NEW amiga specific programming book i would probably buy it immediatly!
especialy if it were about C++ on the amiga!
 :-D  :-D  :-D  :-D  :-D  :-)  :-)  :-)
Title: Re: Anti C++ sentiment?
Post by: Eric_Z on January 25, 2003, 03:45:01 PM
@ DaveP

"...Anyway the first AmigaBOOK for publication is ready and we are submitting it to Addison Wesley Monday!..."

That's great  but who are "we" (you and who?) ?
Title: Re: Anti C++ sentiment?
Post by: DaveP on January 25, 2003, 03:46:49 PM
Well they have to send it to a "reader" first, then do sample manuscripts for checking by us but yes, the idea has been accepted in principle.

Keep your fingers crossed for us! If publishing doesn't happen then it will be available in free PDF,
BookManager, PS and HTML form on AmigaBooks.

Title: Re: Anti C++ sentiment?
Post by: DaveP on January 25, 2003, 03:48:07 PM
@Eric

Does the name Mark Roberts mean anything to you?
Title: Re: Anti C++ sentiment?
Post by: iamaboringperson on January 25, 2003, 03:53:38 PM
Quote

DaveP wrote:
Well they have to send it to a "reader" first, then do sample manuscripts for checking by us but yes, the idea has been accepted in principle.

Keep your fingers crossed for us! If publishing doesn't happen then it will be available in free PDF,
BookManager, PS and HTML form on AmigaBooks.


i hope they do publish it! i have all the ARKRMS 3rd edition, + some of the 2nd edition! now i need some decent documentation for all the new features

what exactly will be covered in the book?
how in depth will the amiga stuff be?
what libraries/devices?
Title: Re: Anti C++ sentiment?
Post by: Eric_Z on January 25, 2003, 03:54:33 PM
@DaveP

Well now it does mean something to me.
Title: Re: Anti C++ sentiment?
Post by: DaveP on January 25, 2003, 04:00:56 PM
"what exactly will be covered in the book?"
How to use StormC, HiSoft C++, GCC to build executables, libraries and more.
C++ introduction.
C++ recommended design patterns ( where the auto-pointer code is also republished from the other topic ).
Taking advantage of the Amiga

how in depth will the amiga stuff be?
How to implement:
    multi-tasking ( exec tasks, dos processes, signals etc )
   message passing
   intuition for newbies
   basic graphical operations
   writing a commodity
   app icons and other strange stuff
   interacting the user
   TCP/IP networking
   security
   device I/O

what libraries/devices
   oh man. :-D Not everything by a long way but enough to get going!

We will not be allowed to publish under the name "amigabook" because it is considered a trademark problem. So authors full names.
Title: Re: Anti C++ sentiment?
Post by: cycloid on January 25, 2003, 04:01:02 PM
i use m$ visual C++ on the PC for game coding and it's bloody nice being able to browse through your class tree and go to the playerclass->Killed( attacker ) type function just by clicking on it!

if there was (or will be)  something like that (or even borlandey) for A1 then i'd be forking out big bucks for it. ASAP!

as for C vs C++ i think that people should try both, i have no trouble going back and forth. infact i recently just started playing witht the Quake 2 source, it's C and a bit oddly implimented , but i rather like it! But then i had to convert my class based water simulation code into C and hook that in, took a while :-)

Title: Re: Anti C++ sentiment?
Post by: EntilZha on January 26, 2003, 12:53:19 AM
> That's so strange to read in 2003 that people still don't like C++ and prefer C.

Hey, if you look at the Windows programming community, they prefer VisualBasic over C

Most people still fall for the myth that C++ adds too much overhead.
Title: Re: Anti C++ sentiment?
Post by: EntilZha on January 26, 2003, 01:04:11 AM
> i love C++!

Me too.

> perhaps also people arent used to thinking OO, procedual is easy, but for some OO is bit daugnting?

The way C++ handles OO (i.e. structures with data and functions in one entity) is really more of a procedural approach than an OO approach.. That's why I think C++ is in fact relatively easy to learn when you know C...

> amigaos includes etc... need to be re-done in a C++ OOP way... that would definently get more support

The problem with C++ in the system is that it can't be done without locking out other languages, i.e. if you have a C++ interface, you can't use it from C without troubles..

Plus, you have the non-standardized way that name mangling and object layout is handled...
Title: Re: Anti C++ sentiment?
Post by: csirac_ on January 26, 2003, 01:18:43 AM
@cycloid:

Check out Anjuta on Linux. I hate MSVC :) The only real feature I would like in Anjuta that MSVC has is the class/method suggestion drop-down box-as-you-go sorta thing. But Anjuta absolutely rocks in every other respect!

BTW how does such an "industry standard" tool have such ABSOLUTE ####e printing support??! My options are, after clicking "print" from the file menu: OK, Cancel. WTF? I wanted to print some code syntax highlighted with page numbers and filename in the header. I ended up using the freely available Bloodshed DEV-C++ package for WIN32 (I didn't have access to my Linux box at the time).

I would love to learn C++ properly but haven't got around to it... think I might do a wxWindows project. wxWindows looks cool; I think it needs an AmigaOS4 port ;)

- Paul
Title: Re: Anti C++ sentiment?
Post by: iamaboringperson on January 26, 2003, 03:24:06 AM
@EntilZha

Quote
The way C++ handles OO (i.e. structures with data and functions in one entity) is really more of a procedural approach than an OO approach.. That's why I think C++ is in fact relatively easy to learn when you know C...

i think you may be a bit confused as to what OOP is all about?
data and methods put together, called a class, is probably the main advantage of OO, you cant have and OO language without classes & objects!
java is just another OOP language that also has classes and objects
that is what OOP is all about!
Quote
The problem with C++ in the system is that it can't be done without locking out other languages, i.e. if you have a C++ interface, you can't use it from C without troubles..

what i acctually mean, is that you could have both c++ & C includes, the C ones would form the basis for includes for other programming languages
Quote
Plus, you have the non-standardized way that name mangling and object layout is handled...

?
Title: Re: Anti C++ sentiment?
Post by: Fozzy on January 26, 2003, 03:51:05 AM
I have noticed that people tend to attack or dismiss things that they do not understand. I can understand that "C" is a better selection at the system level, since overhead required by the VMT and extra constructs tend to produce larger and (a little) slower binaries. However, regardless of the language, it has been shown that good object oriented design princples produce extensible, robust, reusable and reliable software. To dismiss or claim hatred of "C++" seems narrow minded.
I prefer java when perfomance is not a consideration, but "C++" has been the tool for me when speed is required by the application.  
Title: Re: Anti C++ sentiment?
Post by: Waccoon on January 26, 2003, 08:10:24 AM
I've never used C++, and I'm just a casual programmer, so I can't say too much about the difficulty curve.  What I think most people are griping about is using OO code when it's not needed.  C++ programmers really want to use OO design for everything when a simpler C program will do it just as well.

That's a coder dicision.  Good programmers know to use a language that fits the task.  I really don't know what happens when you try to mix C and C++ together.  I presume that's a bad thing to do?

All I know is, when I complile a C program with a C++ compiler, the program turns out huge.  I mean, just for fun I wrote Hello World in MSVC with default values, and it compiled to over 250K.  WTF?  Or is that just because it's Microsoft?
Title: Re: Anti C++ sentiment?
Post by: DaveP on January 26, 2003, 08:27:30 AM
Quote

That's a coder dicision. Good programmers know to use a language that fits the task. I really don't know what happens when you try to mix C and C++ together. I presume that's a bad thing to do?


Not at all, mixing C and C++ is half the fun of C++. The freedom of both languages. So the fear is the OO bigot view of the world - everything is an object! I understand a bit more now.

Design patterns should be applied where they are best suited - this includes OO.

Oh and the compiler bloat, that IS because of the compiler implementation and not the language.
Title: Re: Anti C++ sentiment?
Post by: JetFireDX on January 26, 2003, 10:20:58 AM
My problem with C/C++ is simply the learning curve involved. I don't have time to devote to picking up the language when a much simpler solution could be prodiced from something like BASIC. But then, computers don't ship with easy languages like BASIC anymore, so not everybody gets the pleasure that comes from creating, regardless of the lang used. Mostly, my programming habits are just proof of concept types of things...I don't usually care how fast I get something done, so long as the desired effect is created. I figure if I really created something fantastic, I would then be motivated to learn C++ and recode it. I guess I also don't understand what makes object oriented languages special. Ultimately, I would like to see a language so easy to use there was very little learning curve to it, but mastering it would take time. Also, with so many intelligent people programming in the world nobody has been able (or wanted to) come up with a fast (running) easy to learn and understand language? (Maybe something that parses natual language using a set of keywords, and then converts it to C or C++?) To me, I see it as being a painter in ancient times as to being a painter now. Way back when, you had to have the skill to make your own paint, canvas and tools....now you can buy these things freeing you to simply be creative, and not have to put in hours or days of prep work. Thats what I think it should be about, being creative, not difficult.
Title: Re: Anti C++ sentiment?
Post by: EntilZha on January 26, 2003, 11:26:15 AM
> i think you may be a bit confused as to what OOP is all about?

No, not really ;)

OO means objects that have data and methods. Methods are sent from object to object and the object manipulates it's data.

However, in C++, you have more of a procedural interface.

In C, you write do_something(object);
In C++, this becomes object->do_something();

That's a lot less OO than for example smalltalk...

> what i acctually mean, is that you could have both c++ & C includes, the C ones would form the basis
> for includes for other programming languages

Include files wouldn't be enough... there would have to be a class framework as well...

About the non-standardized way of name mangling and object layout:
Every compiler is free to implement name mangling in any way it sees fit. There is (or better was) no standard. So if the system is using a C++ framework, the system would have to define the name mangling, and all compilers would have to implement that...

That's the problem BeOS has: They have their system interfaces as C++, so you were forced for some time to use the BeOS compiler... There's a gcc variant in the meantime, though...
Title: Re: Anti C++ sentiment?
Post by: SlimJim on January 26, 2003, 12:48:25 PM
Very good to hear about the AmigaBook (or whatever it will be called). Once publication is confirmed, this should be put out as news.
.
SlimJim
Title: Re: Anti C++ sentiment?
Post by: Cymric on January 26, 2003, 01:18:05 PM
Quote
DaveP wrote:
Anti-C++-sentiments, why?

I think a quote from Stroustrup himself is in order here: 'C makes it easy to shoot yourself in the foot. C++ makes it harder, but when it does, it blows away your entire leg.' It is indeed easy to abuse C++, or just see the language as a better C. So why would you bother with it then?

I myself don't use C++ for the simple reason that my programs aren't big enough to profit from OO-ness. They would just end up to be same modules, only now embedded in a class architecture. I also have developed a very robust set of input, output, memory handling and error propagation routines, with clear interfaces. You could say I've already programmed in an OO fashion. C++ has a few things going for it (although if you read some of the criticisms on the net, you have to wonder), but I simply haven't felt limited by what C offers me. That said, I think that for many people it's just the fear of tacking on a runtime library to resolve some of the more advanced features. I used to think about performance loss too---now I simply buy a faster CPU  :-P .
Title: Re: Anti C++ sentiment?
Post by: Treke on January 26, 2003, 03:25:04 PM
Hi folks

With OO I mean polymorphism (Wasn't ment as an allusion on morphos, Thomas ;)) ). That's the tool it gives to me.  
 I'm sorry to say that here, but it seems to me that C# is nicer than Java (even with these delegates, which according to James Gossling, break the OO principle).   I think C++ will slowly retire (but not entirely) when everybody becomes more negligent to the the performance aspects of SW. The process has started. Even when it is an OO  language which gives a developer the greatest freedom.

re

Treke
Title: Re: Anti C++ sentiment?
Post by: DaveP on January 26, 2003, 03:54:33 PM
@Treke
Quote

I think C++ will slowly retire (but not entirely) when everybody becomes more negligent to the the performance aspects of SW. The process has started. Even when it is an OO language which gives a developer the greatest freedom


Simplified dialects of C++ will in my view become more popular over time. C will never die, it is too tied to the heart of Win32 and Unix. Java will not die as it is used at the core of many enterprise days ( e.g. WebSphere ).

I see the future as a simplified C++ and complex C++. C++ will be taught in simplified form with auto-pointers and single inheritance ( and pure virtual classes for interfaces ). With perhaps a decent class library with reasonably rich function like the Java class library.

No, I think C and C++ are here to stay, Java too. C# will become a nother VB - something that there is a market for and people use but it will not be the be all and end all dominant spirit of the marketplace.

Perhaps I am wrong, I hope not.

As for SystemjProgramming, yes I can see that the naming issues with classes makes it difficult anyway. In theory you could have a structure with function pointers to class methods and all that but it would be a nightmare.

Hence there will always be a place for procedural C/C++.

IMVHO of course.
Title: Re: Anti C++ sentiment?
Post by: mdwh2 on January 26, 2003, 05:27:54 PM
Quote

All I know is, when I complile a C program with a C++ compiler, the program turns out huge.  I mean, just for fun I wrote Hello World in MSVC with default values, and it compiled to over 250K.  WTF?  Or is that just because it's Microsoft?

But what are you comparing to? And is it the exact same hello world program (ie, still using stdio and no iostream)?

Using Amiga gcc, compiling the same hello world program produces a program size 2704 bytes in C mode, and 2716 bytes in C++, so hardly an unreasonable difference, and I guess what you get is just because it's Microsoft.

In Borland CBuilder, compiling a Hello World program using stdio/printf takes 54272 bytes, but using iostream/cout takes 111616 bytes. So there is a significant difference here, but down to using different libraries, and not necessarily just that it's C++.
Title: Re: Anti C++ sentiment?
Post by: Treke on January 26, 2003, 05:38:19 PM
@DaveP
Quote
No, I think C and C++ are here to stay, Java too. C# will become a nother VB - something that there is a market for and people use but it will not be the be all and end all dominant spirit of the marketplace.

I think oposite, C# has future, because:
1. From the language point of view it is an improved Java, for M$,  years of experience with Java were enough to see, what to improve in desing of new, similar language
2. It is an inherent part of .NET, which is a big movement towards real distributed SW systems (without the COM Hell). Don't missunderstand me, as an old amigan, I do NOT like M$, but some things I have to admit ;). The MS's millions that went into research must yield somewhere.
3. It has one of the best IDE's
4. It has a giant with money behind

Off course Java will not die.

Quote
Perhaps I am wrong, I hope not.

I also hope, that  you are not wrong.

Quote
Hence there will always be a place for procedural C/C++.

Sure.

re

Treke
Title: Re: Anti C++ sentiment?
Post by: N7VQM on January 26, 2003, 07:43:46 PM
Quote

Waccoon wrote:

All I know is, when I complile a C program with a C++ compiler, the program turns out huge.  I mean, just for fun I wrote Hello World in MSVC with default values, and it compiled to over 250K.  WTF?  Or is that just because it's Microsoft?


I wrote two Hello World! programs using printf and cout in MSVC6.  There were exactly the same size:  28,672 bytes.  Perhaps you need to set the active config to release?  Debug config always creates large files.
Title: Re: Anti C++ sentiment?
Post by: Karlos on January 28, 2003, 09:33:02 AM
I love C++. I've written tons of code that is fast, compact, tidy and efficient in C++ that could not be written in C without great effort and the risk of introducing tons of bugs.

People who dismiss the language out of hand, especially on performance reasons are living on another planet.

To all the C coders, there's no non-trivial C program that could in no way benefit from some of C++'s features. Even without classes, there's stuff in there that's damn handy, such as function name overloading, declarations as statements, references to name but a few...

Title: Re: Anti C++ sentiment?
Post by: on January 28, 2003, 10:49:26 AM
I LOVE C++!
I am software developer and C++ is my favorite language. The more I learn about it the more I love it. And more languages i learn to program in, the more I recognize how much C++ is better than anything else. (Have you ever programmed in PowerBuilder? It's horrible.)
I like Java too, espacially this reflection thing and the ability to have native 64 bit integer support.
But as DaveP stated you can create your own dialect of C++ and implement other datatypes.

The only thing I would prefer is an ISO norm for variable names that says: [vartype][bits] e.g. int8, int32, int64 instead of char, short int, long, etc. and an extended support for string objects so that companies such as M$ don't create their dialects in their IDEs and you have a lot of work to be IDE independent. The CString class in the MFC is a good string class, but as I want to be as platform independent as possible when programming GUI apps I must do workarounds to read strings from controls when not using CString but the string class of the STL.

Title: Re: Anti C++ sentiment?
Post by: on January 28, 2003, 10:58:17 AM
@Waccoon:
Quote

mdwh2 wrote:
Quote

All I know is, when I complile a C program with a C++ compiler, the program turns out huge.  I mean, just for fun I wrote Hello World in MSVC with default values, and it compiled to over 250K.  WTF?  Or is that just because it's Microsoft?

But what are you comparing to? And is it the exact same hello world program (ie, still using stdio and no iostream)?

Using Amiga gcc, compiling the same hello world program produces a program size 2704 bytes in C mode, and 2716 bytes in C++, so hardly an unreasonable difference, and I guess what you get is just because it's Microsoft.

In Borland CBuilder, compiling a Hello World program using stdio/printf takes 54272 bytes, but using iostream/cout takes 111616 bytes. So there is a significant difference here, but down to using different libraries, and not necessarily just that it's C++.


It also depends on which compile method you use. If you compile your program in DEBUG mode, the source code will be filled with debug trackings by the M$ C++-compiler. Try compiling your project once in DEBUG mode and once in RELEASE mode and you'll see the difference.
As mdwh2 already said, it also depends on which libraries you use. When I include stdlib, stdio and iostream the programm is much bigger than when I only include iostream, because the include macro, includes the headers into the code before compiling it and than your libraries have to be linked and as result you get binary code that's much bigger than your simple C++ source code file.
Title: Re: Anti C++ sentiment?
Post by: trgse on January 28, 2003, 11:01:47 AM
Quote

1. From the language point of view it is an improved Java, for M$,  years of experience with Java were enough to see, what to improve in desing of new, similar language
2. It is an inherent part of .NET, which is a big movement towards real distributed SW systems (without the COM Hell). Don't missunderstand me, as an old amigan, I do NOT like M$, but some things I have to admit ;). The MS's millions that went into research must yield somewhere.
3. It has one of the best IDE's
4. It has a giant with money behind


all those arguments could be put towards VB too and no real programmer likes that one and it surely hasn't taken over the program development scene

Microsoft even stated that Windows would be made with VB one day (well that explains a lot actually).

and one reason why C# won't be a big language is ...
MicroSoft, not even their own developers like C# (or Windows for that matter)

 :-D  :-D  :-D
Title: Re: Anti C++ sentiment?
Post by: on January 28, 2003, 11:13:16 AM
Quote

Treke wrote:
@DaveP
Quote
No, I think C and C++ are here to stay, Java too. C# will become a nother VB - something that there is a market for and people use but it will not be the be all and end all dominant spirit of the marketplace.

I think oposite, C# has future, because:
1. From the language point of view it is an improved Java, for M$,  years of experience with Java were enough to see, what to improve in desing of new, similar language
2. It is an inherent part of .NET, which is a big movement towards real distributed SW systems (without the COM Hell). Don't missunderstand me, as an old amigan, I do NOT like M$, but some things I have to admit ;). The MS's millions that went into research must yield somewhere.
3. It has one of the best IDE's
4. It has a giant with money behind

Off course Java will not die.

Quote
Perhaps I am wrong, I hope not.

I also hope, that  you are not wrong.

Quote
Hence there will always be a place for procedural C/C++.

Sure.

re

Treke


I agree with you Treke.
Some things could be done better in Java. Espacially what the Virtual Machines concerns. The .NET Framework is very fast. I've tested it. But I think, if Sun continues the Java development and improves their language maybe with dropping a little bit of backwards compatibility and creates an extreme fast Virtual Machine, could again overtake C#.

But don't forget: Java runs on cellular phones (NOT SMARTPHONES WITH WIN CE).  There are also many people hating M$ and who won't program in C# but only in Java. Java is open source. And whe have JSP as a PHP alternative to PHP for great projects. All those people, developing for this systems won't stick to C# or VB.NET or ASP.NET or WHATEVER.NET.
Title: Re: Anti C++ sentiment?
Post by: Cymric on January 28, 2003, 10:45:09 PM
Quote
Karlos wrote:
To all the C coders, there's no non-trivial C program that could in no way benefit from some of C++'s features. Even without classes, there's stuff in there that's damn handy, such as function name overloading, declarations as statements, references to name but a few...

I avoid function name overloading like the plague: the implicit argument type promotion rules to test whether two functions are equal are a nightmare. The feature is useful in a few select cases, but in my experience too often led to obfuscation rather than clarity. References... Now there's a feature I'd love to have in C. Although I also believe that every C(++)-programmer should experience the exquisite emotions caused by an oh-so-subtle pointer bug at least once in their lives.

But despite the better features, it has its share of problems too: the syntax is complex (although not unbearably so), it has no garbage collection and still has you managing memory by yourself, and quite a number of others, which may not directly affect a programmer working on his own, but will when working in a team. See this site (http://www.progsoc.uts.edu.au/~geldridg/cpp/cppcv3.html), for example, although the author gives off the impression of being holier than thou. You can write solid and tidy code with C++; just keep in mind it is not a miracle cure to every programming problem, OO or otherwise.
Title: Re: Anti C++ sentiment?
Post by: Karlos on January 29, 2003, 10:31:24 AM
Hi Cymric

Quote

Cymric wrote:
...
I avoid function name overloading like the plague: the implicit argument type promotion rules to test whether two functions are equal are a nightmare. The feature is useful in a few select cases, but in my experience too often led to obfuscation rather than clarity.


I agree with you that overloading can be awkward, but if your's sensible with it it can be very useful.
Generally, I only overload function names for custom types rather than the builtin ones, unless I'm damn sure its a good idea.
As you probably know, the classic ambiguities are caused by things like

// plain bad overload example ;-)
// return types not part of overload resoulution

double func(double x, double y);
int func(int x, int y);

int ix = 1, iy = 3;
double dx = 1, dy = 3;
double z;

z = func(ix,  iy); // ok
z = func(dx, dy); // ok
z = func(ix, dy); // Promotion ix to double (?)
z = func(dx, iy); // Promotion iy to double (?)
z = func(1, 3); // Which func() is used?

As you point out, it can get real messy ;-)
To be totally unambiguous, you need to write stuff like

double z = func((double)ix, dy);
double z = func(ix, (int)iy);
double z = func(1.0, 3.0); // uses func(double, double)
double z = func((int)1, (int)3); // uses func(int, int)

Yuk! All of which is not nice for readability.

Now, what I would do is something like this

// in reality, I'd use a class, but for sake of a
// no-classes C-style code example

typedef struct {
  double real;
  double imaginary;
}  complex_t;

// function name overloading and references...
complex_t func(complex_t& x, complex_t& y);
double func(double x, double y);

It would be pretty difficult to muddle up the above two functions.

Quote

References... Now there's a feature I'd love to have in C. Although I also believe that every C(++)-programmer should experience the exquisite emotions caused by an oh-so-subtle pointer bug at least once in their lives.


:-) Agreed. When I first started using C, I had to chase a few obscure pointer bugs. Lovely!

References are real handy and often get used to avoid passing/returning large objects. But you do have to be careful when returning references - a lot of problems are caused by returning references to objects that only exist within the scope of the function in which they were created. Just as bad as any pointer bug :-D

Also, unlike references in Java, once assigned, the reference can't be reassigned - the reference and the object referenced are as one ;-)

Quote

But despite the better features, it has its share of problems too: the syntax is complex (although not unbearably so), it has no garbage collection and still has you managing memory by yourself, and quite a number of others, which may not directly affect a programmer working on his own, but will when working in a team.


Well, C has no garbage collection either. It's a double edged sword anyhow. Garbage collection is not all that it's cracked up to be IM (not so?) HO.

Incidentally, there are plenty of garbage collectors available for C++, it's just not part of the standard library (some implementations do come with them however).
The difficulty in their implemtation comes down to the fact that C++ is not pure OOP and things like pointers make garbage collection tricky.
In java for example, there are no pointers and every class is ultimately derived from 'Object' so it's possible to track every instance of every class and determine when an object has gone out of scope and can be recycled. But the convenience does not come for free either.

In most C++ garbage collectors, you have to write your class around whatever 'collectable' service class the garbage collector implementation provides.

Maybe I'm old school but I prefer manual memory management. Best clean up after yourself, so my mum taught me ;-)

When it comes to large scale, multi-person programming, features like namespaces are ideal.

Quote

You can write solid and tidy code with C++; just keep in mind it is not a miracle cure to every programming problem, OO or otherwise.


Well, I never said it was a miracle cure ;-)

But it is quite useful nontheless.

Title: Re: Anti C++ sentiment?
Post by: Mr_Capehill on February 12, 2003, 03:00:15 PM
Well, it's "natural" to program Amiga in C. I mean all the examples from DevCD, for example, are pure C code.

In the eyes of a beginner C++ looks scary (as a novice, I know that :). Lots of complex structures etc, namespaces, constructors, pointers, polymorphism etc. It doesn't look very nice and clean, no wonder since it was originally extended from C.

But the point is that C is an old language missing many features, and C++ is very important language these days (with Java). Maybe this could be taken into account with the new developer material?

Anyway, I hope the best luck to you with your book and I will be buying it when published :-D
Title: Re: Anti C++ sentiment?
Post by: iamaboringperson on February 12, 2003, 06:00:05 PM
@Mr_Capehill
Quote
In the eyes of a beginner C++ looks scary (as a novice, I know that :). Lots of complex structures etc, namespaces, constructors, pointers, polymorphism etc. It doesn't look very nice and clean, no wonder since it was originally extended from C.

pointers are in C too! didnt you know that?
+ structures can be complex in c

it might not look 'nice & clean' to a begginer, but i would say it looks ok to me

being extended from C is one of C++'s best features!

Quote
But the point is that C is an old language missing many features, and C++ is very important language these days (with Java). Maybe this could be taken into account with the new developer material?

its an old language, but what features is it missing?
apart from OOP?

C AND C++ are both very good languages, and very general purpose, these two languages should last for decades and allways stay strong no matter what 'fad' languages there are out there

Title: Re: Anti C++ sentiment?
Post by: Mr_Capehill on February 13, 2003, 09:52:16 AM
Yes I know that there are pointers in C, and that it can look very complex too. (I'm sure C doesn't fascinate beginners either :)

Well, of course the classes and many other things which might make it more complex but also more powerful and suitable for large scale applications etc.

C won't die as long as the Unices (whats the plural form?) and Linux  stay around.

I didn't actually meant to put C++ down, but just wanted to tell about my feeling when I first time read C++ code. Of course it has become a lot more clear since then  :-D

Any C++ tutorials for Amiga on the net?
Title: Re: Anti C++ sentiment?
Post by: gregthecanuck on February 13, 2003, 10:59:20 AM
Hi siciliano -

One of the things you learn as a developer is that no one tool does everything.

C++ is very good for certain applications.  So is Java .  So is Powerbuilder.

I wouldn't try writing an accounting system in C++.  Neither would I try writing a device driver in Powerbuilder.

For most of the stuff I do C++ is too low-level.  I have used Powerbuilder for applications such as hotel reservation systems.  It is a good fit for this type of application (database, objects, heavy GUI user I-O, report writing, etc).  This type of support is all built-in.

Sorry to stray off-topic, but why do you think Powerbuilder is so horrible?  


Have a great day, eh?

Greg
Title: Re: Anti C++ sentiment?
Post by: Karlos on February 13, 2003, 11:25:45 AM
What we have all learned here is that everything is good for something...

Except for AMOS....

(a hail of blazing molatov's rain down on karlos...)

Jeez, only joking! Still, better get my flame retardant jacket ;-)

Title: Re: Anti C++ sentiment?
Post by: Mr_Capehill on February 13, 2003, 11:44:46 AM
I prefer using Amos any day instead of AmigaBasic!!! !! !  :-D
Title: Re: Anti C++ sentiment?
Post by: on February 13, 2003, 11:45:39 AM
Quote
its an old language, but what features is it missing?

garbage collection.
Title: Re: Anti C++ sentiment?
Post by: Hammer on February 13, 2003, 11:50:00 AM
I prefer Borland C++ Builder (and I’ll use MS’s VC IF required), Borland builder products should be similar to MS’s C#, since the person who created it has been assimilated within Microsoft (for the dotNET Visual Studio product).  

PS; “Amgia Basic” is just Microsoft Basic renamed…
Title: Re: Anti C++ sentiment?
Post by: Mr_Capehill on February 13, 2003, 12:02:04 PM
Now, the lack of carbage collection and pointer usage separates languages for real men and others :)

Yes, indeed AmigaBasic was a Microsoft product. Luckily I haven't been using it a lot (it crashed all the time) but I have heard from a zillion of sources that it was a nightmare  :-P
Title: Re: Anti C++ sentiment?
Post by: on February 13, 2003, 12:17:03 PM
Quote

Mr_Capehill wrote:
Now, the lack of carbage collection and pointer usage separates languages for real men and others :)

[...]

yes, the real men have much time and strong nerves.  :-D
Title: Re: Anti C++ sentiment?
Post by: replicated on February 13, 2003, 01:32:54 PM
I think there may be some resentment in the amiga camp towards C++ simply becuse it took so long for us to get a decent compiler. I rember the attitude was we dont need it and  we dont want it. That seems to have stuck. BTW I learnt C++ very quickly and found it easy, i learnt OO through coding some BOOPSI stuff then when I got hold of C++ complier it was like whoa this does it all for me.  
Title: Re: Anti C++ sentiment?
Post by: itix on February 13, 2003, 03:16:24 PM
Need for C++ is IMO inexistant in AmigaOS/MorphOS where you can have BOOPSI classes.
Title: Re: Anti C++ sentiment?
Post by: Loki1 on February 13, 2003, 04:55:07 PM
Quote
all those arguments could be put towards VB too and no real programmer likes that one...


I beg to differ there my friend. VB is a great language for certain things like Database programming.  I use it alot for my Web business and store Point-of-Sale systems.

I would not dream of coding a 3D game (although is is quite ease to do) in VB or any program that need extreme speed.

Any program that is event driven is a good candadate for VB.  By events I am not talking about HW interrupts but Keyboard/mouse types where nothing happens until the user presses a key or clicks a button.

VB is great for quick and dirty programs/utilities that can be developed in a few minutes to a couple of hours.

I am a professional Engineer & Programmer working for the DOD in flight simulation.

I code in C/C++, FORTRAN, ASM, VC++ & VB.

They all have there place and their strengths.
But saying no REAL programer likes VB is pure BULL!

Loki :-P
Title: Re: Anti C++ sentiment?
Post by: MarkTime on February 13, 2003, 06:05:21 PM
My boss forced me to do an ASP.NET, ADO.NET, C-sharp application.

And guess what, c sharp is good.  Its the next step beyond java.

I am very glad Microsoft released it as a standard, and already we are seeing .NET ports from Borland, and the CLI being ported to various platforms.  Microsoft did the first port, to BSD.

Microsoft's a huge company and they buy up talent.  The guy behind .NET was a real legend and compiler guru.

.NET made programming a web based, database backend application very very logical, and somewhat easy.

I'm still a sucker for a super easy scripting language...like TCL...but this .NET stuff is cool.

And yes, you can program a 3d game in it too.

GAWWWD help you if you can't program a 3d game around here :-))
Title: Re: Anti C++ sentiment?
Post by: MarkTime on February 13, 2003, 06:16:54 PM
@DaveP

I once did a series of articles on programming in C for the Atari ST, and this was years after Atari was dead....I did it for fun.

The articles were published in user group magazines, and it was really neat...of course all the programming guru's who you never hear from otherwise, came out of the woodwork to 'correct' me constantly....and they were usually wrong.

Lawd knows, I couldn't have been wrong  :-P
but anyway, I betcha there is a bunch of interest in learning to program the next Amiga.

I have no intention of doing any programming in C++,
though, I guess I have to admit, finally that I am against C++

C was great, cause it was a very simple to use language....C++ is a good extension to C, but its not simple and time has changed and their are now the next level beyond C++ (java and c sharp)

That being the case, that C++ has never been simple, and it is no longer the 'best' (in my opinion java and c sharp DO lots of stuff automatically, that was tedious in c++)....then why use C++

The tool I use, is either 'the easiest' if I need that...or 'the best' if I need that.

I would use C++ now, only if I had been using it for years, and it was just comfortable to use.....

then again, on the new Amiga, whats the choices.....not a whole heck of a lot, GCC it is, then
Title: Re: Anti C++ sentiment?
Post by: BlackMonk on February 13, 2003, 08:18:02 PM
C++ is put down for a simple reason:  elitism.

Most programmers cut their teeth on C.  Most Unix/Linux users had to learn C and C-style of programming for mucking around on their systems.  Anything "new" that might be labelled as BETTER is instantly cause for concern.

I think it's largely hurt pride--how DARE some glorified version of C (it's got "C" in the name, after all!) purport to be more advanced?  Objects?  Bah!  Just use functions, same thing!  

I don't want to learn a new way of doing things!  If it were so great, why isn't my Unix distribution written in C++, eh?  I don't want to be told that my entire C-mindset is obsolete or not as advanced as something else!

---------

That's why I think there's so much C++ resentment.  Not so much on the technical merits but because the C style of programming and C-isms have become a way of life for many people.  This has been passed on to the newer generation of Linux newbies who get told that it's cool to deal with C's shortcomings and cryptic commands and it's cool to make fun of stuff that's non-Linux and non-C.

Simple.  Stupid.  It's 31337!
Title: Re: Anti C++ sentiment?
Post by: Hammer on February 13, 2003, 10:16:01 PM
Quote

all those arguments could be put towards VB too and no real programmer likes that one and it surely hasn't taken over the program development scene

Well, it depends on the task at hand…

I personally wouldn’t use C++ for automated MS Office based solutions.
Title: Re: Anti C++ sentiment?
Post by: Karlos on February 14, 2003, 09:50:36 AM
Hi,

Quote

itix wrote:
Need for C++ is IMO inexistant in AmigaOS/MorphOS where you can have BOOPSI classes.


I beg to differ. OOP lends itself nicely to so many things other than GUI / datatype design. Once you think of objects rather than procedures you suddenly realise the horizon is a lot bigger than you thought.

BOOPSI is great for GUI stuff and runtime class loading/method dispatching. It's written in C and the designers made a *very* good job when you realise the limitations of the language for this kind of system. But consider if we had decent C++ support since the start. I'm sure BOOPSI would have been written in it ;-)
The thing is, BOOPSI lends itself well to event-driven code (such as a GUI) where the users interaction is rate determining. However, the method dispatch mechanisms and data access methods are vastly slower (by virtue of how they work) than a C++ virtual function call, let alone a non-virtual or static member func. Trust me, I've measured this ;-)
You wouldn't want to rely on BOOPSI for all your OOP needs. Imagine the speed penalty of the method calls used in a time critical loop. Ouch :-)
Title: Re: Anti C++ sentiment?
Post by: Calken on February 14, 2003, 03:45:21 PM
Title: Re: Anti C++ sentiment?
Post by: Treke on February 14, 2003, 04:44:21 PM
Quote
Shame c# is written by ms and there isn't a free compiler yet, or is there?


Maybe Project Mono (http://www.go-mono.com/) is what are you looking for, because the ".NET specification" is open.

re

Treke