Jsdr3398

Jsdr3398

Why do companies not use Assembly for their (web) server?

I just thought of this. Are there any disadvantages when making your server in Assembly (other than having to learn a bunch of stuff :rofl:)? Wouldn’t servers be much faster if they were made in Assembly? :thinking:

Most Liked

ohm

ohm

Chris Sawyer wrote 99% of the original RollerCoaster Tycoon in x86 assembly. RollerCoaster Tycoon (video game) - Wikipedia :crazy_face:

ohm

ohm

Maybe. But the cost is abstraction. Assembly is as close to bare metal you can get, without going into complete binary mode. :laughing:

The following examples are borrowed from https://courses.cs.washington.edu/courses/cse378/03wi/lectures/mips-asm-examples.html:

A simple program

i = N*N + 3*N

could in assembly be written as

lw     $t0, 4($gp)       # fetch N
mult   $t0, $t0, $t0     # N*N
lw     $t1, 4($gp)       # fetch N
ori    $t2, $zero, 3     # 3
mult   $t1, $t1, $t2     # 3*N
add    $t2, $t0, $t1     # N*N + 3*N
sw     $t2, 0($gp)       # i = ...

However, this isn’t an optimized solution.

lw     $t0, 4($gp)       # fetch N
add    $t1, $t0, $zero   # copy N to $t1
addi   $t1, $t1, 3       # N+3
mult   $t1, $t1, $t0     # N*(N+3)
sw     $t1, 0($gp)       # i = ...

See how complicated it gets real fast? Right here, we are only adding and multiplying numbers, nothing fancy at all. Your compiler would catch such an easy optimization, but you might have spend an hour to figure it out. That is what’s meant by abstraction. You sacrifice a bit of speed (sometimes it’s even negligible) in order to not have to write at such a low level.

mindriot

mindriot

Many web/network applications performance is dominated by IO concerns rather than raw number crunching. There are some unique cases where you can benefit from such optimisation, however they are usually quite rare and quite small in comparison to focusing on other areas like DB query optimisation, caching etc. Dropping down to assembly is a lot of pain and very expensive in terms of development/ maintenance for what is likely to be a tiny percentage of the possible benefits. At the very least it is worth testing and benchmarking to find out what is actually slow in your application design before working on optimising.

Where Next?

Popular Backend topics Top

AstonJ
Thought this video was interesting: What are your thoughts? Any areas you agree/disagree? Which web-dev tech do you think is worth ado...
New
New
First poster: bot
This Python script mimics Babbage’s Difference Engine. In Use this Python script to simulate Babbage’s Difference Engine, Python offered...
New
New
mafinar
I’ll be participating. This would be very interesting because I have been having coders block + a lot of distraction this weekend. But l...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
jaeyson
Hi all!, anybody tried this Elixir quiz from @Tetiana? She’s the one who made Elixircards.
New
jss
If you like video courses, maybe you should try this: https://clojureforpros.com/
New
apoorv-2204
Hi everyone, I’m considering pursuing the Elixir/Erlang certification exam offered by Erlang Solutions and wanted to check in with the c...
New
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1143 25883 760
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New