How Relevant is C in 2014?
Nerval's Lobster writes: Many programming languages have come and gone since Dennis Ritchie devised C in 1972, and yet C has not only survived three major revisions, but continues to thrive. But aside from this incredible legacy, what keeps C atop the Tiobe Index? The number of jobs available for C programmers is not huge, and many of those also include C++ and Objective-C. On Reddit, the C community, while one of the ten most popular programming communities, is half the size of the C++ group. In a new column, David Bolton argues that C remains extremely relevant due to a number of factors including newer C compiler support, the Internet ("basically driven by C applications"), an immense amount of active software written in C that's still used, and its ease in learning. "Knowing C provides a handy insight into higher-level languages — C++, Objective-C, Perl, Python, Java, PHP, C#, D and Go all have block syntax that's derived from C." Do you agree?
Si.
Because not too much in C++ makes a whole lot of sense if you don't know where it's coming from. Every programmer should know how C++ features are/were/and can be mapped to plain C and what implications this might have for run time behavior and errors.
Relevant C
2B || !2B
Either learn what you're doing
Or stick to the Wii
Burma Shave
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
It is the equivalent of creation narratives for human cultures.
It is a bridge between the bare metal of the system (biology, assembly language) and culture/high-order functioning (culture, modern languages).
There is no better way to simultaneously understand (not to mention use) both system hardware and everything that has been erected atop system hardware than C.
There are few (any?) other languages that occupy this middle, connective ground so well.
With C you can be OO, but you can also be nearly ML. And you can do them at the same time.
Those widgets the clueless newspaper reporters and marketers call 'the internet of things', otherwise known as embedded systems, depends on Linux and C. So therefore C is 'the next big thing'.
It's like asking if verbs are any use when we can just noun everything.
Because it's extremely dangerous and a lot of people are still using it. The 'standard' standard library is so full of security holes it's not even funny, and attempts to 'improve' it over the years have mostly been unsuccessful because the bad coding patterns still exist.
C is a great language, it's just that most humans are incapable of using it safely and securely. It's like a .45 with a downward-pointing barrel. It's all too easy to shoot yourself in the foot.
For full disclosure, I used to be an avid C programmer, until I realized the harm I was causing myself and others. It's like when you drunk drive and think you're just fine. It takes an external perspective to realize how reckless your behaviors are.
A fool and his hard drive are soon parted.
C is the high-level language there. If you want actual control over your target, you'll need to use assembly.
As an embedded software dev, I use C on a daily basis still, and it's unlikely to be replaced by anything else any time soon
Is there another OS/system programming language that is universally accepted as a reference, rather simple to learn, available on virtually any OS, real fast? I mean, go is nice and multi platform and powerful, but it is not even close to C popularity.
C++ should have been C successor, but it is too complex to be.
Do you agree?
I agree that with a summary like that, this is a trollish article designed to get a lot of posts and bring out people's emotions.
C is used for embedded devices. No other languages are competing for it at that level.
Most C developers are probably a bit older, and as such don't waste their time on social media.
As C is a simpler language, there's less need for online help. C++ is a cluster fuck of a language, so it *requires* a huge online support community. Social media popularity is an extremely poor metric. That's more based on fads and marketing than usefulness.
Languages don't just go away and vanish. Almost everything you use is built on top of it, even if you never have to see it yourself.
You can have a good career without ever touching C, but you need to know it is there. The only way to make it irrelevant is to replace all the existing infrastructure code with something else, and it is far too late for that to be feasible.
Like COBOL and FORTRAN, it will probably be with us forever.
Modern, best-practice C can be compiled with a C++ compiler. (There are a few gotchas moving in either direction - http://www.cprogramming.com/tu... - but it's not hard to avoid them.) For all its object-oriented impurity and spec-bloat, the one thing I love about C++ is that you can write relatively high-level code when that makes sense, but you always have the option to grapple with all the fine detail when that's useful.
Virtually serving coffee
Too many C++ programmers who learnt C++ without learning C first jumped straight into the OO and/or generics including the STL. Which is fine up to a point. But they tend to get completely lost when someone asks them to do any low level coding such as writing a bespoke B+ tree from scratch or something similar. Also when presented with multi level pointers they tend to get confused and don't really seem to understand the difference between pointers and C arrays.
A lot of problems want to have a solution that is very close to the hardware. C is an excellent macro assembler, but you need to remember to treat it as such.
It seems like very many programmers don't know, or don't want to think over the lower level implications of everything you do in C.
C is relevant because as long as we use computers, we need to tell them what to do, and C (and fuzzy bloated C like C++) does that for us.
Most people and most programmers don't need to touch computers on that level, and then other programming languages should be used. Those languages are often written at least partly in C.
As usual, use the right programming language for the problem.
I would even go as far as saying that you shouldn't do C++ if you can't do C, and you should probably not do C if you don't know how assembler (and machine code) works. Then you should stick to all the protective layers that you can, like in Python.
(Any good programmer should be able to program on any level from assembler to C and C++ to Python and shell-scripts and up.)
If you write a good useful library in C, it can be used from almost any other language, with little effort. If you write your library in any other language, you limit its use to a handful of related languages. Also, properly written C can be very portable to a wide variety of systems.
In Murphy We Turst
Not only are a great number of software packages, including almost every operating system kernel and device driver written in C, also almost all of the other languages in current use are usually compiled or interpreted by code written in C. It is still easily the most important language.
As to why there are more threads related to C++ on the Internet, easy, it's because C++ is a lot more complicated and complex to grok. I need as much help as I can with some of its tortured constructs and seldom used idioms. C is more straightforward (even if there are plenty of tricky things in it, which the seasoned programmers will either know how to use or steer well clear of).
Non-Linux Penguins ?
It's so ironic but in the modern day of high level languages designed for fast development of single use code I still go back to C several times a year to do the job properly. Code written in C is fast and, if you try just a little, is easily portable between platforms. Up to a certain point, what you tell the machine to do in C and what it actually does are the same thing. Beyond that point (memory vectorisation for example) it is still possible to work out what the difference is and change your code to deal with issues if need be. Not related to scientific work: but when I was learning C words that people used were orthogonal and small, meaning that there was a minimal number of things that you had to learn and for the most part there was one way to do any given thing. This made it easy to learn and practical to use. Also C exposes it's belly to the user so you can get in and hack at the elements that make the language up. C (to paraphrase Paul Graham) is a high point in the landscape of programming. There are very few such high points and vast expanses in between. I would still recommend to any who wants to learn computing today to learn C.
Lots of old traps in there, I stopped about 5 years ago with this book, needs a lot more work, but covers the basic "ooops" events. Thankfully at least with things like Valgrind / CLANG|gcc a lot of the older dramatic mistakes can be picked out quickly.
"C of Peril" - the book (pdf, free) at http://www.pldaniels.com/c-of-...
I always tell people who want to learn to code to go for modern C++ (preferably C++11 or newer) first, and then if necessary learn some C afterwards.
It is crazy how much more C code is needed to get the same level of performance and security that equivalent C++ has, and C coders know it. Just look at all the extensions that C compilers, and even the C11 Standard, borrow from C++ (generics, RAII) - but in a convoluted ugly way to preserve the precious ABI for 50 years.
And for all those who will say that C++ can't fit in the tight spaces that C can...well, you're wrong. Just disable the parts of C++ that you don't want (usually exceptions), and you can still get most of the benefits of clean code and RAII, with the same or better performance.
If you want performance, it's C or assembler. C is 1/3rd the speed, but 100's of times faster to write. Then you profile and do the expensive bits ONLY in asm ...
I mean, know other languages, but C is still relevant.
I hope than C will evolve to add a clean simple and single inheritance object model without all the over-complex crap from C++.
A even more advance would be that C get an optional standard library comparable to boost and the like that make consensus in the developer community.
Finally a JIT would make it competitive to the increasing markets areas with high diversity of silicon processors architectures.
Case in point, GCC recently switched from being compiled with GCC to being compiled with G++.
(Although I think it's a tad too absolute to say that "best-practice C can be compiled with a C++ compiler", but nearly.)
Help build the anti-software-patent wiki
As long as C continues to serve as the foundation for a number of operating systems, it will remain relevant. To understand its merits as a language alone however, it along with C++ should be used only _after_ learning a high level language that doesn't clearly model allocation or memory within in its syntax, e.g. Haskell, Python, Java, Lisp. Then one can return to C, along with C++ and say "hey, this is an incredibly useful syntax for reasoning about efficient allocation and memory use". It does have competitors in that arena, however it continues to dominate due to tooling, inertia/entrenchment in education, industry and cargo cultism.
The C language has a stable ABI, and it is the only mainstream language that can make such a claim.
C is very much still relevant - most of the deeply embedded computer firmware is written in either assembler or C, where the bit twiddling capabilities, compactness of the language and efficient generated code are of high importance. All those ATMegas, PICs, 80x51, Z80, Renesas, small ARM Cortex cores - chips that are too small in terms of available memory to use higher level languages and OSes effectively. Essentially, if you are writing "to the metal", you are most likely going to use C, assembler and (rarely) C++. Those chips costs peanuts and are pretty much everywhere, controlling everything from your toaster to brakes in your car ...
Programming is not only about the desktop and web, you know.
Even on more "grown up" platforms you will find C in the network code, most of system programming is done in C, C with its standardized ABI is an interface language (e.g. you can load a C-interfaced DLL into Python or Java, for example) and many many other applications. I would say that knowing at least the basics of C is as much a must for any programmer as knowing basics of English - unless all that you do are web apps in Javascript.
C++ is C
I used to believe in this until I had to work on both. Although one can compile best-practice C with a C++ compiler (sans the gotchas), that glosses over the idiosyncrasies of each language. C does not have initializers as in C++.
More importantly, it does not have references, type-safe casting operators and its template language is not turing complete as in C++. These differences will never go away, and these differences alter completely the type of design and implementation of your code and your abstractions.
Not to mention the C++ rules of PODs versus everything else which affect how we link C code with C++ code (and viceversa.) And modern C++ heavily uses templates in manner that makes the language resemble something else entirely. Whether that is a good thing is highly subjective, but whatever.
So from a practical point of view, it is sane to treat both languages as fundamentally different.
When we program in a language (be it Ruby, Java, C or C++ or whatever), we ought to do so in the idiomatic way that naturally exploits the best capabilities of the language. So with that in mind, we cannot treat C and C++ as the same language (and it is not quite accurate to compare modern C++ as a superset of the former, regardless of historical evolution.)
I do believe, however, that is very important, if not fundamental, to understand C semantics to use C++ effectively. The fundamental semantics behind the primitive types and control structures remain more or less the same. And I've always found that C++ programmers without a good background in C tend to make certain mistakes when they need to operate with pointers (since they are so used to work with references.)
Furthermore, integration of C with C++ is not an uncommon task, and development of C++ code with that in mind is paramount. It is very hard to do that without a good understanding of C.
To clarify: "Small target" means memory (RAM/Flash) is measured in kB, sometimes even in bytes.
You still have Python-capable processors for embedded systems if you can't afford to learn C.
As far as target size goes, that thing does not qualify as "small target".
FWIW, I've been struggling with LPC4300 series processors.
Those chips look like they're on the large end of "small target". Cortex-M4s are already pretty beefy CPUs.
The open source toolchain is just so bad that your CPU hard faults on first attempted function call (most likely due to incorrect memory maps).
You can usually get pretty detailed reasons for a hard fault if you dig into the appropriate CPU registers (HFSR, etc).
I'd check the linker command file. Setting up a basic memory map isn't that hard - it's the not-so-basic stuff where things get interesting (copying functions to RAM for execution, etc).
It's as if engineers could skip calculus because there are automated systems that will do it for them. Even if they never work directly with calculus, the experience is critical to being a competent engineer.
Yes, C has features/bugs that can be really ugly. But as a professional you can make a system like C and it's runtime libraries work then you are much better equipped to do other complex tasks. The experience can result in careful habits that will help your entire career.
Why is Snark Required?
The most important reason-feature to learn and use C is that it's the LOWEST COMMON DENOMINATOR in many other languages' attempts for interoperability. These APIs are many times written in C in order for the libraries to operate seamlessly between them. Another good reason is to improve what you can do with Lua. With C and Lua you can literally tact almost any problem, from drivers to databases. It might not be the most efficient way, but definitely you will get more bang for your time and money.
"Sum Ergo Cogito"
To mobile application market? Irrelevant.
To online web services? Not so relevant.
To online web server? Very relevant!
To high efficiency applications? It's almost the standard.
To operating systems? There's almost nothing other than C (in terms of market share).
Please, elaborate more on your stupid question, you insensitive mobile clod!
Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
I agree. C is a powerfull language.
A lot of HW related companies use mostly just C. Any sort of small device development or most appliances (switches, storage, etc.) have software written in C. Any driver development, etc. It is still the language anyone can pretty much agree on.
If programs would be read like poetry, most programmers would be Vogons.
C is great for low level stuff since it is capable of generating machine code that has zero dependencies. K&R even explicitly mentions "non hosted mode" with no libc and implementation defined entrypoint semantics. In fact, it is the only language in mainstream use today that has this feature (aside from assembly.)
For kernel, drivers, firmware, embedded, and RTOS its pretty much the only choice unless you want to code everything in straight assembly. Since my current job is firmware programming, I've actually like the C language now that I've been forced to do a lot of heavy coding in it instead of Python.
The only real place C is used any more is embedded systems. I never had any experience with that. I used to be a C expert. Understood pointers and C quirks. But the work dried up. Everything went to Java and C# as far as applications programming goes, and I went with it.
C started out with high level "constructs" that were basically the operators of the PDP-11 and VAX processors from DEC. While those constructs have mapped well to other processors, virtually every statement in C originally compiled to one instruction on those processors.
To this day, C still gives you the power and flexibility of any low-level language worth it's salt, and ample opportunity to hang yourself and your code. Don't forget -- C++ originally targetted C as it's output, not machine code. C has similarly provided the "back end" for no small number of special-purpose compilers.
Then there are the operating systems and device drivers that have been written with it, and all the embedded systems logic for devices all and sundry.
C will never die any more than assembly or COBOL and FORTRAN will. There will always be those special-purpose high-performance tasks where it is worthwhile to use C instead of a higher level language. Just as there are times where it still makes sense to drop even lower and into assembly.
You go ahead and try to bootstrap an entire C++ implementation so you can write a kernel in it. Good luck with that. Getting a C library framework running on a bootstrapped kernel is hard enough. C++ would be orders of magnitude harder.
I do not fail; I succeed at finding out what does not work.
All those web servers. All those Android devices. They run a Linux kernel. It's written in C.
If you need to be efficient, you write in C, end of story. That's why.
C++ and all the other languages there simply have too much overhead and give you not enough control over what's actually happening.
Assembler isn't worth the major hassle for the tiny improvement you get over C.
C, however, is at this unique point between the bare metal and the high-level abstractions where the trade-offs are perfect. You get just enough abstraction to be a) hardware-independent and b) can use a high-level programming language while remaining close enough to the machine that you can be really, really efficient, fast, short, the whole nine yards.
Assorted stuff I do sometimes: Lemuria.org
If you want to write something highly performant C is still the preferred option. Not because C produces faster code, languages with advanced run time environments like Java are in a better position to optimize your code, but because you know exactly what is going on. In my experience, the two things you should avoid in a highly performance application are system calls and locks.
In a high level language you can never be sure when a lock is taken or when a system call is fired off. In C, well, you'll have to be pretty explicit about both.
C sucks - it is the third worst thing to happen computer history. Pascal was rising and C took over with it's appeal to anarchy. It is so easy to write nasty, trashy code in C. I would how much "C++" is actually C.
What the first and second worst thing to happen computer history? The introduction of the IBM PC and the rise of Microsoft. The original IBM hardware (with 68000 computers with hard drive available dropping price) and MS-DOS set the industry back YEARS.
I think it is a shame C isn't used more for business software. In my company we have a large number of C# projects and every one I've looked at is over engineered. We're a bit 90's in that most of our software is shunting bits of XML around the place. Most of the teams are huge (30+ people) and I think most could be done with maybe 5-6 good C programmers producing simpler, faster and better software.
We're talking about C. You want the zeroeth post.
At least he made the first post.
If C starts having OOP features like inheritance, I will start wearing black suits with my shirt collar buttoned up all the way, hold a copy of K&R, and throw objects at you blasphemers and heatens. If you want those features, defile yourself with the 98 standard of C++.
I have written embedded Pascal. Never ask me to do it again.
Once. Gave me a real appreciation for high level languages like C.
And, yes, it was an embedded application. No user interface, the controller talked to the device, the device ran some very precise valves. It was actually a fun month getting all that working.
Best Slashdot Co
Yes - C is still useful, and very relevant as a touchpoint for its descendants.
But no, those other languages do not "have block syntax that's derived from C." They all, including C, have a block syntax that's derived from Algol-68.
Mudge
In theory, theory and practice are the same.
In practice, they're not.
Though "embedded" systems are getting more sophisticated and complex, and some migrate to Linux (Car infotainment/navigation, etc), the age of IoT will require smaller (i.e. micro controller) sized systems, that will be heavily resource (i.e. memory, both RAM and FLASH) constrained. For the "real time" stuff, Assembly will still be used. C provides the capabilities that cross the lines between those "low-level" needs and yet, you can still create "object oriented like" higher level constructs if need be.
Java and its copy C# were written from the ground up to be OO. C++ is really an OO hack on top of C. I was a pretty damn good C++ dev back in the 90s (did other things after that) but god, today's C++ code is pretty much unreadable to me. WTF happened to it?
Interesting alternatives to C seems to be D, Vala and Rust.
Perhaps C# with the .NET Micro Framework? .NET Native?
Or C# with
I think there's a disadvantage with having languages designed solely by language design experts, and that is a tendency to over complicate things. They all understand it, and appreciate it's elegance, so it must be the best way.
To draw an analogy, consider the musical excesses of prog rock / jazz fusion. The musicians themselves may appreciate a Locrian scale played against an AbSus13th arpeggio , but the audience can easily end up excluded. Then a musically simple but catchy band like the Sex Pistols comes along and steals their audience.
I reckon languages need to be really really simple to understand, in order to become popular. For most people they're a tool, not an end in themselves.
> Do you agree?
Yes
Umm... the original IBM hardware did not use 68000. It used the 8086 - with its horribly inefficient instruction set.
And even the latest incarnation, it is still a horribly inefficient instruction set.
"C is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use C itself a lot."
Now, nobody in their right mind would call C a "good" language with regard to syntax. It is however unsurpassed if you want a portable language that gives you almost as much control and speed as assembler. While simpler things can often optimized by compilers for other languages to be reasonably efficient, some things cannot or there are huge other costs, for example inflated memory footprint or crippled system interfaces. So when you do understand the machine model and need fine-grained control, C is the way to go. That is one reason why C is relevant today and will stay relevant for the foreseeable future.
Another thing is that anybody that can program C well does understand how CPUs execute code. That provides a number of advantages when writing things in other languages and it allows the implementation of performance-critical sub-modules in C. For example, I have made excellent experiences with algorithm cores in C and glue- and control-code in Python. My personal take is that those that call C outdated or even demand its retirement do not understand how code is actually executed and just want to remove the advantage those that do have. In other words, a programmer that cannot (also) program well in C is limited in understanding and capabilities and hence I expect that many jobs requiring C do not actually entail work that is mostly or completely done in C, but people that do understand how computers actually work in the lower levels.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
We know that problem in and out: People mixing up C, C++ and Objective-C. Especially non-experts. That's no surprise. Then saying, despite requireing "C/C++" in the confidential: "Oh, you only have 20 years of C - I thought you knew at least a little C++ - OK then, sorry, you're the wrong guy." ...
Me: *pictures Vincent and Jules pulling out their 9mm parabellums and pumping the HR guy full of bullets"
Non-trivial JavaScript only caught on on a large scale when the term Ajax was coined and with it we finally had a better word for JavaScript - until then most decision makers would mix up Java and JavaScript. Sometimes without anybody noticing that. ... In hindsight, I really can't blame them all that much.
I think of all the C stuff as the "C" family of languages.
As far as I can tell, coaxing C into some OOP thing is a little tricky, but doable. C++ is different, yea, but if you turn on your brain and are willing to ditch the habit of writing your own stacks, any C dev worth his money should be up to pro-level C++ development in a few weeks. Same for Objective-C. It's not that C people write everything from scratch these days. Where to you think those bazillion libs in Linux come from?
As for the C-Family of languages: Of course there still relevant. What kind of stupid question is that? What's Linux built with? C. What's Windows built with? C++. What's Mac OS X built with? Objective-C. What is any non-trivial system critical component built with? C, C++ or Objective-C (in the case of OS X / iOS).
And that's not changing any time soon, trust me on that one.
We suffer more in our imagination than in reality. - Seneca
I would suggest that you in need to be efficient, then write the core 20% that has to be fast in C, and then write the rest of the system in a nice language.
C is not intended to be a beautiful language. C is intended to give you as much control over the raw machine as possible, without going to assembler level and with (these days) reasonable portability. If you compare C and Pascal, then you have failed to understand the purpose of C.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
C, C++, Objective-C, Perl, Python, Java, PHP, C#, D and Go all have block syntax that's derived from Algol.
Minimally c++ is c with better type checking. Templates are superior to macros. Mangled names enforce correct bindings. There is no issues writing os kernels in c++. Get with the nineties man.
It seems C++11 was just finalized yesterday, but already we now have C++14 finalized and C++17 in the works....
This is hardly the same language from a few years ago - the power and ease of use that has been added, both for library and application developers is amazing.
Anyone programming in C++ who isn't thoroughly familiar with all the new stuff in C++11 is missing out tremendously...
It's very relevant for producing more slashdot page loads. But since the summary includes the answer to the question ("But aside from this incredible legacy, what keeps C atop the Tiobe Index?") this is a non-story.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
They never used the letter ...someone else did ;-)
Actually Windows is built with a mix of C and C++. OSX, a mix of C and Objective-C.
We're talking about C. You want the zeroeth post.
You have to remember, there are two kinds of people in the world:
1) Those who begin their indexes at 1.
-and-
1) Those who begin their indexes at 0.
If people think that C is not relevant in 2014, I'd hate to think what they thought about the ladder logic type languages in PLCs that pretty well run every manufacturing plant in the world.
I am Slashdot. Are you Slashdot as well?
When you look at the output code from a C compiler, it tends to be small and fast, and relatively light on resources. In many cases, with modern compiler optimizations, the resulting code can actually be smaller and faster than all but assembly code written by someone who really knows how to optimize for a specific machine. Almost all embedded development work is done in either C or assembly, and C tends to be faster to write, and portable - so you can move the code to the next project if necessary.
Using any 'modern' object oriented language immediately adds a level of bloat which is generally not acceptable in places where C still shines. These modern programming languages are written for environments where a few extra bytes or a few extra cycles isn't going to cause a problem. When working on a resource-limited platform (aka where you'd kill for a few hundred KB of code space, and more than a few thousand bytes of ram) you're just not going to be able to use a modern language because of the overhead of an object oriented language.
I'd actually predict C is going to grow in the near term, just because of the growth of internet-connected low-resource devices. I actually develop products on a platform which has a complete TCP/IP stack (including web server and SNMP) running in less than 128KB (yes K not M) of memory. These and other similar small platforms are going to be the basis of the 'things' half of the internet of things, all of which are going to have C code at their base.
C is still the right tool for a lot of jobs. It's also the wrong tool for a lot of jobs.
Proceed accordingly.
C and C++ are not the same.
One of C staying power is it runs on everything down to the smallest 8 bit CPU.
With out the larger overhead of C++
It can be faster in low level and driver code.
Windows PE does not support dot net so there is another potential use.
In short it is still useful.
90+% of programmers claiming to be working in C++ are really writing straight up C code with the occasional object. because they occasionally use an object and want to be lazy and declare their local variables at any random moment, they end up having to use the C++ compiler and so claim to be writing C++.
what they are really doing is writing bad C.
so, saying C++ is twice as popular as C is incredibly misleading.
The difference between Theory and Practice is greater in Practice than in Theory.
Tue 12/09/2014 8:48 am. I assume a lot of people write supposedly C++ programs that are actually mostly C; I know I do....
It may also be that 90% of C++ projects are ones that should have just been C to begin with. The code will naturally try to fit the problem domain.
"C++, Objective-C, Perl, Python, Java, PHP, C#, D and Go all have block syntax that's derived from C"
And C got the block syntax from B which got it from BCPL which was a simplified version of CPL which was influnced by the first block structured language, ALGOL.
I was taugh ALGOL at University, though I had already been "mentally mutilated beyond hope of regeneration" by BASIC before that...
You should try embedded FORTRAN then...
I started digging around in the Gnu flex source code for fun recently. Even though it's pretty moldy and old and uses global variables all over the place while it's generating your scanner, I'd still rather use flex than anything else if I'm going to be parsing a complex file format. I'm looking at sprucing up its C++ classes a little bit. I know there are projects out there to do that already, but this is really more of an excuse to go digging around in its guts than anything else.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
I always begin my indexes at 512 just to mess up with whoever has to work on my code.
What you're saying then is that there is nothing more popular than code written in a bad, mongrel version of C.
quiquid id est, timeo puellas et oscula dantes.
How many times more this year (only 22 days left!) are we going to see these types of "articles"? Give it a rest. C, COBOL and Fortran will be around long after all of you are dead.
That's a great sig...
There are two types of people in the world: Those who crave closure
C is a great language, it's just that most humans are incapable of using it safely and securely
That sentence is self-contradicting. To my mind C cannot simultaneously be a "great language" and be impossible for most people to use safely. I would posit that to be considered a great language, the ability to use the language safely and securely by someone of ordinary skill in programming is a necessary condition.
Since we are so fond of automotive analogies here... While the power and utility of C is undeniable, it's kind of like a car with too much horsepower and not enough traction. Really talented people can handle it but most should drive something else. It might be amazing in the right hands but that doesn't make it great.
There's also OpenCL which is far closer to C than the rest of them, and that is a language that is still up and coming.
The acronym ML is a Meta Language for functional programming. Variants of ML are quit popular, for example OCaml and Haskell.
That is, very much so because of huge established code base, but watch out for your future career. C would not be the best choice for any new code base. For low level programming, it can not achieve the best performance because it enshrines how CPUs and compilers worked in the 60s instead of being amenable to extensive optimization, non-trivial vectorization, running on GPUs or automatic use of multiple cores. On high level, it's not suitable for large teams, as one developer's bug can affect others' code in unpredictable ways.
So anyone with long term career plans should at least be familiar with Java, .Net, Swift, Go and so on to be prepared when progress happens.
wow... someone does not know anything about coding. Go ahead and try to write a kernel extension in python... wow. there are different languages for different tasks. C will be around for a very long time.
So long as programmers feel the need to write C to show off what studly coders they are we'll be stuck with C. We'd all be better off if we could spend less time fixing C-related bugs and concentrate on making sure safer languages were just as fast and functional. I'd suggest C# as a better alternative but recently I've been discovering how stupid its handling of byte order is. It's not a bad language except the amount of idiot Microsoftisms it has. C++ is just as bad as C. Objective-C is a mix of genius and insanity. Java is its own set of kludges. Python is nice but slow. Go isn't enough of an improvement. ... Not sure we're ready to replace C yet but we should get ready.
At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
First off I'd consider C++ and Objective-C to both be variants of C. And you can make a fairly good case that Java is also a variant of C.
That being said there is a good use case for C by itself. Lots of algorithms execution times are of forms like R*n^2 + S*n + T. For N large, A is all that matters. For N small T can often be the dominant factor. The C language, like assembly excels at getting the execution times for T down. However for most business processing execution time isn't really all that important since n isn't large nor is T particularly big. In which case programmer efficiency matters a great deal.
C's [] operator works with an offset, not an index. Incidentally, this permits some really odd, but valid, code:
int sum = 0;
int a[1000];
initialize( a, 1000 );
for( int i=0 ; i1000 ; ++i ) sum += i[a];
The first element of an array is located at offset 0, so it is indeed the first post. In your defense, it would be posts[0]...
Well to go off topic for a second. What is the news with Rust? I know Samsung was backing it, but I haven't heard anything in well over a year. Anything happening exciting on the Rust from?
Yes. There is an entire world beyond the sphere of web programmers. Go into the automotive sector and ask about using python, java or any other higher level language in a engine controller.... LInux? I don't want my car to take 2 minutes to boot and go into a kernel panic because a guy in his basement wrote a driver for something. Python? We can put 1 GB of ram so a lazy programmer can have his pristine language environment. In the world where things have to work reliably and there is no room for esoteric languages, C rules the roost
Who cares about how popular code is now? How popular was it? How much stuff is coded in C that is vital to people willing to pay people to fix it and maintain it and perhaps even improve it. Fer craps sake, Cobol is still alive and kicking. Just because some computer science wiz farts out some new language every three years doesn't mean that all the previously built code goes up in flames. The old code has more lives than a zombie apocalypse and some poor sap gets to make a living off of it. This is supposed to be a serious profession not a gaggle of high school sophomores giggling over who got asked to the senior prom.
Creative Spelling Copyright (2002). May use without Persimmons
I recently purchased "The C Programming Language" second edition to learn C. Can anyone recommend other must read books to become a competent C programmer? Books on good procedural design, modularity, writing code that can be easily ported to other platforms, coding conventions, testing, etc. I'm interested in OS development.
... the relevance of C is more than it should be.
As the base layer for cPython, the world cannot do without it.
C was obviously invented to fill a niche - SkyNet will need a language to develop their self-aware minions.
Otherwise, don't try this at home, kids.
Since we actually have a widely accepted portable assembly language now, I have been pondering this very question. LLVM assembly holds a lot of potential, similar to how the TAOS operating system promised back in the early 90's with its virtual processor assembly: https://sites.google.com/site/...
The guy who inspired me to want to program used to write assembly on a 386 with a slightly hacked copy of the 8086-oriented freeware assembler CHASM. He read compiled binaries in hex like code. I asked him, "Doesn't it take a lot more time to write in assembler?" "Not that much", he replied, "You break things down into functions and build libraries of code you don't have to reinvent, just like in C." The guy was freaking brilliant.
We've so frequently created new languages around new ideas in programming, and that's great, but eventually the number of abstractions becomes quite an issue. People are willing to write operating systems like MenuetOS in assembly in x86_64 asm. That's great. I'd love to see a compiler there to do validation of code, uphold Ada-like programming by contract, that sort of thing, but I'd love to see assembly programming make a comeback.
Just because you doesn't use it doesn't mean it's not relevant.
I don't code in D-Flat or Python; but that doesn't mean they're not relevant.
And yes, this is more stupid click-bait courtesy of Nerval's Lobster and dice.com.
The Internet of Things does and will run on C.
Your watch, your router, your oven, your car - all C.
i feel that the answer lies in the sentence "the internet is driven by c". if you want direct performance, executable compactness as well as operational efficiency (that is also massive step up from assembly language), you have *one* option available to you: c. that means that apache, wine, postgresql, openldap, cups, samba, libc6, the python interpreter itself, the linux kernel, the windows NT kernel and many more OSes: they're written in c.
only when some of those constraints - performance, compactness and operational efficiency - may be relaxed in favour of, for example, a higher bang-per-buck ratio in the expressive power behind the lines of code written (python dict), or where code-resuse is critical without too much inconvenience (templates and objects of c++), *then* you begin to choose alternative programming languages.
but as a general rule, if ever you see the word "system" or "service" in a sentence (operating "system", web "service"), automatically that implies "high performance" which automatically implies "high efficiency needed" and that means "c".
so i feel it is therefore much more interesting to note the situations in businesses where c is *not* used despite there being circumstances where performance is critical. when people choose java for web services, for example.
I have worked in process control and high energy physics for the last 30 years. When the PAW (physics analysis workstations) were converted from Fortran to C++ it was a total disaster, a bloated piece of crapware emerged that took more resources, ran at half speed if it didnt crash with a memory leak first. I have stood on the bank of the river and watched the corpses floating by, the latest fads in languages back then, remember Pascal, Modula, Algol68 .... During that time Linux hackers were perfectly happy to write their C code with vi and make, perhaps with cscope and get reliable binaries that are maintanable.
The point about C is its a SIL (Systems Implementation Language), no one in their right mind would think about writing a kernel in C++, its an abomination. For those of us who need OO then C# and Java are great, look at Android.
The old languages that have survived the test of time have done so because they work for the niche they were intended for. C is brilliant at describing and using hardware interfaces and writing beautiful fast kernel code, and yes macros are great "ContainerOf" and "WaitEvent" are two that come to mind.
So cheers to C, Fortran (making a strong comeback), Lisp and Python. May C++ rot in hell as soon as possible with the rest of the crap, if I want OO I will use Java.
For embedded systems, there is just no replacement. I have been developing in embedded systems for eight years now. We use compilers like IAR, operating systems like ThreadX, and develop for microprocessors like Atmel and ARM.
First and foremost, higher level languages are just too top-heavy for these systems. They have low code space and must be fast and efficient. Higher level languages, including C++, just do not offer that. Secondly, the language is very entrenched. It is the de-facto standard for almost all embedded development.
The way I see it, the industry will eventually move to a point where something like Java or Objective-C is more standard, but the cost-benefit ratio isn't there yet. Android and iOS can do that because smart-phones cost a lot of money. But most embedded systems are cheap. The micro has to cost as little as possible.
Yes, this means we live in a world plagued by all kinds of pitfalls. Buffer overruns, bad pointers, memory leaks, improper use of semaphores. I've seen all of it. I'm no purist. I would like this industry to move away from C. It needs to. The software we support is getting far too complex. RTOSes with several threads. Full stacks for TCP/IP, SSL, USB, Bluetooth, ANT. Complex memory and power management schemes. As it is though, C will probably be the standard for this industry for at least the next few years.
It's simple. C is self hosting and extremely portable, and the amount of extra stuff needed to run C can be none (in the case of kernels, everything can come with the binary), little (shared libraries) or lots (a whole OS). There aren't many other languages which can self-host and can create binaries which can run on bare metal.
Other supposedly portable languages like Java, Perl and PHP require an OS and environment to do anything, which makes them unsuitable for running on small embedded systems, for high performance applications, or for talking intimately to hardware.
The languages also change too much over time. You can't just take old code and run it in a new interpreter. If Java wasn't in the hands of a megacompany, it MIGHT be more portable and less bug-ridden, but right now it's write once, run only in certain places, deal with a zillion security issues. Many companies I support have to keep around a VM or an older machine to run an older JVM because new Java is not compatible with old Java.
C has changed, but not so much that K&R C is unrecognizable to someone learning C now. A program written in the 1970s can be compiled by a CS student today without much more than, perhaps, changing a few #includes. This is what makes it lasting and worth learning.
C is not intended to be a beautiful language.
And yet, it is.
"First they came for the slanderers and i said nothing."
Line 4 of your code fails to compile... Sigh...
Browsing at +1 - no ACs, I ignore their posts. So refreshing!
I think programming in C as a hobby is fun. Its just verbose, kinda like COBOL. I haven't seen too many job descriptions that mention C; the companies want .NET experience. Just saying.
The largest program I build each day is the Linux kernel.
When I ask the question "How relevant is the Linux kernel in 2014?", the relevance of C becomes hard to question considering its 15 million lines or so. ;)
It doesn't matter if you are building a house, a supermarket, a factory or a major civil engineering project you will needs some bricks.
Building Software is the same
I am not implying that is what the C stands for.
But C programs are best for what I consider to be Core Level software.
Operating Systems, Compilers, Database engines, Web Servers...
In general C is good for programs that needs to take the most out of your computer.
However higher level langues should be used for those application where faster development time is more important then the products overall speed.
Being that most business apps are just a form where people fill out and query a db. Those can be done in the PHP/Python/C++/Javas of the world. While the stuff handling the IO Calls should be done in C.
Now back in the Mid 90's C was to be the the main programming language for any program. Due to the decline of Business Languages (Cobol, FoxPro, Delphi...) and the move to the PC which needed the extra speed to run on the slower Desktops.
However now with most stuff being server based. It is cheaper to use a quicker to code, language with the cost of performance due to cheaper hardware prices vs expensive labor costs.
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
C-x M-c M-butterfly
http://xkcd.com/378/
General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
Are you still ignoring us?
Slashdot ate their less-than operator between i and 1000. Let's see if mobile can do this... <
Test-Driven Development for Embedded C by James W. Grenning an absolutely essential read for anyone new to embedded c development. Or I guess you could call it IoT development if your are feeling like a cool kid.
C is still my second-favorite language.
It was my favorite from... around 1983 to 1989, at which time Objective-C became my favorite.
(Apple is working towards destroying Objective-C, so my favorite may very well go back to C in a couple of years.)
Unix was proclaimed dead in 1990 by Byte Magazine. Windows is broken, Apple is rotten, Solaris has set, IBM AIX with age, HP-UX was fed to ducks, Excel has left Word that it is out of the Office, the Oracle is learning Delphi, but still there's quite a byte of C code running for president every day.
C is a COMPILED language that produces assembly code for the specific CPU being used when compiled. It is used in low level development. It is used in places where maximum performance in required such as other languages and operating systems. All other languages, except assembly language are at least initially implemented in C (++ or obj or Pascsal). Interpreted languages (PHP, PYTHON, Javascript) are not used for real OS'es. They are good to make demo Os'es. Unless a replacement low level language is developed, C (and family) will be used whenever there is a new OS or a new CPU or scarce resources are available or maximum performance is needed.
Interpreted and other higher level languages are good for APPLICATION development.
>Python
>block syntax
Kill the blasphemer.
It is relevant since there is no other low-level lango available and stable enough.
Except C++, but it`s not that loved as C. And it shoots off your feet when you`re about to hurt a toe in C.
It is the only language that I use for embedding programming when you only have 1k of ram.
Here's the thing about c. If you're good enough to use it well (rare, I admit), the results can be made to be faster, more efficient, and more *clear*, meaning, you can actually see what's happening, while still remaining reasonably portable, than any other language. Even in the largest applications. Perhaps especially in the largest applications.
Until someone comes with something faster, c is *the* goto language for high performance coding.
As soon as you start sticking generalized objects in generalized boxes, as soon as you decide you can't manage your own memory, as soon as you decide you must have generalized abstraction (as opposed to specific, high-efficiency custom abstraction, boxes and objects), you're sacrificing performance, and you're probably sacrificing size and efficiency at the same time.
If what you're writing is a word processor, well, so what. But if you're writing real time goodness, or something truly CPU bound (like almost any AI undertaking, or SDR, or speech recognition, or object recognition, etc.), not using c is a mistake. Not to mention a waste of the eventual end user's resources. Just because there are CPU cycles available doesn't mean that it's OK to chew them all up, likewise available RAM. Operating systems can do more than one thing -- if they're not choked to death by some lumbering, clumsily implemented hunk of crap.
c is awesome. c is simple. But c is difficult, because you really have to know what you are doing. All that power at your fingertips means its 1000x easier to drive straight into a tree. You have to truly understand, on an intuitive level: stacks, memory management, objects, abstraction, how c statements likely map to CPU activity and instructions, and how to write clear code and documentation and a bunch of other stuff -- because it's up to you to manage all that stuff, and a failure in any of those areas is very likely to negate all the other advantages, or worse.
The only thing better is assembler, where you can *really* be efficient and produce ultra-fast code. But assembler isn't portable, and that, sadly, is usually the end of that.
I've fallen off your lawn, and I can't get up.
Yep. c++ = larger executables; slower executables; less comprehensible code; less clear code (what is the CPU likely to be doing here? No bloody idea.)
c is the bomb. c++ is just a bomb. A crutch. Anything you want to do in c++, you could have done in c, the primary difference being that as a c programmer, you would have -- had to have, in fact -- actually understood what it was you were doing.
c++ is building kits from nasty little pre-molded pieces. c is carving your own pieces, where, if you like, every one can be a work of art and YOU control how they all fit together. You even get to make your own glue. :)
Of course, if you can't carve, have an irrational phobia re glue, and can't design the pieces you need... well, time to drag the crutches out.
I've fallen off your lawn, and I can't get up.
through the years, I have heard the old c vs c++ arguments many times. c++ advocates all forget one inconvenient truth; c++ is not only a c derivative, but stroustrup's original implementations of c++ were PRE-PROCESSORS that read c++ code and generated c code.
as with anything else, c is just a tool. when used appropriately, it is a great tool. in the hands of the wrong person, it becomes a danger.
back in the days of PC-DOS I wrote quite a few TSR programs in c; i can't imagine writing a TSR in c++. given all the overhead involved, i am not sure it would have been possible to fit the resulting code in 64K!
C is an abstraction of hardware concepts, and newer languages (even C++) tend to be abstraction of concepts from Comp Sci (object, function curries, comprehensions, templates etc etc). Someone has to bridge the two concepts. C++ succeeds as a language that supports both, but never been that big because most people either use it as C (and not use any features), use it poorly (because they don't understand how the various constructs work) on the hardware end. C has lesser concepts to worry about, but gives more rope to shoot you on the foot.
E.g. simple statement like "if (string == "hello")" in C++ could mean that == is overloaded and if it accepts an object string, "hello" invokes the copy constructor for string object and passes it to the string object's == operator, which might do a char by char comparison, and then the unnamed object "hello" is destructed.
You generally don't care about this for business logic or if your website is getting one hit every few seconds, but if you are getting a million hits per second, you need to start optimizing the way you do things, you'd need to know which of L1/L2/L3 caches you'll miss, what'll be the real impact of your code. C, without the fluff, gives you lesser things to worry about.
C will be relevant because no other new language is trying to replace it.
I agree.
Lodragan Draoidh
The more you explain it, the more I don't understand it. - Mark Twain
...relevant... as in:
"nearly each pixel of your screen while reading this is rendered via either C, C++ or something that is written or compiled in C and derivatives".
That makes it sufficiently relevant, doesn't it?
are advertised seeking specifically 'C' is that a large portion of people who routinely program in C are not employed as programmers per se. It is the language (as many others here have pointed out) used to code for embedded systems and real-time control devices but these are generally programmed by Electrical Engineers or techs who are not listed on the company rolls as "programmer". In the math, physics and chemistry academic environments, guess how simulations and models are coded? Yep, in C (and yes, physicists and mathematicians programming on the CUDA platform largely use C too). FORTRAN is hardly ever used these days. Aside from my own experience, I have numerous friends who work as engineers, physicists, mathematicians - and even biologists - who regularly code in C. However, that's not their job function and most of them are, frankly, not great coders if you're looking at clarity and standardization of code. The EE's working on embedded sys stuff are probably the best of this lot because they realize that other people WILL have to read and work with their code.
I'm not trolling here, I've spent way too many years using C++ to earn a crust and am an unpreposessing Scheme junkie too. The purpose of a language is to provide an automatic mapping from our "headspace" into something the computer understands. Complex semantics make this process more prone to overt errors and much more vulnerable to subtle errors that seem to work. Simple languages lay everything on the table, there is very little buried deeply in libraries. Really good code is usually "bespoke" code which someone has thought carefully about, not the result of putting a bunch of popular object classes into a code-supercollider. Good programmers can use C as safely as they can use C++, Java, Python or any of the other rising/risen stars; arguing that C provides little protection (using whatever metaphor you like) is just trolling: C isn't a language that you *expect* to protect you -- you take extra care with it. Pick the tools for the jobs -- there are a lot of jobs that need to be explicit, clear and easily checked: C beats the other popular imperative languages hands down here. Bet Ron Swanson codes in C (or assembler if he wants that "hand-tooled" feel).
Most often for high performance you don't even write the expensive bits in assembly.
You take a look at the output of the C compiler, then modify your code so that the C compiler writes the assembly you want.
No it's an index not an offset. Unless you're talking about byte arrays.
I've been paid well to write tens or even hundreds of thousands of lines of code in C++ and Java. I've had reason to mess with Python and JavaScript and I enjoyed it. I keep wanting to get into languages like Haskell and Scala because they remind me of the research I did in graduate school thirty years ago on languages and operating systems for Fifth Generation architectures (yes, I _am_ that old). But you know what language has been the most profitable for me by far over my forty year career? C. Most of the work I do is either down close to bare metal (device drivers, kernel hacking, embedded systems), or else deep in software stacks in multimillion line code bases, and it's all in C, for better or worse. C is the structured assembly language we all wanted back when the microprocessor was first invented. There's this huge world of embedded systems, digital control, real-time, that is growing by leaps and bounds as everything we manufacturer has some kind of microcontroller or microprocessor in it, and the vast vast bulk of software built for those products is in C. I really, strongly, loudly encourage people to work as high on the abstraction ladder as they can, for two reasons: [1] it's a cost issue for the product development organization, and [2] the less other developers understand the low level stuff, the more money I'll make. I appreciate that the Eloi working on big servers, laptops, and even mobile devices, need to use as high a level language as possible. But down here among the Morlocks, it's a different world.
C is relevant as fuck in 2014. /thread
We're talking about C. You want the zeroeth post.
You have to remember, there are two kinds of people in the world: 1) Those who begin their indexes at 1. -and- 1) Those who begin their indexes at 0.
I programmed in APL, a most wonderful language. For each function, you could specify the index origin to be used. ([]IO was set to 1 or 0, as you wished). You could be in the same function with index origin 0 and later with it set to one.
it isn't PL1
Go to Heaven for the climate, Hell for the company -- Mark Twain
> OSX, a mix of C and Objective-C.
Don't forget the I/O Kit which is written in Embedded C++
Posting as an anonymous coward to protect the guilty:
I was meeting with the owner of a hedge fund a few weeks ago, and while reviewing a performance-sensitive part of their stack, I asked why it was in Java not C.
The *owner of the hedge fund* said "C Programmers are Too Expensive for Me".
Y'all go ahead and keep learning Ruby.
Teach your kids to drive manual transmissions, this will give them a better understanding of what is going on in their engine. Then they can drive nearly any car on the market and they will have more respect for their machines. Teach a programmer a compiled language like C, a scripting language like Perl and something with objects, C++ or Java come to mind. Then they can handle most languages except the really low ones, Assembly language. All they need to do is learn the syntax and apply what they have learned. C is still relevant and so is Perl even though I have been hearing for years that Perl is dying. The programmers graduating now lack much of the fundamental knowledge. They rely on their environment to do most of the syntax for them. They are not as good at debugging unless it is obvious and their tools spoon feed it to them. Many have never used a command line.
Karma, We don't need no stinkin' karma!
That is not true. I wrote my own kernel in C++, it runs in x86_64 long mode, has a fairly powerful ATA 6 driver, mounts an EXT 2 partition, parses ELF32 headers, and starts a homemade shell in Ring 3 with proper protections and nice syscalls wrapped by a 200 LoC C89 userland library.
The raw kernel.elf fits in 300kB, the Live CD with grub weight a bit under 7 MB, the running OS uses a total of 568kB of RAM.
Things like new, new[], placement new and the equivalent deletes are not a problem at all, they are one line wrappers around malloc and free. Defining those takes a grand total of 16 lines of code, and it translates to a whopping ~24 bytes of machine code... Still too much for you ? You don't even have to use those if you don't want to. I know I want them.
There are obviously no external dependencies, C++ can be freestanding without problem. I use no exceptions, no RTTI, no global static constructors (since there are no startfiles (but you can cheat anyway)), and no STL in Ring0 without rewriting it yourself, everything else's fair game.
Please, do a bit of research. C is not always the right answer just because you work on low level problems or constrained platforms.
>they occasionally use an object and want to be lazy and declare their local variables at any random moment Looks like you haven't got that memo a couples degades ago about keeping things in the innermost possible scope.
Function globals and file globals are so much better, amirite ?