# Where is C

This topic is 4137 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have been learning C language since summer, i tried other languages but somehow C just seemed to be the simplest language to learn for ***ME***. Now i wanna know where C stands as compared to other languages as to popularity, and ease of use with the More popular APIs like opengl, Directx, SDL and Allegro based on facts not on your opinions. THANKS

##### Share on other sites
OpenGL and C work together very well. OpenGL was ment to be for C and i have used this combo, as for the rest, i believe you will need C++. I would learn C++ as soon as possible. C++ is just a superset of C and is backward compatible, it just adds stuff like classes, which are commonly used.

Greetings.

##### Share on other sites
You can use DirectX with C++, but i personally think that it feels more natural to work with classes in this case.

##### Share on other sites
As far as I know SDL can work in C.

I do agree that you should learn C++. Since you know C right now, it will only take a little bit to know how to use it. IMO it is easier then C.

##### Share on other sites
Quote:
 Original post by Limitz I would learn C++ as soon as possible. C++ is just a superset of C89 and is backward compatible, it just adds stuff like classes, which are commonly used.

Corrected. Also, it is advised to forget everything you know about C before starting C++.

To answer the OP's question, C is historically popular because it provides the most popular means of using libraries. The Windows API as well as the core UNIX and Linux libraries are written in C and provide a C interface. Besides, except for the recent .NET libraries and some historical artifacts, accessing any library from C is extremely simple. The other reason why C is popular is that, being a glorified assembly language, it can run on almost any platform known to man, and thus provides ultimate portability as long as system calls are not involved. This includes space probes, airplanes etc ...

Since the appearance of C++, the use of C for library access has declined. Even though C++ is not as powerful as C as far as creating library interfaces goes, some do provide C++ bindings (for instance, DirectX). The appearance of .NET brings an end to the dominance of C on the Windows API, and KDE has moved away from C and into C++ some time ago already. In game development, except for a few notoriously skilled programmers, C++ is used whenever possible, with its C-inspired subset being used whenever necessary. This, of course, in cases where the game development language isn't ActionScript, Java, C# or some variant of LISP. The fact that most C compilers are bundled with (or part of) C++ compilers only adds to the hegemony of C++. Right now, C is still used in its historical niches (such as UNIX systems programming), platforms without other language support (such as embedded Airbus chipsets) and some libraries, but most of the work is done either in C++ or in C++-- (that is, C++ used as if it were C, which some may consider an abomination).

Of course, C has been abandoned long ago by almost everyone in many domains where productivity (as opposed to optimization potential) is important. Replacements and alternatives are Java or C# for business needs, Visual Basic for management of Office and similar components, PHP/Perl/ASP for dynamic web pages, and (remarkably) C++ for finance.

##### Share on other sites
Quote:
 Original post by LimitzC++ is just a superset of C and is backward compatible, it just adds stuff like classes, which are commonly used.

That is a grossly inaccurate description of C++.

##### Share on other sites
Quote:
 Original post by LimitzC++ is just a superset of C and is backward compatible, it just adds stuff like classes, which are commonly used.

Not even close. C++ is it's own language and shouldn't be seen as 'C with classes' like many of the first books used to publicize. C++ includes functionality of the C language but is in no way a superset as there are many fundamental differences and many C'isms that you should never use.

##### Share on other sites
well C++ has tiny insignificant differences (syntax-wise) from C..
Although it really is a totally different languages, the programming concepts are all the same (as it is with almost all languages), but even the syntax is almost the same..
the only new concepts introduced are Objects ... that is classes and structures.

Without those it is very hard to write a fully structured program and you will have truble maintaining and remembering your functions after your game jumps over the 1000 lines...

I really suggest you move to C++ and forget everything you know about conventional function calling... use classes WHENEVER you can.

##### Share on other sites
Quote:
 Original post by memento_morithe only new concepts introduced are Objects ... that is classes and structures.

You forgot templates, references, exceptions, namespaces, overloading, RTTI, safer casts, an entire crapload of standard library functionality, and several other details as well.

Quote:
 Without those it is very hard to write a fully structured program and you will have truble maintaining and remembering your functions after your game jumps over the 1000 lines...

You can code an object oriented design in C without too much difficulty as well, even if it isn't as simple.

##### Share on other sites
Quote:
 Original post by memento_morithe only new concepts introduced are Objects ... that is classes and structures.

Let's also not forget:

templates
references
exception handling
namespaces
anonymous namespaces
specifically-typed enumerations

As someone who learned C first, then C++ as an extension to C, before realising that this was a very dumb way to be taught C++, I feel I am reasonably well qualified to point out that C++'s "backwards compatibility" with C (and I use the quoted words advisedley) was purely commercially motivated and it is a great shame that so many academic institutions still feel that this is a good way to "educate" people.

[EDIT] Sorry, ToohrVyk. I was just a bit too slow there.

##### Share on other sites
Quote:
 Original post by memento_moriwell C++ has tiny insignificant differences (syntax-wise) from C..

