Programming thread

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
@Rusty Metal Skull Gun @std::string @macrodegenerate @y a t s @Kosher Dill @Creative Username Just wanted to say thank you for looking over and critiquing my code! I’m still really new to C so I can be extremely retarded at times. But really appreciate the feedback.
IMG_6188.jpeg
In the meantime, someone reminded me of Raylib and I know there’s a c library version of it. So that could be cool to mess around with.
 
lol one big takeaway from my time working in math and CS is that averages and the law of large numbers are more much powerful than many people think. I run into a lot of similar problems when doing signal processing work.
Have you read Oswald Spengler? He thinks certain ideas are a product of the age in which it is developed and you can characterize an age by the ideas it develops including for math and science. I kind of agree somewhat but Spengler is a bit too autistic and extends this every Civilization ever with a repeating pattern rather than something for one or a couple civilizations.

But getting into what you said probability comes up all the times and is the fundamental basis of thermodynamics. Low level thermodynamics for small amounts of particles is all probabilistic. And the thing about that is once you describe enough of the behavior of particles at a low level the laws of thermodynamics that you would use for normal everyday problems like engines emerge from that behavior as rules.

Tolerancing and Quality control are just this stuff as well.

This is a different concept but I'll never forget that physical spring mass systems are expressed mathematically as the same as inductors, resistors and capacitors.

I see CS people come up with similar solutions to things and talk about similar problems they have to the stuff I deal with in the more "traditional" engineering realm.
I was thinking that if this thread keeps growing, it becomes harder to pick out good bits of discussion around particular problems like this. Some really good nuggets of wisdom could get buried.
This is a good suggestion. This might end up being especially useful if Null ever restarts the Kiwi OSS forum software project. I might participate especially if I could use a language like GO which I've heard is close to python in some ways. Judging from this thread there are enough people here who could contribute.

Starting with the ideal gas law then looking at more complex deviations. Or starting with basic Mendelian genetics then moving on to stuff like pleiotropy and sex linkage. I don't see why programming should be any different. I don't think starting with something like C++ is good pedagogy. It's putting the cart before the horse. I can't help but think of the Cold War-era response to Soviet threats in all areas including educational outcomes by teaching set theory in grade school.
This is the way things are supposed to be done. I really like lecturers who do this but it is much rarer than it should be. I find this to be doubly true for things like Engineering because you can make way more money doing things as opposed to teaching, so those subjects don't always get great people.

Also in reference to something talked about earlier this allows for the creation of recursive elements in the understanding of knowledge. Recursion is in well told stories as well. The author will tell you what will happen with a small tiny thing and then the author will tell you again and again in a gradually increasing way until they reach the end where everything is revealed clearly.
1712469734996.png


I did a lot of AI math in my work in the time leading up to me quitting out of a sense of bring about our doom lol
I don't agree with this at all. Compare AI to non-linear regression used for something like probabilistic scheduling. You won't find a clear difference between the two. In fact the place "AI" is most practically and monetarily useful is for things like this. I know of a guy that is trying to use deep learning models to figure out when machines will need maintenance with a high degree of certainty for a certain window. If he succeeds it would be incredibly useful because it would allow companies to prevent a lot of down-time especially for certain industries.
 
