
Forum engine written entirely in Assembly - alexeyr
http://asm32.info/fossil/repo/asmbb/index
======
todd8
For those that want to get started in assembly language programming, here's a
suggestion. Write a simple skeleton in un-optimized C first. Next take a look
at the generated code and replace or fill in the missing parts with assembly
language.

When programming in assembly language, one starts with a blank slate. Every
abstraction you want to construct, say a data structure or even a function
call, you build from scratch. By starting with C you eliminate many dead-ends
and false starts.

By adopting C's conventions for stack allocation of local variables and how
parameters are pushed on the stack and how return values are passed back to
callers, you get yourself situated on firm ground rather than floundering
around trying to reinvent basic linkage of caller to called functions.

~~~
jwdunne
When learning MIPS, the lessons I followed recommended something similar to
this. We didn't look at the compiled assembly but used C as a form of
pseudocode for assembly. It was a valuable experience - especially the
illumination on how close to the machine C is whilst looking much higher level
to me before that.

I tested to see if writing the code first in Scheme or CL offered the same
benefits. It did not - it was far easier to translate solutions from C to
assembly. My only guess is that a lot of work in C is similar to what I had to
do in assembly, where in Scheme there isn't such things. So C only took away
handling the stack for procedures and what not, where as scheme took away that
and the rest of what I would need to do in assembly. Long story short, the
solution in C was closer to assembly than the solution in scheme.

------
combatentropy

      > This is an engine for web based message board (forum)
      > implemented entirely in assembly language,
      > using FastCGI interface and SQLite database as a storage.
    

Whatever acceleration is gained by writing the middleware in assembly seems
like it would be lost by relying on a database written in C, even SQLite.

~~~
banachtarski
To be fair, if I were to write an assembly project in this day and age, it
would be to keep my chops up, not for performance (usually). Optimizers are
pretty good at writing assembly these days.

~~~
combatentropy
Fair enough.

------
chendies
This is very impressive. I wonder what the server costs to run a website like
Reddit would be if they hadn't used Python and instead used assembly, C or
C++.

The benchmarks game [1] suggests that C++ can have a speedup of 10x to 100x
for many toy benchmark programs and use far less memory. A highly optimized
assembly version could add another factor.

While code closer to the metal would require higher investments in coding, it
would be drastically easier to scale. And in the long run, server costs will
dominate, so it would be beneficial to reduce those.

Who knows if Reddit would be cash positive if their codebase were written in a
different language?

[1]:
[http://benchmarksgame.alioth.debian.org/u64q/cpp.html](http://benchmarksgame.alioth.debian.org/u64q/cpp.html)

~~~
gtirloni
They probably wouldn't be able to find enough assembly developers on any
consistent basis (i.e. major risk)

------
raptaml
Dude, this demo site is so blazingly fast...i have never seen a site rendering
like that before.

~~~
jeff_petersen
It is very fast, but how much of that is due to it being written in assembly?
Isn't the real bottleneck for an application like this going to be network
speed?

~~~
johnfound
Hard to say, but some details about the hosting may help to estimate. The site
is hosted on the cheapest possible shared hosting for 2.5€ per month: 15GB
space, 150GB monthly transfer, CPU usage 30 minutes per 24 hours, 1GB RAM, max
60 processes.

------
aab0
So... anyone tried fuzzing it yet?

~~~
lightlyused
I was wondering that also. Looking at the source, it looks decently written.

