Should one start learning programming from assembly?

otinane

Member
Oct 13, 2016
68
13
36
As title says, should one first study assembly and then move to other languages (C, Python, Java) or the other way around is more efficient?

And if yes, how hard could it be?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Learning assembly can help you understand what languages like C are doing with pointers, references, malloc and new, but I'd say that's not a requirement. Unless you write device drivers or operating systems you might never use assembly, even for embedded systems.

They were still teaching 8086 assembly when I was in college, but I'm old
 

MagnusTheBrewer

IN MEMORIAM
Jun 19, 2004
24,135
1,594
126
Assembly has the same relationship to programming as DOS has to a modern OS. Unless you're interested in embedded systems, assembly isn't good for much but, nerd points.
 

Chaotic42

Lifer
Jun 15, 2001
33,929
1,098
126
It depends on what you're trying to do. You don't need to understand much about metallurgy or mechanical engineering to work on a car. You don't need to understand the topology of the number line or functional analysis to use math. If you want to do certain types of embedded engineering or work on systems where every single drop of performance is critical, then it's important. You could happily bang out Java-based corporate software all of your life without understanding what's going on at the assembly level.

You said you wanted to do networking in the other thread. Do you want to do things like design routers and switches? If so, learn assembly. If you want to be a network admin, focus on Python and Bash.

Of course, if you're just plain interested in assembly, then absolutely go for it.
 

otinane

Member
Oct 13, 2016
68
13
36
You said you wanted to do networking in the other thread. Do you want to do things like design routers and switches? If so, learn assembly. If you want to be a network admin, focus on Python and Bash.

Of course, if you're just plain interested in assembly, then absolutely go for it.

Yes, as i wrote on another thread my priority now is networking/sysadmin. When it comes to programming is mostly because i have a lot of ideas on software, so if i never end up working as a programmer, i could work on private projects (of course if the knowledge of some basic coding provides any kind of "advantage" on a working environment, that would be totally welcomed).

Now, the reason why i shoot out that post here. After some research i came down to a list of the books i should get for C/C++, Python and Java. Somewhere i found out that a basic knowledge of assembly, can help you understand better, what are those lines of code that you read, how they actually work, or even help write better code your self.

I opened the books, for a quick review, to see what i' m going to face. I realize that in the first chapter, all language show few lines of code for the famous "Hello world".

Python's looked simple, C looked abstract, assembly looked natural. It looked how i would write few lines of code for a program that would make a computer saying "Hello world".
 

Greyguy1948

Member
Nov 29, 2008
156
16
91
One way is to start with C, C++ or Pascal. All of them can compile to the ASM code so you can learn it in parallell. It is possible for X86 and ARM for example.
 

Mr Evil

Senior member
Jul 24, 2015
464
187
116
mrevil.asvachin.com
Learning assembly can help you to understand some non-obvious things that happen in higher level languages, e.g. why something as simple as writing a value to a double might not be atomic. Still, I don't think it's a good place to start learning programming, and even writing embedded software, you're likely to be better off using a high-level language like C.

...Python's looked simple, C looked abstract, assembly looked natural. It looked how i would write few lines of code for a program that would make a computer saying "Hello world".
"Hello world" might be ok in assembly, but once you get to any level of complexity, it will look horrible, and quickly become unmaintainable. For instance, compare 99 bottles of beer in assembly to Python - and that's still a very simple program.
 

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
Don't bother with assembly.
Don't even look at it.
It's a complete waste of time.

It's like learning how to do weld heavy metal, if you actually want to be a car mechanic. It's 99.99% sure not going to be useful. I would even dare to say: it is going to be counter-productive. Learning assembly will cause your mind a lot of problems learning a higher language later.

Just start with Python. That's probably the best language to learn programming at the moment, imho. And if you enjoy it, and get any good at it, Python is a language that will get you a lot more jobs than assembly would.

If you really wanna be hardcore, learn C. That's a language that allows you to do all kinds of low level stuff. But if you are good and disciplined, you can still achieve a high level of abstraction. You can never do that with assembly.

