Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 May 2000 19:17:29 -0500
From:      "G. Adam Stanislav" <adam@whizkidtech.net>
To:        J McKitrick <jcm@freebsd-uk.eu.org>
Cc:        chat@FreeBSD.ORG
Subject:   Re: assembly vs C
Message-ID:  <20000509191729.A228@whizkidtech.net>
In-Reply-To: <20000509212637.A73322@dogma.freebsd-uk.eu.org>; from jcm@freebsd-uk.eu.org on Tue, May 09, 2000 at 09:26:37PM %2B0100
References:  <20000509212637.A73322@dogma.freebsd-uk.eu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 09, 2000 at 09:26:37PM +0100, J McKitrick wrote:
>I've heard some debates recently, mostly by 'old-school' hackers from the
>C64 days who are calling for a return to machine language.

So which one was it? Old-school hackers, or C-64 days hackers? C-64 days
weren't that long ago. Believe it or not, some of us pre-date even Unix,
let alone C-64. :)

And I think you really mean assembly language, not machine language.
I can't imagine anyone coding in *machine* language when we have excellent
assemblers around.

I certainly *can* imagine coding in assembly language: I do it all the
time. And I had to laugh at some comments stating here that a human cannot
"beat" a modern compiler. That will be the day when humans cannot
out-think computers!

That said, what do you mean by "return"? Assembly language programming
never disappeared. It is not like we either program in assembly language,
or we program in C and other languages.

Languages are tools. Different tasks require different tools.

>  They claim that
>CPU speed, memory size, and HD space will begin to plateau soon, and that ML
>would bring a much needed return to efficiency and clean coding.

Efficiency and clean coding are certainly necessary regardless of the
underlying hardware, or the language chosen for software.

>The other side of the coin argues differently.  I can think of 2 arguments
>against: first, OOP and C++ were developed almost expressly to make it
>easier to deal with the size of today's apps.  Modularity only goes so far,
>they claim.  Objects are needed to further simplify development and
>maintenance.  The other point is illustrated by Unix itself.  ML was
>abandoned for C, since compilers are advanced enough  in time and space
>optimization to make hand-coding unnecessary, even obsolete for everything
>but device drivers.

Who says you need C++ for OOP? You can certainly use OOP in assembly
language. Assembly language was not *abandoned*, it was complemented.
The C compiler still produces an assembly language result which is then
assembled.

The whole argument does not make sense to this "old-timer." Choose whatever
tool is best suited for the task at hand. Generally, for a large Unix
application C is your best choice, especially on "true" Unix, such as
FreeBSD, because its system calls are optimized for C programming style.

I have recently (days ago) compared the way FreeBSD handles system calls
with the way Linux does. Under FreeBSD you push parameters on the stack.
Under Linux you place them into registers. I then spent some time thinking
on how I would do it if I were to write an OS kernel. I finally decided
that the FreeBSD way would be my choice as it would be more efficient from
a larger perspective.

There are many factors one needs to consider when choosing the right
tools. Am I looking for an answer to a question? Once I have the answer,
will I ever need to run this code again? If not, why would I want to
spend too much time writing it in assembly language? Or, for that matter,
in C. Perhaps I can write a shell script in a couple of minutes and get
my answer.

Am I looking for many answers to many questions? Will I be looking
for more answers to similar questions in the future? Perhaps C is my
best tool.

Am I constantly looking for answers to specific types of questions,
writing code that will always run on my system, taking up memory
and processor cycles? Perhaps assembly language is my best choice.

Programming is the art of solving problems. Different problems call
for different solutions.

Should you know assembly language? Of course you should! Should you
know C? Of course you should! Should you know how to program the shell?
Of course you should! The more tools a programmer has at his disposal,
the more choices he has in using them. But the most important
ability a programmer needs is not the ability to use this or that
language. The most important ability a programmer needs is the ability
to solve problems. Once you have found the right solution, coding
it is a snap. And only at the coding stage should you decide which
tool is your best choice.

Cheers,
Adam

-- 
Can you imagine the silence if everyone said only what he knows!
		-- Karel Čapek


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000509191729.A228>