Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
idk it doesn't sound all that retarded
they say it only allows letterlike and numberlike unicode characters though. that prevents names like:
Code:
> (define 🌽 'corn)
> 🌽
corn
idk I just don't want to look up Cyrillic characters in the middle of reading a program
Do "best practice" but that's always a guideline. Use docstrings and type hinting. Keep in mind how Python manages data. For example, list comprehension is faster than traditional looping but can get ugly fast.
Generators (with yield) can be much more readable than the generator variant of list comprehensions and are more memory-efficient than just coming up with a big list
The various math libraries people like to use have nuances you just have to learn about.
One thing every beginner should know, regardless of language: don't represent decimal currency with floating-point numbers

Really nice video from Brian Kernighan BTW
 
Computer scientists are 90% trannies it is unbelievable.
It's to the point where if I hear something like "She is a computer scientist" I instantly know it's a troon.
Very strange time we live in.

idk I just don't want to look up Cyrillic characters in the middle of reading a program
I draw your attention to the world of Russian programmers. There you will find all manners of schizophrenic esotericism that you only got a sampling of with Terry Davis.
 
Computer scientists are 90% trannies it is unbelievable.
It's to the point where if I hear something like "She is a computer scientist" I instantly know it's a troon.
Very strange time we live in.
I honestly despise this reality. 13 years ago it wouldn't have been much of a problem for me, with a "live and let live" mindset, yet people change.
I have more respect for farmers, construction workers, plumbers, mechanics electricians, et al. They are essential and you will always need them.

Not to throw shade to the Kiwi programmers & other enthusiasts.
 
I draw your attention to the world of Russian programmers. There you will find all manners of schizophrenic esotericism that you only got a sampling of with Terry Davis.
In fairness I can recognize most Cyrillic characters by their relationship with Greek which of course I recognize as math symbols. Sometimes I can pick out cognate nouns and names of people.
I used to own the set years ago (whatever the set consisted of back then, anyway) but after a few moves I've misplaced it. I'm so annoyed at myself for it.
Here's what I have (no fascicles):
Code:
Art of Computer Programming, The, Volume 1 (Fundamental Algorithms), 3rd Edition.djvu
Art of Computer Programming, The, Volume 2 (Seminumerical Algorithms), 3rd Edition.djvu
Art of Computer Programming, The, Volume 3 (Searching and Sorting), 2nd Edition.djvu
Art of Computer Programming, The, Volume 4a (Combinatorial Algorithms, Part 1).pdf.xz
 
the only good case is kebab-case but it's good to use the local convention in languages with braindead infix syntaxes that don't let you use actually good identifiers because somebody thinks the stylistic mistake a-b should be treated as a subtraction and not an identifier (s-expression languages sidestep the issue by not having any infix operators at all)
I wouldn't be too proud of that, since COBOL also allows hyphens in identifiers (it also allows identifiers to start with digits, and some members of the committee wanted to allow them to consist only of digits if you wanted, so that an inventory program could use actual catalog numbers as identifiers, but they settled on a compromise position where there has to be at least one letter in there).

Of course, the best answer to the identifier question was provided by Forth, where any run of non-whitespace characters can be an identifier (and if there's no definition, an attempt will be made to parse it as a numeric literal). It's the only language where this sort of thing is a legal program, which is why I'll always love it (even if it's not really a practical language):
Code:
: ~o CR ." HELLO, WORLD" ;
: 8==D ~o ~o ~o ;
8==D ~o ~o ~o
 
Of course, the best answer to the identifier question was provided by Forth, where any run of non-whitespace characters can be an identifier (and if there's no definition, an attempt will be made to parse it as a numeric literal). It's the only language where this sort of thing is a legal program, which is why I'll always love it (even if it's not really a practical language):
Is Forth really not practical? From what I've seen I wouldn't want to use it directly for the most part but it looks like there have been a number of OS kernels written in Forth. In that case, I'd want enough Forth to make something like C possible and then use C to make Python etc. possible.
 
In fairness I can recognize most Cyrillic characters by their relationship with Greek which of course I recognize as math symbols. Sometimes I can pick out cognate nouns and names of people.
If you fancy Bible study in Koine Greek (with a dictionary), you have a head start with Cyrillic, indeed. But that's something else, since Cyrillic has evolved with more letters - plus we are talking of a different topic entirely.
Here's what I have (no fascicles):
Thanks for the recommendation, as well!
 
Computer scientists are 90% trannies it is unbelievable.
It's to the point where if I hear something like "She is a computer scientist" I instantly know it's a troon.
Very strange time we live in.


I draw your attention to the world of Russian programmers. There you will find all manners of schizophrenic esotericism that you only got a sampling of with Terry Davis.
I must be lucky then. After a few years at my current office I've seen way more competent female devs than I've seen trans employees working here. The few I have seen were either interning or on contract from another company.
 
So last week, I was in Bongland visiting friends (and hung out with a Kiwi while I was out there).

I got back Monday, drank for a few days and I'm sorta now getting back to my routine. I really should get jobhunting again, so yesterday I talked to some borderline incomprehensible jeets. Including answering some terrible quizzicles about pointless technical nuances about web languages.

"uhh, what's the difference between a package and a module in golang?" "what's the difference between an array and a slice in golang"

(Frankly, as an established programmer with a decade+ of experience in professional development, I reserve the right to be uptight and crotchety about knowing every spergy little detail about your new pet webshit language's terminology. That being said, I think I got the package/module question wrong and I think I got the array v slice question right, which is probably the least petty and most job-relevant combo to fuck up. Slices and arrays will actually affect performance, your algorithms and your code equality. Package v module is a vocabulary quiz.)

Anyway, I also got back into my game/opengl dev stuff. Was a little rusty yesterday and this morning, but I'm getting into it again.

The part that I'm at right now is probably the most "computer sciencey" part of a project like this. Everything else before this point was just a matter of code design, making stuff readable, and reading APIs and documentation and applying them properly.

I'm working on something to render 2d sprite graphics from spritesheets using OpenGL. For those who aren't familiar, OpenGL is a 3d rendering API, not a full fledged 3d engine. One aspect of OpenGL is that as you draw 3d elements, it draws it to the framebuffer which ultimately will get shown on the screen. Naturally, you're going to want to have items closer to the screen (in the case of 2d, backgrounds vs characters) obscure things that are spatially behind them. In order to do this, OpenGL's approach is really just to draw things in reverse order and draw the later stuff over them. Sometimes for efficiency they'll use a z-buffer, but that's just a specialization of the same concept.

So you need to sort your graphics and draw them in order, further ones first. (This is especially important if you've got any semi-transparent things, so like tinted windows need to shade the things behind it.)

So my little 2d tile manager library maintains an xy position for each tile, because it's 2d. But actually, internally, it has a full xyz coordinate, and the z is for depth for rendering. You can use the full tile-position function to set/get it. But you'll probably want to use tile-position/xy most of the time.

Most code will set the depth when the tile is first allocated and leave it as it is. But still, the rendering order for the objects in my OpenGL buffers will need to be kept sorted.

So I want to write an algorithm that maintain the sorted buffers. You give it your buffers and the index of the object that might've shifted, and it'll make sure the object to its left is nearer and the one to its right is further, if not, it should do some swaps (and as few swaps as possible, because any updates mean OpenGL calls) to reorder them.

Now this is the kind of thing that gets super in-the-weeds, and it's something I could see myself easily fucking up. So I'm implementing it as an extremely generic algorithm like this:
Code:
(define (vector-shift-sort-item! vect idx #!key
                                 length
                                 is-empty?
                                 less-than-or-equal?
                                 swap!
                                 )
  ...
)
All the keyword arguments are functions the caller needs to pass in. Those will be simple, simple functions to move some bytes around in OpenGL buffers, but for my initial development and testing purposes, I can run it with ordinary Scheme vectors.

And I've got a bunch of tests like this:
Code:
      (add-vect-shift-test!
       name-suffix: 'left-min-equal-neighbor
       idx: 0
       in-vect:
         (vector
          (make-item value: 0.6 key: 'a)
          #f
          (make-item value: 0.6 key: 'b)
          (make-item value: 0.7 key: 'c)
          (make-item value: 0.8 key: 'd))
       out-vect:
         (vector
          (make-item value: 0.6 key: 'a)
          #f
          (make-item value: 0.6 key: 'b)
          (make-item value: 0.7 key: 'c)
          (make-item value: 0.8 key: 'd)))
So because the function itself has a very functional (in the sense of lots of use of functions as an interface, not in the sense of not using side-effects) interface, I can make up these completely bogus test cases and make sure it's working.

The key, btw, is to make sure there aren't unnecessary swaps when the value is equal. That's what this is testing. Sorting for a shouldn't require any changes, because the next item to its right, b, has the same value. No reason to float it "above" bif they're equal.

I just started this and I have some basic cases like the above working. The more complicated ones will take a bit. I'll need to have a bunch of tests by the time this is done.
I must be lucky then. After a few years at my current office I've seen way more competent female devs than I've seen trans employees working here. The few I have seen were either interning or on contract from another company.
Occasional I meet competent female devs. Often they're jeets though.

Or I meet smart women with interests in computer adjacent stuff, although they often do stuff like data science that requires them to fuck around with stuff like Python, but they're not necessarily particularly great Python programmers specifically.
 
So you need to sort your graphics and draw them in order, further ones first. (This is especially important if you've got any semi-transparent things, so like tinted windows need to shade the things behind it.)
i think you can actually draw shit in a random order if you're using a z-buffer and enable a z-test mode in the rasterizer so things in the back don't get drawn when the renderer already drew some shit in front
it doesn't work with semi-transparent things at all but you can then use alpha scissoring to render as many transparent leaf textures as you want without making the gpu shit itself
so you technically can render out your sprites unsorted but there are quirks involved and for simplicity's sake it's probably just smarter to sort everything instead of having both the sorted translucent bullshit pass and the 1-bit alpha overlay pass
after all if you wanted real performance you would be using vulkan and some sort of insane shader to do all of this on the gpu or something
So because the function itself has a very functional (in the sense of lots of use of functions as an interface, not in the sense of not using side-effects) interface, I can make up these completely bogus test cases and make sure it's working.
oopniggers like making a shitload of classes for this and they call it "dependency injection" :smug:
 
i think you can actually draw shit in a random order if you're using a z-buffer and enable a z-test mode in the rasterizer so things in the back don't get drawn when the renderer already drew some shit in front
it doesn't work with semi-transparent things at all but you can then use alpha scissoring to render as many transparent leaf textures as you want without making the gpu shit itself
so you technically can render out your sprites unsorted but there are quirks involved and for simplicity's sake it's probably just smarter to sort everything instead of having both the sorted translucent bullshit pass and the 1-bit alpha overlay pass
after all if you wanted real performance you would be using vulkan and some sort of insane shader to do all of this on the gpu or something
Yeah, I've heard of some fiddly ways to pull it off. I suspect they're more feasible looks-wise with actual 3d, whereas I'm trying to go for pixel-art 2d.

The sorting stuff isn't too difficult. I'm just paranoid about fucking it up, so a lot of the work will just be churning out a bunch of tests and getting them to pass.

And yeah, maybe one of these days I'll pick up Vulkan.
oopniggers like making a shitload of classes for this and they call it "dependency injection" :smug:
Oh lol yeah, "structures with functions will blow your mind".
 
Yeah, I've heard of some fiddly ways to pull it off. I suspect they're more feasible looks-wise with actual 3d, whereas I'm trying to go for pixel-art 2d.
i think it would work well for 2d, your sprites just need to have 1-bit alpha (which is what the snes can do, so you can do quite a bit artistically)
it's just a thing you might want to do if you want to render too many sprites to sort on the cpu
then you enable z test and alpha scissor and shit out triangles in whatever order you like
 
So I want to write an algorithm that maintain the sorted buffers. You give it your buffers and the index of the object that might've shifted, and it'll make sure the object to its left is nearer and the one to its right is further, if not, it should do some swaps (and as few swaps as possible, because any updates mean OpenGL calls) to reorder them.
This sounds to me like a task a BSP tree could handle nicely. Maybe your needs are different though.
 
Getting back into programming recently with gamedev stuff has been funny because the things I've been working on have been giving me a really specific cross-section of issues. I've been doing some good learning, but the majority of it's been focused on initialization and race conditions. It feels like most of my thinking has been some permutation of "I should build a manager for everyone in this domain to register to so all the relevant entities are in one knowable and available place" because it's a pattern that seems to keep occurring.

Between that and figuring out phases of initialization (and making sure relevant dependencies are ready before registering to them), it seems like I've spent the last month or two just turning over problems in my head about the dance of dependency injection/registration, asynchronous "get the reference if it's ready, and if it's not, register to its delegate so it can tell you when it is" patterns and stuff like that.

Still, I'm happy to be fighting with these problems because I feel like I'm building a stronger intuition. These could all be super inefficient and basic answers to these problems, and maybe I could just go look up the best answers, but I feel like tackling them yourself gives you a little more pride and a lot more practice, you know?
 
Last edited:
Getting back into programming recently with gamedev stuff has been funny because the things I've been working on have been giving me a really specific cross-section of issues. I've been doing some good learning, but the majority of it's been focused on initialization and race conditions. It feels like most of my thinking has been some permutation of "I should build a manager for everyone in this domain to register to so all the relevant entities are in one knowable and available place" because it's a pattern that seems to keep occurring.
I don't intend to become a game dev but I think a lot of the patterns could be reused elsewhere. Got any recommendations?
 
Back
Top Bottom