The status of C

  • Thread starter Martin Johansen
  • Start date
J

jacob navia

Lawrence said:
Extrnal libraries could even be written in standard C. But they are only
well defined and portable in the comp.lang.c sense if their source code is
available and considered to be part of the program under consideration.

The source code of Mr Boehm's GC is available everywhere.
 
L

Lawrence Kirby

It is not standard but it is just an external library.
External libraries are allowed of course!

But not supported by standard C, they just inhabit an area that the
standard leaves as undefined behaviour.
External libraries can be very portable. Mr Boehm's GC
runs under Unix, windows, and many other OSes.

Extrnal libraries could even be written in standard C. But they are only
well defined and portable in the comp.lang.c sense if their source code is
available and considered to be part of the program under consideration.

Lawrence
 
M

Michael Wojcik

Note that if your implementation provides garbage collection as an
extension, you have to exercise some discipline to use it. Not as
much discipline as what's required to use malloc/free properly, but GC
can potentially break some valid C programs. (The cases I can think
of involve storing a pointer value as a disconnected sequence of
bytes, thus hiding it from the GC system, and then reconstructing it;
there may be other cases I can't think of.)

There's the ever-popular one of writing a pointer value to a file
with fprintf (or string with sprintf) and %p, then later "during the
same program execution" (as the Standard has it) converting it back
with fscanf (or sscanf).

This (and other variations, eg inspecting a pointer variable's value
as a sequence of unsigned char, storing the individual bytes as hex
in a string, and later restoring them) is of course basically the
same as the "disconnected sequence" case you described. The point is
that there are a handful of ways in which conforming C programs can
hide a pointer value from a collector and recover it later.
 
J

jacob navia

Michael said:
The point is
that there are a handful of ways in which conforming C programs can
hide a pointer value from a collector and recover it later.

If they use the collector and do that, those programs will crash.

Who cares?

The documentation specifies that the collecotr will work
assuming certain conditions, and if you do not respect them
your program may crash, or the block that the collector thinks
its free will be reused with unpredictable results.

The GC library is as any other library. There are zillion ways
to make it crash. The same as, say, a sockets library. You
can crash it in a zillion ways by feeding it wrong data,
using invalid pointers, destroying its internal data
structures whatever.

So what?
 
P

Paul Mesken

Is that because objects reduce the amount of code or because objects are
easier to deal with at this level?

I wouldn't say that C++ results in less code ;-)

C++ just has better ways to do things like abstraction, encapsulation,
polymorphism, etc. Such techniques help to keep big projects
manageable.
 
P

Paul Mesken

C is obsolete.
C++ was designed to replace C
and that seems to be what is happening.

I tend to agree, but this might not be the best place to make such
statements ;-)
 
K

Keith Thompson

jacob navia said:
If they use the collector and do that, those programs will crash.

Who cares?

Anyone who uses the collector should care.

