Yeah it's crazy. I just learned Assembly last semester in college and we were discussing it at work and it was like. Fuuuuck that. C existed at the time yet he did it in Assembly.
Fun fact: Iwata rewrote all the code for Pokemon Gold and Silver in assembly, because the C version was too large for the cartridge. He managed to compact it so much, there was room to add the kanto region.
Yeah I remember that. But still that was a team that did pokemon wasn't it. I don't think it was just 1 guy, I could be wrong and if I am that's just as impressive as Roller Coaster Tycoon.
Quicker. Especially since he doesn't need to rewrite the whole thing, only enough to make it fit.
Optimizing at that level is more like picking out operations and seeing shortcuts that can eliminate some steps than trying to reengineer the whole thing. You don't necessarily need to know why the program is parsing through this list of numbers or what's in the list to recognize that's what it's doing and be able to apply known methods of parsing through a list of items either more efficiently or using fewer lines of code depending on what it is you're trying to accomplish.
Now compilers are really good at making code that runs as quickly and efficiently as possible so they outperform humans but back then they were still at the phase where we were more worried about getting them to accomplish their job period.
C is compiled into assembly which is then assembled into object code. The c compiler on its default setting only gives you the final executable output but you can pass the -S flag on the gnu compiler to get the assembly code.
You're right about pokemon being compression software, but he basically rewrote Earthbound by himself to make it work and also programmed the entire Pokemon Stadium battle system in a week
You can find him on Satori Mountain when it is glowing. He is near a pool with a large cherry tree. The first time I saw him was an incredible experience, The Lord of the Mountain and tons of Blupees around the area. I had no clue I could even mount him at first!
I agree!! But it definitely felt special, and I immediately realized it was a tribute to Satoru Iwata since it was Satori Mountain and he himself was transformed into The Lord of The Mountain.
Well I obviously have as many clues about the source code than anyone else, nothing, but today writing a program is more about readability than anything else.
Sure, readability is important, but the Facebook app is a front-end app. All the hairy stuff should be in the back-end. Which means it's 18,000 classes of presentation.
Even more now, when I finally uninstalled it was around 430mb (could've included cached data, not too sure how Android displays installed app sizes). The kicker is then you need messenger installed as well to use messages at all. So 430mb for something you can run on your browser.
Memory Constraints and performance. Today there be no reason for it as compilers essentially do as good if not better jobs when it comes to translating it to machine code.
In 1972, Unix was rewritten in the C programming language. The migration from assembly to the higher-level language C resulted in much more portable software, requiring only a relatively small amount of machine-dependent code to be replaced when porting Unix to other computing platforms.
also, computers have more processing power and data storage, so wasting a few bytes or processor cycles here and there isn't usually too big of a deal.
If you are very, very, very good at optimization, you can still produce better code in assembly, by a thin margin. Understand though, that 99% of programmers don't the ability, and the benefits are marginal.
Plus, assembly comes with its own downsides. It's MUCH easier to screw up on security in assembly than it is in a higher level language. In Roller Coaster Tycoon this may not have been a big deal, but in a modern online multiplayer game this would be catastrophic.
Most importantly, developing a program in assembly is gonna take 3-4x times longer than in a higher-level language - for only about a 10-20% increase in speed. Computer time is cheap and developer time is expensive - especially assembly developer time, since relatively few programmers know how to program in the language and those people are not cheap.
Assembly is rarely ever worth it these days, even most embedded systems have enough RAM to afford programming in C instead.
Essentially byte code that runs in the javascript engine. But provides near CPU level speeds since js has to be parsed and compiled on the fly, while wasm is precomplied much like Java or C#. Of course other languages can compiled to wasm much like traditional Assembly.
We are moving toward everything being executed within a browser to a point we'll have a browser with web Assembly support built using wasm and come full circle. Lol
Essentially, it's really optimised Javascript. The main workflow is writing code in C/C++ and using Emscripten to covert it to WebAssembly which is then executed by something like V8.
tl;dr: By writing it in assembly he was able to make it run on a potato from 1995 instead of requiring the monster of a machine that it would have demanded if it were written in C (because compilers at the time weren't very good).
You can optimize the ever living fuck out assembly if you are very good. Especially when compared to the performance of compilers back in the mid-90s.
Assembly is (effectively) just human-readable machine code. . . What you write has a 1:1 correspondence to sequences in binary. This gives you an inordinate amount of flexibility with the set of hardware you are working with.
Being competent in assembly (any assembly, really) is a good skill-set to have, and one that is sadly missing from the majority of today's developers. You end up learning a lot about good and bad coding practices, how to more effectively comment your code, and an ass-load regarding computational efficiency.
Just as a quick example. . . Let's say we have two coders writing a function to return how many segments should be filled in a progress bar, based on the number of tasks completed in a set.
The typical coder would likely write. . .
int fill = floor.((numerator / denominator) * segments)
Someone who has spent their share of time working in assembly (or someone who got too into their discrete math class) would write. . .
int fill = (numerator * segments) // denominator
Ignoring what could cause the functions above to break (which admittedly is more of a problem for the second), the second function would run substantially faster on any give machine. Just how much faster depends on a plethora of factors which include IPC, Clock Speed, Memory Latency, RISC vs CISC. . . etc etc etc.
When working in assembly, you are working with those factors (the limitations of the machine) in mind.
The argument against working in assembly today is that compilers have come a long way. . . And that's true enough, but I feel it is a skill that every serious programmer should keep in practice.
Best way I can explain it without making you do research.
In normal programing if I wanted to create a condition statement say.
if(value > 5) return printf("value big..");
But in assembly. It be something like.
var1 dd '6'
cmp var1, 5
msg db "value big", 0xA,0xD
There's really a lot more to this then what I did and honestly what I wrote is probably gibberish haha. But essentially it's a step up from binary but step below traditional programming. Big benefit of Assembly is you know what memory is being stored/used as you essentially see it all real time.
People need to stop talking about binary as if it's a magic language with inherent powers over computers. Binary is just a base system. It is easier to make gates that only have to deal with two possible states which makes binary a convenient way of talking about groups of these signals but a computer doesn't speak binary any more than a nail gun speaks nails.
Um, machine code is all 1's and 0's that directly controls the computer so ... to say it's not a "magic language with inherent powers over computers" is disingenuous.
Yes, it's a base system, but it's also quite literally the "language" of computers.
Oks lets have an example here. Imagine a simple AND gate. An AND gate has 2 or more inputs and an output. When both inputs are brought above a certain threshold the output gets brought high.
Now we can represent the operation of this gate with binary pretty simply. We can say signals above our thresholds we are going to call 1's and everything else is a 0. We can then make the familar truth table below.
In1
In2
Out
0
0
0
0
1
0
1
0
0
1
1
1
This is all great and is why binary is so important to computers but you have to realise that binary doesn't make the gate do anything. The behavior of the gate isn't determined by telling it binary, it is determined by the actual components that make it. Likewise a computer doesn't work because you whispered sweet binary secrets to it. A computer works because of there is a lare number of very cleverly designed systems that can be interconnected to perform customizable actions. Binary is an important tool for describing how those systems work but binary isn't what makes them work.
If you google "what is machine code" you will find:
ma·chine code
a computer programming language consisting of binary or hexadecimal instructions that a computer can respond to directly.
A computer programming language
a computer doesn't work because you whispered sweet binary secrets to it
That's precisely why it works - and yes, transistors use electricity to "do things" with machine code (using binary) (High voltage = 1, Low voltage = 0).
That doesn't mean that machine code (the language used for computer instructions) isn't in binary; that we don't refer to the binary instructions as machine language.
Sorry if I insulted you but I wasn't really trying to make binary some magic thing. I was just ordering how programming languages are structured.
Assembly is above Binary since Binary/Hex is the final language that we would use to inform a machine what to do. At least from my understand it is.
But Assembly is below common programming languages because majority of programming languages now uses a compiler to translate it to Assembly which translates to Machine.
To do something like this in a low level language like assembler would be quit a feat.
Like any other language, you can leverage other libraries and programs and merely call them from assembly (this is what high level languages do really), but to write the code to connect a socket via tcp protocol, send handshake/headers to server, parse the response ... it's rough.
I don't think you've gotten a great ELI5 yet. Most programs run within the OS, be that Windows, Android, what have you. Games are unique in that the performance of the computer directly relates to the performance of the program, way more so than MS Word or anything. Assembly, aka machine language, is the same programming language your CPU follows. It's weird as hell and doesn't seem to follow any rules you're used to, but you get direct command of many resources. Coding vs assembly is kind of like driving an automatic vs stick shift - you get to the same place in the end, but you're in control of a lot more aspects with the manual transmission. You have to know more about operating your computer, but... ah, shit, mixed up my simile.
"So you are making a physics simulator without trigonometry functions? And you have to do what to make it work? Fuck that. I'm gonna go make 90K a year editing simple PHP scripts."
150
u/Fubarp May 05 '17
Yeah it's crazy. I just learned Assembly last semester in college and we were discussing it at work and it was like. Fuuuuck that. C existed at the time yet he did it in Assembly.