You said you wanted to do networking in the other thread. Do you want to do things like design routers and switches? If so, learn assembly. If you want to be a network admin, focus on Python and Bash.

The software (firmware) of routers and switches are written in assembly ? Maybe Huawei's code. Who knows ? The companies that I know of all write their networking OS code in C. And maybe a little in C++. If I had to guess, I would guess that sophisticated router OS's now have tens of millions of lines of code in their source code. If not 100+ million. You really do not want to write that in assembly. That would be unmanageable, believe me.

Here's a company that is building router software in a higher language. I believe they build it all in Python. (Not sure, as it isn't actually mentioned on their website).
https://www.rtbrick.com/md/about.html

The days that people wrote any software in assembly, for whatever reason, those days are long gone. Maybe one or a few small critical functions. Maybe handful of code that needs to interact with specific hardware in a specific way. But in general, you want to avoid assembly code like the plague. Not portable. Not maintainable.
 
Reactions: mxnerd

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
Even if you want to do networking/system admin, you don't have to learn assembly, it's compiler's job to compile higher language into assembly.

One simple high level language line can translate into over 10 lines of assembly code.

But even now high level language usually only compiles to intermediate code, virtual code or API calls, not assembly code.

In early days, operating system like DOS is written in assembly, but DOS OS is probably only 64K. Even Windows 3.1 is written in C, not assembly.

Assembly definitely helps you understand computer's internal architecture, but you don't need to learn it, absolutely not.

Like what Gryz said, the days you have to write any code in assembly is long, long gone.
 
Last edited:

Cogman

Lifer
Sep 19, 2000
10,278
126
106
You should learn assembly if you are a C, C++, or Rust programmer. Primarily because it is always handy to know one abstraction lower than what you work in daily. Otherwise, no way. You'll gain nothing from assembly if your language is VMed.

The prime benefit of learning assembly is to give you a picture of what actually runs on your hardware. However, in most languages you simply don't care about that and you are so far removed from it that you can't even really affect it.

I also believe that any Java/C#/Ruby/Javascript/etc dev will gain a lot from learning C/C++/Rust, even if they never use it. That is because those lower level languages shove memory management in your face and you have to think about the cost of doing things.

On a side track. I think every programmer should learn how to program in a language that doesn't have a familiar paradigm to what they are used to. I think picking up a functional language will make you a better imperative programmer.
 
Reactions: cytg111

exdeath

Lifer
Jan 29, 2004
13,679
10
81
Don't bother with assembly.
Don't even look at it.
It's a complete waste of time.

And these opinions are why today's fresh Java generation programmers know nothing about microprocessor and machine architecture and why it takes 8 GB RAM to play Tic Tac Toe in a web browser.

Understanding assembly, even if not to program with it, but to understand fundamentals that haven't changed AT ALL since the first stored program computer in history, and that all computers and all languages only perform 5 classes of basic operations (arithmetic, logic, load/store, comparisons, and flow control), is valuable. Three if you consider arithmetic, logic, and comparison are all done by the same functional unit.

I'd say a programmer that just cut and pastes gigabytes of API and SDK snippets from a wizard without knowing what he/she is actually doing is more worthless and why a simple wrist watch today can't be made to just tell time unless it's running 4 cores and 16 GB. Contrast, an assembly language master can pick up practically any high level language in hours or days.

Program in assembly as a primary role? Very specialized and limited. But to understand fundamentals that are the basis of every programming language ever invented? Priceless.

One who includes assembly language and machine organization, and by extension, operating system and compiler operation, into their foundation, is one capable is mastering all there is in computer science.
 
Last edited:

Cogman

Lifer
Sep 19, 2000
10,278
126
106
Ok, I'll bite.

First off, lets talk about memory usage and modern languages. Particularly the pros and cons of a GC

GCed language's main goal in most instances are to reduce the time spent allocating and managing memory. The process of getting memory from the OS is an expensive one because the OS is also running its own, effectively, gc algorithm to try and figure out which blocks of memory it can give up. As such, GCed languages will tend towards taking up more memory rather than less. Not generally "gigabytes" like you claim, but certainly hundreds of megabytes isn't unusual if it hasn't been bounded.

