Help - Search - Members - Calendar
Full Version: Question for C/C#/C++ etc. programmers
Hydrogenaudio Forums > Misc. > Off-Topic
Cobra
Hi,

I want to learn C++ and I have some questions:

1) Is there any difference between C++ and C# ?
2) Which software should I use? Borland C++ Builder or Microsoft Visual Studio .NET?
3) Maybe should I learn Basic before learning C++? I know ppl who started with C/C++, not Basic and they are happy wink.gif
PoisonDan
QUOTE(Cobra @ Mar 3 2004, 04:02 PM)
Hi,

I want to learn C++ and I have some questions:

1) Is there any difference between C++ and C# ?

You bet. The difference is huge.

C++ is basically an object-oriented extension to C, while C# is more like a Java-clone (with some extra features).

C++ is a lot more difficult to learn and use than C#, but it allows you to write native code, while C# will always generate IL (Intermediate Language), which will run on the CLR (Common Language Runtime) - comparable to the Java VM.

QUOTE
2) Which software should I use? Borland C++ Builder or Microsoft Visual Studio .NET?

Hmmm... if you're just starting with C++, why not give Dev-C++ a try ?

QUOTE
3) Maybe should I learn Basic before learning C++? I know ppl who started with C/C++, not Basic and they are happy wink.gif

I don't have any idea why anybody would want to learn Basic first...
boojum
Good luck.

If you have no programming experience I would start with VB to learn what programming entails. The "C" family of languages offer numerous opportunites to make mistakes which can be undetectable even when testing. After testing you will get to learn what "memory leak" means. These are very tricky languages. cool.gif
PoisonDan
QUOTE(boojum @ Mar 3 2004, 04:26 PM)
Good luck.

If you have no programming experience I would start with VB to learn what programming entails.  The "C" family of languages offer numerous opportunites to make mistakes which can be undetectable even when testing.  After testing you will get to learn what "memory leak" means.  These are very tricky languages.   cool.gif

Actually, I disagree somewhat.

While you get can results pretty fast from VB, the language itself is very ugly and full of hacks. Check out this little "essay":
http://www.ddj.com/documents/s=1503/ddj0001vs/jan00.htm

Yes, it's written in a humorous way, but the author makes a lot of valid points. By the way, the majority of those issues have been corrected in VB.NET (which caused this language to be quite different to the original VB).

Actually, for somebody who is beginning with programming, I would recommend C#. Of course, I already had 6+ years of C experience when I learned it, so that may make a difference, but I really have the impression C# is very easy to learn. It's certainly a lot easier than C++.

Get the .NET SDK and SharpDevelop, and you'll be getting great results in no time, with 100% free (as in beer) software.

BTW, Python is another excellent choice for learning how to program, if you want to look further than the C/C#/C++ family of languages.
http://www.python.org/
http://mindview.net/Books/TIPython
Cobra
I`m slightly confused with another thing. Is Borland C++ 6 Personal FREE (of charge) ?

Is Borland C++ 6 Builder next version (similar to) of Turbo C++ (I have e-z books for Turbo C++)?
niktheblak
Agreed, learning to program with a language based on syntactic sugar and trickery might be a bad idea. With C/C++ you probably won't "see the forest from the trees."

When you're learning programming, you should be learning programming (as in algorithms, object orientation etc.) instead of particular quirks of a specific language. Very decent languages for learning programming in general would be Python and possibly Eiffel (does anyone besides Bertrand Meyer actually use it for anything?) After that, C# and Delphi are IMO very clean and powerful OO languages. After that, when you have a pretty decent grasp of programming in general and are prepared for challenges, assembler, C and C++. Make sure you've memorized Stroustrup's "The C++ Programming Language" and the web pages I will refer to at the end of this post by heart before you write a single semicolon in C++.

Finally, to prove my point on "syntactic sugar and trickery":

C++ Pitfalls
C++?? A critique of C++

Edit:

Also, I forgot to mention, Kerningham & Ritchie's "The C Programming Language" is an excellent book even for C++ programmers. Features from C will surely haunt you when programming in C++, so knowing about these features is vital.

Also, regarding the original question "Which software should I use? Borland C++ Builder or Microsoft Visual Studio .NET?", Microsoft's IDE is widely used, known to be pretty good and you also get C# with it.
niktheblak
QUOTE(Cobra @ Mar 3 2004, 07:27 PM)
I`m slightly confused with another thing. Is Borland C++ 6 Personal FREE (of charge) ?

