Fog Creek Software
g
Discussion Board




Learning Assembly--opinions?

As a coder who does most of his work in C, do you think I ought to try my hand at assembly? Randall Hyde, the author of this (http://www.onlamp.com/pub/a/onlamp/2004/05/06/writegreatcode.html) OnLAMP article as well as an upcoming book called "Writing Great Code" thinks so.

What do you wise JoS people think? Is it worth it--not necessarily in the practical sense, as a tool I'll get to use often, but more as some useful, fundamental concepts I'll be able to learn and take with me to C and other high-level languages?

Thanks.

Operation Northwoods
Wednesday, May 12, 2004

Yes, absolutely learn about it.

I learned assembler basics many years ago on 8 bit Ataris and that knowledge has been extremely useful over the years.  Assembler has little practical application for a lot of the programming done these days but knowing about it can help expose computers for what they are.  That would be blindingly fast bit movers and calculators.  Everything else is built on top of those abilities.

Assembler knowledge can also be useful in certain debugging scenarios.

Doug
Wednesday, May 12, 2004

My personal feeling on assembly is it's good for you if you care.  To elaborate, I'll use an analogy (no comments on how analogies are awful).  In calculus, one can learn to use a calculator to compute the definite integral of a curve.  It takes about 2 seconds to do.  However, I feel that if you really want to get an understanding of calculus, you have to understand ways to aproximate the integral, understand that as the limit of delta x approaches 0, you arrive at the actual value of the integral, etc.

If you want to learn more about the ins and outs of programming, and why things work and how things work, then go ahead and learn some of it.  If all you want to do is develop business apps that interface to a database, it probably isn't ncessary.

Elephant
Wednesday, May 12, 2004

I say "YES!"

The bulk of my undergraduate and graduate work was in BAL (or IBM mainframe assembler). 

Do I directly use that knowledge today???  Not really, but it formed a foundation upon which I work.

I still run into a nontrivial amount of x86 assembler in the Delphi projects I work on.

Steve

Steve Forest
Wednesday, May 12, 2004

Hi,

Maybe you missed my topic about "Compatibility and OSses", but right there I confessed I'm doing an OS in assembly. Well... a microkernel - but anyway, I know quite a lot about assembly and IA-32 system programming. And I have experience with writing a large programming project in it.
Now, should you learn it? Basically, yes. It helps a lot to know how your C statements are broken up into funky little pieces, and then fed to the CPU. The trouble is, that IA-32 assembly (i.e. everything up to Pentium 4), spanning the complete CPU vocabulary, is *extremely* complex, so there are only a few people who know everything (not including myself, btw). But, if you don't want/need to know everything, just the basics are easy to learn.
Take a look at NASM (the netwide assembler project). Lots of documentation & examples available (not on the main project site though - just google for it). It can create OBJ files which link into your windows project, or you can just start with basic DOS stuff (or Linux, now that would be *gReAT*, no?).
However, beware: I told you it's complex material.

Good luck,

Jay.

Jay
Wednesday, May 12, 2004

Yes, learn it.

Assembly language was the first language that I really learned and having those fundamental concepts under my belt made a big difference later down the road.

Mark Hoffman
Wednesday, May 12, 2004

As an exercise, a good beginning examination of assembly programming is Donald Knuth's MIXAL assembler. It's a ficticious machine language which was used as a pedagogical tool to describe all the algorythms in "The Art Of Computer Programming". MIX is a very simplified instruction set with only a few registers to manipulate.

MIXASM, Docs and Tutorials can be found on GNU web sites.

old_timer
Wednesday, May 12, 2004

I also think learning assembly is a good thing.  Second language I learned was Z-80 assembly, third was 8086 assembly.  I was an expert in both, but have done neither for 15 years now.

I'd say your best bet is to see if you can find a Z-80 virtual machine for a PC and code with that.  You'll learn what you need to know, and it's a pretty easy language to learn.    The Z-80 was much nicer than the 8080 was.

Hmmm, that may be bad advice.  Where are you going to get  "Teach yourself z-80 in 30 days" nowdays?  I still have the 2 books I learned from, but I'm not giving those up until my wife has scattered me across the ocean :)

Snotnose
Wednesday, May 12, 2004

I think Joel opined once that knowing assembly was a good thing because it allowed you to understand the abstractions going on.

As you're familiar with C I'd begin with inline code and as always find something non-trivial to do. 

Simon Lucy
Wednesday, May 12, 2004

It is not a question of learning it or not. the real question is what you would do with your time if you didn't spend it on learning some assembler language. It is always about tradeoffs, nothing is free.

Just me (Sir to you)
Wednesday, May 12, 2004

Be familar with it, but it's not necessary to be an expert.  Able to read assembly is good enough, IMHO.

I'd spend my time learning on the other end of the scale: J2EE, .Net, SQL, ...

5v3n
Wednesday, May 12, 2004

yes, do it. i started assembly programming on c64 when i was 13, then do some on x86 as well at age 16.

now i'm 29, and i do project management :(


Wednesday, May 12, 2004

Yes, learn it and then teach me too.


Wednesday, May 12, 2004

Yes, learn it.

You'll never program in it, but there will come many a day when you'll look at the output of your compiled code to see the performance cost of doing things a certain way.

Alyosha`
Wednesday, May 12, 2004

Do it! Yes!

No MIXAL, no Z-80; do 80x86 assembly; it's the stuff you're working with every day.

Alex
Wednesday, May 12, 2004

Learn assembly.

I've found two showstopper bugs in the past two years that could only be tracked down by reading assembly.  Both were MSVC++ compiler bugs: One had to do with tail call optimization, and the other had to do with static object initialization.

You won't write much assembly, unless you hack on compilers or graphics code, but a reading knowledge is invaluable for a professional developer.

Another good thing to do is to truly understand your computer's memory hiearchy--registers, L1, L2, TLBs, main memory, swap, etc.  Learn the sizes and performance characteristics of each layer, and you'll know more about high-performance computing than most assembly-language hackers.

J. Random Hacker
Wednesday, May 12, 2004

Steve Forest...did you go to NIU?

I just graduated from a program that had a lot of BAL and HLASM.  I don't see it helping me get a job (i feel hopeless on this aspect unfortunately), but it has totally made programming more clear to me.  Encryption/decryption, pointers, memory management, everything became so much clearer after you have to set up close to every aspect of your application in the end with a 0 or 1.  Thus far it has been the funnest language I've worked with.  After taking a few classes I started to finally enjoy programming, now its become an obsession.  If you are already employed and secure in your job and have the time, i'd say go for it. 

Grover
Thursday, May 13, 2004

If you want to be a good programmer, you should learn several languages well.  Peter Norvig suggests you learn at least a half dozen, of varying types.

Each language (even assembly) has its own idea of how to represent the incredibly broad concept of "computation" as abstractions -- classes, message passing, pure functions, declarative specifications, and so forth.

It's no exaggeration to say that nothing made me a better C++ programmer than reading Steele's, Norvig's, and Graham's books on Common Lisp.  New language = new way to think about the problem.

So yeah, learn assembly.  Assembly isn't a huge stretch from C, but it's another tool to have in your kit -- better to know it than not, right?  Just don't stop there.  :-)

(About the only thing on par with learning new languages is implementing one.  Writing a compiler will draw on pretty much everything you've ever learned about computer science.  Hardest -- and best -- CS course I took in college.)

Compiler geek
Saturday, May 15, 2004

*  Recent Topics

*  Fog Creek Home