A forum engine written in Assembly

175 points by utf_8x 1 year ago | 127 comments
  • sctb 1 year ago
    The flat assembler (which assembles this project) is worth checking out if you haven't already: https://flatassembler.net. I first played around with it almost 20 years ago and it was noticeably more ergonomic and productive than masm, nasm, to say nothing of gas. I imagine it was designed for human programmers rather than primarily compiler front ends, so it's a popular choice for hand-written assembly projects.
    • anta40 1 year ago
      Unfortunately FASM is written in 32bit assembly, which means it won't run on recent macOS versions.

      Not an issue for NASM, since it's written in C.

      • msla 1 year ago
        I'm not seeing a lot of difference between flat assembler code and NASM code.

        What in specific makes flat assembler better than NASM?

        • deaddodo 1 year ago
          I wouldn't personally say it's better, so I can't speak for OP; but generally people that use FASM prefer it for two reasons: 1) it's self-compilable (vs NASM, which is C) and 2) they like its macro system.
      • flumpcakes 1 year ago
        This is amazingly fast to my eyes.

        I am endlessly annoyed by slow interfaces. At $DAYJOB I have to use a web and desktop GUI for managing CheckPoint firewalls. These often will freeze for dozens of seconds, and generally make my computer crawl. I feel that this should not be acceptable in 2023.

        • briHass 1 year ago
          This is one of the reasons I really like the Mikrotik network gear, because of the Winbox application for management. It's Windows Forms (GDI) in the MDI style of most Windows apps of circa 2000. Lightning fast, responsive, and with nice touches like being able to drag files on/off the interface to upload/download and the ability to copy/paste entries like they were lines in a text file.

          I know why the web for UI took over, but I sure do miss Windows forms-based applications. The web is fine for the UI to a bank or some other tool you don't interact with that often, but for tools where you can spend hours working inside, browser-based interfaces are terrible.

          • theamk 1 year ago
            Also unusable by many people - I see mostly macbooks around me, with some Linux laptops or Chromebooks. Windows is for those super-low-privileged users who cannot be trusted with their own system and need IT to manage them; or for gamers.

            And yes, I can probably run the management software in wine, but I will avoid it if I can.

            • briHass 1 year ago
              They recommend and 'support' running it in Wine. I haven't tried, but I'm sure it works fine given Wine tends to work best with no frills Win apps from a decade ago.
          • aleph_minus_one 1 year ago
            > I am endlessly annoyed by slow interfaces. At $DAYJOB I have to use a web and desktop GUI for managing CheckPoint firewalls. These often will freeze for dozens of seconds, and generally make my computer crawl. I feel that this should not be acceptable in 2023.

            This is probably not a problem of the principal slowness of the software. With a high likelihood (source: personal programming experience of my colleagues and me), the root cause when the GUI freezes in such situation is typically rather that some operation that needs a little bit of time (say, a server request) is done in the GUI thread, thus blocking the processing of any other event (message). Windows programming is very sensitive in this regard.

            • fredrikholm 1 year ago
              > and generally make my computer crawl.

              Sounds like its worse than that.

            • eterps 1 year ago
              The D forum is also quite fast: https://forum.dlang.org/
              • hxii 1 year ago
                Reminds me of bbPress, at least visually.
            • alberth 1 year ago
              It makes me happy to see people still build stuff like this.

              Also interesting that they host their code on Fossil, which itself has a builtin forum engine written in C.

              https://www2.fossil-scm.org/home/doc/trunk/www/forum.wiki

              • jbm 1 year ago
                I don't understand — isn't the speed mostly limited by network or disk access? Is there a significant improvement by having the underlying code in Assembly?

                A very cool application regardless, I haven't seen Assembly since college now.

                • theamk 1 year ago
                  yes, the speed is mostly limited by network/disk; no, there is no improvement from writing entire thing in assembly (optimizing a few hot functions is a different story)

                  I have not looked at this at this software in particular, but the few assembly web engines I have looked at in the past had worse performance that C versions due to making a much higher number of syscalls. For example, multiple send calls per response; lack of pool allocators; etc...

                  • okaleniuk 1 year ago
                    You are right. The site is not fast because of Assembly, it is simply well designed.

                    Assembly, however, pushes towards healthier design choices. You have to keep things simple since you are the one who pays for the complexity, not a third-party library providers who use several third-party libraries themselves.

                    • alberth 1 year ago
                      The website being only 65kb in total size, all inlined with no additional downloads, plays a massive role in its performance no doubt.

                      Regardless of what language is serving up the request.

                      Still neat though.

                      • jacquesm 1 year ago
                        That means it fits in cache in its entirety. I've found this often to be the biggest factor: reduce the size of the 'hot' set so it fits in cache and you can see crazy speed improvements.
                        • 1 year ago
                        • lost_tourist 1 year ago
                          if cpu is the bottleneck, then sure, if it's network/db then it won't make much of a difference at all.
                        • epcoa 1 year ago
                          > This is an engine for web based message board (forum) implemented entirely in assembly language, using FastCGI interface and SQLite database as a storage.

                          A lot of heavy lifting isn't even done in Assembly. Not to say anything of what it's using for a TCP stack. I don't know where in the Amdahl's distribution the assembly part falls, but I'm guessing it ain't much.

                          Edit: Also now that I perused the link, I wonder how many people commenting here are confused and are actually commenting on the speed of the Fossil browser vs the actual forum.

                          • jacquesm 1 year ago
                            That depends. If you do more complex stuff you can easily be CPU bound, but if you're just pumping data then likely the network will be your first limit. Caching should take care of the disk as a limitation (besides that, SSDs are wicked fast).
                            • chefandy 1 year ago
                              What computationally complex operation would a forum application regularly do? I can't think of any but I've never written a forum application.
                              • deaddodo 1 year ago
                                Deeply/truly threaded forums are definitely computationally intense. You have to leverage something to recreate the necessary tree from it's database structure (preorder tree traversal, adjacency lists, etc) while applying ACL methods, view transformations, etc on the dataset. This is much less of a problem nowadays though (compared to when forum software was "in vogue").
                                • jacquesm 1 year ago
                                  Database joins for instance. Ranking articles.
                                  • layer8 1 year ago
                                    Figuring out which posts to display on page 853 in threaded view.
                              • fortyseven 1 year ago
                                • fortyseven 1 year ago
                                  (Oops, somehow I missed the existing discussion thread on this further down. Sorry for the repetition.)
                                  • sodimel 1 year ago
                                    Ouch, I wasn't prepared to read this post.
                                • mcint 1 year ago
                                  Real-time notifications give a sense of activity, nice for building a community. Reminds me of http://listen.hatnote.com/ showing live wikipedia edits, but more integrated. Some anonymity, or mention of a group, e.g. anonymous users, forum member, admin, would be better. Too much and too specific sharing of activity makes this feel stifling--more like chat with read notifications, less like email or forum where people take time to compose replies.
                                  • GaNuongLaChanh 1 year ago
                                    Fantastic forum engine, the demo is https://board.asm32.info/ and beautiful themes are at https://asmbb.org
                                    • Waterluvian 1 year ago
                                      Got me thinking. How easy is it to write Assembly that looks good but is slower than C?

                                      Like can you be really good with Assembly and still not be certain your effort is actually worth not doing it in a higher language?

                                      • stephencanon 1 year ago
                                        People do this all the time. The world is littered with assembly code written by people who believe that modern x86 uarches are just like the Pentium IV they cut their teeth on, or that an M2 is just a fancy Cortex-A53, meticulously hand ordering instructions while entirely missing the big picture.

                                        If you’re going to take the trouble of writing assembly, you should do it right; figure out the fastest you can theoretically go, and see if you can get within a few percent of that without using assembly. If you can, stop. If not, figure out why you can’t, file compiler bugs as applicable, and then write assembly where it’s necessary. Re-measure, and if you aren’t within a few percent, figure out why not, then go back to step 1.

                                        • okaleniuk 1 year ago
                                          If you're inclined to write fast code in assembly, you will. If not - not.

                                          The thing is, optimizing compilers don't actually do any optimization in the classical sense. They don't do run-measure-modify loop as programmers do so all they can apply to the code is the heuristics some other programmers taught them. Some things are trivial like loop unrolling or function inlining. Some are not, like trigonometric approximations.

                                          In the long run, when a compiler stops, a person goes further. That's why empirically, hand-made code is still faster than the compiled one. Of course you can write slow code in Assembly, but if you already decided to go low, you'll optimize your thing until satisfied with the result.

                                          One particular thing comes to mind, C is ridiculously bad with automatic superscalarization (try VTune's HPC characterization on any code you like and see). Sure, you can use intrinsics and implement things manually, but that would be essentially the same as writing in assembly.

                                          There is another contender though. Spiral (https://spiral.net/) that actually do solve the optimization problem can in fact be as effective as a human programmer and at a fraction of the cost. Spiral is overly specialized, so it's not a threat to all the HPC, but a more generic thing may indeed become a gamechanger.

                                          • hoten 1 year ago
                                            Trivially easy. Just try to beat a C compilers optimization for constant integer division.

                                            https://clang.godbolt.org/z/MrMxo678x

                                            • okaleniuk 1 year ago
                                              Have you tried measuring the actual impact of this?

                                              This optimization is so old, I'm not even sure if it's still worth the effort. It definitely worked in the 90s.

                                              What you do here is you save on division, and lose on instruction cache. This might look good on a benchmark when all your code fits the cache nicely, but bite back in-vivo. You should try it out in an actual problem and see how it goes.

                                              • hoten 1 year ago
                                                I know it's an appeal to authority, but if clang does it at high optimization levels then that's good enough for me to know it's faster.

                                                Division is really really slow in CPUs, as I understand it. Like, CPUs are just awful at it.

                                                It being an old opt doesn't mean it is invalid. I'm not aware of CPUs getting meaningfully better at division.

                                              • tekknolagi 1 year ago
                                                Add -O2 for even fewer instructions :)
                                          • skilled 1 year ago
                                            All I want for Christmas is the old-school :lol: emoji from phpBB days…
                                          • kmoser 1 year ago
                                            Not exactly a forum as we now know it, but I believe Bill Basham's Diversi-Dial (DDial) BBS software for the Apple II was written entirely in assembly. https://paleotronic.com/2019/09/28/diversi-dial-an-apple-ii-...
                                            • jacquesm 1 year ago
                                              Imagine what you could do with a smartphone if it were programmed entirely in assembly.
                                              • jodrellblank 1 year ago
                                                You could make a device that was slower than Window CE and go bankrupt! https://news.ycombinator.com/item?id=36570062
                                                • jacquesm 1 year ago
                                                  Yes, you could do that too. But you wouldn't have to.
                                                  • epcoa 1 year ago
                                                    Why not? How do you avoid the same failure mentioned in the linked comment and associated post?
                                                • petabytes 1 year ago
                                                  Kolibri OS was written entirely in Assembly. I think the performance was pretty poor compared to C operating systems. Much easier to write optimized algorithms in high level languages. https://kolibrios.org/en/
                                                  • simulosius 1 year ago
                                                    Why would anyone want to program a smartphone entirely in assembly?

                                                    There is a reason (well actually there are many) that the vast majority of software development these days is done using more advanced languages.

                                                    • jacquesm 1 year ago
                                                      Cost. Convenience. In that order.
                                                      • simulosius 1 year ago
                                                        Cost? Please explain why writing programs in assembly is supposed to be *cheaper* than writing programs in a higher level language? The same goes for convenience: Since when is writing an application in assemlby more convenient than writing an application in a modern language?
                                                        • squeaky-clean 1 year ago
                                                          How about security? I would never want an app written entirely in assembly to be allowed to take in arbitrary user input from the public internet.

                                                          Cross-platform support, which you might argue just falls under convenience, but if you're writing for a different CPU architecture, you've basically written 2 separate programs now and not one.

                                                      • wyldfire 1 year ago
                                                        Weird. I just tried it and it seems to be bootlooping now.

                                                        Hmm. maybe there's a bug in one of the lines of someone's code.

                                                        Guess I better get started investigating it. 'Cause once I'm done I've got to start porting it to RISC-V.

                                                        • kaba0 1 year ago
                                                          Yeah, let’s leave it up to people to allocate registers, they are surely consistently good at it throughout whole code bases /s

                                                          In general, writing something in assembly won’t be faster. Some expert can in certain cases come up with a better hot loop in asm, but for larger scopes we can’t be as diligent as a machine can be.

                                                          • kwhitefoot 1 year ago
                                                            Why would you be able to do more, or indeed less, with it programmed in assembly rather than a higher level language?

                                                            There isn't anything about assembly language that makes it inherently more effective or efficient than a high level language.

                                                            • rahen 1 year ago
                                                              In principle, this amounts to giving a gift to society: the programmer spends more time on their work so that society as a whole consumes fewer resources. Often, the opposite happens: the programmer transfers their productivity gain into an additional cost for society (usually by contributing to e-waste and added resource requirements).

                                                              It's easy to extrapolate this to other domains. Imagine that in order to enhance their productivity, aerospace engineers started buying off-the-shelf generic components and get them assembled as quickly as possible without seeking optimization. The airplanes will consume a lot more fuel, have a worse safety record and require constant upgrades and maintenance, but it doesn't matter much as the manufacturer can now hire fewer engineers, and it's other people's fuel you're wasting anyway.

                                                              I understand that seeking immediate profit is the norm, but I'm always a little disillusioned when I see selfless initiatives ridiculed.

                                                              • djur 1 year ago
                                                                I'm not sure how to make sense of this analogy without assuming that assembly language programming self-evidently produces superior programs than programming in high-level languages, and it's exactly that claim that the comment you're replying to is challenging.
                                                              • jacquesm 1 year ago
                                                                Your executables will be a small fraction of the size that you expect, you will likely be able to fit the whole thing in cache and you will consume less power because you will be happy with a smaller cycles budget so you can run the cpu much slower.

                                                                Of course this all comes at a price: decreased programmer efficiency.

                                                                • rafram 1 year ago
                                                                  I don’t think that’s actually true. Compilers write machine code that’s often much more efficient than anything you could think up by hand, and the bulk of the disk space/memory used by a modern executable is for resources/strings, not instructions. Stereotypical assembly code - extremely lean routines that accept minimal user input and don’t create human-readable output - is indeed smaller than a stereotypical compiled executable, but you’d have trouble beating the compiler 1:1 on the same problem.
                                                                  • kwhitefoot 1 year ago
                                                                    > Your executables will be a small fraction of the size that you expect,

                                                                    No they won't. There is no way that you can write more compact code than a modern optimizing compiler for anything except the most extreme edge cases.

                                                                    • kaba0 1 year ago
                                                                      Many instructions in assembly is simply “logistics” of where should this or that byte go. Machines are eons better at it at large scopes than humans, you surely don’t have enough hair to sit through and carefully examine every register. Also, will you decide on a case by case basis to “inline” a function’s body? What if the function’s body changes? Will you go back to every “inlined” part? What if that makes a more efficient register allocation possible, rewrite the whole function where the inline happened?
                                                                  • xigency 1 year ago
                                                                    I’m sure it would be very fast at booting and fast at crashing as well. However, on the Android side it’s probably what’s needed to compete with Apple hardware and software.
                                                                    • ReactiveJelly 1 year ago
                                                                      The real problem is that I don't control all the code.

                                                                      If I had millions of person-hours to RE all the apps I hate, I'd just write them in Rust or something.

                                                                      • cultofmetatron 1 year ago
                                                                        assembly? the current standard is kotlin or swift which while reasonably performant, leave a lot on the table. i'd love to have first class support for writing android and ios applications in rust. plenty fast enough for me. my day job is elixir but the memory requirements are a bit high for mobile apps (though I'm sure the guys at nerves would disagree)
                                                                        • HeckFeck 1 year ago
                                                                          Didn't we have something similar to that with the early DOS-based palmtop PCs?
                                                                        • Jyaif 1 year ago
                                                                          Very fast! Or should I say, the normal speed at which websites should operate.

                                                                          x86 only.

                                                                          • 1 year ago
                                                                            • mhd 1 year ago
                                                                              I looked into maybe using this a few months ago, but decided against it.

                                                                              https://board.asm32.info/hi-johnfound-welcome-back.351/#1624...

                                                                              • 10000truths 1 year ago
                                                                                What the hell are those god-awful notifications that keep spamming the bottom right corner of the page? I can't seem to turn them off.
                                                                                • xigency 1 year ago
                                                                                  Would be fine if they didn’t cover the content on the page, but maybe that’s a mobile problem.
                                                                                  • mcint 1 year ago
                                                                                    There's a bell icon in the header, it toggles the real-time notifications. Took me a minute to find it too.
                                                                                    • StingyJelly 1 year ago
                                                                                      I went straight to ublock element picker without thinking about it

                                                                                      board.asm32.info##div.info.toast

                                                                                  • xigency 1 year ago
                                                                                    While this is mainly a technical discussion forum, I am a bit disappointed to see the comment linking to the author’s political views posted on their own forum as being flagged. This is relevant information for people deciding whether to support, use, or be affiliated with this project.
                                                                                    • fasterik 1 year ago
                                                                                      Agreed. That comment doesn't seem to break any rules. Is "flagged" something that just means enough people downvoted it, or does it require moderator intervention?
                                                                                      • 1 year ago
                                                                                    • YeBanKo 1 year ago
                                                                                      I just checkout out the chat functionality and the first thing I saw there was a a bunch of obscene racists messages in Russian.
                                                                                      • 0xDEF 1 year ago
                                                                                        Thanks for posting. In the .Net world we had the whole Moq library drama recently. Now I check the social media of library creators before I use the library. I'm sorry but I cannot trust deranged people's code in production systems.
                                                                                        • ndegruchy 1 year ago
                                                                                          Ugh, yeah. That's unfortunate.
                                                                                          • serf 1 year ago
                                                                                            to each his own, but I can't really use a computer without implicating myself with software written by people with totally different ethics/philosophy/politic than myself; in fact I think that no one can.

                                                                                            if you find a software stack that aligns itself perfectly with any single dogma (outside maybe TempleOS) then let me know, but right now that seems like a pipe dream.

                                                                                            I mean, just as food for thought, is there any common-use cryptography without major ties to war parties and national security groups?

                                                                                            aside: I can think of plenty of more practical reasons to avoid a net-facing forum software written in asm in 2023.

                                                                                            • winternewt 1 year ago
                                                                                              I don't think it's a black-or-white thing. You weigh pros and cons. Linus can be a bit of a jerk but the Linux kernel is immensely useful to me, so I use it in spite of some misgivings. This software, on the other hand, is mostly a fun curiosity and the author is promoting actual genocide. So in this case I'll say no thanks.
                                                                                            • RagnarD 1 year ago
                                                                                              It's an indication that someone can be a good programmer while still lapping up Putin's propaganda.

                                                                                              On a related note, I somewhat recently posted just the link to the very religious SQLite ethics page on Facebook - which immediately flagged it as some objectionable something or other. Just a link to a web page of one of the most popular open source packages on the planet which Facebook itself no doubt uses. They're so incredibly leftist that their algorithms can't even abide linking to a religiously oriented page.

                                                                                              • 1 year ago
                                                                                                • veavo 1 year ago
                                                                                                  [flagged]
                                                                                                  • charsii 1 year ago
                                                                                                    It's still always better to do N-1 than N evil things.
                                                                                                    • cultofmetatron 1 year ago
                                                                                                      > If you really took that to heart you would be unable to use a computer at all.

                                                                                                      yea no kidding. its like these people never looked up von Neumann. https://en.wikipedia.org/wiki/John_von_Neumann

                                                                                                      • karmakurtisaani 1 year ago
                                                                                                        You mean his stance on the whole nuclear war thing? At least with that I can kind of see where he was coming from, but this forum guy just seems delusional.
                                                                                                        • jacquesm 1 year ago
                                                                                                          What's so bad about von Neumann?
                                                                                                        • pessimizer 1 year ago
                                                                                                          > If you really took that to heart you would be unable to use a computer at all.

                                                                                                          Or any transistor. Although Shockley certainly wasn't a communist, so maybe his views are more appealing?

                                                                                                          https://en.wikipedia.org/wiki/William_Shockley

                                                                                                          • jacquesm 1 year ago
                                                                                                            This is a bit more than a 'wrong political opinion', this is outright support for genocide.

                                                                                                            "The Nazi plague must to be eradicated from Ukrainian society. "

                                                                                                            Fuck that shit.

                                                                                                            • YeBanKo 1 year ago
                                                                                                              This is almost verbatim translation of the top putin’s propagandist.
                                                                                                              • karmakurtisaani 1 year ago
                                                                                                                Yep. When someone holds a view like that, they come off as an unstable or delusional person. Using a product from such a person can quickly become a liability.
                                                                                                                • pessimizer 1 year ago
                                                                                                                  [flagged]
                                                                                                                • Genwald 1 year ago
                                                                                                                  I don't understand this all or nothing rebuttal. You can avoid supporting an individual that you don't like without doing background checks on everyone involved with everything you use.

                                                                                                                  Also, not supporting the Russian invasion of Ukraine is not about not supporting communism.

                                                                                                                  • thaumaturgy 1 year ago
                                                                                                                    If the only classification you have for supporting the brutal genocide of a people is "wrong political opinion", then you have woefully inadequate mental models for the world around you.
                                                                                                                    • 0xDEF 1 year ago
                                                                                                                      Where do you see "commmunists"? Did you check the link? The chat functionality is full of racist messages in Russian.
                                                                                                                      • mhh__ 1 year ago
                                                                                                                        Not that many in my experience at least.
                                                                                                                        • wetpaws 1 year ago
                                                                                                                          [dead]
                                                                                                                      • Chiba-City 1 year ago
                                                                                                                        Garbage collecting interpreters are (mostly) for wimpy scripting kiddies. The obvious historically documented exceptions are the "Symbolic AI Researchers."

                                                                                                                        In 1990, SQL (and dBASE and Excel) was a "computer language" for secretaries. Now in 2023, we suffer uneducated halfwits manically typing in endless repugnant "ad tech" and "SEO" with our "Bioinformatics Researcher" hacks inflicting delusions based on Excel #Err cells (look it up) upon an unwitting populace.

                                                                                                                        Somewhere, we went wrong. We have GREAT and WISE Software Engineering (Prescriptive and Historical) guidance available in the public domain now. Our mercenary "job hoppers) don't seem to be interested in accessing that.

                                                                                                                        Going forward, some combination of ASM and Forth in Open Source incarnations and with type-checking hints will wring the most computation out of energy resources (CPU cycles).

                                                                                                                        • kaba0 1 year ago
                                                                                                                          That’s a thoroughly uninformed take, and this stance is overly elitist for no good reason.
                                                                                                                          • lost_tourist 1 year ago
                                                                                                                            All I can say is good luck with that philosophy in anything other than writing drivers or small embedded systems.