Is Borland C++ 6 Builder next version (similar to) of Turbo C++ (I have e-z books for Turbo C++)?

No. Borland's C++ compiler 5.5.1 is freely available, but the full C++ Builder IDE isn't.

IIRC Turbo C++ was made well before the C++ standard, so...
smok3
nm.
Cobra
Ahem, it looks like some posts in this thread are gone, maybe i`m wrong...
rohangc
If you want to learn C/C++ or any other programming language of the future, please DON'T learn VB or Basic. If you do that, you will never be a proper programmer and will turn into a M$ zombie. Trust me, you will have a lot of un-learning to do which might be very frustrating. If you are starting from scratch, better do it the right way from the very beginning. Stay away from VB and Basic.
niktheblak
I agree that anyone seriously interested in programming should steer clear of VB if possible. Just about anything is better than VB...

But C# and Delphi are completely different beasts. While both of them are designed by the same man, Anders Hejlsberg, Delphi has a huge userbase in enterprise software engineering and C# seems to be a very promising new language. Unlike Delphi (and Java), C# and the associated bytecode format (MSIL) are ECMA and ISO standardized, making them in par with C and C++ in terms of "openness". There's still some uncertainty of the .Net Framework, but up to date MS hasn't sued Mono or GNU for implementing it.

Under normal conditions I wouldn't plug a virtual machine driven language under any circumstances, but unfortunately I've read a lot about Windows Longhorn.

Longhorn will have an MSIL virtual machine integrated to it, so .Net programs will have negligible performance overhead and no memory overhead compared to native code. In other words, you won't get punished for using C#. Furthermore, the .Net Framework will be the native API of Longhorn, while it currently just wraps Win32 API (just like MFC).

I remember Sun rambling something about a similar "JavaOS" years ago, but it seems that hey had neither the resources nor the guts to actually create one. Actually they also rambled about standardizing Java, but they didn't have the guts for that either.

Naturally a lot of people aren't ever going to switch to Longhorn and for the current Win2k and XP implementations, .Net programs carry some overhead compared to native code.

And .Net isn't portable, as of yet. If creating portable software is important to you, I would suggest using plain vanilla C in favour of C++ for all eternity. Why? For starters, even today there isn't a single 100% standard compliant C++ compiler in existence. And I predict that there never will be. That means that your C++ programs might behave differently on different compilers, or they might not be compilable at all on certain compilers. That tells us something about the language itself. If it's impossible to create compiler for a language, the language doesn't have such a bright future IMHO.

C on the other hand, is a different story. There are 100% C89 compliant compilers for everything, probably even for your washing machine. Sure, programming everything by hand in C is tedious, but I can assure you that when you start using namespaces, templates, multiple inheritance, RTTI, operator overloading, Boost, STL and possibly Win32API in a same project, you will start dreaming about the wonderful simplicity of C.

Besides, C++ is so horribly abused today (look through sourceforge.net projects) that it might have been better to use C all along.

Well, so much for pathos tongue.gif
Cobra
I started to learn C++ using Borland C++ Builder 6 Personal Edition (some ppl are saying that this package (and MS.NET) is 'shit'. These guys are mainy open-source zealots wink.gif). I want to make some useful Windoze apps. But question is: will it be easily portable for linux? I tried to copy my first console app to Dev-C++ - it won`t compile.

Are apps made with Borland C++ Builder compatible (will run) with Wine?
I wonder - if c++ and Borland C++ Builder 6 are so bad why so many ppl use such software?

And - after mastering c++, will there be much pain to learn pure c if needed? What should I learn first - c or c++?
sony666
Microsoft Visual C++ and a good beginner's book (1000+ pages) next to your keyboard.
Everything else is moot smile.gif
Cobra
I use Borland C++ 6 Personal because it is legal and free-of-charge. I have acces (!= I use or/and distribute) to Ms Visual Studio .NET Enterprise DVD RIP 3.30 GB, but I want to relase my own apps, I want no piracy here. Legal version of MS package - for beginner like me it is too expensive.