The recent discussion about splitting this thread made me do a bit of thinking. I've noticed that this thread has a few distinct subtopics:
  1. General programming discussion and sperging (talking about various algorithms with a dash of "YOUR LANGUAGE IS GAY MINE IS THE BEST IT HAS NO FLAWS SHUT UP SHUT UP SHUTUPSHUTUPSHUTUP", this thread's ideal purpose IMO)
  2. People posting what they're programming at the moment (Not code reviews. I think it could probably continue being part of this thread. I think there's a distinct thread for that already?)
  3. People needing help with certain difficult problems (A thread/board for this would be nice)
  4. People posting their code so a half-dozen random pedants can nitpick it aggressively (A thread/board for this would be nice, maybe the same thread/board as #3; I don't know)
Honestly if I could rearrange this forum to my whims I'd make I&T only for regular civilian-grade techsperging and add a new board called "Math, Science, and Programming" for threads like this one. Also a "Technical Q&A" for getting help with problems and requesting code reviews, using those tag thingies you see in certain other boards? I don't know.

Honestly, the thread's too small for shit like this. Or is it? Would the benefits of splitting offset the drawbacks? I don't fucking know lol.

Anyway this is stupid and I should shut up
 
Have you read Oswald Spengler? He thinks certain ideas are a product of the age in which it is developed and you can characterize an age by the ideas it develops including for math and science.
I haven't, but I'll definitely check out his writings; sounds cool.
Spengler is a bit too autistic
Spergler lol

But getting into what you said probability comes up all the times and is the fundamental basis of thermodynamics. Low level thermodynamics for small amounts of particles is all probabilistic. And the thing about that is once you describe enough of the behavior of particles at a low level the laws of thermodynamics that you would use for normal everyday problems like engines emerge from that behavior as rules.
This reminds me of how Newton was able to effectively derive relativity at low speeds when he came up with his classical mechanics. Einstein later came along and showed that you could arrive at Newton's work once you plug in the right values to Einstein's more general equations that work at bigger scales. One scientist crawls so another may fly by jet pack some day.

This might end up being especially useful if Null ever restarts the Kiwi OSS forum software project.
I would love having the old self-hosted git repo up again on here. I have some ideas for improving things like SneedChat and KiwiFlare after having worked on writing tools for both and getting familiar with their workings. I have never seen the SneedChat source, but I am pretty confident I understand its functionality enough to rewrite a clone of it. I made an open and long standing offer to Jersh to help out with programming stuff like that back when I joined, so the ball is in his court.
I might participate especially if I could use a language like GO which I've heard is close to python in some ways
Go is really enjoyable to write. It's a C-like systems language made by a group of C++ haters, and it has a lot of the flexibility of things like Python with its garbage collection. I like how the language design still largely retains the spirit of the C language, and it makes it easy to reason about what you're writing if you're a seasoned C developer. At the same time, it's not super inaccessible to people used to languages like Python instead.

Based on the way you described OOP and wanting to work on things in small chunks, I think you would like the quasi OOP it has. It sticks more with the Unix philosophy of doing one thing and doing it well, and encourages breaking up your problem into those modular bits. There are some exciting projects for ML stuff with Go. I haven't looked into them much, but I want to. I assume they make heavy use of C bindings, similar to the Python ML projects.

I don't agree with this at all. Compare AI to non-linear regression used for something like probabilistic scheduling. You won't find a clear difference between the two. In fact the place "AI" is most practically and monetarily useful is for things like this. I know of a guy that is trying to use deep learning models to figure out when machines will need maintenance with a high degree of certainty for a certain window. If he succeeds it would be incredibly useful because it would allow companies to prevent a lot of down-time especially for certain industries.
You make a good point. With all science, there is a nuance with the implications of research where a researcher's well-meaning work could get used to do arguably bad things for mankind or the world as a whole. On the same coin, we have miracles like modern medicine; we can literally take the heart out of one person and put it in another with fairly minimal long-term complications. I still think AI is an incredibly fascinating field of research, and I still do some hobby work on it, but I see it quickly being used at a rapidly accelerating rate as financial and political interests start focusing on it. I got very blackpilled over time about the powers that be and what kind of research actually gets interest and funding.

With all of the generative models we have now, there is a massive incentive for large organizations (corpos, governments, etc.) to develop them better and more quickly than their competitors. Even if we in the west somehow ended up joining hands and singing Kumbaya as we burn OpenAI to the fucking ground, there's nothing stopping the typical world bogeymen like Russia or North Korea from developing advanced AI systems they can weaponize against other countries. They can erode public trust in videos, photos, and audio used for evidence; they can weaponize AI to better hack banks and infrastructure to help fund their programs; they can eventually figure out AGI and effectively create a god on Earth. That's only scratching the surface.

I want these things to be used for good, but it's naïve to think that everyone will keep all of the Pandora's boxes closed out of a sense of duty to mankind, future generations, and life on Earth as a whole. At the very least, I feel a lot better being an artist and contributing to society in that way instead. Oppenheimer, say what you will about him, did a very nice radio speech on the roles of the artist and scientist in society. I highly recommend listening to it. What I take from it and the context around him was that he was plagued by the idea of whether all of this "advancement" is actually adding anything in net to society.

Anyway, this is probably better suited for something under Deep Thoughts.

sperging (talking about various algorithms with a dash of "YOUR LANGUAGE IS GAY MINE IS THE BEST IT HAS NO FLAWS SHUT UP SHUT UP SHUTUPSHUTUPSHUTUP", this thread's ideal purpose IMO)
Based.

Honestly if I could rearrange this forum to my whims I'd make I&T only for regular civilian-grade techsperging and add a new board called "Math, Science, and Programming" for threads like this one. Also a "Technical Q&A" for getting help with problems and requesting code reviews, using those tag thingies you see in certain other boards? I don't know.

Honestly, the thread's too small for shit like this. Or is it? Would the benefits of splitting offset the drawbacks? I don't fucking know lol.
I agree. A concern of mine, which I expressed to a degree in my KiwiOverflow proposal a few posts ago, is that we would run out of things to talk about in this thread if we move that objectively constructive conversation about real-world problems to a separate sub-forum. I ended up considering this thread is probably another case of a general thread topic getting split up into an entire board. Internet & Technology is too broad to work for fragmented programming discussion, so a programming sub-forum is probably the best way to go.
 
Last edited:
I agree. A concern of mine, which I expressed to a degree in my KiwiOverflow proposal a few posts ago, is that we would run out of things to talk about in this thread if we move that objectively constructive conversation about real-world problems to a separate sub-forum. I ended up considering this thread is probably another case of a general thread topic getting split up into an entire board. Internet & Technology is too broad to work for fragmented programming discussion, so a programming sub-forum is probably the best way to go.
How about a thread in the programming sub-forum where people recommend resources and projects for beginner programmers? I made one but everyone started recommending compiler and hardware design projects (which aren't beginner friendly).
 
  • Agree
Reactions: y a t s
How do I force a worker to consume a task from a particular queue at runtime with celery? If I could do this, it'd solve 90% of the problem (I'd still need to watch and tune priorities). I don't need working code, please just point me to the celery feature that does this.
Here: https://docs.celeryq.dev/projects/k....transport.redis.Channel.queue_order_strategy

I think what you want is

priority (priority_cycle).

Consume from queues in original order, so that if the first queue always contains messages, the rest of the queues in the list will never be consumed from.
Though this is redis, I assume switching message broker shouldn't be a big deal though? or you could run a redis alongside rabbitmq, it's super lightweight anyway
 
  • Informative
Reactions: Safir
I propose spinning the programming thread off into its own sub-forum. Part of that programming section could be a Q&A style thing, call it KiwiOverflow, for discussing specific problems and general concepts in a way that's easier to browse than searching through a single megathread.
The Forum Discussion suggestion has now been made. The full post has some extra details and the rationale; I'm only quoting the first bit.

How about a thread in the programming sub-forum where people recommend resources and projects for beginner programmers? I made one but everyone started recommending compiler and hardware design projects (which aren't beginner friendly).
I like the idea. My project ideas come out of some necessity, and I don't always have the time to start them. It would be nice to collect ideas that pop up from time to time like that in case someone wants to take the initiative. Collecting resources would be really useful as well.
 
Never tried it, but it looks interesting as a concept. In a practical learning sense, I would just use a different language with that familiar ALGOL-inspired syntax that has more widespread, mainstream use. Depending on your level of comfort, consider picking something that will handle essential memory management for you.
I'm a noob so excuse my boomer questions but does that mean langs like python or C do memory management better (and lessen the workload for a new programmer?
I'm one of the few Dart fans out there. I think it lives in roughly the same niche as Python. Good for basic high level stuff. Easy to write, you can write it quickly, and it's easy to understand. I also enjoy using it.

However, I will say this: unless you plan on using Flutter, it's probably not worth learning. There are other languages out there that are approximately as good and fill the same role while also being more popular and thus easier to get help (and jobs) with.

I would really recommend Flutter if you plan on getting into cross platform app development though. It's the least shitty of the options, I think. As soon as I started using it my productivity increased noticeably. It does definitely have some really bizarre quirks you need to work around, but so does every cross platform solution.
I thought Dart and Flutter were the new cool kids and had a big userbase already because of being made by google and allowing mobile and desktop development kinda-seamlessly (from what I've read). If the oldies are still better on the support front, I'll choose between them instead. I guess its pointless to want to "learn programming" with no clearer goal behind it but since I'm not sure about making a job out of it, my main first goal would be to release a small game or app, cross platform if possible but its not a priority as long as its desktop first.
tbh C++ as a first language is entirely doable these days and forces you to deal with heinous shit almost immediately. That's usually what I recommend to people who I know won't give up easily.
I always try to make this point to prospective learners when they ask for language suggestions. Starting with one of the "main" languages helps with getting the hang of the skills that carry over to other languages and builds that intuition, and having plenty of existing reference material certainly helps.
And @The Ugly One @Doubly Punished Snigger
Yeah, actually there's a trap here. C++ Crash Course is the best book I've seen for modern C++ and it should be accessible even if you're new to programming.
I always try to make this point to prospective learners when they ask for language suggestions. Starting with one of the "main" languages helps with getting the hang of the skills that carry over to other languages and builds that intuition
This is the conundrum I've had every time I've thought about learning; I don't want to start something too complex that I'll just seethe at and quit but I don't want to learn something that's only useful for gimmicks. I've even gone through book recommendations and have read about the C++CC book. I understand that cumulative knowledge is what makes a good programmer but I don't want to learn something dead-end like HTML either.
 
  • Like
Reactions: y a t s
I'm a noob so excuse my boomer questions but does that mean langs like python or C do memory management better (and lessen the workload for a new programmer?
Memory management techniques all have trade-offs between efficiency, security, and ease of use. Languages that use garbage collection basically handle freeing allocated memory for you when it goes out of scope, but they are inefficient compared to well written C code where everything is done manually but in a hopefully sane way. Each are better for certain tasks, depending on resource requirements and typical use case.
 
I'm a noob so excuse my boomer questions but does that mean langs like python or C do memory management better (and lessen the workload for a new programmer?
That's the great thing about C. It doesn't do memory management, at all. It's all on you. It will either make you a better programmer or let you write code that will be hacked within 30 seconds of your first release or both.

Python does all the handholding and memory safety* It seems easier to me for novices as, like Perl before it, there's a minimal runtime environment, no compiler, no build system. It's just type the code and go. Make a quick venv and pip any packages you need.

*External libraries not guaranteed memory safe.
 
My project ideas come out of some necessity
Do you have any recommendations when it comes to intermediate projects in Python? I'm currently building a music player in Python and want some other projects to keep me occupied after I finish it. Preferably don't recommend any projects that have to do with compilers and hardware design.
 
  • Thunk-Provoking
Reactions: y a t s
Do you have any recommendations when it comes to intermediate projects in Python? I'm currently building a music player in Python and want some other projects to keep me occupied after I finish it. Preferably don't recommend any projects that have to do with compilers and hardware design.
Good question. Something I thought of starting recently was something that collects torrent search results from major trackers and gives an easy way to select them and add them to a torrent client all from the command line. And I could eventually add passive DHT result collection later on. Such a project means working with HTTP requests, possibly JSON, working with HTML parser libs, and perhaps some sort of TUI.

What do you think of Smalltalk
I like it and want to use it more. It has been a while.
I had the idea a while back to make a variant of it called Girltalk for the meme.
 
I thought Dart and Flutter were the new cool kids and had a big userbase already because of being made by google and allowing mobile and desktop development kinda-seamlessly (from what I've read). If the oldies are still better on the support front, I'll choose between them instead. I guess its pointless to want to "learn programming" with no clearer goal behind it but since I'm not sure about making a job out of it, my main first goal would be to release a small game or app, cross platform if possible but its not a priority as long as its desktop first.
Flutter is absolutely the cool new kid and definitely the best option for what it does, in my opinion. Dart, on the other hand, is basically just a vector for creating Flutter. People think brick houses are cool, but nobody thinks bricks are cool.

I absolutely would not attempt to make a game using Flutter, or really any cross platform solution except the ones specifically designed for games. Use something like Godot, Game Maker, Unity, etc. if you want to go that route. I've personally gotten a lot of mileage out of Game Maker, which has its own fully functional programming language that'll teach you some good skills that will transfer easily to basically any other OOP language.

Better yet, just don't worry about making cross platform apps straight away. Focus on one platform until you're comfortable with the process. Even the simplest thing in the world becomes ten times more complex when you need to design it for more than one platform, even with modern tools. Mobile development is significantly more of a pain in the ass than developing for computers, but it's also where all the money is so that choice is up to you.
 
I hate to be that guy, but the ~ operator in C is confusing me. Apparently, it’s one’s complement but it’s also some kind of mask? I want to try some of the exercises in K&R and one of them is the invertbits function. There’s mention of moving bits around but I’m not too sure what to do. Again I’m extremely retarded and I’m amazed I made it this far in life.
 
  • DRINK!
Reactions: UERISIMILITUDO
I hate to be that guy, but the ~ operator in C is confusing me. Apparently, it’s one’s complement but it’s also some kind of mask? I want to try some of the exercises in K&R and one of them is the invertbits function. There’s mention of moving bits around but I’m not too sure what to do. Again I’m extremely retarded and I’m amazed I made it this far in life.
~ is the bitwise complement.

For example, let's take the number 88. In binary (to 8 bits), it is 01011000. To take the complement of it, we flip each bit (i.e. 01011000 -> 10100111). So if uint n = 88, ~n == 167 if I did the base conversion properly in my head. Use caution when working with signed integers, as the sign bit will likely get flipped when you operate on individual bits like this.

Operating on individual bits is helpful when dealing with hex values and memory addresses. Masking is where you can use binary "masks" to isolate or operate on certain bits. An example would be a simple mask to get the lower 4 bits from a byte. We can do this by doing a bitwise AND between the value and 00001111. Since AND needs both bits per slot to be 1 to output a 1, any lower bits that are 1 get isolated with the mask. Endianness starts to matter here, but that's a topic for another post.
 
Last edited:
Back