Xref: utzoo comp.lang.c++:2111 comp.lang.c:14355 comp.lang.forth:664 comp.lang.fortran:1528 comp.lang.misc:2185 Path: utzoo!utgpu!watmath!clyde!att!pacbell!lll-tis!oodis01!uplherc!esunix!bpendlet From: bpendlet@esunix.UUCP (Bob Pendleton) Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc Subject: Re: Assembly or .... Message-ID: <1107@esunix.UUCP> Date: 23 Nov 88 17:26:38 GMT References: <1388@aucs.UUCP> Organization: Evans & Sutherland, Salt Lake City, Utah Lines: 143 From article <1388@aucs.UUCP>, by 861087p@aucs.UUCP (A N D R E A S): > > Since this are Newsgroups that mainly programmers write I > would like to ask them if it really worth it to spend time to > learn assembly language.I know that when you program in > assembly you loose the portability but you gain in speed. > I've been told also that there are some low-level operations > that you just can't do in C or any other high level language. > Apart from this most of the commercial programs are written > in assembly(Turbo Pascal etc.).Device drivers are also written in assemly. > So why is everybody against assembly when many programs available are > written in assembly? > I hope I'll get some answers from you guys !! There are several different questions here. I'll give my opinions on the ones I think are important. Then I'll sit back and watch the fun. 1) Why should you learn assembly language? No one should ever learn AN assembly language. You should learn at least 3 or 4 DIFFERENT assembly lanuages or you are wasting your time. By different I mean for different machines. Though looking at several different assemblers for the same machine can be instructive and amusing. To really know what a machine will do you need to learn and program in its assembly language. Learning one assembly language tends to make you believe that all machines are like the one you know. This can make you truely blind to the good points of other machines and the horrible gotchas of your one and only machine. One assmbly language folks can be real bores at parties and conferences. I actually met one idiot who thought that the phrase "assembly language" was just another name for BAL. He didn't see how I could possibly be writing in assembly language for an 8080 (dates me, I know) when he KNEW that BAL didn't generate 8080 machine code. Sigh. The only way to learn an assembly language is to write in it. Writing a simple assembler or a simple compiler that emits assembly language is almost as good. A complete introduction to the software side of computing should cover everything from transistors to objects. With some understanding of how each layer in the hierarchy depends, and is implemented in, the lower layers. That understanding requires a knowledge of assembly languages and machine architectures. Being able to program in assembly languages is also a marketable skill. What the hey, it's always nice to have a skill to fall back on :-) 2) Why are some programs written in assembly langauge? Economics. Writing in assembly langauge is expensive. But, when the possible market is large, like say the PClone market. And, speed is important, which it always is. And processor cycles are a precious resource i.e. the processor is slow, like on say a 4.77 mhz 8088. And memory is a precious resource, as it is on every machine in the world, but especially on PCs. Then the pay back from writing in assembler can be huge. That is to say, there is a whole class of marketable applications that won't fit or will be to slow if you don't write them in assembly. So, if you want to make a buck, you write it in assembly. For any given machine, there exists some application that is just barely doable on that machine. And there exists someone who is willing, for some reason, to jump through hoops of real fire to make that application run on that machine. The cost of high quality compilers for unusual processors is staggering. $20,000 to $100,000 and up, is not unusual. There are cases where you can't afford to write in anything but assembly language. Of course $100,000 is about one man year of software engineering time, so this cost might look high up front, but over the life cycle of a product it might be dirt cheap. Personal preference. Some people LIKE to program in assembly language. I like to program in assembly language, but then I like to write haiku sequences. No accounting for taste. I don't like to maintain assembly language. And I hate writing the same program N times. So I don't write much in assembler. Expediency. I've written assembly code because I didn't have a compiler and couldn't get a compiler. Sometimes the compilers don't exist, sometimes you can't afford to buy them. I've written small chunks of assembler to get at instructions the compiler never generates. 3) Why do people object to using assembly language? Econonomics. Assembly code is expensive to write, expensive to maintain, and nonportable. With modern compilers and modern computers (even PClones) you can write just about anything in a high level language and get the size and speed you need. OS dependencies might make it hard to port, but it can be ported. You might need a few assembly language routines to access some hardware or to speed up a few critical parts of the code. So why pay the price of writing the whole thing in assembly language? Esthetics. Somewhere along the way we all pick up a sense of good and bad, right and wrong, truth and lie, beauty and ugly... We see something and it strikes us as good, right, correct, beautiful, it pleases us. A lot of people see high level code as good, beautiful, and right, and low level code as bad, ugly, and wrong. Trying to read a piece of assembly langauge that you wrote last month might convince you that low level code is indeed bad, ugly, and wrong. Haiku stands the test of time and readability much better than assembly language. In summary I'd say that you should learn several assembly languages because it will give needed insight into machine architectures. And because when you need to use it, nothing else will do. But, when it isn't needed, it isn't worth your time, or anyone elses, to use it. All the questions seemed to assume that the PClone world IS the computer world. It isn't. Keep that in mind. Bob P. P.S. Please don't think that any of this is intended as a slam against the PC world. I just bought one, just because of all the software available for it. Does anyone know how to get BZONE to work with and Everex Micro Enhancer II with and EGA monitor? Weird machines, truely weird .... -- Bob Pendleton, speaking only for myself. UUCP Address: decwrl!esunix!bpendlet or utah-cs!esunix!bpendlet Reality is what you make of it.