News for hackers. Stuff that matters.
Re:55 GiB/s FizzBuzz (2021) by pier25 on Monday July 03, 2023 @02:04AM (#36569418)
Makes you wonder... How fast would everything be if it was written in assembly.

In audio dev it's very common for dsp code to be written in assembly.

Re:55 GiB/s FizzBuzz (2021) by geek_at on Monday July 03, 2023 @02:44AM (#36569605)
Or if everything had been written by "ais523 - high effort answers"
Re:55 GiB/s FizzBuzz (2021) by xxs on Monday July 03, 2023 @03:09AM (#36569750)
You dont need Assembly, you need to the code not to be terrible, which is generally hard with the amount of code/developers needed.
Re:55 GiB/s FizzBuzz (2021) by dumdumchan on Monday July 03, 2023 @03:27AM (#36569891)
It wouldn't run at all since it wouldn't exist.
Re:55 GiB/s FizzBuzz (2021) by nickelpro on Monday July 03, 2023 @03:41AM (#36569985)
Assembly is hardly the reason this is fast. It is necessary to this solution but by no means sufficient.

Extreme algorithmic research combined with a high LOK of Linux syscalls and platform specific optimizations is what allows this to exist. To quote ais themself:

> @chx: I already have a master's thesis. This was harder.

This is in a different universe than what can be produced by simply "do it in assembly".

Re:55 GiB/s FizzBuzz (2021) by wheelerof4te on Monday July 03, 2023 @04:27AM (#36570274)
"Extreme algorithmic research combined with a high LOK of Linux syscalls and platform specific optimizations is what allows this to exist."

No, author's extreme boredom and/or free time allowed this to exist. Nothing else.

Re:55 GiB/s FizzBuzz (2021) by moreati on Monday July 03, 2023 @06:40AM (#36571109)
What's LOK in this context? Search and Wikipedia didn't throw up anything. Thanks.
Re:55 GiB/s FizzBuzz (2021) by bonzini on Monday July 03, 2023 @07:00AM (#36571246)
Level of knowledge, I think.
Re:55 GiB/s FizzBuzz (2021) by nickelpro on Monday July 03, 2023 @09:17AM (#36572461)
Correct.

It's one of those extremely-common-in-the-US-military-almost-no-usage-outside-it type things apparently, like behoove or tack (hyphen) or diggit (multi-tool), which I'll keep in mind in the future.

Re:55 GiB/s FizzBuzz (2021) by bonzini on Monday July 03, 2023 @04:44PM (#36578551)
The second ranked solution (by me :)) shows that a more or less trivial assembly tight loop can get about 70% of the speed. The remaining 30% is... something else.
Re:55 GiB/s FizzBuzz (2021) by kryptiskt on Monday July 03, 2023 @03:53AM (#36570062)
It would end up like Steve Yegge's tale of Geoworks:

"OK: I went to the University of Washington and [then] I got hired by this company called Geoworks, doing assembly-language programming, and I did it for five years. To us, the Geoworkers, we wrote a whole operating system, the libraries, drivers, apps, you know: a desktop operating system in assembly. 8086 assembly! It wasn't even good assembly! We had four registers! [Plus the] si [register] if you counted, you know, if you counted 386, right? It was horrible.

I mean, actually we kind of liked it. It was Object-Oriented Assembly. It's amazing what you can talk yourself into liking, which is the real irony of all this. And to us, C++ was the ultimate in Roman decadence. I mean, it was equivalent to going and vomiting so you could eat more. They had IF! We had jump CX zero! Right? They had "Objects". Well we did too, but I mean they had syntax for it, right? I mean it was all just such weeniness. And we knew that we could outperform any compiler out there because at the time, we could!

So what happened? Well, they went bankrupt. Why? Now I'm probably disagreeing – I know for a fact that I'm disagreeing with every Geoworker out there. I'm the only one that holds this belief. But it's because we wrote fifteen million lines of 8086 assembly language. We had really good tools, world class tools: trust me, you need 'em. But at some point, man...

The problem is, picture an ant walking across your garage floor, trying to make a straight line of it. It ain't gonna make a straight line. And you know this because you have perspective. You can see the ant walking around, going hee hee hee, look at him locally optimize for that rock, and now he's going off this way, right?

This is what we were, when we were writing this giant assembly-language system. Because what happened was, Microsoft eventually released a platform for mobile devices that was much faster than ours. OK? And I started going in with my debugger, going, what? What is up with this? This rendering is just really slow, it's like sluggish, you know. And I went in and found out that some title bar was getting rendered 140 times every time you refreshed the screen. It wasn't just the title bar. Everything was getting called multiple times.

Because we couldn't see how the system worked anymore!

Small systems are not only easier to optimize, they're possible to optimize. And I mean globally optimize."

http://steve-yegge.blogspot.com/2008/05/dynamic-languages-st...

Re:55 GiB/s FizzBuzz (2021) by sillysaurusx on Monday July 03, 2023 @04:49AM (#36570408)
Interestingly, AI might change this. Not that it would be a good idea to write everything in assembly, but at least it would be possible now.

Some wonderful systems were written in assembly. Donkey Kong comes to mind.

Re:55 GiB/s FizzBuzz (2021) by lmm on Monday July 03, 2023 @05:20AM (#36570611)
> Interestingly, AI might change this. Not that it would be a good idea to write everything in assembly, but at least it would be possible now.

More likely to be the opposite IMO. AI could make the Sufficiently Smart Compiler a reality; maybe autovectorization will finally work and you could write FizzBuzz in Python and it would perform like this.

Re:55 GiB/s FizzBuzz (2021) by _dain_ on Monday July 03, 2023 @06:43AM (#36571132)
>Object-Oriented Assembly

what in the god damn

Re:55 GiB/s FizzBuzz (2021) by nickelpro on Monday July 03, 2023 @09:28AM (#36572577)
vtables aren't limited to any particular language

That you have some set of macros that work on common data structures and use a function pointer lookup to dispatch some behavior isn't insane. I mean, if your macros are that advanced why not use a real programming language, but shit got weird in the 80s and early 90s.

Re:55 GiB/s FizzBuzz (2021) by jerf on Monday July 03, 2023 @10:00AM (#36572975)
Paradigms are not a characteristic of programming languages, they are a characteristic of programs.

Now, obviously, programming languages encourage and afford the use of certain paradigms. But that's all they do. A program is not object oriented because it's written in C++. It is object oriented because it is written in terms of objects, regardless of what the underlying language may support or encourage.

Assembly, being the base language of the CPU, can be written in any paradigm any other language might permit, since all other programming language paradigms are obtained as limitations on the underlying assembler that may be generated. You can always just apply those limitations manually to get an object oriented program, or a logic programming program, or a functional programming. It just might be very costly and difficult.

Re:55 GiB/s FizzBuzz (2021) by dahart on Monday July 03, 2023 @11:11AM (#36574020)
Haha! This is a real thing. “It is easy to assume that OOP requires such an OOP language. This is not the case.” https://zsmith.co/OOA.php

https://www.amazon.com/Object-Oriented-Assembly-Language-Len...

Indeed, my first industry job, after spending my undergraduate and graduate degrees honing C++ skills, was doing object oriented C. It was actually great, taught me a lot about what actually matters in a language versus what people will tell you.

Re:55 GiB/s FizzBuzz (2021) by tragomaskhalos on Monday July 03, 2023 @04:16AM (#36570211)
I started in software dev in 1988; the only languages I knew were BASIC and Z80 assembly so, since everyone knew BASIC was kind of lame I naturally assumed I'd be a machine code programmer, albeit on slightly more exotic processors. Day one got handed a book on C -> mind blown.
Re:55 GiB/s FizzBuzz (2021) by jojobas on Monday July 03, 2023 @04:47AM (#36570398)
It depends. You can write bubblesort in assembly and it will be pretty damn slow. I can imagine those assembly leaders could push out pretty fast C implementations as well.
Re:55 GiB/s FizzBuzz (2021) by MagicMoonlight on Monday July 03, 2023 @04:56AM (#36570451)
Even if everything was just written in java we’d be better off than the current system of embedding chrome into a python instance and then running a webserver in javascript to render a document.
Re:55 GiB/s FizzBuzz (2021) by pkolaczk on Monday July 03, 2023 @05:57AM (#36570829)
I don't think replacing one bad idea with another bad idea is a good idea ;) I'm also not sure if Java would be less bad in that case. At least JS has years of research that went into making it start fast, not only run fast after warmup.
Re:55 GiB/s FizzBuzz (2021) by selimco on Monday July 03, 2023 @06:16AM (#36570963)
Modern Java has Coordinated Restore at Checkpoint (CRaC) as well as ways to compile it to native binaries that can start very fast (GraalVM & Substrate VM). The former has the benefit of a JIT as well!
Re:55 GiB/s FizzBuzz (2021) by therealdrag0 on Monday July 03, 2023 @06:55PM (#36579869)
Have you used any of these? I’m looking for ways to speed up start time of JVM, but almost options I’ve seen so far are “experimental” and not sure best route to take. For example was sad to see ahead of time compile being removed from JDK.
Re:55 GiB/s FizzBuzz (2021) by pulse7 on Monday July 03, 2023 @07:22AM (#36571386)
Is this "years of research" the reason why most Electron apps still start slower than - for example - IntelliJ IDEA, which is written in Java and Swing?
Re:55 GiB/s FizzBuzz (2021) by dahfizz on Monday July 03, 2023 @01:51PM (#36576476)
Just imagine if those years of research went into a good language instead. Instead of expending a huge amount of effort making an inherently slow language perform reasonably, we could have taken a reasonable language like Rust and made it so good it would legitimately push computing forward.

And then all you web devs could still compile rust to wasm. wasm is already faster than JS anyway. JS was a mistake.

Re:55 GiB/s FizzBuzz (2021) by adamrezich on Monday July 03, 2023 @10:42AM (#36573598)
at $DAYJOB we're in the (slow) process of replacing a tool written in Java with its successor tool, which is a web app. the Java tool works great and has reasonably snappy performance. the web app is terribly slow (at least 0.75 jiras), frequently hangs, and is often unusable for simple tasks. it's been miserable enough to make me miss the Java Era.
Re:55 GiB/s FizzBuzz (2021) by winrid on Monday July 03, 2023 @02:30PM (#36577036)
I will start measuring things in jiras, thanks :)

Also I bet the reason is more of architecture in your web app. It's harder to make it as fast, for sure, but it shouldn't hang or be unusable.

Re:55 GiB/s FizzBuzz (2021) by adamrezich on Monday July 03, 2023 @03:52PM (#36577959)
I wish we could do anything about it, but it's a third-party SaaS (like everything else these days...)
Re:55 GiB/s FizzBuzz (2021) by hedora on Monday July 03, 2023 @03:15PM (#36577558)
If that were true, then eclipse would be faster than VS Code, right?
Re:55 GiB/s FizzBuzz (2021) by actionfromafar on Monday July 03, 2023 @05:43AM (#36570759)
I think an oft overlooked detail of more primitive languages yielding faster programs, is this:

when it’s painful to progress even a little bit while coding, you try very hard to implement as little as possible

resource constraint can give clarity of focus

Re:55 GiB/s FizzBuzz (2021) by zokier on Monday July 03, 2023 @08:22AM (#36571885)
Shortest/smallest code is rarely the fastest. Loop unrolling and inlining make code larger, and occasionally faster as an trivial example
Re:55 GiB/s FizzBuzz (2021) by actionfromafar on Monday July 03, 2023 @12:23PM (#36575189)
Sure, but my comment meant to address systems thinking and application design, not micro optimisations.
Re:55 GiB/s FizzBuzz (2021) by XCSme on Monday July 03, 2023 @08:00AM (#36571701)
Assembly is so far from the original code written today that it is not even feasible to think about. That being said, imagine how fast everything would be if the companies developing the software would actually care about performance.

For like 99% of websites and software today, if anyone cared about the app performance, I am pretty sure most would be able to achieve at least 50% speed-ups through very basic changes (correct caching, optimizing assets, replacing bloated 3rd party libraries with a basic native call that does the same thing, configuring the servers and databases properly, etc.).

EDIT: That being said, I am pretty sure in a few years AI would be able to provide one-click optimizations to a repository that would either apply best-practices or rewrite the original code in performant Assembly.

Re:55 GiB/s FizzBuzz (2021) by jodrellblank on Monday July 03, 2023 @12:27PM (#36575250)
> "if anyone cared about the app performance, I am pretty sure most would be able to achieve at least 50% speed-ups through very basic changes"

See https://danluu.com/octopress-speedup/

> "This blog is a static Octopress site, hosted on GitHub Pages. Static sites are supposed to be fast, and GitHub Pages uses Fastly, which is supposed to be fast, so everything should be fast, right?"

followed by

> "I'm not sure what to think about all this. On the one hand, I'm happy that I was able to get a 25x-50x speedup on my site. On the other hand, I associate speedups of that magnitude with porting plain Ruby code to optimized C++, optimized C++ to a GPU, or GPU to quick-and-dirty exploratory ASIC. How is it possible that someone with zero knowledge of web development can get that kind of speedup by watching one presentation and then futzing around for 25 minutes? I was hoping to maybe find 100ms of slack, but it turns out there's not just 100ms, or even 1000ms, but 10000ms of slack in a Octopress setup. According to a study I've seen, going from 1000ms to 3000ms costs you 20% of your readers and 50% of your click-throughs. I haven't seen a study that looks at going from 400ms to 10900ms because the idea that a website would be that slow is so absurd that people don't even look into the possibility. But many websites are that slow!"

Re:55 GiB/s FizzBuzz (2021) by winter_blue on Monday July 03, 2023 @05:16PM (#36578967)
> For like 99% of websites and software today, if anyone cared about the app performance, I am pretty sure most would be able to achieve at least 50% speed-ups through very basic changes (correct caching, optimizing assets, replacing bloated 3rd party libraries with a basic native call that does the same thing, configuring the servers and databases properly, etc.).

I'd say a big factor to include here is the choice of language. Going from Python/Ruby to Kotlin/Rust/etc could probably yield a speed up of over 10x / over 1000%.

Re:55 GiB/s FizzBuzz (2021) by XCSme on Monday July 03, 2023 @06:39PM (#36579745)
I think the ecosystem is more important than the programming language. You can choose any language, if you bloat your application with 20MB JPEGs, 3rd party API requests that take tens of seconds or implement animations that take seconds to complete, the language won't matter that much.

I am not sure if there are languages that come with a fool-proof ecosystem when it comes to implementing things and making them fast. The only one I can think of are UI-based applications builders, that only allow you to add to your app only a limited subset of UI elements or features.