Author |
Message |
nintendo64 Seasoned Helper

Age:40 Gender: Joined: Dec 01 2002 Posts: 104 Location: Dominican Republic Offline
|
Posted: Fri May 07, 2004 12:48 am Post maybe stupid Post subject: Why Learning Assembly Language is Still a Good Idea? |
 |
|
|
|
Good read for programmers,
http://www.onlamp.com/pub/a/onlamp/2004/05/06/writegreatcode.html
I see your point, Mr Ekted, i do beleive the internals should be the main focus, even thought the author of this article shows learning assembly is a good way for gaining this knowledge. I admit, he was advertising assembly , he went a little overboard.
-nintendo64
Last edited by nintendo64 on Fri May 07, 2004 3:16 am, edited 1 time in total |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri May 07, 2004 1:39 am Post maybe stupid Post subject: |
 |
|
|
|
Nice. And agreed. L1K
It's not even the point to learn ASM per se, just to understand the kinds of things that happen on the inside. Most programs treat the computer like a black box, and they end up writing slow bloated crap like ICQ, Internet Explorer, WinAmp, Windows Media Player, etc. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Qndre Server Help Squatter

Gender: Joined: Jan 25 2004 Posts: 295 Offline
|
Posted: Fri May 07, 2004 8:57 am Post maybe stupid Post subject: |
 |
|
|
|
You can write everything in ASM, you can also write in other languages. (Because every high-language becomes ASM after compilation!) But in ASM you can do more. And it's very useful for reverse-engineering. But it's hard to learn. |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Fri May 07, 2004 9:26 am Post maybe stupid Post subject: |
 |
|
|
|
Qndre wrote: | But it's hard to learn. |
Its easy to learn, as there are only so many different instructions. Its just difficult to master, because there nothing watching over you saying "oops, there is an error." |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri May 07, 2004 10:26 am Post maybe stupid Post subject: |
 |
|
|
|
Read the article before you comment, Qndre.
I think telling all modern-day programmers to learn ASM is a little over-the-top, since many would not do it. I think the simplest way to improve code is just to know smaller code is smaller compiled code (usually), and also take into consideration what external methods they are using to accomplish their goals. If everyone wrote windows apps with the Windows API instead of the bloated MFC, programs would shave off huge chunks of their run-time bulk. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
NightHawk Newbie
Joined: Dec 09 2003 Posts: 20 Location: Sabotage'd Offline
|
Posted: Fri May 07, 2004 1:47 pm Post maybe stupid Post subject: |
 |
|
|
|
I'm getting my Comp Sci degree at a University, and had to take an assembly course in my second year. I thought that this would be standard material at other institution.. am I wrong? |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Fri May 07, 2004 3:46 pm Post maybe stupid Post subject: |
 |
|
|
|
I had a look at some U's and only one said the asm was an optional module that was taken in the electronics department. My main impression was that they were focusing on AI/neural networks and consultancy ('we don't live in India so we don't have to code' was the message I got). |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri May 07, 2004 4:08 pm Post maybe stupid Post subject: |
 |
|
|
|
I am not saying that people should write their apps in ASM. I am saying that by learning ASM it helps you understand HOW to design and write better code in whatever language you choose -- orders of magnitude better. |
|
Back to top |
|
 |
nintendo64 Seasoned Helper

Age:40 Gender: Joined: Dec 01 2002 Posts: 104 Location: Dominican Republic Offline
|
Posted: Fri May 07, 2004 4:45 pm Post maybe stupid Post subject: |
 |
|
|
|
For the people that are saying, "not everything should be written in assembly", they are right, but that's not what the article is saying, why don't go read it? The Article is talking about that many programmers don't know how the internals works, hence the bloatware applications.
Assembly is a just a good way to learn how the computer treats your variables (on the stack or on the heap), etc.. the internals.
Main point of the Article
Quote: | The only problem with the demise of assembly language is that as its popularity waned, so did the percentage of programmers who understood the low-level ramifications of the code they were writing. Those programmers who were claiming that assembly language was dead already knew how to think in assembly language and how to apply that low-level thinking to their high-level code; in effect, enjoying the benefits of assembly language while writing high-level language code. However, as new programmers worked their way into the system, without the benefits of having written several applications in assembly, the efficiency of software applications began to decline. |
-nintendo64
Last edited by nintendo64 on Fri May 07, 2004 4:49 pm, edited 1 time in total |
|
Back to top |
|
 |
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Fri May 07, 2004 4:49 pm Post maybe stupid Post subject: |
 |
|
|
|
the difference here is between a designer and a computer scientist. This is not to say that great coders can't benefit, they certainly will. However, many of the low-level protocols and high-efficiency environments are merely implemented by coders, while the actual theory behind them is implemented by true nuts and bolts computer scientists.
try to look at it this way, in a game like Quake or Unreal, the engine itself is hot-wired for speed speed speed. I would venture to say that many of algorithms in either engine bank on ASM code or snippets for fast and efficient access to system resources. I haven't seen said code, of course, but it seems only logical given the tremendous performance achieved.
Even less impressive apps benefit from assembly procedures, especially in processing large data structures ie image editing, sound, and scientific data processing.
in approaching assembly, i never set out to actively code in assembly, as that is a step into an expertise which i share no stake in. I did, however, take the time to learn how a program is written in ASM and try to comprehend the small ASM parts that make up the implementation of higher-level processes (ie other language constructs). in other words, mentally comprehending, step by step, the transfer from C to ASM in terms of what the programmer indicated and what was accomplished.
i suppose an auto mechanic analogy would be good in this case. A good mechanic can fix a belt or true an axle or fix even trivial engine problems, yet they can do nothing immediate about malfunctions in the high precision machined parts within the engine. the good ones know what goes on inside and how to prevent wear, tear, and get the highest performance, but they don't necessarily carry qualifications for developing such parts.
becoming familiar with assembly language shares a common purpose. you will understand better how to transfer ideas from your mental process into computer instructions, even if that process does not take place in ASM, but in another language...
java programmers needn't bother _________________ Signatures just seem so quaint. |
|
Back to top |
|
 |
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Fri May 07, 2004 4:52 pm Post maybe stupid Post subject: |
 |