They do this because they want to spend less time garbage collecting and more time actually running the application. Garbage collection, counter intuitively, becomes more efficient when dealing with larger amounts of garbage.

Certainly Java isn't the language for watches and microwaves, they don't have the hardware or memory that would make a GCed language a good choice, but when you talk about running on servers with hundreds of gigs of ram, Why not? Even with consumer desktops and laptops it is becoming more and more common to see large amounts (8->16gb) of memory available for relatively cheap.

The same rules apply to javascript and its GC. While it has different targets that it is looking at (low pause time rather than high throughput). The game is the same. Larger heaps = less time GCing and more time doing useful work for the user. It also doesn't help that browsers are getting more and more content per page pushed onto them. That content needs to live somewhere.

Now, if we want to talk performance. GCed languages have an interesting property. (Depending on the GC algorithm, but true for most) they can allocate heap memory WAY faster than non GCed languages can. Even with things like JEMalloc. They can do this because memory allocation in most GCs is literally just adding a number to an integer and checking if it overflows the region they are allocating. Very little time. So while they consume more memory, they make applications which churn through loads of memory much quicker. In a non-gced language you end up having to do your own form of GC if you want to get some of the same benefits.

Next up, lets talk about what assembly actually teaches you.

Well it teaches you how the computer architecture works? right? Nope! Not at all. In fact, on modern CPUs the instruction set is an abstract over what actually happens in the processor. All of the assembly instructions are themselves transformed into micro-opts which you can't control or affect.

It teaches you how the compiler works? No! Not at all. No compiler is written in assembly and most of the work that compilers do happens WAY before they get to the point of turning code into assembly. In fact, assembly is so bad for a compiler that they avoid even thinking about the output assembly until the very final stage of compilation. Both the GCC and LLVM (and I believe MSVC) have an intermediate byte code which looks nothing like any computer's instruction set (well real, the Mill architecture comes close to it). The most you can say learning assembly will teach you is how to read the end result of a compiler. But even then, the optimizations that compilers do often make assembly much harder to read (even though it is often much faster than what you could hand write).

It makes you capable of understanding all of computer science? Again, no. Assembly makes you capable of understanding assembly. However, many concepts of computer science transcend what you can glean from assembly. Types? Not in assembly. Inheritance? nope. Generics? nadda. Datastructures? A big zilch. Higher kinded types? Nope. You can do and make some of these things in assembly, but learning assembly will not make these concepts easier. In fact, it will mostly only hinder the understanding of them by getting in the way. Mastery of assembly makes you capable of mastering assembly.

Assembly makes it possible to pick up higher level languages? Only if that language is C. How would assembly help you understand Haskell or Lisp, for example. The same argument has been made about C and I think it is simply false. Knowing a lower level language doesn't make it easier to pick up a higher level language. If anything, I would say the opposite is more true. Higher level languages often include all of the concepts of lower level languages and most of the advanced techniques in lower level languages are approximations of what is available in the higher level languages. (the exception here is that higher level languages often have automatic memory management and they lack the concept of pointers. Those are two things you need to learn when you go down to lower level languages).

At the end of the day, the use case for assembly is getting access to instructions on your architecture that aren't exposed to the language you're working in. Beyond that, there just isn't much benefit to knowing assembly over C. Particularly because as you go up into higher level languages it becomes impossible to actually know what is going on. JITs can do impressive things and so being able to reason about what is actually happening is nearly impossible.

I will say that understanding computer architecture, OS, and JIT design is important. Because people often make bad assumptions about what is fast and what is slow when they base it solely on what they learn in CS classes. However, learning assembly won't help you because it is often surprising to find out which instructions are actually costly and which ones are cheap.
 

Gryz

Golden Member
Aug 28, 2010
1,551
204
106
And these opinions are why today's fresh Java generation programmers know nothing about microprocessor and machine architecture and why it takes 8 GB RAM to play Tic Tac Toe in a web browser.
I agree with you about the problem.
But I don't think learning assembly programming is the solution.

