[ale] Hello World - in C# - in Mono - in Ubuntu is done

Pat Regan thehead at patshead.com
Thu Sep 16 23:52:59 EDT 2010


I'm going to preface my comments with that fact that I Am Not A
Programmer.  I don't know how much value my opinion actually carries in
this context :)

On Thu, 16 Sep 2010 22:45:32 -0400
"Michael B. Trausch" <mike at trausch.us> wrote:

> C# (and the CLR as a whole) is a very expressive and useful language.

Compared to what?  C# is nearly as rigid (if not as verbose) as Java.
Neither of those come any where near the expressiveness of languages
like Perl and Python.

> I've used it for a few projects, and I rather like it.  However, if I
> may, I would like to offer a little bit of advice:  Learn C.  Yes, I'm
> serious.  Learn C99 at least---it's useful, and you'll find a very
> strong development environment built around GCC and the C programming
> language such as it is used in GNOME and its entire stack.

There's very few good reasons to set out learning C today.  Isn't
poor use or malloc/free the number one cause of security problems?
There's very little reason to use a language that forces you to do your
own manual memory management.

> Why do I say this?  It is because learning to program in C is helpful
> to your development as a programmer in nearly every single programming
> language that you can imagine.  There are some constructs in Java or
> C# or Python or whatever nifty-language-of-the-month you can find
> that are insanely easy to use and look very inexpensive if you look
> no further than the source code.  But as you get really familiar with
> the C programming language you begin to understand that this comes
> with a cost---and that cost can sometimes be a million or more lines
> of assembly language code.

The nifty constructs in Python and Perl don't save CPU time, they save
programmer time.  Most of us aren't Google and Amazon.  Programmers are
more expensive than hardware, at least up to a point.  That point gets
farther away every year.  Most of us aren't going to actually hit that
point.

> If you don't believe me, check out Hello World written in C:
> 
> #include <stdio.h>
> 
> int
> main(int argc, char *argv[]) {
>   if(argc > 1)
>     fprintf(stdout, "Hello, %s!\n", argv[1]);
>   else
>     fprintf(stdout, "Hello, World!\n");
> 
>   return(0);
> }
> 
> This program looks pretty simple, right?

No :).  It is way too verbose.

> In any case, it's something to think about.  If you become very
> familiar with programming in C, it can't hurt---and it will likely
> help you a great deal.

I'm starting to get old, or maybe I'm just starting to act old.  I
agree with you that everyone should learn C.  We are quite likely both
wrong about that, though :).

I just think it is a very bad idea to learn a language that saddles you
with all the outdated baggage that C makes you deal with.

I'm very excited about Perl's Moose object system.  I'd definitely want
to start with a language with an object system that modern and
awesome. :)

> Perhaps one thing to mention:  I'm not saying that you should think
> about this all the time and use it to optimize code before you've even
> found a bottleneck!  What I am saying is that if you are aware of what
> these things can turn into as they get closer and closer to the bare
> metal, you'll be more easily equipped to ask the right questions when
> you do have a performance bottleneck of some sort, and you'll be more
> likely to look further than just your own written code when you do,
> because you'll understand that every layer adds sometimes more
> overhead than you can possibly imagine even as a very experienced
> programmer.

You have to use the right tool for the right job.  If you're going to
write something that is extremely CPU intensive like a video encoder or
some sort of scientific simulation you'd probably be best to start with
C or C++.  The CPU time you save running those kinds of applications
will easily pay for the extra programmer hours.

Higher level languages will require fewer lines of code, fewer
programmer hours, and they will be easier to debug.

> Anyway, enough with the going on and on---congratulations for starting
> down the road with a new programming language, and may you find other
> languages to learn to be fluent in as well.  The more the merrier!

Yes!  Programming is fun.  I wish I could give myself reason to write
more than the shell scripts I normally cobble together :)

Pat


More information about the Ale mailing list