=== ANCHOR POEM ===
═════════════════════════════════════════════════════════──────────────────────────
If you have a thousand options in your case / switch statement, you should
probably refactor.
consider putting function pointers (to the things you would have switched to)
in an array and instead of checking "if this enum, then this, if that enum,
then that" etc send an index into the function pointer array. That way there's
no branching at all.
The best way to generate performant code is to reduce or eliminate branches.
If you're working on a video game or networked program, this can be incredibly
important.
The second best way is probably reducing cache misses and increasing
parallelism, but those are different problems.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════════════════─────────────────────────┘
=== SIMILARITY RANKED ===
--- #1 fediverse/702 ---
═════════════════════════════════════════════──────────────────────────────────────
Branches cause cache misses which are slow when done on repeat.
Better to structure your code to avoid them, if possible, for example by using
an array of function pointers instead of switch statements.
unrelated, but once the data is cached from memory, operations like bit
shifting and arithmetic are essentially free. The slowest part of the process
is moving data from RAM to cache so that the CPU can use it.
That being said, CPUs and compilers are VERY good at optimizing that type of
thing these days.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════─────────────────────────────────────┘
--- #2 fediverse/1034 ---
═══════════════════════════════════════════════────────────────────────────────────
@user-192
be careful, recursion can cause stack overflows.
better to run function pointers from a loop. That way you can operate as long
as necessary. Just make sure you don't get in an infinite loop...
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════───────────────────────────────────┘
--- #3 fediverse/4123 ---
═══════════════════════════════════════════════════════════────────────────────────
@user-883
you're right
but I think your first impulse should be to think about how to do it in a
multithreaded way
If the result is that single-threading would be better, great! It'll be easier!
But thinking about multithreading first will give you crucial insights into
the structure of the program.
depending on what kinds of programming you do...!
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════════───────────────────────┘
--- #4 fediverse/5689 ---
═══════════════════════════════════════════════════════════════════════────────────
why don't we make large arrays of vram that are slightly slower because
they're farther on the circuit-board from their host and their reception at
the processing section has to be gated such that they all enter to be
processed at once.
like that one infinite scrolling XKCD cartoon where the things move from one
screen to the other simultaneously assembly line style.
[fail safes. https://xkcd.com/2916/#xt=7&yt=35 ]
if we all feel like we're doing nothing, we'll all grow tired of it and decide
to do some prevailing. gosh I wish I wasn't so useless is code for
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════════════════════───────────┘
--- #5 fediverse/3034 ---
═══════════════════════════════════════════════════════────────────────────────────
@user-570
I've messed around with Bevy and the library most similar in C is Raylib. in
Lua it'd be Love2D I think.
I love the idea of those systems. I haven't built a full game using them but I
can conceptualize operations within them easier using a framework like that
versus a game engine like Godot.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════───────────────────────────┘
--- #6 fediverse/5402 ---
══════════════════════════════════════════════════════════════════════─────────────
@user-1773
that point about HTML is soooooo good
like, we could be designing websites like we design video game UIs but instead
we use React which fills your browser with insecure-by-design javascript
generated visuals
or, even better, or just use HTML like a config file
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════────────────┘
--- #7 fediverse/282 ---
════════════════════════════════════════════───────────────────────────────────────
@user-209
I think you're right. Every letter in the variable name is another byte the OS
has to keep track of, which was a bigger problem in the past than it is today
(when it's been made irrelevant)
it's interesting how habits persist though the conditions that caused them
have faded. like a personal reflection of the environment you learned in.
"A a = new a();" is much more concise and (crucially) you can fit more words
to the right.
"a + b = c; c -= 2; f_z.write(c); f_z.close();" could conceivably be written
on a single line if you have short variable names. and when you only have so
many lines...
glad we're not constrained by those things anymore. the skeletal code that we
look at daily is much clearer - scope is more important, and so it makes sense
to encourage a coding style that illustrates it. however I can't help but
think block formatting like this could be useful in some situations, such as
when you'd normally be compelled to write a function for an operation that
runs once or more.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════──────────────────────────────────────┘
--- #8 fediverse/581 ---
═════════════════════════════════════════════──────────────────────────────────────
@user-428
sometimes I think about how much more productive I'd be if I had a code editor
that let me draw arrows and smiley faces and such alongside the code. Or if I
could position things strangely, like two functions side-by-side with boxes
drawn around them. Or diagrams or flowcharts or graphs or...
something that would output to raw txt format, but would present itself as an
image that could be edited.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧══════════════════════════════════════─────────────────────────────────────┘
--- #9 fediverse/2879 ---
══════════════════════════════════════════════════════─────────────────────────────
┌────────────────────────┐
│ CW: re: tech info-dump │
└────────────────────────┘
@user-1370
I love this a lot! I want to put function pointers in a "matrix architecture
array" and make them point to different functions at different points in the
program. I bet you could even point them at each other, so like if M and Y
then point at N, A, Y or something.
this is really cool I like stuff like this tomorrow I'll take pictures of
something similar I'm working on! I abandoned it tho hehe anyway remind me if
I forget!!
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════────────────────────────────┘
--- #10 fediverse/3680 ---
════════════════════════════════════════════════════════───────────────────────────
it's probably a good idea to write pseudocode, then real code, instead of
starting with real code, and bugfixing something incomplete and more difficult
to reason with.
unless you write real code easier than pseudocode. idk do what works for you.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═════════════════════════════════════════════════──────────────────────────┘
--- #11 messages/999 ---
══════════════════════════════════════════════════════════════════════════─────────
Okay bear with me, but, what if we took the AI that they use to play games
(like, the kind that memorize the best way to play space invaders or whatever)
and instead of A and B and start and select they could use programming
languages to try and recreate exactly a winning move, which in this case is
just the exact behavior that is created by the test case playthrough of Super
Mario Bros or Space Invaders. Free open source everygame!
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════════────────┘
--- #12 fediverse/4664 ---
══════════════════════════════════════════════════════════════─────────────────────
@user-1725
LLMs can't do math. Duh. That's like asking an "if check" to do recursion.
What he should have done is had the AI output the requested calculation as
JSON or something and use a calculator function call with the specified
arguments instead of trying to memorize every answer. But that requires more
functionality that has no reason to exist if your only goal is to be a tech
bro and build up a vacuous product that exists only to be hoovered up by
Google or Microsoft.
We could build such beautiful things if we just dethroned those giants. They
suck the creativity out of tech.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════────────────────────┘
--- #13 fediverse/6015 ---
══════════════════════════════════════════════════════════════════════════─────────
┌──────────────────────┐
│ CW: AI-mentioned │
└──────────────────────┘
In 2025, if you want to create a piece of software your options are to either:
devote your life to it, or use AI to build a semi-working prototype that you
can use to pitch your idea to a bunch of people who have devoted their lives
to learning how to use your idea as documentation while they build it from
scratch, throwing out most of the code but keeping all the checklists and
progress-trackers you built along the way, perhaps even utilizing some of your
tooling that you used while constructing the scaffolding of this monstrous
application that you won't be using most of the source-code for.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════════────────┘
--- #14 messages/574 ---
═══════════════════════════════════════════════════════════────────────────────────
Steps to make a game waterfall style:
Lay out all the data structures
Build methods which manipulate those structures (think getters and setters)
Then build machinery which operates upon those structures using those methods,
like game loops, cooldown timers, and status effects
Then develop a way to present it to the player using UIs, visuals and
graphics, narratives, sound, all that junk that's probably someone else's job
anyway
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════════───────────────────────┘
--- #15 fediverse/3299 ---
═══════════════════════════════════════════════════════────────────────────────────
what if we could record and playback certain timeframes of our CPU and RAM
status and use it for debug purposes
like running some code in a VM every time you wanted to show a youtube video
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════───────────────────────────┘
--- #16 fediverse/1602 ---
╔═══════════════════════════════════════════════════───────────────────────────────┐
║ @user-1037 │
║ │
║ those all seem really cool though! They all kinda have the same basic UI tho, │
║ kinda feel like there's opportunities for different kinds of expression. Like, │
║ in game design there's a lot of different genres, and yeah sidescrollers │
║ include mario and sonic but they're both very different experiences. So too │
║ perhaps could we interact with our computers by programming them in more │
║ engaging ways. │
║ │
║ they say some people are visual learners, others need to be taught, some │
║ people need to watch someone else doing it, and a few might just learn by │
║ plugging their brains into a computer and downloading a black belt in kung fu. │
║ │
║ Maybe typing long paragraphs of logic makes sense for some people, I know for │
║ most it doesn't come naturally. Maybe some people are more used to like, │
║ looking at maps that you can examine at different levels of abstraction. Like │
║ players who play Paradox games zooming from a national perspective to states │
║ and individuals and all the other things they might want to strategize using. │
║ Or m │
╟─────────┐ ┌───────────┤
║ similar │ chronological │ different │
╚═════════╧════════════════════════════════════════────────────────────┴──────────┘
--- #17 fediverse/5850 ---
══════════════════════════════════════════════════════════════════════════─────────
@user-1074
if you'd like I can give you a lua script which will take your fediverse
archive and turn it into a pdf which you can edit or print or whatever. Might
be a fun diversion from posting. You can reply to yourself, add
clarifications, change some things, put things in a new light, add context,
etc... before you know it you'll have something printable. Could even pull out
your best stuff and make zines.
should require just a little configuration to suit your setup. That's part of
how I stay "productive" without posting all the time.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧═══════════════════════════════════════════════════════════════════────────┘
--- #18 fediverse/3226 ---
═══════════════════════════════════════════════════════────────────────────────────
if your man page is longer than a list of options and their usage and a
paragraph or twenty of how to use the software... then you need to abstract,
and break your code into multiple purpose-built applications.
do one thing, and do it right. alternatively, do one set of things, and do
them concisely.
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════════════───────────────────────────┘
--- #19 fediverse/849 ---
╔══════════════════════════════════════════════────────────────────────────────────┐
║ wish there were ascii characters that took up more than one line of code │
║ vertically. │
║ │
║ wonder if we could use a sorting algorithm, or markup language, or something │
║ like that to organize less structured data along user-customizable rules. │
║ Like, a code editor that worked with your ideas, rather than the strict │
║ expression of your text. You could pretty much write in any language, even │
║ pseudocode, and the LLM behind the scenes would translate whatever you wrote │
║ into whatever result you needed. Writing Rust, but need to fit in with C code? │
║ No worries it'll translate for you. As long as the end result is functionally │
║ the same, which could be verified by running two separate VMs that ran │
║ interpreters every time you saved. And as long as their translation layers │
║ matched completely, then odds are they're the same. And if not, well, the │
║ programmer can always debug it. It's not like this would be running on │
║ something that needed to perform in the moment? Like, improv instead of │
║ tragedies, or battles instead of strategies │
╟─────────┐ ┌───────────┤
║ similar │ chronological │ different │
╚═════════╧═══════════════════════════════════─────────────────────────┴──────────┘
--- #20 fediverse/895 ---
═══════════════════════════════════════════════────────────────────────────────────
most video game ideas suck
most of the time they're like "oh what if we had a racoon who found a magic
hat and saved the world from sentient apple blossoms"
that's not a game idea, that's a painting
a game is mechanics, and you can use the aesthetic to justify the mechanics,
but not generally the other way around.
the art isn't bad, but the art isn't the game. a game idea is "what if
tic-tac-toe had an extra square in the center" or "what if chess was played
with checkers, to hide your moves from your opponent"
there have been thousands of super mario bros. if games were designed as an
API, we could use whatever visuals we wanted, and those could be copyrighted
and sold if you really want. but mechanics are the basis for everything they
are built on, so doesn't it make sense to separate the two? abstracting the
logic such that two complementary functions are accomplished, [see code editor
idea], more flavors of game could be produced.
rulesets can be switched in and out too, as an API is just an engin
┌─────────┐ ┌───────────┐
│ similar │ chronological │ different │
╘═════════╧╧════════════════════════════════════════───────────────────────────────────┘
|