Click to See Complete Forum and Search --> : Why's C so popular?


SonOfAres
01-22-2003, 10:49 PM
Personally I'm learning C++ right now (a bit confusing, but I'm getting there!) and from my understanding C is older and more outdated, yet I still see it as being the most popular. Can someone set my straight as to what's what?

oh, and something I wuz just wondering.... how do you convert words and strings into binary? I know how to convert numbers and all

ViMan
01-23-2003, 01:01 AM
C's very popular since so many programmers used to use languages such as Pascal and lisp before C. C is much more powerful (at least more powerful than lisp) and is fast. In fact, there's a big discussion (more like a flamewar) between whether the new features introduced in C++ are worth the speed loss, since C supports almost everything C++ supports (although C++ makes programming easier with things such as STL).

arlenagha
01-23-2003, 02:45 AM
SonofAres, just learn C++, that is what I am doing and i did not start out with C. I don't know the speed difference between C and C++, but the new features are worth it., like C++ OOP, which C does NOT have. Eventhough you can emulate OOP in C, its is not the same as C++.

just go to Bjarne Stroustrup's (designer and original implementer of C++) website, and read about C++.

bw, may i ask what kind of code are you going to write once you learn c++?

JayC
01-23-2003, 09:57 AM
I don't think that C is that much more popular overall. In fact, scripting languages are the ones that are gaining market share. C is popular because it is 1)Fast 2)Portable. Many of the C++ compilers have compatibility issues and it takes some extra code tweaking to move the program to a new platform.

truls
01-23-2003, 10:10 AM
oh, and something I wuz just wondering.... how do you convert words and strings into binary? I know how to convert numbers and all

If you are using std::string for this, you already have the binary version ( using std::string::c_str(), which gives you a char pointer ). Strings are just collections of chars, and chars can be handled as signed bytes.
Why are you asking? Is there something you want to do with the strings?

SonOfAres
01-23-2003, 10:51 AM
well I figure I'll learn c++ first since I've alrdy started it
I haven't made any decisions about what kind of stuff im gonna program, I'm still in middle school! it's just interesting and I wanna learn how to do it to open some doors.... and it's my dream job(next to pro drummer)......

Again, I just wanted to learn how to make strings into binary for my own personal info, it's interesting and I wanna know how to do it cuz i may need to someday, but there's no big need....... how would characters be converted to binary?

BFK4ever
01-23-2003, 10:58 AM
I don't program, but I am almost positive the Linux kernel is written in C :D

(What's good for a first language? I am currently looking at python...)

bwkaz
01-23-2003, 11:12 AM
Originally posted by ViMan
(at least more powerful than lisp) :eek: :eek:

Did I hear you right? Why do you think Lisp isn't as powerful? It's a heck of a lot easier to manipulate, for example, lists and trees, in Lisp than in C... and there are a lot of other things that Lisp does better as well (parsing text, for one, writing interpreters for other languages for another, and changing the executing program as it's executing for a third -- code == data is nice...). The majority of AI programming is done in Lisp, as well... but I'd like to know why you think it's not powerful.

BFK4ever: I've heard that Python is indeed a good first language from a few different people.

stoe
01-23-2003, 12:00 PM
c++ is not any slower than c ... its just easier to write less efficient code in c++ than in c. if you're a good c++ programmer, there should be little or no difference between the efficiency of c++ code and c code. certain c++ features such as virtual functions and exceptions do have an overhead cost when used, but employing them intelligently will make no signfigant impact on the speed of a program.

c is used more often for several reasons:

1) its been around longer.

2) its procedural, not object-oriented. more programmers are comfortable with procedural programming.

3) as already mentioned several times, its easier to port because pretty much all systems have a fully compliant c-compiler, while the vast majority of c++ compilers are not fully compliant to the c++ standard (the official c++ standard came out in 98).

4) its easier to make well written c code than it is to make well written c++ code.

continue learning c++. c++ is c with more language constructs. by focusing on c++, you will know the c language. if then you are required to or want to program in c for some reason, you'll just have to get used to not using classes, templates, exceptions, overloading, and namespaces.

or, if you want something easier, learn python. its an object oriented scripting language. it's very enjoyable to program in, and removes much of the complexity of c/c++ (working with pointers, etc). however, being a scripting language, its not quite as fast as a compiled language such as c/c++.

Stuka
01-23-2003, 12:12 PM
Originally posted by SonOfAres
Again, I just wanted to learn how to make strings into binary for my own personal info, it's interesting and I wanna know how to do it cuz i may need to someday, but there's no big need....... how would characters be converted to binary? This is done with a character encoding. The most common in the US and PC industry is ASCII, though Unicode is catching on. For starters, look up an ASCII chart - it shows what each character looks like in binary.