Just wondering, since assembly code is more or less what every other language is compiled into, would it be useful to learn how to do things in assembly before learning say, C or C++, pascal, python, etc? I am already fluent in Visual Basic but I want to get to a lower level and more powerful and useful language. I'm just wondering if knowing assembly would even help really...I've read that it can but I don't understand how--the compiler already has its own efficient methods of writing the processor instructions and then it optimizes it even more, so why would one need to know assembly?

> so why would one need to know assembly?
Curiosity mostly.

Being able to follow the code the compiler generates, and very rarely writing very small snippets works for me.

A native compiler never compiles to assembly it compiles to machincode (zeros and ones). Assembly language is just a bunch of "mnemonics" so that we can get a grasp at what all those zeros and ones mean. It's interesting and instructive to know what it does, but I would not like fact that from tomorrow on I would have to program in an assembly language. Give me C++, C# or Java!
With C or C++ you can get close to what an assembly language does(if you want to)
Personally I rather like C# for the moment, just for the fact that it releaves me from bothering with basic memory, register, pointer, adressing and other things you have to take into consideration otherwise.

well that's what I figured, though I read somewhere that learning assembly is important because it makes you a more efficient coder? I suppose because doing anything in assembly requires a LOT of instructions and a lot of working directly with hardware and memory so you'd learn to do things quicker, with less instructions. And probably which operations take the most clock cycles etc. so that when you move up to C or C++ you take those skills and learn to be more efficient with your code?
Anyways, I didn't really understand shifts and rotates, or how the deep deep insides of a computer worked until I learned assembly. So now it'll probably be easier to grasp how other languages are working?

Oh, and when I said a compiler compiles a language "to assembly" I meant machine code, that's why I said "more or less." But yeah I understand what you mean, just I was getting the relationship across that assembly is the closest thing to the ground that you use a compiler for, since the assembly mnemonics are interchangeable with the machine code (in debug, etc).

i dabbled in it as part of my CS course and it was good for learning how the computer actually works.

in general though no i dont think its a good starter language.

well, not a starter language for doing anything with it, just for learning how other languages are going to do what they do

Knowing how the internal combustion engine works doesn't necessarily mean you're a better driver.

I've seen many experienced asm programmers turn out the most abominable C you're ever likely to set eyes on.

> that learning assembly is important because it makes you a more efficient coder?
Speaking from personal experience, I'm not thinking about asm when I'm writing C code.
Picking the right algorithm is what really wins big, not worrying about whether a 'for' loop is 5nS quicker than a 'while' loop.
For example, your carefully crafted bubble sort in asm will still suck.

> so that when you move up to C or C++ you take those skills and learn to be more efficient with your code?
Except you have no control over instruction choice. Good compilers' already know this, so you don't have to.

okay, well put, I understand now, but what you said about algorithms, would asm make you any better at picking algorithms, since asm is basically ALL about algorithms?

> since asm is basically ALL about algorithms?
And every other language isn't?
Algorithms and data structures are abstract, they don't need a programming language in order to understand them, study their efficiency, compare with other algorithms etc.

Programs themselves are algorithms

well, I know all of them are about algorithms but assembly is especially so because each assembly instruction is so simple that every action you want to take requires an algorithm... in VB for example, you can find out what 4 * (3 ^ 6) equals and then store it in a variable in one line,
number = 4 * (3 ^ 6)
but obviously in assembly that would take a lot more work, I was just thinking understanding how a processor actually carries out those regular easy functions in other languages, or knowing how complex it gets for the simplest little tasks could be of some benefit. In VB it doesn't matter but I know in C you can manipulate processor registers and the like, I wanted to know what those were and it led me to assembly and many many sites telling me that getting good at assembly could help me be an excellent C programmer.

And about algorithms not being specific language, I guess I never considered that since each language has its own way of using those algorithms, I guess its usability in different languages depends how simple the algorithm is.

But thanks for your help

Learning assembly helps you understand how the hardware works.
On certain platforms, learning how the hardware works is necessary to program the hardware, in any language.
Learning the hardware isn't necessary to be a good C programmer- though, if you've ever learned about the indirect addressing mode
of certain processors, you won't be wondering what pointers are used for when you meet them in C, because you'd have used it
to step through memory and such.

I don't think assembly is a good starter language. I think it's better to start higher, then work down.

pointers still are pretty confusing to me, I understand what they do, just I have never been able to use them properly. I guess I just have to practice. Haha and I started high, then went really low

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.