Productive C

K

Khookie

Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C. At the moment, I find myself learning & reinventing stuff for C a
fair bit. And I seem to be doing lots of debugging as well. For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode... but then I'm not sure whether
the gains made by sorting out a nice program structure quicker and
having lots of libraries will be outweighed when I need to bring it
over to C? Maybe I should check out an alternate language like C++/D?

Anyone with thoughts in these areas?

Chris
 
E

Eric Sosman

Khookie said:
Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C. At the moment, I find myself learning & reinventing stuff for C a
fair bit. And I seem to be doing lots of debugging as well. For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

This is why it is a good idea (1) to #include the "exporting"
header in the module that contains the definition and (2) to access
struct elements by their names and not by what you think their
order and offsets might be.
How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode... but then I'm not sure whether
the gains made by sorting out a nice program structure quicker and
having lots of libraries will be outweighed when I need to bring it
over to C? Maybe I should check out an alternate language like C++/D?

Anyone with thoughts in these areas?

C is a relatively low-level and relatively general-purpose
language. You may find that more specialized languages provide
more built-in help for their specific tasks.

Implementing in one language with the intent of porting to
another strikes me as a poor idea, likely to lead to poor code.
Next time you write a love poem to your Significant Other, try
writing it in Russian and then hiring a professional translator
to turn it into your S.O.'s favored tongue; compare the result
to what you'd expect to get had you written in the chosen language
in the first place.
 
T

Thad Smith

Khookie said:
How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

That is true for me. A lot of it was developing habits appropriate for
1) the language
2) my applications and environment
3) my personal strengths and weaknesses

For example, I give more scrutiny to potential errors that would result in
infrequent and hard to analyze symptoms (such as buffer overflow) than I do
for errors which will result in a compiler error, since the latter will be
much easier to find and fix.
 
C

Chris Hills

Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C. At the moment, I find myself learning & reinventing stuff for C a
fair bit. And I seem to be doing lots of debugging as well. For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

Surely your static analyser picked it up?
How are people's experiences with productive C coding?

It's used a lot on high integrity systems.
 
M

Marc

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Have you considered using a server side script language instead of C? PHP,
for example. It's syntax is quite similar to C, so it won't be difficult to
learn. Performance is the only reason I can find here to use C. Is
performance really an issue?
 
I

Ivan Novick

Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C. At the moment, I find myself learning & reinventing stuff for C a
fair bit. And I seem to be doing lots of debugging as well. For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode... but then I'm not sure whether
the gains made by sorting out a nice program structure quicker and
having lots of libraries will be outweighed when I need to bring it
over to C? Maybe I should check out an alternate language like C++/D?

Anyone with thoughts in these areas?

Chris

Why are you even considering using C?

If you don't know exactly why it is you are planning to use C probably
you shouldn't be using it.

There are many projects where C is the only viable option.... because
of low level control , etc.

It sounds like you don't need any of the advantages C has to offer.

Regards,
Ivan Novick
http://www.0x4849.net
 
M

Mike Wahler

Khookie said:
Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C.

What were your reasons for choosing C for the project language?

-Mike
 
W

William Hughes

How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

Indeed, but in a fairly specialized domain. I know parts
of the standard library very well, other parts not at all.


I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode...


Seem like a reasonable idea except for the bit about porting it
to C (why would you want to do this?). Caveat: I know little about
HTTP stuff, there may be a better choice than Python.

- William Hughes
 
K

Keith Thompson

Khookie said:
OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience. [...]
For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

If you do things correctly, this particular kind of error should be
nearly impossible to make in the first place. It sounds like you
either have definitions for the same struct in two different places,
or you're accessing members of the struct by some means other than
referring to their names.

Define the struct in a single header. Any source file that needs
access to the struct definition has a #include for that header. The
layout will never get out of synch because there's nothing to get out
of synch.

Another possible way to have this kind of problem would be to change
the definition, but forget to recompile files that depend on it. A
good build environment should prevent that from happening by forcing a
file to be recompiled whenever something it depends on changes. <OT>A
Makefile lets you specify the dependencies, but doesn't automatically
guarantee you've specified them correctly.</OT>

[...]
I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode... but then I'm not sure whether
the gains made by sorting out a nice program structure quicker and
having lots of libraries will be outweighed when I need to bring it
over to C? Maybe I should check out an alternate language like C++/D?
[...]

At a previous job, I had planned to prototype a large chunk of code in
Perl, and then reimplement in C for speed. It turned out the Perl
code was more than fast enough (the major bottleneck was elsewhere),
so rewriting in C wouldn't have helped significantly. (Whether Perl
or C would have been a better implementation language in the first
place is another question.)
 
R

Rico Secada

Hi all

OK, some stuff not necessarily related to the C spec, but please read
- I would really appreciate advice from your collective experience.

I'm currently writing a piece of software for the medical industry.
It's going to be a HTTP server app serving pages so that multi-user
deployment is real simple (and other reasons).

Everytime I go to somewhere like Reddit/Slashdot/etc., there's always
news about Python/Ruby/Lisp/etc. - so I get an itch to go back to
them, especially Python.

I always find myself thinking whether I've made the right choice with
C. At the moment, I find myself learning & reinventing stuff for C a
fair bit. And I seem to be doing lots of debugging as well. For
example earlier today, I forgot to update the header file when I
repositioned a few char pointers in a struct. This stuffed me for
about 2 hours - I couldn't figure out why reading struct values in
another module had completely different values than to the module
itself. Anyhow, I digress :).

How are people's experiences with productive C coding? Do you find
that you reach a certain point where you're fairly productive with C
(not too much debugging, easier to add features, you're reusing your
previously implemented functions and you know the standard library
pretty well, etc.)?

I also considered implementing the project in Python and then porting
to C once it reaches maintenance mode... but then I'm not sure whether
the gains made by sorting out a nice program structure quicker and
having lots of libraries will be outweighed when I need to bring it
over to C? Maybe I should check out an alternate language like C++/D?

Anyone with thoughts in these areas?

Chris

Hi Chris.

It looks like you haven't done a proper evaluation of language-use in
your project.

You must define exactly what you want to achieve and by doing that, you
will better be able to judge what kind of language will meet your
specific needs.

If you are in doubt whether you should do it in C or Python then you
haven't evaluated properly.
 
A

Al Balmer

Hi Chris.

It looks like you haven't done a proper evaluation of language-use in
your project.

You must define exactly what you want to achieve and by doing that, you
will better be able to judge what kind of language will meet your
specific needs.

If you are in doubt whether you should do it in C or Python then you
haven't evaluated properly.

The question isn't actually about which language is better for the
project - we don't have enough information to comment on that.
However, I think we can answer the questions in the "How are people's
experiences" paragraph with "Yes to all the above." The questions in
the next to last paragraph, again need more information, except to
comment that "sorting out a nice program structure quicker" comes with
experience in C, and, depending on the project, may actually be easier
in C than in a OO language.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top