|
|
|
Mr Ekted wrote: | I am not saying that people should write their apps in ASM. I am saying that by learning ASM it helps you understand HOW to design and write better code in whatever language you choose -- orders of magnitude better. |
(my preceding post): no shit |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri May 07, 2004 4:57 pm Post maybe stupid Post subject: |
 |
|
|
|
I was replying to Qndre mostly. I should have quoted him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri May 07, 2004 7:15 pm Post maybe stupid Post subject: |
 |
|
|
|
int i;
char buffer[256];
// code that sets buffer here
for (i = 0; i < strlen(buffer); i++)
if (buffer[i] == ' ')
buffer[i] = '_'; |
What's wrong with this?
1. strlen() is called every loop. This will easily make this loop 10x slower, maybe more.
2. Indexing is expensive, even for char arrays. If you are sequentially walking an array, use a pointer.
char *p;
char ch;
char buffer[256];
// code that sets buffer here
p = buffer;
while (ch = *p)
{
if (ch == ' ')
*p = '_';
p++;
}
|
This is a tiny example. You can't fix most poorly written apps by tweaking 10 lines of code at a time. They have inefficiencies in design (functional, data structures, etc). |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Fri May 07, 2004 8:29 pm Post maybe stupid Post subject: |
 |
|
|
|
Mr Ekted wrote: | strlen() is called every loop |
Actually, Microsoft's optimizing compiler fixes this problem for people, as it does for the simple indexing code you wrote. But that doesn't excuse people from writing sloppy in the first place. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri May 07, 2004 8:59 pm Post maybe stupid Post subject: |
 |
|
|
|
Only because strlen() can be an "intrinsic" function. If it was an arbitrary function, the compiler cannot make the assumption that it only needs to call it once. Agreed otherwise. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat May 08, 2004 12:07 pm Post maybe stupid Post subject: |
 |
|
|
|
char *p;
char ch;
char buffer[256];
// code that sets buffer here
p = buffer;
while (ch = *p)
{
if (ch == ' ')
*p = '_';
p++;
} |
Can't you just do
while (*p)
{
if (*p == ' ')
*p = '_';
} |
Maybe I'm just overlooking something obvious. |
|
Back to top |
|
 |
SuSE Me measures good

Joined: Dec 02 2002 Posts: 2307 Offline
|
Posted: Sat May 08, 2004 12:28 pm Post maybe stupid Post subject: |
 |
|
|
|
<measures dick> |
|
Back to top |
|
 |
Dustpuppy Server Help Squatter

Age:40 Gender: Joined: Jan 23 2003 Posts: 215 Location: England Offline
|
|
Back to top |
|
 |
-Smong- Guest
Offline
|
Posted: Sat May 08, 2004 2:17 pm Post maybe stupid Post subject: |
 |
|
|
|
I think char ch will probably be a register so the if() is faster. Although it's not the sort of think I would think up myself. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
|
Back to top |
|
 |
Grav(FU OL) Guest
Offline
|
Posted: Sun May 09, 2004 11:05 am Post maybe stupid Post subject: |
 |
|
|
|
I totaly agree, understanding the very basic principals is the most important thing.
Take math for example, sin, cosin, tangent, log, etc., today's kids - they just push buttons, they rarely understand what exactly is going on there.
Tell them to do manual calculations for a square root of 1, they won't know how to, they'll ask for a computer.
I always argued against the education system in that fashion, being able to know how to operate a hand held computer is all nice and dandy and sure, it makes calculations easier and faster, but it also dulls the brain, you need to know for yourself and understand what exactly is happening there.
Take McGuyver for an example, sure most of the time it was a bit over the top and more lcuky than one should and would be, but still, it pushed a strong message of relaying upon intelligence, knowledge, understanding, brain power instead of brawn power.
P.S.
Efficient Coding: http://www.theprodukkt.com/
P.P.S:
DIE SCUM! |
|
Back to top |
|
 |
Grav(FU OL) Guest
Offline
|
Posted: Sun May 09, 2004 11:08 am Post maybe stupid Post subject: |
 |
|
|
|
Also for example, there was back then BATTLETECH 3025.
The entire MMOFPS ran on 36MBs total!!!
I have no idea how they compressed shit so tight and so forth, but boy, they did it. |
|
Back to top |
|
 |
Grav(FU OL) Guest
Offline
|
Posted: Sun May 09, 2004 11:09 am Post maybe stupid Post subject: |
 |
|
|
|
In addition: assembly rox |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun May 09, 2004 11:43 am Post maybe stupid Post subject: |
 |
|
|
|
Ekted wrote: | you are dereferencing p twice (testing *p). Granted the optimizer should handle it, but who knows. |
I think I'll just go with Akai... |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun May 09, 2004 11:49 am Post maybe stupid Post subject: |
 |
|
|
|
SuSE wrote: | <measures dick> |
... in pixels. |
|
Back to top |
|
 |
|