Global Sources
EE Times AsiaWebsite
Stay in touch with EE Times Asia
eeBlogs-Article content Home?/?eeBlog?/?eeBlogs
Profile
Nickname:?Jack Ganssle???? Articles(193)???? Visits(278892)???? Comments(30)???? Votes(165)???? RSS
Jack Ganssle is a lecturer and consultant specializing in embedded systems' development issues. He has been a columnist with Embedded Systems Design for over 20 years.
Blog Archive
2016?-? Apr.,?? Mar.,?? Feb.,?? Jan.??
2015?-? Oct.,?? Sep.,?? Aug.,?? Jul.,?? Jun.,?? May.,?? Apr.,?? Mar.,?? Feb.,?? Jan.??
2014?-? Dec.,?? Nov.,?? Oct.,?? Sep.,?? Aug.,?? Jul.,?? Jun.,?? May.,?? Apr.,?? Mar.,?? Feb.,?? Jan.??
View All
Comment?|?Add to Favorites

Posted: 05:49:49 PM, 18/04/2016

What would you change about C?

? ?

If youre an old-timer youve most likely written code in a large number of languages that have many different underlying philosophies. Have you used Perl? Thats a lot different from the ideas behind Algol. Interpreted Basic is so easy it brought many people into this field, but Visual Basic is an entirely different beast. My first language (after English) was Fortran, and I worked with a number of dialects and compilers. Assembly is, well, assembly. Theres not much one can say about it. C is basically assembly with massive productivity improvements. C++ is, in my opinion, rather full of complexity and dark spaces where one is wise not to tread. Java is an interesting approach to OO but garbage collection and a lack of pointers make it inappropriate for most embedded work.

?

C has been the lingua franca of this business for many years. Survey data shows it has most of the embedded spaces market share, and that the numbers havent changed much over the years.?????????????????????

????????????????????????????????????????????????????


Language use, UBM 2014 Market Survey

?

More modern aspirants like Python just havent caught on. C is going to be a major force for a very long time.

?

But the language is quite old and suffers from that longevity. It is also cryptic to the point of obtuseness; critics point out that C developers seem to have an aversion to typing. Most of that comes from poor habits, like using very short variable names. Any language can be abused. But comparing typical C programs to, say, Ada code and one does wonder why we seem to be so terse. And the language itself is terse.

?

Suppose you could wave a magic wand and change just one aspect of C. What would that be and why?

?

My vote is to get rid of the curly braces. All of us have suffered from bugs and compiler complaints from deeply-nested blocks of code where we get mixed up about how many closing braces are needed, and where they should be placed.

?

Id prefer requiring matching begin and end blocks, with the end statement indicating which block is being closed. For instance:?

?

for (i=0; I < max; i++)
begin
code;
?? if(something)
???? begin
???? code;
???? end if;
end for;

?

Theres more typing, but any developer who cant type fast is in the wrong profession. The upside is it is much easier to understand where blocks start and end. Sure, careful indentation tells us the same thing, but so much code today has been modified by so many people that the original engineers careful indenting often becomes hopelessly mangled. It can be hard to know what brace closes which block. And a misplaced brace can drive a compiler mad.

?

Sure, deeply nesting control structures might result in a lot of successive end if statements. Thats likely to be the exception rather than the rule. Theres no silver bullet that will save us, but small changes, like begin/end instead of braces, could greatly help out.

?

I often put an indication of which brace is closing which block in the comments. But if the language were as Ive indicated, the compiler could point out missing and mixed-up end statements.

?

Other languages mandate and benefit from labeled end statements, with Ada being a prime example.

?

What about you C if you could change just one thing about C, what would it be, and why?

?

Label: compiler c python
Views(254) Comments(0)
Total [0] users voted ????
[Last update: 05:49:49 PM, 18/04/2016]
Have Your Say!

Bloggers Say

Got something to say? Why not share it with other engineers?

Just introduce yourself to us, we'll contact you and set you up. Yes, it's that simple!

See what engineers like you are posting on our pages.

Interviews & Viewpoints

Talk

Learn how senior executives are seeing the industry from interviews and contributed opinions.

Back
?
Back to Top