Sponsored by Travelzoo
Take Advantage of Ridiculously Low Holiday Airfares view!
travelzoo.com - Flights $52 and up for Thanksgiving, Christmas & New Year. But move on it now.
149 Comments
- inactive, on 10/12/2007, -4/+99"I'm not sure how you could call yourself a programmer and not know C."
It gets worse. I meet web designers all of the time who call themselves programmers. - inactive, on 10/12/2007, -20/+69Top 10 Reasons NOT to program in C
1). Because the C code is ugly.
2). Because those that want to fondle embedded technologies from the inside risk creating a new order of intelligence that will exterminate mankind.
3). C stands for cryptic, crusty and conniption.
4). If you use C, you'll spend most of your time rewriting library routines already included in C++.
5). C uses pointers which often point to nothing in particular.
6). C programs are small, tight and efficient and make Microsoft programs look bad.
7). C programmers consider themselves elite and wonder who are you to think that you can join their club.
8). Programming in C can cause dain bramage.
9). Bugs in C look remarkably like undocumented features.
10). C isn't object oriented and you probably can't afford the version of C that is. - sirsteveh, on 10/12/2007, -4/+50Nope. C.
I would disagree with the author's assertion that C is more low-level than C++, however; they're both at the same level (C++ just allows classes and namespaces and has a stronger type system). - RayQ, on 10/12/2007, -11/+55"Even non-programming engineers should know basic C. I (adequately) learned it in high school in about two weeks."
rofl. - lcarsdeveloper, on 10/12/2007, -6/+48"It gets worse. I meet web designers all of the time who call themselves programmers."
I think the term web designer is used incorrectly. You're either a graphic designer or a web programmer. I suck at designing things, but if a designer hands me a photoshop mockup I can turn it into an XHTML/CSS page, and then start adding in PHP/MySQL/GD or whatever is required. Although I do not know C, as a PHP/MySQL programmer some of the code I have written is extremely complex and powerful, and I would get upset if someone said I wasn't a true programmer just because PHP is used primarily for websites and not for actual applications. I use functions and classes just like other programmers. However I would get a little annoyed if someone called themselves a programmer just because they could splice up a photoshop image, add some rollovers and export it as a HTML page.
Or even worse....
1) Open MS Word
2) Make your page
3) Export to HTML
**shudder** - Eleo, on 10/12/2007, -3/+36Please don't digg me down; this is an honest question from a newb: how do you program an operating system in just C? It was my understanding that most operating systems are millions of lines of code. I have trouble imagining how you can manage a project as massive as an operating system when it's written only in C.
- l0gden, on 10/12/2007, -10/+37There are two types of 'programmers' from my perspective. Geeks and non-geeks. The arguments presented are spot on for the first type.
For the second type (these guys may not even use a computer outside of their job), however, the reasons given don't compel as it is unlikely most of them will be writing device drivers are participating in open source code development. More likely they will be developing business applications in C# or JAVA (or the next big high level language to come along) their entire career. - rolf, on 10/12/2007, -5/+32I actually learned on C. Then I learn other languages (Java, C++, C#, whatever flavor of year). Over time, programming became vastly less fun.
When I learned Lisp last year, it was a reawakening - what a completely different way of thinking. It actually made programming fun again. Which is good.
C has lost it's importance because, besides Lisp, all those other languages listed descend from a C style of thinking to a large part - so there is a large overlap of skills - if you learn Java/C++/C#/etcetera you undestand most of C (though the converse may not be true).
These days, it's still important in areas like kernel programming, but unless you are planning to go into such a direction - there are better uses of time.
Years ago, people insisted you had to learn an Assembly language - yeah it's a good experience to have but your just as well off learning on a tool you'll be working with, or perhaps even better the math under Computer Science - it's more important to understand those concepts than a programming language who has been imitated widely (and thus you are inevitably exposed to it in one form or another anyway). - balkanboy, on 10/12/2007, -0/+2499.5% C, and parts of it (like the bootloader possibly or some other super critical piece of code) are probably written in assembler (as are most Unices).
Not to say all of it couldn't have been written in C++ either, it's just that if C gives you 5 ways to shoot yourself in the foot with its memory("object") model, then C++ gives you 100 ways to blow your head off with its object/memory model. Plus some people would argue that C++ compilers still turn out bloated assembly code, whereas you would be hard pressed to hand write more optimized assembly code than a good C compiler would generate for you (unless you're a compiler writer, that's highly unlikely, and most of the general population of programmers do not write compilers for a living, but rather apps) - capiCrimm, on 10/12/2007, -0/+23I'm pretty sure the linux kernel has some asm in it... in fact I can pretty much guarantee it, however that's not a good reason to go out and learn assembly. Funny enough, I didn't really "get" pointers until I learned asm.
#5 is just blatantly wrong. Lisp, Haskell, OCaml, Perl, Ruby are all languages that no matter the C background your still going to have to do some heavy relearning. Infact, even Java and C# will need heavy relearning. Syntax is only a tiny fraction of a language. If you program C in Java you'll be pitiful.
I recommend learning C. In fact, I recommends learning as many difference languages and paradigms as you can. Just not for the reasons stated. - rm999, on 10/12/2007, -24/+46If you call yourself a programmer and don't know C or C++, shoot yourself. Seriously, learning C/C++ will likely increase your earning potential and job security. Every programming interview I have been to has assumed at least basic knowledge.
Programming in Java and C# is fine, but I wouldn't call programming in C or C++ "geeky." C is likely to hang around for a very long time, which I cannot say with certainty for C# and Java
Even non-programming engineers should know basic C. I (adequately) learned it in high school in about two weeks. - leinir, on 10/12/2007, -1/+23Short version: With a LOT of REALLY heavy pondering ;)
- inactive, on 10/12/2007, -1/+17You use other tools to help you organize your work, such as an IDE (Visual Studio, for example), and project management software. But the actual code can be done in pure C if you're so inclined.
- inactive, on 10/12/2007, -2/+18Writing code in C doesn't preclude you from applying appropriate programming design techniques such as modular separation of code and even OO. It's certainly more verbose to do so in C than in higher-level languages, but by no means impossible or even difficult if you know what you're doing. The linux kernel is segregated into many different nested directories--each having a fairly narrow and well-defined purpose--with Makefiles, common headers, and UNIX tools tying it all together. GNU make is especially a good candidate for such organization.
Anyways, a good reason to learn C is to prepare yourself to deal with leaky abstractions, as described here: http://www.joelonsoftware.com/articles/LeakyAbstractions.html - geminitojanus, on 10/12/2007, -0/+16"I would disagree with the author's assertion that C is more low-level than C++, however; they're both at the same level (C++ just allows classes and namespaces and has a stronger type system)."
Well, that is the case now, with the state of C++ compilers being much better than they were when the language was invented (sad to think it wasn't all that long ago). The original C++ compilers just compiled their code into C and then used a C compiler to make machine code. With GCC/++ now, it all compiles into a meta-language which is then compiled to the specific machine. A lot of older.. (a-hem, more mature) programmers see C++ as being a higher level language because of this (as nobody writes operating systems in C++, and it's almost just as unheard of that anyone writes system libraries with it). More or less, C is taught as the fundamental machine abstraction language, because at the time of its authorship, it was.
I agree that the argument is more or less specious now. - inactive, on 10/12/2007, -1/+15Chicken/Egg.
You're probably going to be using a computer with an Operating System with C to build this new OS. - MasterDirk, on 10/12/2007, -4/+181: No. Both assembly and pure machine-code is lower-level than C
2: Silly. See 1.
3: Who WANTS to program those? Oh, and see 1.
4: C is small and fast. And buggy, and prone to break. And some things really do go faster in other languages like (off the top of my head) (a) anything that's moderately complicated to code, and (b) really big computations where you actually need to let the computer code it for you (use oCaml). Oh, and your code will be buggy, so it won't be fast.
5: No. Procedural languages often hark back to C. But functional is not the only way to go, it's not even often the way to go. Object-oriented or functional programming could be just what you need, and then your C knowledge would have negative value if any.
6: No problems with this one. Not exclusive to C, though.
7: C++ and Java (now that it's GPLd) are the poster-childs of OSS. So say I. Check out how many C apps are on sourceforge compared to java. Go on, do it.
8: Gotta give the guy this. Strange that Java and C#, none of which use pointers, don't teach you pointers. Should we perhaps mention that pointer-arithmetic and use are BAD FOR YOU? Bugs galore.
9: I agree with this. C is good to know, it'll make you happy to work in something else. Almost anything else.
10: See 1. - gameforge, on 10/12/2007, -1/+14Seen as the *expressed* solution to a problem, C allows you to *express* virtually anything. For example, you can "pretend" to do OOP in C and still gain the benefits of object oriented design (minus compiler enforcement).
Further, most raw assembly language is first written in C, compiled, and then hand optimized, rather than being written from scratch - this is true of boot code, BIOS code, graphics code or what have you.
That said, I thought 8 of the points in the article could have easily made the same case for assembly language (excluding #7 and #9). The only problem is that there is no standard assembly language. There's x86 assembly, that will get you so far, it's very popular and there's a lot of existing open code... but there aren't a lot of x86 microcontrollers. And with 64-bit multi-core chips out now, there's a lot of variation between "versions", and simply "how the chip behaves at its best", if that makes any sense. It's the language you never really fully learn; it just keeps evolving.
However, there's PIC microcontrollers, Parallax SX microcontrollers (which can be configured to run BASIC), Intel microcontrollers, and every which kind of proprietary ones - but nearly all of them have a C compiler written for them, including PICs, SX's, Intel's, etc.
C is everywhere. - uzytkownik, on 10/12/2007, -1/+13Simple by good dividing into smaller parts (modules, objects, structures...).
You can look thought Linux code ;) - WiskyDrinker, on 10/12/2007, -1/+12@ ElectricGrandpa
Actionscript?.. Sorry dude, but scripting a flash movie isn't the same as programming in C...And to think you that you know actionscript so that means you don't need to know C or C++ .. that nut's ... you're totally wrong on that one... - sandofsky, on 10/12/2007, -2/+11The author has no idea what he's talking about.
1) Assembly is lower level.
2) Why would you have to modify a device driver? Legacy hardware? The day I'd have to do that is the day I quit.
3) "What if..." is always a retarded reason.
4) Nothing can be faster than assembly. However, a smart compiler on a high level language can optimize better than low level hacking.
5) How about Ruby, Smalltalk, Perl, LISP, and on and on?
6) That's true of any popular language.
7) It's the language of the linux kernel. The language of any given open source application depends on the project needs.
8) You only learn them because C gives you no choice. Modern languages provide you garbage collection that in many cases works better than managing memory by hand.
9) Quantity over quality: McDonalds is the world's most popular restaurant. I haven't touched C in years, and I'm in the upper salary range of my peers.
10) No, it doesn't.
Everyone should learn one new language every year, but a fraction of working programmers develop games, database engines, or operating systems. - Schpariel, on 10/12/2007, -0/+9C# has pointers, although you need to mark your code as unsafe if you want to use them
- daeken, on 10/12/2007, -0/+9@BobbyOnions
"Assembly is not machine code. Please don't propagate that myth."
Assembly is machine code in human-readable form. There's a 1:1 translation between the two in either direction. Assembly is machine code just like decimal 10 == hexadecimal A; two different forms of the same information. - whizkid, on 10/12/2007, -0/+7As a computer engineer with a love for assembly I take issue with #3 as well. While I'm sure a compiler can create much more efficient assembly from a C program than I can code, there is a different mindset when programming in assembly and for many of the programs I have written outside of the ones to teach me in my college course would be just weird to write in C.
Just to be a fanboy of assembly: Programming microcontrollers in C is for pussies. - NCSUCodeMonkey, on 10/12/2007, -0/+7Why C? The main advantage that I see to learning C language is that you have to manage your own memory and be very careful with your types. It teaches you responsibility, but I think that assembly is what all "programmers" should know. Assembly really teaches you that even things that look computationally cheap can be really expensive.
- balkanboy, on 10/12/2007, -1/+7It'd be more correct to say C was a subset of C++, since C++ compilers would (for the most part) compile any C code without major hickups. As for doing anything with either, you can insert your favorite language there, and you'd still be able to pull anything off. The issue is - is it the write tool for the job? Surely, you wouldn't want to be writing an OS in BASIC?
- ragipy, on 10/12/2007, -0/+6In two words "Code Reuse", even for linux it took a long time to be a fully functioning operating system. And I believe a lot of the code isn't changed very often
Another thing is operating systems are not as complicated as you might think, the kernel(the main part) is farily simple compared to the whole system. The rest includes applications, installers, user interfaces and they are generally programmed in higher level languages.
- Eleo, on 10/12/2007, -1/+7Even with organization tools, that much code sounds like a lot of strife and impending headaches.
- dex2k, on 10/12/2007, -6/+12i dont agree with the author, sure its great to learn C, a must-know language, but microprocessors run on machinecode, not C, C is compiled to machinecode, so any language that has the right compiler would run on such a processor, there are even some basic-like compilers out there.
- zephc, on 10/12/2007, -0/+6I definitely agree with paching on both major points. Despite every new layer of abstraction built on top of old layers, if you don't understand what is going on behind the scenes (at least theoretically), breakage will leave you stumped until you learn it, or ask someone. C is pretty much the best way to learn what is going on underneath your normal programming levels. I think its important to be able to switch from your normal mindset of thinking in classes, objects, generators, etc., and to think about the call stack, and heap allocation, and so on.
It's sort of like how Alan Watts described Zen - being able to see reality both from your every-day perspective (higher-lvl languages), which is more useful, and from the universal perspective (the interaction between the OS, the hardware and your program), which more properly reflects the underlying truth and nature of the system.
Additionally, it is probable that as a programmer you will have to alter C code *some*where at *some* time, due to the the sheer amount of it out there. - squelart, on 10/12/2007, -0/+6To add to 4, there's a good debunking of "C is fast" there: http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php#more
Excellent post, excellent blog.
I'd still recommend learning C anyway but not for all the reasons in the article. Always good to know different tools so that you can choose the right one. Or sometimes you can't choose and you might as well know something that's still in demand... - zephc, on 10/12/2007, -1/+6YOU FORTH LOVE IF HONK THEN
- pHr34kY, on 10/12/2007, -0/+5C++ is basically C with some added functionality. C code will theoretically compile on a C++ compiler without an issue. C++ is good when you feel the need to code classes, but I would personally just write a C header instead, C++ does my head in.
Oh, and the reason C works on virtually any microprocessor is because it compiles directly into native machine code (assembly). In reality, ALL processors can only read machine code. It's just that there's a C compiler for pretty much every processor ever produced :) - capiCrimm, on 10/12/2007, -0/+5No, actually. C and C++ were standardized at different times. So there are things you can do in C that you can't do in C++(although, for the most part your correct.). Second there are different paradigms involved, which is really the core of a language, not the syntax.
- sakhamuri, on 10/12/2007, -0/+4Don't think of a OS complexity in terms of language (how a language can solve OS complexity is a wrong question). The complexity of OS is reduced by partitioning the OS into kernel, device drivers, memory management each is a individual module co-operating with each other to achieve the fine balance of providing a place for all your programs to execute.
- geminitojanus, on 10/12/2007, -3/+7"It'd be more correct to say C was a subset of C++, since C++ compilers would (for the most part) compile any C code without major hickups."
Absolutely NOT. It's more correct to say that C++ is a modified superset of C; even when thinking about object orientation, this makes more sense. C was developed first, and it is more fundamental (and a different language), and there are many super-sets of it, for example Objective-C is a strict super-set of C. - sirsteveh, on 10/12/2007, -0/+4@ragipy: it's not higher-level, it's just used in a higher-level context. STL is written in C++, just as there are libraries for C. It just so happens that because C++ has a few extra (but crucial) bits of functionality, its standard libraries look a lot higher-level; this is just code reuse.
A real high-level language would be something like Python, which turns _everything_ into an object for you, without any handling of low-level types. - ragipy, on 10/12/2007, -7/+11"I would disagree with the author's assertion that C is more low-level than C++, however; they're both at the same level (C++ just allows classes and namespaces and has a stronger type system)."
I am totally wasted right now but even I know that C++ is definitely higher level than C. For one thing the mentallity is totally different it is an object oriented language not a functional one which means a lot of code reuse templates(STL) etc.
Even C++'s founder says it is decisively higher level (look it up, thats what I learned).
Check back in the morning for more concrete reasons :) - muramasa, on 10/12/2007, -0/+4I agree with the premise of the article. Learning C even if you never use it, gives you fundamental knowledge about things like memory management, and how pointers work. Even if you never use C for any of your projects this is valuable information.
I personally would never select C or C++ for any of my own projects, because there are so many newer/higher-level languages that are much less painful to code in. But, there will always be a place for skilled C and C++ coders. - GliTCH82, on 10/12/2007, -0/+4Look, I know it's a really hard concept for some of you geeks to grasp, but honestly some people don't really have a need for that much control over their electronics. It used to be that anyone who was halfway serious about learning computers had to build their own processors using electronic components. Most of us don't need to do that anymore.
My point is that in order for any useful amount of work to be done in abundance we need to reach a point of not having to fiddle with low level languages and functions anymore. These redundant tasks are being automated. There will always be people out there who need to learn C, but in my limited area of writing business applications I find that .NET and Java work just fine.
To each his own. - ElectricGrandpa, on 10/12/2007, -4/+7@ Wiskydrinker
"Actionscript?.. Sorry dude, but scripting a flash movie isn't the same as programming in C...And to think you that you know actionscript so that means you don't need to know C or C++ .. that nut's ... you're totally wrong on that one..."
Go look at some AS2 or AS3 code, and tell me it's not damn similar to C. You obviously don't know anything about ActionScript. It's come a LONG way. - frukt, on 10/12/2007, -6/+10"When I learned Lisp last year, it was a reawakening - what a completely different way of thinking"
I suggest you learn Haskell or some other functional programming language for a far greater awakening. Haskell reminds me of the quote "To iterate is human, to recurse divine". - 256byteram, on 10/12/2007, -0/+3"3) What if you ever want to get a job programming microcontrollers? They are programmed in C. Are you going to limit your possible list of jobs because you didn't want to learn a new language?"
Not every microcontroller can be programmed in C, nor can every function be programmed in C, though the majority can be..
"4) C programs are smaller and faster then any other program created in a different language. Sometimes your program needs that speed boost that only C can give it."
Ever programmed in FORTH? In my opinion it's the second fastest language from Assembler and doesn't need compiling.
By the way, I spend a lot of my time tinkering with 8-bit microprocessors - 8080, Z80, 6502 etc, so naturally I revolve around FORTH and assembler :) - LordofShadows, on 10/12/2007, -0/+3I really dont understand why people here are treating C/C++ like some sort of archaic language here. -- What languages are you writing *real* code in?
- awhiteflame, on 10/12/2007, -4/+7It's been a couple times in this thread so I won't quote any particular person, but can anyone tell me how "MySQL" justifies as "programming"? SQL syntax really..isn't..that difficult.
- Bibimbap, on 10/12/2007, -0/+31. lower level is the complete opposite of abstraction - something taught in programming. Do car painters need to know how valve timing works in a car engine? that's what abstraction's all about.
2. They aren't written exclusively in C. In Unix they may be, but they could very well be written in C++. Microsoft's testing a new kernel where everything's written in C# and a very small real-time app handles the time slicing of managed code - SUN was working on something similar for Java.
3. Micro controllers are often programmed in ASM. There's not a C compiler for every micro controller, especially ones with limited or synchronous bus access.
4. C is slower than C++ in most cases due to compiler optimizations in C++ in the last few years when everyone stopped working on C compilers. Java's very very fast at certain large dataset operations because of the way the VM can prefetch and cache independent of hardware. If you really need speed, assembler's the only way, not C.
5. Completely wrong... I can't even begin to say how wrong this is. Syntactically this may be true, but syntax is meaningless. The semantics of C are vastly different from other languages. It's a single paradigm language who's paradigm has been mostly ignored by modern language.
6. So? There's a lot of C++ and Java code too. COBOL's been around longer, and there's lots (too much) COBOL code in use still, should we all learn COBOL by your logic?
7. Maybe, but most people except the kernel and driver guys don't write in C. Most people in those groups know better than to use C on every application they write anyway. I doubt any of the kernel guys would use C for anything other than a kernel. Plus there's even debate about using C for the kernel now, and some C++ code has crept in.
8. Wrong. A pointer is just variable of buswide width that holds a memory address. C has the syntax to automatically look up what's in that memory address. Assembler uses pointers with different syntax so by your logic assembler's the only way to "show what pointers really are" C++ uses pointers, in fact C++ has smart pointers as well. Java passes everything by reference which are.... get this.. POINTERS. I know they're a little dumbed down, but they're passing "what pointers really are: " Memory addresses with built in dereferencing syntax.
9. Ok
10. No... god. - balkanboy, on 10/12/2007, -0/+3To correct myself on: "is it the write tool for the job?", I meant is it the RIGHT tool for the job. But I guess at 4am PST, dyslexic attacks are commons even for those that know how to barely spell ;).
- wangeyes, on 10/12/2007, -1/+4A tedious list written from a very narrow (and in places, inaccurate) perspective.
- ElectricGrandpa, on 10/12/2007, -5/+8"If you call yourself a programmer and don't know C or C++, shoot yourself. Seriously, learning C/C++ will likely increase your earning potential and job security. Every programming interview I have been to has assumed at least basic knowledge."
I don't know C or C++, but I'm damn good with ActionScript. Should I shoot myself? I have no doubt that I *could* learn C, but I don't want to and I don't need to... for my job or my "earning potential". - Rabbethan, on 10/12/2007, -5/+8Guess I must learn C then.
-
Show 51 - 100 of 149 discussions



What is Digg?