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

**URL:** <https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052>\
**Category:** Backend Chat/Discussions\
**Tags:** assembly\
**Created:** [15 February 2021 19:22 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052 "2021-02-15T19:22:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jsdr3398](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@Jsdr3398](https://forum.devtalk.com/u/Jsdr3398)\
**Post date:** [15 February 2021 19:22 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/1 "2021-02-15T19:22:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ohm](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ohm/32/559_2.png) [@ohm](https://forum.devtalk.com/u/ohm)\
**Post date:** [15 February 2021 20:08 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/3 "2021-02-15T20:08:13Z")

</div>

> [@Jsdr3398](#):
>
> Wouldn’t servers be much faster if they were made in Assembly?

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

The following examples are borrowed from [https://courses.cs.washington.edu/courses/cse378/03wi/lectures/mips-asm-examples.html:](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

```auto
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.

```auto
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.

---

<div class="post-metadata">

**Author:** ![Jsdr3398](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@Jsdr3398](https://forum.devtalk.com/u/Jsdr3398)\
**Post date:** [15 February 2021 20:16 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/4 "2021-02-15T20:16:54Z")

</div>

Ah, true 😅

Man, now I kinda feel bad for people who made games for the NES 🤣

---

<div class="post-metadata">

**Author:** ![ohm](https://forum.devtalk.com/user_avatar/forum.devtalk.com/ohm/32/559_2.png) [@ohm](https://forum.devtalk.com/u/ohm)\
**Post date:** [15 February 2021 20:29 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/5 "2021-02-15T20:29:32Z")

</div>

Chris Sawyer wrote 99% of the original RollerCoaster Tycoon in x86 assembly. [RollerCoaster Tycoon (video game) - Wikipedia](https://en.wikipedia.org/wiki/RollerCoaster_Tycoon_(video_game)#Development) 🤪

---

<div class="post-metadata">

**Author:** ![mindriot](https://forum.devtalk.com/user_avatar/forum.devtalk.com/mindriot/32/6660_2.png) [@mindriot](https://forum.devtalk.com/u/mindriot)\
**Post date:** [16 February 2021 09:02 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/6 "2021-02-16T09:02:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![iPaul](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/i/7feea3/32.png) [@iPaul](https://forum.devtalk.com/u/iPaul)\
**Post date:** [19 February 2021 15:18 UTC](https://forum.devtalk.com/t/why-do-companies-not-use-assembly-for-their-web-server/7052/7 "2021-02-19T15:18:23Z")

</div>

There is little to gain by implementing an entire web server in Assembly. A more pragmatic approach is to implement it in a high level language like C++ or Rust, measure the performance and only then, eventually, convert the “slower” parts to Assembly.