So I choose Borland. Also there are good books for Borland C++ Builder 6.
Now i study "Symfonia C++" - bestseller on Polish market - it is collection of three books about C++ (Turbo C++ compatible). I learn quite pure c++ from it before learning all these e-z things served by Borland C++ 6 Builder (you know, these buttons, mainmenus just with few clicks).
niktheblak
QUOTE(Cobra @ Mar 8 2004, 07:20 PM)
But question is: will it be easily portable for linux?

It depends. If you use only standard C++ features then yes, it should be directly compilable on Linux. Make sure you recognize the difference between standard C++ features and for example, Borland compiler specifics.

However, in the quest for total portability we still have to worry about endian issues, datatype sizes etc...
QUOTE
Are apps made with Borland C++ Builder compatible (will run) with Wine?

Not necessarily. If you use advanced windowing functions and/or advanced DirectX, it probably won't work with Wine. Consult Wine's documentation on supported features.

If you want portable graphics, you should probably use wxWindows instead of relying on Wine.
QUOTE
I wonder - if c++ and Borland C++ Builder 6 are so bad why so many ppl use such software?

C++ just happened to be there at the right time. It was the only alternative. Things are different now though.

Borland's C++ Builder isn't "bad" by any means. Practical experience just shows that MSVC, Intel Compiler and GCC tend to produce faster code than Borland's compiler.
QUOTE
And - after mastering c++, will there be much pain to learn pure c if needed? What should I learn first - c or c++?

That is a very difficult question. Bjarne Stroustrup recommends to learn C++ first, others recommend C.

Let's just say that learning pure C after C++ is extremely easy. C++ is an incrediably complex beast compared to plain C. The definite masterwork on the C language, K&R's "The C Programming Language" is only 250+ pages long, for crying out loud wink.gif

Edit:

Typos
Cobra
Anyone knows how to add support of Polish Specific characters (for example by using ISO-8859-2) to "Console Application" made with Borland C++ Builder 6?
KAMiKAZOW
Hi,
if you want to learn programming, I advise to use another language than C or C++.
Learn Pascal. Honestly. Unlike (Visual) Basic it's a real programming language, but easy to learn. Once you've learnt the concepts, you can easily switch to another language since the concepts are usually the same.
Try Free Pascal 1.0.10 from http://www.freepascal.org/. It comes with a text IDE that looks like Borland's Turbo Pascal. Don't mess with GUI apps at the beginning. GUIs will just distract you from learning.
Kuranuk
QUOTE
Learn Pascal.

Or Lisp. =)

Honestly, though, I agree; if you have no previous programming experience, the best way to learn is probably to avoid any language where the language-specific quirks will become a concept to understand in themselves.

