On Thu, Aug 09, 2012 at 11:31:12AM -0400, Mathieu Trudel-Lapierre wrote:
> On Thu, Aug 9, 2012 at 10:50 AM, Hendrik Boom <[email protected]> wrote:
> [...]
> > It survives because of inertia.  It's the systems language most people
> > use, so most systems programs are written in it, and so most programmers
> > have to learn it, because a lot of programming deals with changes to
> > existing software, not writing new.  Because most programmers know it,
> > most new programs get written in it.
> 
> Can you explain why you think C is obsolete? What issues makes it so?
> Please provide examples, alternatives, solutions.

I'll give a technical argument about the kind of thing that's 
wrong with C.

You can't write any significant program in it without using unsafe 
features, such as pointer arithmetic, or malloc/free.  Corresponding 
safe features (such as bounds-checked subscripts or 
garbage-collectin) just don't exist in the language.

Now I'm not saying you shouldn't be able to do pointer arithmetic or 
explicit storage allocation and deallocation when you need it.  When you 
need it, it's a complete pain not to have these features available, and 
you take on the responsibility of using them correctly.  I'm saying  
that you should have safe alternatives, and certainly, you shouldn't 
have to us them almost by accident.

A languagee can have safe and unsafe dialects.  In the "safe" dialect 
you'd have bounds-checked subscripts and garbage collection.  In the 
"unsafe" dialect you would have these, but in addition, you could use 
explicit pointer arithmetic and explicit storage allocation and 
deallocation.

The first language in which I remember seeing this distinction was 
Mary, which I believe was build in the late 70's.

The vast majority of code in the vast majority of programs never needs 
the unsafe features.  By making it impoossible to use them by accident, 
you achieve a vast improvement in reliability at very low cost.

But C is such that trying to restrict it to its safe subset, 
produces an unusable language.
 
> 
> IMHO, no amount of convenience of programming (e.g. easy to code in,
> or easy to learn), or nice features like garbage collection and
> whatnot amount for the flexibility and power that C provides.

You don't have to lose the flexibility and power to gain garbage 
collection.  Coding convenience.  My first conccern in the choice of a 
programming language is how easy it is to get a program to be correct.  
My second is how fast the code runs, because it doesn't matter how fast 
it runs if it's wrong.  I have to say, most interpreted languages fail 
on both counts. 

Retrofitting a compiler onto a language designed to be interpreted
usually doen't recover efficiency.

The reason new languages (like python and perl) come out as interpreted 
ones is, I think, that it's very much easier to implement an 
interpreter than a compiler.  No doubt language designers have other 
motivations, but I think this is an important one.  Even when I design a 
language that's intended to be compiled, I first try it out as an 
interpreter to get a feeling for it.  It usually shows me what's wrong 
with it really early.

> 
> Yes, it's complicated, yes, it's definitely not always the right
> choice for just any project, and yes, you have more than enough rope
> to shoot yourself in the foot with when you use C... ;)  But it
> remains that all languages have different purposes, different
> strengths and weaknesses.

You shouldn't have to use a loaded gun to untie a shoelace.  You should 
have it available when you do need it, though.

> 
> Cobol is clearly an obsolete language that is still sticking around
> due to inertia -- most people aren't writing new things in it, but are
> forced to maintain existing complex systems because of the cost of
> rewriting from scratch.
> 
> C however, *is* being used for new projects. It's being taught in
> schools (though definitely not everywhere), and is a clear choice, at
> least to be considered, when building complex systems. It's not only
> used for new projects because most programmers know it -- but because
> it really works. I've seen a definite shift in schools from teaching C
> to teaching other programming languages, at least in CEGEPs.
> 
> I have yet to see other languages that provide the level of
> reliability and speed of execution of well-written C. I have also yet
> to see any language (other than C++) that makes it as easy to leak
> memory and make hard to debug, painful mistakes as C.
> 
> Don't get me wrong -- I'd just as well use Python for most things I'd
> write, and I wouldn't hesitate to use Java or god-forbid, ocaml should
> it clearly be the right tool for the job; but I totally disagree that
> C is obsolete, and you haven't brought evidence to support your
> position.
> 
> [...]
> 
> > Modula 3's specific handicap is that it's distributed under a
> > free-sofware licence that happens to be incompatible with the GPL and
> > after a series of  corporate takeovers, the entity that now owns the
> > copyright no longer has any interest in it, so it's impossible to get
> > the licence changed.  And it's not popular enough to make it worth-while
> > to write a new implementation.
> 
> I had never heard of Modula.

Modula 3, not Modula 2 or Modula.  It's a different language with 
different language designers.

> But again, there are so many different
> languages out there, it's impossible to know them all.

Agreed.  There was once an ettempt to maintain a registry of all 
programming languages.  I thint it gave up about 20 years or so.

> 
> Why has it not gained in popularity? It's highly likely that there are
> very good reasons for that. Maybe it's just really good at one
> specific thing, and its use can't be generalized to just about any
> problem?

It's at least as generally applicable as C.  I think you're 
underestimating the power of being the first mover in a particular 
industrial niche in an high-tech industry.

> 
> The licensing is a definite issue. There are so many "free" languages
> to choose from, all of them particularly well designed and that have
> proven their efficiency and reliability, that there is no reason to
> choose a "private" implementation for anything.

Modula 3 is free/libre, until recently is  was normally distributed as 
source code.  Nowadays the lazy can download precompiled object code 
instead and ignore the source code.  The free licence it's distributed 
under is somewhat freer than the GPL, but it happens, unfortunately, to 
be incompatible with the GPL.
  
> If only just the fact
> that then, the pool of people that have designed and have seen the
> internals is so small, you're absolutely in your right to question
> whether it's really going to do the job right in the long run, or if
> it's just a matter of time before it explodes.

It's not secret code.  Thats not the problem.

I can't use Modula 3 if I want to distibute linked executables 
containing Modula 3 libraries and GPL libraries.  Givn the amount of GPL 
stuff these days, that's a big restriction.  For Windows, in particular, 
it's unrealistic to expect most users to install a complete development 
environment when all they want is a particular application.  I have no 
difficulties distributing souce code.  But my users may well have 
difficulty using it.

> 
> > But you're right.  No one is about to rewrite the Linux kernel in
> > another language.  It's too much work.
> 
> I don't think the amount of work required is the real blocker in open
> source projects. People have tried re-implementing X. Everyone knows
> just how complex X is and how much work it would be to rewrite it from
> scratch. It hasn't stopped various re-implementations to spring up,
> like Wayland.

And trying to find out just what X does internally is an almost 
impossible task.  It isn't even properly documented.  I looked for such 
documentation a few years ago, and at that time the best documentation 
was years obsolete, not recommended, and out of print.

Mind you, I'm not saying you shouldn't use C.  Modula 3, for 
example, is a better language in many ways, even for the low-level 
coding that C was designed for.  But it's not widely enough used to 
ensure it'll still be there in ten years when you have to migrate your 
critical softeare to another OS or annother machine.  If you can 
afford to maintain and port the language yoursef, though, things can be 
different.  I know of one copany that's hosting the development 
repositories for Moduka 3 to ensure they will have it available 
into the future.

-- hendrik
_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca

Reply via email to