C++/C, C++ or C#?
I want to start programming with C, as I need a fast flexible language that can do graphics. I have previous experience with QBASIC, Visul Basic, PHP and PHP-GTK(adaption of PHP to display windows, buttons etc. not webpages). However, I am a little confused by the different types.
What is the difference between C, C++ and C#?
I want to easily and quickly create fast programs that can handle 2D graphics and preferably 3D in the future. I.E. I don't want to have to write the low level functions such as read/write files and drawing lines, circles etc. I also don't want to have to pay for a compiler! Which one is best for me?
Also, what exactly is .NET? I always thought it was something dreamed up by microsoft, but Borland seems to be using it too. How can it help me in my programming, and what languages support it?
I hope this is not too many questions!
Thanks in advance.
You were asking about free devleopment tools, and I have just found out that MS are producing "Express" versions of their development tools which may be free or fairly cheap (details are unclear at the moment). I thought you might be interested. Information can be found at http://lab.msdn.microsoft.com/express/
You have asked several questions. As the answers to some of these could end up as book length my answers have of necessity to be brief and introductory. Others require opinions or recommendations which I cannot give – either because I do not know or you have not given enough detail in the question. I apologise in advance for these shortcomings.
1/ Difference between C, C++ and C#:
Of the three C is the oldest (somewhere between 1970 and 1978) and in some ways simplest of the three languages. It has been described as a high level assembly language by some. It supports mainly a procedural programming paradigm, but does have support for user defined data types. It is often used to write operating systems and the like - UN*X, Linux and as far as I know MS Windows are examples for operating systems written largely in C. C derived from BCPL though B - both type-less languages - unlike C which is typed and provides a variety of fundamental types such as various sizes of signed and unsigned integer types and floating point types. A good reference is still "The C Programming Language" by Kernighan and Ritchie.
In the preface to the first edition of "The C++ Programming Language" Bjarne Stroustrup - the creator of C++ - says:
"Except for minor details C++ is a superset of the C programming language".
C++ adds support for object oriented and generic programming paradigms to those supported by C. A good initial C++ book for someone like you who has done some programming before is "Accelerated C++" by Koenig and Moo.
Today both C and C++ are ISO/ANSI standards. The current C standard is ISO/IEC 9899:1999 (E) - or C 1999. The C++ standard is ISO/IEC 14882:1998(E) - C++ 1998, although as of 2001 there is the first correction amendment to this standard (called a technical corrigendum) TC1.
Both C and C++ follow the same model for executing code derived from the program source: compile individual source code modules to object code then link the object code modules together to form an executable.
C# on the other hand does not follow in the same lineage as C and C++. It was designed by Microsoft as a (the) .NET language. In this respect it is much like Java, but with a somewhat more C/C++ feel to the language. I think C# is an ECMA standard, as is the non MS Windows specific parts of .NET. I cannot advise on C# books as I have not really done that much with it - remember I am a C++ expert not a C# expert.
2/ What is .NET:
.NET is a Microsoft invention. In many ways it is similar to the Java development environment. Both compile code to an intermediate language rather than native machine code. Both have to either interpret or compile this code on the fly, both require extensive runtime support over C or even C++ - Java has the Java Virtual Machine or JVM and .NET has the Common Language Runtime or CLR. Both have a rather extensive framework of code that provide various useful facilities. Unlike Java Microsoft has (as mentioned above) submitted and had standardised at least part of the .NET environment. There are versions of the .NET framework that run on UN*X and Linux - see the Mono open source project (http://www.mono-project.com/about/index.html
) for example. See the MSDN site for more on all MS development subject including .NET and C#: http://www.msdn.microsoft.com/
Borland and others are supporting the .NET framework - in the same way I suppose that you could write your own Java compiler for a Java virtual machine (licensing issues aside).
3a/ Best free C and C++ compilers:
The answer is that it depends on your platform and usage requirements. For Linux and UN*X systems the obvious answer is the GNU compiler(s). See http://gcc.gnu.org/
For MS Windows you might be able to make use of the Borland free compiler (http://www.borland.com/products/downloads/download_cbuilder.html
) or maybe the Watcom compiler(http://www.openwatcom.org/
) but you will also require the rest the development tools - linker, debugger, and support of third party libraries, and I do not know the extent of availability of these items. Many people use MinGw (http://www.mingw.org/
You might find http://www.freeprogrammingresources.com/cppcomp.html
3b/ Free C# compilers:
Microsoft's .NET framework and command line tools are free I think and there may be a free edition from Borland as well. Also the Mono project has a C# compiler. See http://www.thefreecountry.com/compilers/csharp.shtml
Note that I cannot really comment on any compilers other than GCC and the MS C# compiler bundled with their Visual Studio .NET 2003 project as I do not use them - and I only use GCC versions bundled with my Linux boxes - which are quite out of date now. Also I have not used C# that much but I would hope that the MS compiler is fairly good as C# was their invention!
4/ .NET language support:
I am not a complete expert on these - I am billed as a C++ expert you know, not a know everything about everything there is to know on all things related to software development. So it is likely that you know as much or more than I do on some products - such as those from Borland - if you have been following their range of products recently as I have not.
The obvious initial two are: C# and Visual Basic .NET from MS. MS also support .NET in C++ through their managed C++ extensions (which are currently undergoing a complete revamp). And of course they also have ASP .NET for web developers.
.NET is not a closed environment - I think MS would like it to gain popularity - and Sun and Java got there first and are well entrenched. So it follows that they would wish others to develop languages and tools that make use of and enhance .NET. Borland obviously is one such party - and they seem to add Delphi to the list of .NET languages. There are also the likes of Visual Perl, Python and XSLT - which plug into Visual Studio .NET but may or may not require/make use of the .NET runtime - the ActiveState site is not clear on this (http://www.activestate.com/
5/ Graphic support libraries
This is difficult. On the one hand you want a high level of abstraction for 2D and 3D graphics operations and file loading and storing. On the other hand you do not tell me what your application area is (the area of abstraction) - so it is difficult for me to advise. The main two APIs are OpenGL - which is available on Un*x, Linux, MS Windows etc, and the various parts of the MS Windows specific DirectX APIs that relate to graphics, animation and video.
These however may be too low a level and general purpose for your needs or where there is support for higher levels of abstraction they may not be in the areas you require - for example DirectX was initially intended for games support so implementing GUI features may not be so easily done.
I believe there is an open source OpenGL implementation for the X window system called MESA - see http://www.mesa3d.org/
(although it seems to have migrated to other platforms).
I also believe that MS have added DirectX support to the .NET framework although I am not sure of the details.
For further details I suggest you make use of you favourite search engine, or for DirectX maybe start with a search of the MSDN site.
Remember that for C and C++ any library you obtain must be compatible with your platform (OS and hardware) and tools (compiler, linker and preferably debugger). Either in binary form (.lib or .a static libraries or .lib and .dll or .so dynamic/shared libraries) with header files. Or as source code from which you can build the binary libraries from hopefully using supplied project or make files - in which case you will need compiler compatibility at least.
Also do not expect to be up and running instantly - you have to learn the new language(s), the tools and the use of the libraries - learning curves on three fronts. Of course you might be a genius and pick up such things without blinking.
Finally you might like to check out the ACCU site for both its book reviews and resource links - http://www.accu.org/
Hope this is of some use.