Syntax means practically nothing. They are similar syntax-wise, so what?

Quote:
 Although it really is a totally different languages, the programming concepts are all the same (as it is with almost all languages),

Far from the truth C advocates the procedural programming paradigm, which is generally considered inferior to the OO programming paradigm. C++ is a multi-paradigm language, but many consider it an OO language because many of the added features in C++ aids in OOP. The concepts aren't even close to similar. C++ also adds proper support for generic programming.

Quote:
 but even the syntax is almost the same..

The syntax is about the only thing which is the same (and that they both have the C standard library).

Quote:
 the only new concepts introduced are Objects ... that is classes and structures.

Have you even considered templates, the type system, type safety, the C++ library, namespaces, cv-qualifiers, exceptions, RTTI etc.?

Quote:
 Without those it is very hard to write a fully structured program and you will have truble maintaining and remembering your functions after your game jumps over the 1000 lines...

No, a well-written procedural program can easily be managed even though it's over 1 million lines of code (I believe some C projects are over 10M lines of code, but I don't have any references).

Quote:
 use classes WHENEVER you can.

No, whenever it's appropriate to do so. Don't do this:
class string_utils{  static std::string to_upper_case(const std::string& in);};

That is just forcing procedural code to be OO. Instead learn proper OO practices, and you will automatically use classes and objects instead of functions in almost all cases.

Why C++ is not just an Object Oriented Programming Language (by the author of C++)
Learning Standard C++ as a new language (also by the author of C++)

##### Share on other sites
Quote:
 Original post by CTarNo, a well-written procedural program can easily be managed even though it's over 1 million lines of code (I believe some C projects are over 10M lines of code, but I don't have any references).

I do.

The in-flight systems on the Airbus A340 are worth 132,000 lines of C code. Note that if said code crashes or otherwise causes an error, people die. Also note that this code has been proven to be exempt of any runtime error (that is, it cannot fail at all, short of a hardware failure).

Red Hat Linux (7.1) contains 30 million lines of code. 71% of these are written in C, which amounts to 21.3 million lines of C code. The separation of one big bundle into many subprojects (many of them being, in fact, reusable subprograms) that are then integrated with each other is an example of good code management that emerged by itself from a large number of developers.

The Linux kernel (2.6) is at around 4 million lines of code, with an immense proportion being C (the rest being scripts and makefiles).

##### Share on other sites
Many game engines, emulators, rendering algorithms, statistical simulations, drivers, and just about anything that values efficency over everything else will use C (or at least primarily the C subset of C++). This is because certain parts of the C++ language (i.e. the oft-cited virtual functions, etc.) can be slightly less efficent. This usually isn't a big deal, but there are cases where this would be a big deal.

##### Share on other sites
Quote:
 Original post by chigga102I ... wanna know where C stands as compared to other languages as to popularity, and ease of use with the More popular APIs like opengl, Directx, SDL and Allegro based on facts not on your opinions. THANKS

I think you will find there is still more software today written in C than in C++, and certainly more than in other languages. Even much of the software written using a C++ compiler is written as C code.

I spent years writing pure C code (and many more writing FORTRAN). It's not hard, and the language is just a tool. I now write C++ code, and I find it painful and awkward having to go back and read C (or even FORTRAN). Compared to C++, the C language lacks expressiveness and requires more thinking in the language domain than in the problem domain. Since my time is expensive, that means C costs more than C++.

You should feel fine simply proceeding as a C programmer, lots of folks do it. Enjoy it now, because once you walk on the dark side of C++, you won't want to go back.

##### Share on other sites
Quote:
 Original post by memento_moriwell C++ has tiny insignificant differences (syntax-wise) from C..Although it really is a totally different languages, the programming concepts are all the same (as it is with almost all languages), but even the syntax is almost the same..

No. One is Structered the other one is Object Oriented (in a simple case). C++ is actually multi-paradigmed. The programming concepts are not the same in "almost all languages".... Take a look at LISP.

To the original poster, C is great for firmware or device drivers. Small utility programs that have limited space and can't afford the overhead of virtual functions etc....

##### Share on other sites
Quote:
 Original post by Anonymous PosterMany game engines, emulators, rendering algorithms, statistical simulations, drivers, and just about anything that values efficency over everything else

Most of those you just mentioned value stability just as high as performance, and reliability is also a factor. Also game engines will be worth more if they are developed quickly because they are more "cutting-edge", so you shouldn't code them in asm even though you could code perfect asm code, it'ld take too long.

Quote:
 will use C (or at least primarily the C subset of C++). This is because certain parts of the C++ language (i.e. the oft-cited virtual functions, etc.) can be slightly less efficent.

Less efficient than what? If the feature is coded in C the code will be hard to read and slower because the compiler can't perform high-level optimizations. A good C++ programmer knows how to avoid the performance pitfalls of C++, and can code more efficient C++ than C because the C++ compiler can take advantage of the fact that he more clearly expressed his intent.

