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.

Popular Backend topics Top

PragmaticBookshelf
Don’t accept the compromise between fast and beautiful: you can have it all. Phoenix creator Chris McCord, Elixir creator José Valim, and...
New
PragmaticBookshelf
You want increased customer satisfaction, faster development cycles, and less wasted work. Domain-driven design (DDD) and functional prog...
New
PragmaticBookshelf
Write Elixir tests that you can be proud of. Dive into Elixir’s test philosophy and gain mastery over the terminology and concepts that u...
New
AstonJ
Another BEAM language… The Hamler Programming Language Hamler is a strongly-typed language with compile-time typechecking and built-in...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
ManningBooks
Deep Learning with Python, Second Edition is a comprehensive introduction to the field of deep learning using Python and the powerful Ker...
New
PragmaticBookshelf
SQL Antipatterns is a short-cut to wisdom, showing you how to avoid "easy" solutions that don't work, and be a better database developer ...
New
ManningBooks
Dodge the common mistakes that even senior developers make, take full advantage of static analysis tools, and deliver robust and error-fr...
New
First poster: bot
Node.js v18.16.0 has been released. Link: Release 2023-04-12, Version 18.16.0 'Hydrogen' (LTS), @danielleadams · nodejs/node · GitHub
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
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
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New