Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

What's To Love About C?

samzenpus posted more than 2 years ago | from the favorite-tool-in-the-box dept.

Programming 793

First time accepted submitter edA-qa writes "Antiquated, clunky, and unsafe. Though beloved to some, C is a language that many choose to hate. The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C. Yet they do. In fact a lot of things, even new things, are programmed in C. The standard was recently updated and the tools continue to evolve. While many are quick to dismiss the language it is in no danger of disappearing."

cancel ×

793 comments

Sorry! There are no comments related to the filter you selected.

because (4, Funny)

Anonymous Coward | more than 2 years ago | (#40518773)

char *post = "first";

Re:because (5, Insightful)

Anonymous Coward | more than 2 years ago | (#40518785)

Using a string literal as not const is very bad form.

Re:because (4, Funny)

Anonymous Coward | more than 2 years ago | (#40518867)

Back to C++ Land with you, rascal!

Re:because (5, Informative)

localman57 (1340533) | more than 2 years ago | (#40518947)

No, he's right. On systems where your constants exist in a different medium than your variables (such as microcontrollers where variables are in RAM but constants are in flash), declaring a string as const or not const can have a big impact on what resources you eat up. Typcially, there's often a #pragma or non-standard keyword such as ROM that goes along with this.

Re:because (0)

Anonymous Coward | more than 2 years ago | (#40519037)

#constlol char *parent_post = "fail"

Re:because (0)

Anonymous Coward | more than 2 years ago | (#40518791)

char *post = "first";

const char* post = "first";

Re:because - (0)

Anonymous Coward | more than 2 years ago | (#40518969)

static char const post[] = "first";

I bet many don't know the difference between :

const char *foo; and char const *foo;...

CAPTCHA = golden (Thank you!)

Re:because - (4, Informative)

19thNervousBreakdown (768619) | more than 2 years ago | (#40519059)

That's because there is no difference! I think you meant:

char* const foo;

for the second one. const modifies the item to the left, unless it occurs at the beginning of the line, in which case it modifies the item to the right.

Re:because - (4, Informative)

AuMatar (183847) | more than 2 years ago | (#40519171)

And the funny thing is that most people who write const char* foo really want char const * const foo. You don't want either the pointer or the data pointed at to change. However, almost nobody knows that, so even those who do just use the weaker const char* so people understand the code.

Re:because - (4, Informative)

DanTheStone (1212500) | more than 2 years ago | (#40519199)

Thank you. "const" modifies the thing that preceded it. Iff nothing precedes it, it modifies the first thing that follows it. It's not terribly complicated.

Re:because (1)

Anonymous Coward | more than 2 years ago | (#40519349)

const char* post = "first"

you troglodyte.

One good reason... (5, Insightful)

Anonymous Coward | more than 2 years ago | (#40518813)

It's not the bloated obscenity that is C++.

Re:One good reason... (3, Insightful)

serviscope_minor (664417) | more than 2 years ago | (#40519117)

It's not the bloated obscenity that is C++.

C++ is not a bloated obscenity. It is an excellent language.

I am not claiming it is a language without warts, but I challenge any one who modded the parent post up to provide a coherent argument as to why C++ is bloated and what features you could therefore remove without detracting from the effectiveness of the language.

Re:One good reason... (5, Interesting)

AuMatar (183847) | more than 2 years ago | (#40519287)

I like C++, but I can think of a few. Lets ignore for the moment things like macros that are outdated in C++ and kept for C compatibility. We can easily get rid of:

*Value templates.
*Diamond inheritance (just make it illegal)
*The entire algorithms part of the STL. Nobody uses it and it makes for unreadable code (keep the container classes, of course)
*Kill either structs or classes. We don 't need both, with one being syntactic sugar to change the default visibility on the other
*The iostream libraries. I don't think I've ever seen code that didn't say fuck that and just use C style stdio. They're clunky.

That's off the top of my head, without going into things we could do better. And I like C++, it's my preferred language. The real argument here is even though C++ is bloated, it's far from the worst that way. Perl takes that crown, with it's 500 special variables. And the people who complain about C++'s bloat generally like Python or Ruby, which are both just as bloated as C++, without the bonus of it's simplicity.

Re:One good reason... (0)

Anonymous Coward | more than 2 years ago | (#40519375)

C++ is a reasonable programming language but to so good as a religion

Useless submission. (1)

chemicaldave (1776600) | more than 2 years ago | (#40518823)

How is this news for nerds? We already know this old story.

Re:Useless submission. (1)

MyLongNickName (822545) | more than 2 years ago | (#40518853)

Not useless. Not everyone who reads Slashdot is a developer.

Re:Useless submission. (2, Insightful)

chemicaldave (1776600) | more than 2 years ago | (#40518911)

If you're not a developer then you don't care about the nuances of C.

Re:Useless submission. (5, Insightful)

Anonymous Coward | more than 2 years ago | (#40519011)

If you're not a developer then you don't care about the nuances of C.

Of course. Curiosity is a bad thing. You should stick to what you already know, and never try to expand your knowledge beyond your field.

Re:Useless submission. (3, Insightful)

Penguinisto (415985) | more than 2 years ago | (#40519223)

Not necessarily.

Some of us were developers at one point in our careers, some of us deal with tech that is extremely close to having to occasionally jump into source code, and some of us are hobbyists who just do it for the hell of it.

Personally, I dabble in it once in awhile, but cannot stand to do it professionally. Why? Because I'd rather dream of naked nubile young ladies (grits optional) than to spend all my sleeping hours mentally untangling someone else's poorly-built code (or worse, my own occasional bork-ups).

That, and it's kind of nice to not have to keep a laptop near the bed any more. :)

Re:Useless submission. (0)

Anonymous Coward | more than 2 years ago | (#40518863)

Yeah. The strong and weak points of C are well-known (by those who care to know), there is nothing new here and nothing to discuss.

Re:news for n00bs (0)

Anonymous Coward | more than 2 years ago | (#40518895)

stuff that everybody knows

Re:news for n00bs (5, Funny)

Vlad_the_Inhaler (32958) | more than 2 years ago | (#40519123)

Move along, nothing left to C

Maybe because it compiles down to the metal... (5, Insightful)

skids (119237) | more than 2 years ago | (#40518831)

...and not some VM? Most of the popular languages these days are all dynamic. And they are very convenient and nice. But if you actually want to know what the machine is actually doing, and want to have a say in such things, C is the way to go.

I mean, unless you want to, you know, use pascal or fortran or something.

Re:Maybe because it compiles down to the metal... (4, Insightful)

interval1066 (668936) | more than 2 years ago | (#40518965)

Although possible, and done, I have a hard time thinking of good reasons to write drivers in higher level or interpeted languages. Besides, most kernels are written in C, makes sense to write drivers in C. When some one trots out a kernel in Python then I'll jump on the systems work in python bandwagon.

Re:Maybe because it compiles down to the metal... (4, Informative)

slew (2918) | more than 2 years ago | (#40519065)

...and not some VM? Most of the popular languages these days are all dynamic. And they are very convenient and nice. But if you actually want to know what the machine is actually doing, and want to have a say in such things, C is the way to go.

I mean, unless you want to, you know, use pascal or fortran or something.

Although "C" compiles down really very close to the metal, so does "C++" (and a host of other more modern languages). However, it's not that easy to take that next step to the metal. In between is a machine that virtualizes the registers (using register renaming techinques), virtualizes the memory (using difficult to predict caching, translation, and ordering operations), and reorders the instructions (speculation, branch target hiding, etc), and runs in a sandbox (under the os which is timeslicing between tasks and faulting and swapping in memory translations and maybe even simulating some instructions).

Knowing what the machine is actually doing is often a mythical quest down the rabbit hole. Although I'm a big fan of "C+" (what I call the c++ subset that doesn't have all the crapola that I don't use**), I'm under no illusion that all you are really doing with C is using a more predictable translation strategy (e.g., static compile time translation) rather than some magical "metal" commanding language.

** +objects, +const, +templates, +-stl (some are okay), -overloading, -virtual inheritance, -rtti, -boost, etc...

Re:Maybe because it compiles down to the metal... (1)

Anonymous Coward | more than 2 years ago | (#40519137)

Everyone has their own subset of C++ that they like, which means when you get a bunch of programmers together on a C++ project, the odds of you running into the C++ misfeatures you can't stand to look at approaches 1.

Re:Maybe because it compiles down to the metal... (1)

serviscope_minor (664417) | more than 2 years ago | (#40519175)

c++ subset that doesn't have all the crapola that I don't use** ...

-overloading

How do you add two ints? How about two floats? Why is overloading bad?

Re:Maybe because it compiles down to the metal... (1, Insightful)

benjfowler (239527) | more than 2 years ago | (#40519227)

OTOH, well designed, modern hotspot JITters can optimize in ways a static compiler can't.

Re:Maybe because it compiles down to the metal... (2, Funny)

Penguinisto (415985) | more than 2 years ago | (#40519335)

Even better - it allows you to actually make the results efficient. While most CS grads these days likely expect hardware tech to keep up with the bloat, there are a few folks out there who know what it's like to economize like hell when it comes to CPU or memory.

Also, when you're seriously pushing limits, it's the performance difference between a 1982 Chevy Nova with a busted head gasket (.NET, I'm looking at YOU), and compiling yourself a Porsche 911 with all the Autobahn goodies included.

Good habits (5, Insightful)

Bucky24 (1943328) | more than 2 years ago | (#40518845)

Personally the thing I like most about C is that it's not "safe". It doesn't take care of a lot of memory management for you and you can easily eat up all the memory or introduce a buffer overload vulnerability if you're not paying attention. It forces programmers to actually look at what they're doing and consider what it will do in the long run, and causes good coding habits to form. I think the majority of people who dismiss C as "too hard" are coming from Java programming. C gives you a lot of power, but, as the well-cliched saying goes, "with great power comes great responsibility".

Re:Good habits (5, Informative)

localman57 (1340533) | more than 2 years ago | (#40518967)

Exactly. My company does a lot of different things from embedded systems to web interfaces, and, generally speaking, the C guys write better Java code than the Java guys write C code.

Re:Good habits (0)

Anonymous Coward | more than 2 years ago | (#40519245)

Your Java guys must write the worst C code known to man, then, because every C-coder-writing-Java that I've encountered just tries to write C code wrapped in a Java class. And then they mess it up.

Re:Good habits (0)

Anonymous Coward | more than 2 years ago | (#40519371)

This has been my experience as well. I don't know many C programmers that translate well to non C languages..because most of the patterns they don't run into much in their world. They tend to write mostly large blocks of if/else and such

Re:Good habits (5, Insightful)

ShanghaiBill (739463) | more than 2 years ago | (#40519305)

the C guys write better Java code than the Java guys write C code.

My experience is that the C guys (and gals) often write better Java than the Java guys write Java.
Programmers who have never written in C (and/or assembly) often have a poor understanding of how computer actually work.

Re:Good habits (5, Insightful)

jmsp (1987118) | more than 2 years ago | (#40519053)

> It forces programmers to actually look at what they're doing

OMG! There. That's where all the hate comes from.

--
(Programming in C since 1984)

Re:Good habits (-1, Troll)

lwriemen (763666) | more than 2 years ago | (#40519089)

Wow! There's an apologist answer if I ever heard one. I have been an embedded programmer for 20 years, and there is no question that C is too hard.

Re:Good habits (1)

Anonymous Coward | more than 2 years ago | (#40519321)

So have I, and C is simple, efficient, and EASY.

Re:Good habits (4, Interesting)

jellomizer (103300) | more than 2 years ago | (#40519139)

Problem is the diligence that is required. A C developer is a really good coder when they do their work in an other language. However for large projects, C doesn't make too much sense, because you need to expect your developers to be on their A Game in the course of the project. A developer is porting their proof of concept code into production, right near lunch time, and he is starving, and some of the other guys are waiting on him to finish up, because they are starving too, might mean some code got copied in, and put into the production set, without full though. Because the Proof of Concept code worked, it may pass many layers of Quality Check (and we all know most software development firms have very poor QA teams) Once it leaves and goes to the customer, it could be wide open to a security problem.

Every Developer thinks they are the best developer on earth about 50% of them are actually below average. C is a great teaching tool, I wish most colleges still used it, and didn't switch to .Net and Java. However once you go into production, unless you really need the C performance (and you can code highly optimized C) going with other Languages that are a little more protected is a safer bet.

Hire a C developer... Give him a higher level language, and you will probably get really good code.
Hire a C developer have him program C, you are setting up a time bomb, where once they miss a beat you are screwed.

Re:Good habits (1)

localman57 (1340533) | more than 2 years ago | (#40519217)

The funny thing about this, is how often higher-level languages let you sweep things under the rug. For instance, how often have you seen some hack take a big, complicated function, and call it inside a try/catch block that just throws out the exceptions? In C, these programs usually crash spectacularly. If you run them under GDB or similar, you can see where they crashed.

Re:Good habits (1)

jellomizer (103300) | more than 2 years ago | (#40519353)

In C, you hope these programs [strike]usually[/strike] crash spectacularly. FTFY
When they do not, that is when the real trouble exists, and could destabilize your application further down the line.

The Try Catch when used properly. Makes sure if there is a problem, you leave your program cleanly. It is open for abuse yes... But so is any language command.

Re:Good habits (1)

benjfowler (239527) | more than 2 years ago | (#40519253)

I've seen "C" written in Java. And it ain't pretty.

Re:Good habits (1)

OTDR (1052896) | more than 2 years ago | (#40519265)

Exactly! Sadly, I'm old enough to see code performance improved more often by the application of better hardware than by better coding practices and smarter software designs. A poor coder will code poorly regardless of the language and C can be just as safe as the next language in the right hands, or as dangerous. C is nice to have around in many circumstances where resources are few (the embedded world, for example) or when you really need to get down to business with minimum overhead and fuss (like the realtime simulation world).

C holds your hand less. C let's you excel when you need to. C reveals your incompetence when you're lazy. If your application doesn't need it or you don't know how to use it, go write an Excel macro instead. :)

Who made that question? (4, Insightful)

Anonymous Coward | more than 2 years ago | (#40518847)

A web developer?

C is the the best tool around for low level programming. It allows very high levels of abstraction and it keeps you very close to your architecture's features.

FORTH and C++ are used to the same means, but I do not hear much about other tools being used for this kind of development.

Control (5, Insightful)

Dan East (318230) | more than 2 years ago | (#40518849)

C offers control. If you can't handle having that much control (over memory, how the CPU acts on that memory, etc) then your software will have many problems and you will hate C.

Re:Control (5, Insightful)

jythie (914043) | more than 2 years ago | (#40519079)

Not just control, but predictability. C does exactly what you tell it to do and you can see what it is doing more easily then other languages. You can tell C++ to do 'X', but it might slip in a 'Y' and 'Z' without telling you.

Re:Control (1)

Anonymous Coward | more than 2 years ago | (#40519345)

Ding ding. This is the correct answer.

This is exactly the same reason that air traffic control still use software running on computers made in the late 90s. Why? Because they know it's reliable and will do exactly what they want. Businesses don't necessarily care about fast, nor do they care about cheap. These are bonuses. What they want is something that requires minimal maintenance and will be foolproof for years.

Re:Control (0)

Anonymous Coward | more than 2 years ago | (#40519365)

a=a++;

I rest my case.

The portable assembler (5, Insightful)

heson (915298) | more than 2 years ago | (#40518861)

Close to the metal but still not specific to any machine if you do not need to. Easy to understand exactly what machinecode the compiler will produce.

Small, fast,simple, support (0)

Anonymous Coward | more than 2 years ago | (#40518869)

While it's true plain C is old and (when not used properly) unsafe, it is also very fast, cross-platform and there have been thousands of libraries made to work with it. Plus, for low-level stuff, it's still one of the better options. Almost all languages have good and bad points, C's good points obviously outweigh the bad or it wouldn't be used for so many projects.

Not a "Nanny State" language... (2)

Anonymous Coward | more than 2 years ago | (#40518873)

You have to know what you are doing when you C and you can do anything...

Sesame Street already covered this (5, Funny)

Zephyn (415698) | more than 2 years ago | (#40518879)

It's for cookie.

That's good enough for me.

a long enough rope... (0)

Anonymous Coward | more than 2 years ago | (#40518891)

C gives you the rope to hang yourself at a lower level - no strong typing, poor tools for abstraction . .Net, Java et al will hang you with their class explosion, athough you might enjoy the higher view before the rope tightens.. It depends on who's writing and for what purpose, not the language itself.aka - No pointers here, keep moving.

Shorthand for Assembler (5, Interesting)

codefool (189025) | more than 2 years ago | (#40518897)

The power of C is - and always has been - that it is a shorthand for assembly. It compiles very small and runs very fast, making it ideal for embedded systems.

Think of it as standardized assembly programming (5, Insightful)

localman57 (1340533) | more than 2 years ago | (#40518905)

C is going to stay around for a long time in embedded systems. In this environment many microcontrollers still have 4k or less of RAM, and cost less than a postage stamp. In these systems there is virtually no abstraction. You write directly to hardware registers, and typically don't use any dynamically allocated memory. You use C because, assuming you understand the instruciton set, you can pretty much predict what assembly instructions it's going to generate and create very efficient code, without the hassle of writing assembly. Aditionally, your code is portable for unit testing or, to a lesser degree, other microcontrollers. This allows you to write a program that will run in 3.2 k of ram, rather than 4k, which allows a manufacturer to save 4 cents on the microcontroller they pick. This saves you $40,000 when you're making a million of something.

Re:Think of it as standardized assembly programmin (0)

Anonymous Coward | more than 2 years ago | (#40519077)

A good optimizing (mostly Intel and Portland group) compiler produce hard to guess machine code for non trivial projects, but I never saw an optimizing compiler that targeted embedded device deserving the name optimizing. Overpriced: oh yeah; but optimizing : meh !

Re:Think of it as standardized assembly programmin (3, Insightful)

vlm (69642) | more than 2 years ago | (#40519191)

you can pretty much predict what assembly instructions it's going to generate

Which is really important, because sometimes you end up debugging at that level or working hand in hand with inline assembly code.

If there is no OS, or you're writing the OS, C is the way to go.

Re:Think of it as standardized assembly programmin (1)

serviscope_minor (664417) | more than 2 years ago | (#40519229)

Well, C++ basically has all the same properties. GCC, for example will happily target really very small ATMEL micros.

Because (1)

Anonymous Coward | more than 2 years ago | (#40518915)

Its a way to tell a machine what you want it to do that ends up doing exactly what you expected in the most efficient way. C++ too, sometimes. Java, never.

Re:Because (1)

jellomizer (103300) | more than 2 years ago | (#40519231)

Just because you are programming in a Lower Level language... It doesn't mean all your code will be faster.

When you code in C (or any other language) your goal is usually focused on your final project. Even with a degree in computer science, you may not have focused all your code to be optimal, (you are short on time so you put a bubble sort in it). Compared with Java where you do a .Sort() to your string class... Chances are it will be coded with a Faster sorting algorithm. Because the person who programmed Java .Sort() class, their business requirement wasn't to make a large project, but an efficient sort algorithm.

 

Letting the opinions of others decide for you (0)

Anonymous Coward | more than 2 years ago | (#40518925)

Is not in your best interest. Or are you just a troll fishing for page views?

Where'd the Unix go? (4, Interesting)

burdickjp (2530248) | more than 2 years ago | (#40518929)

It's not dead because all of your VMs and interpreters have to interact with SOMETHING, and that SOMETHING has to be written in a low-level language. I strongly believe in using only the lowest-level language necessary for the job, but for OS development that's C.

Simple. (5, Insightful)

Short Circuit (52384) | more than 2 years ago | (#40518943)

Tons of people love to have something to hate. It might be because they don't like something about it...but I think it's mostly because people like to set up communities held together by rhetoric against a tool or technology perceived and portrayed as an enemy.

"C++ sucks. We are at war with C++. We have always been at war with C++.[1]"

Swap out "C++" for whatever language you like.

Certainly there are going to be cases and scenarios where C is preferable over C++, where C++ is preferable over C, or where Brainfuck is preferable over either. Use the right tool for the right job,[2] and the right tool is whichever allows you to most effectively achieve your goals.

[1] Or, at least since its inception. Or since [insert arbitrary date here].[3]
[2] For whoever asks "what's the right job for Brainfuck?" ... just wait. Someone will eventually come along and get modded +2 Funny when they reply to you.
[3] I see what you'll do there, Mr. Connor.

Re:Simple. (1)

Bill_the_Engineer (772575) | more than 2 years ago | (#40518961)

Repeat after me: C++ is not equal to C

Re:Simple. (1)

Bill_the_Engineer (772575) | more than 2 years ago | (#40518983)

Disregard. I found your

Certainly there are going to be cases and scenarios where C is preferable over C++, where C++ is preferable over C, ...

Re:Simple. (2)

localman57 (1340533) | more than 2 years ago | (#40518997)

Repeat after me: C++ is not equal to C

Wait. Did you mean equal "=", or equal "==" ?

Re:Simple. (0)

Anonymous Coward | more than 2 years ago | (#40519239)

Repeat after me: C++ is not equal to C

Wait. Did you mean equal "=", or equal "==" ?

I'm a little rusty, but I'm pretty sure "c++ = c" would give you a syntax error (unlike c = c++). "c++ == c" I believe will increment c, then compare it to itself, and so return true. So actually, c++ == c is true.

Re:Simple. (0)

Anonymous Coward | more than 2 years ago | (#40519207)

assert(C == C++);

Re:Simple. (2)

Short Circuit (52384) | more than 2 years ago | (#40519351)

assert(C == C++);

Beautiful. Someone needs to prep an April Fools joke for next year for renaming C++ to ++C.

Re:Simple. (1)

jpvlsmv (583001) | more than 2 years ago | (#40519331)

C++ is equal to C in the context of the current expression (atom).

Or don't you understand the difference between preincrement and postincrement?

The fact that ++i and i++ can be interchanged in many contexts is an optimizer feature.

int main(void) { int C=11; if (C==C++) printf("They are equal\n"); }

--Joe

Re:Simple. (1)

serviscope_minor (664417) | more than 2 years ago | (#40519273)

For whoever asks "what's the right job for Brainfuck?" ... just wait. Someone will eventually come along and get modded +2 Funny when they reply to you.

Brainfuck is the right tool for the job if the job is to be a simple a language for which one can create the world's smallest ELF capable compiler.

Aniquted, clunky and unsafe (0)

sl4shd0rk (755837) | more than 2 years ago | (#40518977)

C is not python, nor is it PHP. Yes, C is quite mature and there are several aspects of it which share a certain amount of tedium but some things can only be achieved with a certain amount of toil. As far as being unsafe, well, that's relative to the programmer. Be glad your not asked to write in Assembly.

simplicity (4, Insightful)

roman_mir (125474) | more than 2 years ago | (#40518995)

C is a very simple language and yet it allows operating memory directly in a way similar to assembler. C is portable (well, it can be compiled for different platforms), I rather enjoyed the language a while back, but since about 98 I use Java for most of big development and I am pretty sure that if I had to do everything in C that I did in Java, it would have taken me much more time.

C is nice in another way - it allows you and in some sense it forces you to understand the machine in a more intimate way, you end up using parts of the machine, registers, memory addresses, you are more physically connected to the hardware. Java is a high level abstraction, but then again, to write so much logic, it is just better to do it at higher level, where you don't have to think about the machine.

C is great tool to control the machine, Java is a great tool to build business applications (I am mostly talking about back end, but sometimes front end too).

So I like C, I used to code in it a lot, but I just to use it nowadays. What's to love about it? Applications written in it can be closely integrated into the specific OS, you can really use the underlying architecture, talk to the CPU but also the GPU (CUDA), if I wanted to use the GPU from a Java application, I'd probably end up compiling some C code and a JNI bridge to it.

C teaches you to think about the machine, I think it gives an important understanding and it's faster to develop in than in Assembler.

Re:simplicity (0)

Anonymous Coward | more than 2 years ago | (#40519099)

My point of view is probably too offensive for most people but I'm just tired to see these poorly designed softwares (developed by this kind of people) :
"If you don't like C, it means that you don't want to understand how machines work, then don't EVER touch a machine again and spare the world of any sh*t you could possibly imagine..."

Use the right tool for the right job (1)

Anonymous Coward | more than 2 years ago | (#40519033)

I don't look at a flat-head screw and grab a phillips screwdriver.

#asm (0)

Anonymous Coward | more than 2 years ago | (#40519041)

#asm is why i fell in love with C. As a hard-core assembly language coder, what was not to like?

As beginner programmer... (2)

bman49er (2518184) | more than 2 years ago | (#40519051)

...I'm looking into learning more C from an embedded perspective. A lot of Arduino libraries are written in plain C and I'm venturing to learn more about it to write my own libraries and/or edit libraries that come into conflict with others. And if you're wanting to go outside the usual Arduino chip sets (mega328, 168, etc) then it looks like C is the way to go.

If programming languages were like tools... (1)

knarf (34928) | more than 2 years ago | (#40519055)

If programming languages were like tools... then this [wikipedia.org] is what I'd prefer over this [howstuffworks.com] when I want to build myself a cabin.

Compilers, Interpreters, and Operating Systems (1)

Anonymous Coward | more than 2 years ago | (#40519061)

C shines when developing programs like compilers, interpreters, and operating Systems. It is the right level of abstraction for modern hardware. In fact, I've heard that hardware research is dominated by making C code run faster.

For everything else, which is probably 99% of all software, higher level languages should be used, with C only used sparingly for optimization. Mercurial (hg) is a good example of this; it is written in python but uses some C code to quickly compare diffs and do I/O, and rivals git, which is C with some Perl.

It's an awesome zen-language (0)

Anonymous Coward | more than 2 years ago | (#40519097)

even though i never got much done in it (just some projects at university), I was always having a good time doing stuff in contrast to other languages and was right as you'd call it "in the zone" all the time as I knew i can't just butch stuff together but have to kinda take it slower :D

Negative opinions, says who? (5, Insightful)

fahrbot-bot (874524) | more than 2 years ago | (#40519101)

Though beloved to some, C is a language that many choose to hate. The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C.

The masses to which you refer are idiots. C is great. It lets you do what you want, how you want. True, you're afforded enough programming rope to easily hang yourself, but you learn not to, and while most things can be more easily done in higher languages (you'll have to pry Perl from my dead, cold hands), many things can only be done in languages like C or its derivatives. C is one of those languages that separates the adults from the kids, so put on your big-boy pants, stop whinging about it and step up.

What a crock.... (2, Informative)

Anonymous Coward | more than 2 years ago | (#40519107)

Who are these people that hate C? A tool is a tool and some are better suited to a job then others. Even COBOL has it's place. If you want something to compile to true binary code that runs very fast on the target hardware, then C is a great tool. If you want to slam out some code that will sort of run and look okay to the user, how about Visual Basic? Pascal has it's place as does C++ and even ASP.

right tool for the job (5, Insightful)

bcrowell (177657) | more than 2 years ago | (#40519115)

The mass opinion is indeed so negative it's hard to believe that anybody would program anything in C.

Huh? What mass opinion? Where's the evidence for this?

Pick the right tool for the job. C is the right tool for some jobs, specifically jobs like writing drivers or operating systems.

Historically, C won by having an innovative syntax for pointers, which a lot of people liked, and it also won by being a small language that was easy to implement. Because it was small and easy to implement, it ended up being widely available. Ca. 1980, the joke was that C was like masturbation: it might not be what you really want, but it's always available. A lot of people in 2012 may not realize that in the era when C was winning popularity, people didn't usually have access to free compilers, and for many types of hardware (e.g., 8-bit desktops like the TRS-80), there simply weren't any good development tools. Another big win for C was that because it was so widely available, it became easy to find programmers who could code in it; it fed on its own success in a positive feedback loop. This is why languages like java had C-like syntax -- they wanted to ride the coattails of C.

IMO the biggest problems have been when people started to use C for tasks for which it wasn't the right tool. It started creeping up into higher-level applications, where it wasn't really appropriate. This became particularly problematic with the rise of the internet. Networks used to be small and run by people with whom you had personal contact, so nobody really cared about the kind of buffer-overflow vulnerabilities that C is prone to. The attitude was that if you gave a program crazy input that caused it to crash, well, what was the big deal? You crashed the program, and you were only hurting yourself.

Re:right tool for the job (1)

vlm (69642) | more than 2 years ago | (#40519263)

people didn't usually have access to free compilers, and for many types of hardware (e.g., 8-bit desktops like the TRS-80), there simply weren't any good development tools. Another big win for C was that because it was so widely available, it became easy to find programmers who could code in it; it fed on its own success in a positive feedback loop.

History repeats itself in microcontroller land. Microcontroller land is full of "free for students" "free for noncommercial use" stuff. Find me a working Scala implementation for a 384 byte (not megabyte, not kilobyte) 10F220 PIC. And now compile that code for a demo on some TI thing, maybe port it to picoblaze for a FPGA demo...

C achieves the status of COBOL & FORTRAN ? (1)

redelm (54142) | more than 2 years ago | (#40519119)

Lets face it -- there are always things to hate. Or, if you are of a more optimistic bent, things to love. Abstraction is tough, and specifying abstraction oxymonically tougher.

... Haters gonna hate. With COBOL & FORTRAN faded, they need a new target.

Fortran is better. (5, Funny)

Salis (52373) | more than 2 years ago | (#40519121)

Go ahead. Argue. I dare you.

v same sig since 2002. v

Re:Fortran is better. (2)

maroberts (15852) | more than 2 years ago | (#40519283)

Go ahead. Argue. I dare you.

v same sig since 2002. v

If a man shouts "Fortran is better" and no-one hears him, he is still wrong.

Because its fun (2, Interesting)

Anonymous Coward | more than 2 years ago | (#40519129)

I'm writing a game in C. I spent a lot of time trying to decide what language to use for the game: Java, C#, Python, C++. Ultimately I decided that I wanted to write the whole thing myself so I didn't have to rely on any releases of virtual machines.

I find it fun. I write in C++ for my job and that is where I spent most of my education. C is an interesting challenge where I don't get all of my comforts. But, it works. I tried writing the game in C++ and I kept getting lost in infrastructure: Objects or get-it-done function? I had to decide all the time. C drops that for a simple set of rules (to me, but I "grew-up" in C++ so I'm used to managing memory) that helps me get the job done. I'm still learning, and I work on infrastructure some to reduce complexity, but its fun.

What about COBOL? (1)

kenh (9056) | more than 2 years ago | (#40519133)

Why will the development community abandon C while so many still embrace COBOL or RPG?

Use the right tool for the right job (4, Insightful)

Anonymous Coward | more than 2 years ago | (#40519147)

I'm as tired of single-langujage zealots as I am about single-issue zealots in politics. It's a repetition of the old saw: "When the only tool you have is a hammer, everything starts looking like a nail." C has its applications. C++ has its applications Perl has its applications. FORTRAN (remember that language?) has its applications. And so on down the list.

The fact is, a true professional doesn't have a single tool, he has a whole toolbox full of tools from which to select one, or two, or three, or more to get a particular job done. Look at your auto mechanic: he doesn't try to use a screwdriver when a torque wrench is called for. Look at the Web developer: he doesn't try to write C code to do Web sites. And no one in their right mind would write the heart of an Internet router in C++ or PHP or (shudder) COBOL. The tool has to be matched to the job.

Sometimes you do the job multiple times, once in an easy-to-debug language to get your algorithms down and your corner cases identified, then a second pass in a language that lets you get closer to the nuts and bolts -- hey, you already have the high-level stuff debugged.

And then you have people who are more comfortable creating tools to get the job done. I don't know how many times I've written a LEXX/YACC package to generate exactly what I need from a higher-level description...or to give a customer scripting capability suited to the particular task. I call it part of layered programming, and using multiple languages in a project to get the job done right, and in a way that can be maintained.

Finally, programming style helps reduce mistakes, as do good development tools like IDEs that do syntax highlighting.

OK, every language has its shortcomings. Even specific implementations of a language will drive you up the wall with its mysteries. But that's part of matching the language to the job.

I'll grant you that string handling in C sucks. It's part of the charm, though, for some projects, because you don't have to worry about the run-time kicking in to do garbage collection at points in your code where timing is critical. But if the job is text processing without real-time constraints, C is one of the worse choices for a tool. So don't use it for that. Use Perl, or Python, or PHP, or any number of other languages where string handling is a first-class citizen. (For a price. For a price.)

That's the difference between a true professional and a one-hit wonder: the former knows his tools, how to use them, and when to use them.

Manual Transmission (4, Insightful)

ClayDowling (629804) | more than 2 years ago | (#40519157)

Lots of people hate manual transmissions in cars, too. That doesn't mean there isn't a place for them. I bought a manual transmission truck for the same reason I use C: it lets me get more performance out of lesser hardware, gives me more control, and it's just plain fun to work with.

Not For Pussies (-1)

Anonymous Coward | more than 2 years ago | (#40519159)

Efficient programming in C requires both a comprehensive understanding of the physical machine and a superior grasp of the abstract notions of code and data structure. IOW, it does not appeal to the intellectual laziness that is so easily accomodated by other languages.

C is not for pussies.

Litmus test. (5, Insightful)

HornWumpus (783565) | more than 2 years ago | (#40519161)

If you can't code in C you can't code.

That said, unless you are doing low level/embedded work if you can't find a better tool for the job, you also can't code.

C should be _every_ programmers second language at the latest.

The other thing to love about C? Pointers! Pointers to pointers! etc. Coding without pointers might be safe, so is fapping.

C - The language of Patriots (4, Funny)

stox (131684) | more than 2 years ago | (#40519185)

After all, in our National Anthem, we ask, "Jose, can you C?"

C is a great Assembly language (0)

Anonymous Coward | more than 2 years ago | (#40519189)

Note that Python and Perl are implemented in C.

C is what computing is (1)

Anonymous Coward | more than 2 years ago | (#40519213)

I didn't "get" C until I studied assembler in college. After learning the basics of assembler and machine code, a little light went off in my head, and I thought to myself, "Ohhhh, so that's why C is like that!"

C is structured in a way that is very closely related to the way computers function. Maybe if CPU's become radically redesigned, another language would become more practical, but it doesn't look like anything is going to change at that level any time soon.

C is great (1)

Gordonjcp (186804) | more than 2 years ago | (#40519241)

It's a very high-level language that ultimately compiles to machine code - and you can stop anywhere in between if you want to look at how it looks with the macros expanded out, or if you want to look at how the resulting high-level macro assembler code looks, all the way down to how the machine code looks.

You've got total control over the code right down to the binary that the CPU runs.

it's all about productivity and automation (0)

Anonymous Coward | more than 2 years ago | (#40519327)

How many people around do we know that are bad programmers? A LOT
C is good in good hands, otherwise means disasters and headaches.
On the other side, even in good hands, C is the wrong tool for a lot of jobs today...
In the clothes industry there are no old grannies sewing stuff, there is higher level stuff going on, people controlling sewing machines. the talented tailor is for custom and expensive clothes, not for the mass industry.
The reason why C is so disliked, is that it's time consuming and that it's easy to make big mistakes and leave around big bugs (especially concerning memory management), while using higher level languages with well-thought frameworks can speed up things a lot, save yourself from fixing serious bugs and have a lower knowledge barrier.
In the modern scenario, a software industrialization is going on: C is not the right tool for most of the tasks: in a real industry it's all about automation.
C is for talented software artisans, not for hard-hat coders

Unsafe? (1)

Anonymous Coward | more than 2 years ago | (#40519363)

If you want safe, then the only place that suits you is a mental hospital. C is indeed not safe. It's a Swiss army knife. You can use one of its blades to slit your own throat. Many people still like Swiss army knives though. You cannot carve wood or cut bread with fluffy toy animals.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>