Abstraction is the tool with which we can make improvement in programming. All the "new guys" learn about programming at high abstraction levels. Which is mostly good. But one should also know a bit about the lower levels. And imho that means you should know about 2 things: 1) what do the data structures look like in memory, and 2) what are the algorithms used to implement some of the library calls you use.

Because if you don't understand those 2 issues, you will not be able to use your memory nor your cpu resources in an efficient way.

I'm sure we agree here.

However, I don't see where assembly comes in here. Assembly is a crude way to denote algorithms and data-structures. Very crude. You'll be spending so much of your time on syntax and writing down little instructions, that you still won't spend much time learning about the memory and cpu resources you use. If you want to teach people about that, you'd better use a slightly more advanced language. Like for instance C. When you write C, you'll know your data structures for sure. And you'll probably will know your algorithms too (because you have to write a lot of the code yourself). Maybe there are more languages like C that have that benefit (I can't think of any this quickly).

Same thing about Operating Systems. It is absolutely not required to know any assembly language to understand Operating Systems.

If you think people should understand the basics so they can work efficiently at higher abstraction layers, then where do you draw the line where the basics are ? Assembly language ? Binary object code ? Firmware ? Electrical circuits ? Transistors ?
 
Reactions: mxnerd

Red Squirrel

No Lifer
May 24, 2003
67,904
12,374
126
www.anyf.ca
I would do it if you really want to learn what's happening under the hood, it's something I always kind of wanted to do myself and never did. I've played with it but not enough to really know what I'm doing. As far as for actual usefulness, probably not really worth learning.

Even for embedded (micro controllers etc) a lot of it is C now. Some can do C++ too. Atmega is the only ones I've worked on and used a mix of C and C++ (well I cheat and use the Arduino libraries as it's hard to find tutorials for raw coding them), though I tend not to go too heavy on the OOP and use lot of globals, you kinda have to as you're trying to conserve as much ram as possible. Every kb counts.
 

otinane

Member
Oct 13, 2016
68
13
36
It seems that for me at least, as a newcomer in the programming languages, that learning assembly will be useful only if your job requires it (drivers etc), as others mentioned already, or to see how things work a level lower, and that probably for your own comprehension.

I decided to start with Python (was writing stuff in bash for an hour), then move to C and after C++. I found a nice book called x86 Assembly Language and C Fundamentals, it's not hardcore, and probably i' m going to study it, as i wrote earlier only for me, to get the bigger picture.

ps. At the introduction section of the book, it has an example of writing code in C, and at certain points integrating assembly using the _asm function. Is that for some kind of refinement or to control things that can't be controlled with typical C?
 

nevbie

Member
Jan 10, 2004
150
5
76
In short, only learn asm if you need to use it, as it differs between processors. If you like how it sounds, but have no use for it, learn C instead. asm is not hard and works pretty much like you'd expect.
 
Reactions: Ken g6
Mar 10, 2006
11,715
2,012
126
As title says, should one first study assembly and then move to other languages (C, Python, Java) or the other way around is more efficient?

And if yes, how hard could it be?

No, learn with a high level language first so that you learn how to program first. Once you know how to actually program, then you should go and learn different, lower level languages.

But your focus really should be learning how to put together programs, devise algorithms to solve problems, etc.

It's much better to learn something like Python or Java first and be able to make real programs than to learn x86 asm but not be able to build anything useful with it.

I started with C++, but I would recommend starting with Java or C#.
 

KWiklund

Member
Oct 30, 2013
35
0
16
It depends on what you want to learn and what you want to do. If you want to learn about how computers *really* work at a fundamental level, then learning assembly language is absolutely crucial. A lot of really interesting things happen at this level, at least if you're at all interested in computer architecture. Old classes I took on low-level computing included 8051 and Z80 assembler. I don't think it's a great way to start for a beginner though. Higher-level languages do a better job of teaching the concepts that matter in programming (including assembly).

In terms of work, yes, assembly is still used by some of us. Most of my work is embedded / DSP, so I've worked at this level with a number of chips (some of which have no C compiler). I expect that people working on compilers, writing drivers, operating systems, etc. will also need to know assembly at some level of proficiency.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |