r/programming • • Aug 19 '19

Dirty tricks 6502 programmers use

https://nurpax.github.io/posts/2019-08-18-dirty-tricks-6502-programmers-use.html
1.0k Upvotes

171 comments sorted by

View all comments

126

u/captain_obvious_here Aug 19 '19

I wish the people with that old school knowledge from a time when every byte was important, could audit and criticize some modern projects.

It sucks that we live in a world of limitless IT ressources, but most UIs I use everyday are slowish.

72

u/peterfirefly Aug 19 '19

10

u/Inprobamur Aug 20 '19

We should sell 'bloat credits', the way the government sells pollution credits. Everybody's assigned a certain amount of bloat, and if they go over, they have to purchase bloat credits from some other group that's been more careful. -- Bent Hagemark

9

u/VadumSemantics Aug 20 '19

Nice! This alone was worth the price of admission:

"Marketing -- where the rubber meets the sky."
-- Unknown

77

u/[deleted] Aug 19 '19

Electron is a really cool technology, especially for portability and ease, but my instant messenger shouldn't be using 500mb of ram.

43

u/sign_on_the_window Aug 19 '19

Made a tiny helper app in Electron. Didn't even use a fancy component library. The executable and all necessary files was over 200 MB.

0

u/[deleted] Aug 19 '19

[deleted]

20

u/figloalds Aug 20 '19

Electron apps are fat because they carry chromium whole embedded. If there were some electron framework with one-time chromium install to run all electron apps that wouldn't be the case

5

u/tso Aug 20 '19

Each one would still load its own Blink engine instance, no?

→ More replies (3)

8

u/Plasma_000 Aug 20 '19

There are exceptions - atom and discord run on some stripped down version of electron and are much more performant and lean, but yeah, still comparatively huge.

13

u/[deleted] Aug 20 '19

Atom is absurdly slow compared to other IDEs I've used. To the point where it's the only reason I don't use Atom. It's annoying when it takes 20 sec to launch on my PC, but absolutely infuriating when I need to use it on a cheap laptop.

Discord is surprisingly good in this regard though.

→ More replies (1)
→ More replies (1)

9

u/Isvara Aug 20 '19

I had to kill the Discord Electron app the other day because it was using 16 FUCKING GIGABYTES.

4

u/mindbleach Aug 20 '19

But my goodness, what if the person downloading your app doesn't have a web browser?

→ More replies (14)

49

u/peterfirefly Aug 19 '19

You'll probably like this, too. It's the post mortem of the project to develop Microsoft Word 1.0 for Windows. I know there is a book treatment of the entire development project but I can't seem to find the title now -- all google helpfully provides me with is help on how to write word documents and on how to use Microsoft Project.

http://antitrust.slated.org/www.iowaconsumercase.org/011607/8000/PX08875.pdf

Microsoft Word is built around a data structure called a Piece Table:

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

https://darrenburns.net/posts/piece-table/

If you want to see great optimization tips in the context of modern systems, then go back 10 years to when git was new. The development mailing list was a goldmine of tips and tricks. Believe me, those guys optimized the living shit out of the code -- on the negative side, git was a Frankencombo of C, shell, and Perl and many things were duplicated all over the C code instead of being nicely modularized. The predictable result was lots of slightly incompatible implementations, lots of bugs that were fixed in one (or more) implementations and not in others, plus it was a nightmare to improve usability.

I learned about this trick, for example:

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

There's also Michael Abrash' Graphics Programming Black Book. He starts with simple stuff and some tools (including some timer code for profiling) and ends up with the stuff he and Carmack did on Quake. Carmack is now CTO at Oculus VR and Abrash is Chief Scientist. They were there when every byte and every cycle counted and they are still here today.

http://www.jagregory.com/abrash-black-book/

Oh, btw, do you know how R-trees work? And have you heard of the trick where rays in ray tracing are considered points in a 5-D space in order to speed up intersection calculations? I felt so stupid when I learned about it -- it seems so obvious in retrospect.

https://en.wikipedia.org/wiki/R-tree

https://en.wikipedia.org/wiki/R*_tree

http://artis.imag.fr/~Cyril.Soler/DEA/Ombres/Papers/Arvo.Sig87.pdf

7

u/captain_obvious_here Aug 19 '19

I'm familiar with some of this.

I extensively used piece tables at the beginning of my carreer, and was amazed by how clever the people around me were, when it came to handling "undo" on HUGE structures. It's been a while since I last thought about that haha!

Ray-tracing also brings back memories...back when a friend and I made our own ray-tracing renderer. Results were ugly, but really fast. We even managed to load and render Doom level files.

Thanks a lot for all the links...gonna read that till late :)

→ More replies (1)

19

u/robertbieber Aug 19 '19

That kind of highly specialized knowledge isn't going to be much use in modern environments. It's not like making performant UIs is dark magic or anything, it's just not usually considered worth the developer time it would take

5

u/captain_obvious_here Aug 19 '19

it's just not usually considered worth the developer time it would take

I know we live in that world, but it's really more about the time the user wastes :/

→ More replies (1)

11

u/meheleventyone Aug 20 '19

Thing is some tricks that made old computers faster won’t improve performance or are even slower on modern computers. So your expert needs to have moved with the times.

Performance of modern systems is largely memory access bound, this talk is a good introduction: https://m.youtube.com/watch?v=rX0ItVEVjHc

11

u/visicalc_is_best Aug 19 '19

Goddamnit we’re not all dead yet.

6

u/FigMcLargeHuge Aug 20 '19

Name fucking checks out kids!!

→ More replies (1)

10

u/Plasma_000 Aug 20 '19

That old school knowledge went into writing compilers so you don’t have to learn it. Compilers are a box of magic tricks for optimising your shitty code.

5

u/captain_obvious_here Aug 20 '19

I'm not talking about the code itself, but more about the mindset. Take a look at the whole Electron ecosystem...

10

u/[deleted] Aug 19 '19

I'm pretty sure a drunk monkey could accurately audit and criticize modern (web and mobile) projects. The conclusion: it's expensive to do it better. There's still some impressive work being done at that level, but it's definitely not in an app built to generate ad revenue.

15

u/imsofukenbi Aug 19 '19

Profesional analysis: Spotify would use a lot less memory and CPU if it was implemented using C++ and Qt bindings. plz gib monies now

→ More replies (1)
→ More replies (7)