Starting directly on a language like C++ without experience in language-universal concepts (recursivity, classic algorithms, etc) could take longer to master than if you learn a completely useless language first just for basic principles (I thought I knew them when I was taught Pascal and Lisp; I didn't) and progress to a more "serious" language afterward.

$.02
Jasper
QUOTE
I wonder - if c++ and Borland C++ Builder 6 are so bad why so many ppl use such software?

Although most arguments that have been made here against C++ are valid, C++ can be a wonderful language to program in. If used properly, C++ can enable you to write much cleaner (and often more correct) code than you could ever write with C.
The biggest problem with C++ (in my opinion) is that it is also very easy to abuse its power and write extremely difficult to read/debug code. Also, C++ has some "stupid" limitations and most compilers are indeed far from conforming to the standard which can make it difficult to make your code truely portable (without resorting to a multitude of defines and ifdef's).
smok3
how about python? good starting language or not?
PoisonDan
I think it is.

At least Bruce Eckel loves the language a lot:
http://64.78.49.204/pub/eckel/LovePython.zip
kl33per
Well, looks like my future programming career is screwed. I was forced into learning VB, and I've just started on Java (VB was for High School, Java for University, next year C++).
gwaihir
This post is totally Off-topic. I'm sorry, but I don't want to start another topic. I'm learning C atm. The following code snippet confuses me :
CODE

#include<stdio.h>

void main()
{
    int i=-10;
    for(;i;printf("%d\n",i++));
}


It generates nos. from -10 to -1 and then terminates. Can somebody explain the behaviour? Why does the loop terminate when i reaches 0? I thought the code ends up in an infinite loop. Where can I find similar tricks ?

Thanks again for reading. If moderator/admin, feels the post inappropriate, feel free to delete.
tigre
QUOTE(gwaihir @ Mar 14 2004, 04:09 PM)
This post is totally Off-topic. I'm sorry, but I don't want to start another topic. I'm learning C atm. The following code snippet confuses me :
CODE

#include<stdio.h>

void main()
{
    int i=-10;
    for(;i;printf("%d\n",i++));
}


It generates nos. from -10 to -1 and then terminates. Can somebody explain the behaviour? Why does the loop terminate when i reaches 0? I thought the code ends up in an infinite loop. Where can I find similar tricks ?

Thanks again for reading. If moderator/admin, feels the post inappropriate, feel free to delete.

Hehe - I've just started learning C too, but I think I can answer it:

"for" syntax works like this:

for ([<variable> = <initialization value>];[condition];[instruction(s)])

In your case the "condition" is "i" which means "true, if "i" has a value (!=0)".
So the condition "i" is the same as "i != 0" here.
gwaihir
For a minute, I thought the post was a goner (What else to think if it was answered by a mod wink.gif ...

Thank you, Tigre. If I understand you correctly, am I right in saying that, any non-zero value is always evaluated to be TRUE irrespective of its sign under conditional expressions/statements?
tigre
Yes. wink.gif
PoisonDan
While we're talking about C: those of you who already have a basic knowledge of C should really read this C FAQ:
http://www.eskimo.com/~scs/C-faq/faq.html

Lots of good stuff there.
gwaihir
Thanks for the link PoisonDan ... it is very useful! biggrin.gif
rohangc
QUOTE(gwaihir @ Mar 14 2004, 04:01 AM)
If I understand you correctly, am I right in saying that, any non-zero value is always evaluated to be TRUE irrespective of its sign under conditional expressions/statements?

You got it!! In C, only zero is considered to be FALSE. Any other integer irrespective of it's sign is considered to be TRUE.
niktheblak
While we talk about extremely useful FAQ's, here's one for C++:

C++ FAQ Lite

How I see it, C++'s biggest threat is it's own complexity. And this is only going to get worse with the upcoming C++0x standard.

The second major threat is the lack of spec-compliant compilers; when you are writing C++, you basically have to target a certain compiler. For instance, VS . NET 2003 ignores exception specifications. No compiler in the world supports the export keyword. World's probably most widely used compiler, VS98, is so full of horrible bugs and incompatibilities that it's basically impossible to write standard (STL and template heavy) C++ for it.

Needless to say, this issue is going to get a hell of a lot worse with the upcoming C++0x standard. Why are they going to publish a new standard when no compiler in the world has caught up even with the previous C++98 standard?
Jasper
I believe there is one compiler that supports the export keyword, but it's not a very common compiler.
I would love for that keyword to become supported more widely though smile.gif
ViPER1313
QUOTE(gwaihir @ Mar 14 2004, 10:09 AM)
This post is totally Off-topic. I'm sorry, but I don't want to start another topic. I'm learning C atm. The following code snippet confuses me :
CODE

#include<stdio.h>

void main()
{
    int i=-10;
    for(;i;printf("%d\n",i++));
}


It generates nos. from -10 to -1 and then terminates. Can somebody explain the behaviour? Why does the loop terminate when i reaches 0? I thought the code ends up in an infinite loop. Where can I find similar tricks ?

Thanks again for reading. If moderator/admin, feels the post inappropriate, feel free to delete.

If I coded a for loop like that and turned it into my CS teacher, I think she would slap me in the face.........
gwaihir
Actually, this was asked in an interview for C Programmers here, for freshers ... perhaps, they are trying to make ppl realise the horrors of such enigmatic code. wink.gif
PoisonDan
Aaaah... horrible abuses of the C language...

That reminds me of the IOCCC (The International Obfuscated C Code Contest).
http://www.ioccc.org/

Those of you who haven't seen this before, please check out the winning entries. There are some real beauties there...

ph34r.gif
gwaihir
There is a book called "Hidden Treasures of C" by an Indian author. The book is supposed to summarize tricks in C programming. Unfortunately, most of the programs target a victorian compiler. And I'm talking about a book which had a edition in 2001. Infact, when most of the books argue for clear coding style against 73310 style, the stand taken by the author is quite the opposite. blink.gif

@PoisanDan : I should check whether this author has submitted for the contest. If he hasn't, I'm sure he could win hands down ... for couple of years atleast. laugh.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.