(Did you think I was arguing that nobody should ever use garbage
collection? I wasn't.)
 
M

Malcolm

Emmanuel Delahaye said:
Yes. Sorry for being unclear.
English lesson.
"C is not an option" means "C may not be used".
"C is not optional" means we may not refuse to use C.
 
M

Malcolm

Martin Johansen said:
Is C still the language of choice for serious programming?

Which businesses favour C, e.g. game, driver, os, device or even web
developement?

Is C on the decline?
What I constantly harp on about is the timewasting potential of computers.
They are great for playing games on, but attempts to use them for any other
purpose are fraught with difficulty.
Email imposes very little cost on the sender, with the result that you get
messages which are not of any real importance to whoever originated them.
Using a new sotware package, or a new language, is a common occurence. The
inevitable delays and inefficiencies are always rationalised as teething
problems, but in fact it is a perpetual situation. For instance I presently
have to use Java, and I am trying to coax the JTree component into doing
what I want (it truncates labels of leaf nodes). So here is a programmer of
over twenty year's experience not able to draw a tree! Totally unacceptable,
but that's what happens once you go down the route of the best and brightest
new language.

I can knock together an algorithm in C basically as fast as I can type. Use
any other language and you spend time playing with its features, making this
virtual or overloading the equals method for that class or trying out fancy
loops in another language that allows snappy syntax for reading from files.
In other words wasting time.
 
P

Paul Mesken

I can knock together an algorithm in C basically as fast as I can type. Use
any other language and you spend time playing with its features, making this
virtual or overloading the equals method for that class or trying out fancy
loops in another language that allows snappy syntax for reading from files.
In other words wasting time.

I agree that this is a danger of learning a new language (especially
with C++) but I believe this desire to be a natural part of learning a
new language (or any new thing) and, thus, a transitory thing.

When I learned C I fell in love with the ternary operator and comma's.
I made an effort to fit entire functions inside a single return
statement (being several lines long).

With learning C++ I started to change my data in such a way that I
could use those neat inheritance features (how can I impose a
hierarchy on my data that didn't exist before?). With T-SQL I went
bananas with triggers, etc.

But now I use the features to make my programs and am no longer
changing my designs to fit the features. Sound programming practices
(readability, maintainability, etc.), once more, rule (of course, not
in the case of Assembly ;-)

So, I think the practices you speak of are merely a natural learning
thing and they won't last.
 
M

Malcolm

Paul Mesken said:
I agree that this is a danger of learning a new language (especially
with C++) but I believe this desire to be a natural part of learning a
new language (or any new thing) and, thus, a transitory thing.
That's the trap everyone falls into with computers.

The installing of new software, converting your data to the new system,
learning to navigate the snazzy new window system or trying to get the
scanner to work with the new PC, never stops. Unless you take firm action
against it, it negates most of the advantages of using computers at all.

Part of that firm action, for programmers, is to do everything in C unless
there is an overwhelming case for another language. In my case I have to use
a Java UI. However the interesting part of the code is in C. The algorithm I
am currently working on takes about an hour to run, so if I wrote it in Java
that would probably mean a two hour running time. New languages usually have
serious disadvantages as well as advantages.
 
L

Lawrence Kirby

The source code of Mr Boehm's GC is available everywhere.

If iot is written in standard, portable C, and you make its source code
part of the source code of your application then fine.

Lawrence
 
J

jacob navia

Lawrence said:
If iot is written in standard, portable C, and you make its source code
part of the source code of your application then fine.

Lawrence

The code of Mr Boehm is his property. I do not want to make
a parallel distribution of his code.

The code is available at request from me of course, but it is better
to get it from the official distribution.

The code is system code of course. Standard C doesn't cover virtual
memory, threads, and many other things, so it is written in C, but
not exclusively in ANSI C, specially because it uses low level
system calls.
 
L

Lawrence Kirby

The code of Mr Boehm is his property. I do not want to make
a parallel distribution of his code.

No doubt, and I'm not suggesting that you do this. Howeever if the source
code is not considered part of your application then you have an area of
undefined behaviour in your program as fas as the standard is concerned.
But you don't have to distribute Mr Boehms code to make it part of your
application, you just have to include instructions on how to obtain the
source code and integrate it into your application.
The code is available at request from me of course, but it is better
to get it from the official distribution.

No doubt true but not the point at issue.
The code is system code of course. Standard C doesn't cover virtual
memory, threads, and many other things, so it is written in C, but
not exclusively in ANSI C, specially because it uses low level
system calls.

Then its portability will naturally be limited.

Lawrence
 
C

Chris Hills

E. Robert Tisdale said:
Good programmers "cause" better programming discipline.


C is obsolete.

In the major expanding area of computing C is the ONLY option. eg
embedded.
C++ was designed to replace C
and that seems to be what is happening.
In may areas yes. However in many areas C++ can not replace C
 
A

Ari Lukumies

Paul said:
I think discipline is even more important with languages that are not
OOP. But for medium to big projects (those that result in more than
10,000 lines of code, to give a rough idea) I'd favor C++.

I'd favor UML - the choice of a language comes afterwards.
I'd say writing device drivers, OS, embedded systems, etc. A lot of
games are written in C++ nowadays (and often some Assembly is thrown
in). There are specialized languages for web development. I wouldn't
want to make a site with C.

Most of the games I've seen (eg. Quake) are a mixture of C or C++ with
assembly for the speedup. Same goes for 3D-imaging software. However, I
wouldn't trade C for another language when writing programs to
communicate with PLCs.
C has a lot of competition of C++. At least where I live, companies
hardly ever ask for C programmers anymore but there is a substantial
demand for C++ programmers.

That has nothing to do with the language, it's a matter of perspection.

-atl-
 
B

BGreene

Martin Johansen said:
Hey guys

Since C is my language of choice for almost any kind of application, I'd
like to know what the status of C is around the world today.

And I am ofcourse not talking about C++ or C#. I think the lack of object
orientation and garbage collection causes better programming discipline
needed for harder projects anyway.

Is C still the language of choice for serious programming?

Which businesses favour C, e.g. game, driver, os, device or even web
developement?

Is C on the decline?

Thanks!

C is dead, no Paul is dead, no...
 

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

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top