Advertisement

Is C a wasted/useless language?

Started by January 28, 2002 04:31 PM
12 comments, last by romer 22 years, 10 months ago
Given the chance, I can''t not post my favorite peice of C that isn''t valid C++ (a little code never hurt anyone). Commonly known as the struct hack, it part of the C99 standard but not in any C++ standards. C++ has different ways of doing almost the same thing (some would argue better ways), but still...
  #include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct {	unsigned char len;	char str[];} byte_string;byte_string *null_to_byte(char *as) {	unsigned int len = strlen(as);	byte_string *bs;	bs = (byte_string *) malloc(sizeof(byte_string) + (len * sizeof(char)));	bs->len = len;	memcpy(bs->str,as,len);	return bs;}int main(void) {	byte_string *bs;	bs = null_to_byte("Testing");	free(bs);	return 0;}  


quote: Original post by DigitalDelusion
DX is C based, so you won''t find anything that is C++:ish in those headers.


Uhh no. It may have been originally, but it is now more C++ than C.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Advertisement
quote: Original post by CaptainJester
Uhh no. It may have been originally, but it is now more C++ than C.


Try not to confuse COM with C++. COM can be done just as easily in Visual Basic as in C and even C++. Does that make DirectX more VB than C++?
C certainly won''t die in that it seems to be a model for plenty of other languages (Java, C#, Python, etc.). Beyond that, everything that''s possible in C++ is possible in C. Harder, maybe, but completely possible. And that includes the Object-Oriented paradigm. Anytime you kids do anything procedural in C++, you''re using C. Anytime you enjoy the low-level nature of C++, you''re enjoying an intrinsic property of C. Furthermore, no single language is the best for all things, so C or whatever other language will always have a place (there are times when C++ is simply overkill; its facilities just add overhead with no extra reliability or any of the other things promised).

This topic is closed to new replies.

Advertisement