Quote:
 This usually isn't a big deal, but there are cases where this would be a big deal.

In those few cases (about 0.1 %), you should just be aware of the performance penalties some C++ abstractions can have, profile your code, and look at the assembly output. If that isn't enough, then C isn't enough either. Many C++ idioms which are hard (harder than C++, where they are already hard) to realize in C, stuff like expression templates, partial specialization, etc. And to quote Bjarne Stroustrup:
Quote:
 I never saw a project for which C was better than C++ for any reason but the lack of a good C++ compiler.

##### Share on other sites
lol i didnt mean it was absolutely impossible to write code without OO, but i meant it was much harder to maintain and structure well...

especially if you are a beginner.. after all how did people write code before C++, or even before C... and how do people write assembly code.. :P

but yeah in general OO is the main new concept (templates and namespaces you call those "concepts" ??)

and even though some people like to hold up on the details i guess everyone agrees that bad programming habits are very hard to unlearn, and you will acquire bad habits from learning C (unless you don't plan on learning C++ afterwards which would really be a loss for you)...
and that explains why many people refuse to give up on some ..outdated.. languages IMO

##### Share on other sites
Quote:
 The programming concepts are not the same in "almost all languages".... Take a look at LISP.

that's why i said "ALMOST"... I don't know LISP, but I do know COBOL and FORTRAN and I have to say they are pretty different with all these goto stupid jumps, but then again .. how many people do you find today who use those languages?

##### Share on other sites
My appologies, but I still stand firm. Programming languages are not "almost all the same".... maybe the flow constructs remain similar, but that's where I would draw the line. There are still differeneces between COBOL and BASIC... and many other languages.... I would say very few are similar. COBOL was desigend for mainframe buisness logic. BASIC was designed for generic programing.

##### Share on other sites
Quote:
Original post by CTar
Quote:
 will use C (or at least primarily the C subset of C++). This is because certain parts of the C++ language (i.e. the oft-cited virtual functions, etc.) can be slightly less efficent.

Less efficient than what? If the feature is coded in C the code will be hard to read and slower because the compiler can't perform high-level optimizations. A good C++ programmer knows how to avoid the performance pitfalls of C++, and can code more efficient C++ than C because the C++ compiler can take advantage of the fact that he more clearly expressed his intent.

Quoted for emphasis.

##### Share on other sites
Personally I feel there are 3 C++ languages ...

1) First, there is the great expanded land surrounding the walled city C, just waiting for brave adventurers to explore it in their quest for great treasure. This land expands in all directions, offering both short and long quests for any level of adventurer. The quests can be completed individually or in large dedicated campaigns. Many of the quests related to each other, but most are accessable directly from the city.

2) Then there is a C++ taught in schools as a First Language, founded atop the great mound of Object-Oriented programming. This C++ is constantly engaged in sectarian fighting with the Old City from which it was born, and more vehemetly with the students of Java who live just across the river in a gated and sanitized community. This school believes that C++ is the one-true language, but would be the unquestioned ruler of all if it could only free itself of its ties to the old city.

3) Finally, there are the Boost Mages. These disiples of constant research into multi-paradigm software synthesis cannot be understood by mere programmers, but unlike the academic disertations given by the school of Java, they live and breath code. Or more acurately, computer usable constructs that yield runnable instructions - often using a mix of compille-time components, generic patterns, and dynamic dispatch to completely astond any who remember the days when productive achievement was measured in man-months.

All of these schools offer a chance for happiness to their members and each sucessive school offers assylum to previous residents of other schools whom make their way outside the gates of indoctrination.

A rare few of us wander outside of these schools in a nomadic life between the schools. We pay for our great freedom by remaining outside of the final circles of development available only to the truely devout, but we feel the price is fair. Oh the joy of fishing with C# all day, journey into the lands of C++ throughout the evenings and holidays, and drink from magical ruby cup when tired and weary.

##### Share on other sites
You guys think i should skip the C and go to C# (because the whole XNA )

##### Share on other sites
Quote:
 Original post by chigga102You guys think i should skip the C and go to C# (because the whole XNA )

I think you should, but not because of the XNA thing, you won't get to take advantage of that until you have learned programming. And you most likely won't really have a use for it in the next couple of years. C# however, has some significant advantages over C++ (garbage collection, better support for concepts, interfaces and other OO constructs, etc.). I think it's much better to learn to program in C# than it's to learn to program in C++. Of course you will most likely have to learn C++ at some point, but once you get the idea of programming and good design it shouldn't be too bad. You could check out Wikipedia's entry for C# and C++.

##### Share on other sites
I actually know alot of C its just that certain things in the language is a little bit tricky like bitwise operators and a bunch of more advanced stuff so thats why i was wondering.

##### Share on other sites
Quote:
 (templates and namespaces you call those "concepts" ??)

*cough*

##### Share on other sites

This topic is 4137 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628734
• Total Posts
2984444

• 25
• 11
• 10
• 16
• 14