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.
Rustaceans (and C++ devs too), it's time to take your estra/diol. It's a benchmarking library. You'll never guess what the developer of these identifies as.
Benchmarking library for Rust... Guess we know which benchmarking library Null will be using for testing Sneedforo.
 
  • Winner
Reactions: y a t s
Rustaceans (and C++ devs too), it's time to take your estra/diol. It's a benchmarking library. You'll never guess what the developer of these identifies as.
You know, I take it back, the web hipster Ruby libraries named after obscure Japanese words weren't actually all that bad.
 
Alright I have more free time. I am going to try and get into robotics and industrial machine design which involves a lot of hardware programming.

I would like to do hardware programming in something like Zig. I'd rather not do C and I'd rather do Assembly over C just because looking at C it seems like it has a lot of strange behaviors that aren't clear to a newbie and something like Zig or Assembly would be better.

I'd say i'm pretty damn familiar with Python and I know a decent bit about your algorithms and data structures. I have been exposed to the concept of memory management as well though I've never needed to do it.

Any thoughts for first projects or first things to try? There is value in writing something like a graphics engine or something like a graphics engine that has a bit of added functionality similar to a game engine. I mention this specifically because it might come in handy for another project that I would like to do eventually.


Before I do any of this I am probably going to play a decent bit of TIS-100 as a good introduction to assembly and low level programming.


Eventually I am going to get to a point where I am going to be doing stuff with a simple computer like a rasberry pi and a motor attached to some kind of robot arm. But before I do that and start buying stuff I'd like to get the basics of hardware programming down. The stuff I want to do with robotics is unique enough that I don't want to just rely on scripting either. I should do the hardware programming so I can make it exactly as I want to.
 
Rustaceans (and C++ devs too), it's time to take your estra/diol. It's a benchmarking library. You'll never guess what the developer of these identifies as.
Benchmarking library for Rust... Guess we know which benchmarking library Null will be using for testing Sneedforo.
What a fucking joke of a language :story:

This is the exact sort of shit that makes it impossible to take Rust seriously.

I would like to do hardware programming in something like Zig. I'd rather not do C and I'd rather do Assembly over C just because looking at C it seems like it has a lot of strange behaviors that aren't clear to a newbie and something like Zig or Assembly would be better.
Maybe I'm missing the point, but assembly will always be more "strange" than C in terms of behavior, particularly if you're writing it for unconventional hardware. Assembly is fun, and I don't want to discourage anyone from learning it, but start by learning C. There's a good reason why people call C "portable assembly".
 
I'd rather not do C and I'd rather do Assembly over C just because looking at C it seems like it has a lot of strange behaviors that aren't clear to a newbie and something like Zig or Assembly would be better.
What yats says. Plus development time is a lot quicker in C than asm. You'll start something in asm then get frustrated that it's taking forever to make any progress.
 
Maybe I'm missing the point, but assembly will always be more "strange" than C in terms of behavior, particularly if you're writing it for unconventional hardware. Assembly is fun, and I don't want to discourage anyone from learning it, but start by learning C. There's a good reason why people call C "portable assembly".
I would rather learn Zig over either but I talked to people who have learnt C after learning something like Python or Java they tell me there can be really strange things going on that you don't really understand until you have really learnt the language.

I've heard Zig is much better in this regard and I've heard Senior Developers recommend it for Newbs trying to learn a procedural language for hardware programming after they learn an interpreted language like Python.
What yats says. Plus development time is a lot quicker in C than asm. You'll start something in asm then get frustrated that it's taking forever to make any progress.
ASM is good to learn even if it is just for like 10 hours or so because you can understand how memory works on a very fundamental level.

ATM I'm just doing some basic stuff before I start any of the actual hardware stuff to make it easier when I start doing hardware stuff.
Rustaceans (and C++ devs too), it's time to take your estra/diol. It's a benchmarking library. You'll never guess what the developer of these identifies as.
This, the difficulty, and long compile times are really the things holding rust back. The Rust Foundations and a lot of the people who use Rust really are not doing that language any favors in terms of being adopted for actual use.
 
Maybe I'm missing the point, but assembly will always be more "strange" than C in terms of behavior, particularly if you're writing it for unconventional hardware. Assembly is fun, and I don't want to discourage anyone from learning it, but start by learning C. There's a good reason why people call C "portable assembly".
I disagree. Only at the first glance I'd put C as "portable assembly". Problems which are worse than necessary:

  • Everything about the preprocessor. Transitive headers. Defines overriding imported stuff and more.
  • And while one can use the preprocessor to define generic types it isn't exactly handy or easy to use in editors/ IDEs
  • The build system. You probably start with make, but after that we have cmake, xmake, meson, visual studios own thing, XCode.
  • Importing other projects. Sure, the direct way is to just put "apt install curl" in the README, but it's very annoying when compared with any other language where it's established to list dependencies in the build system.
  • No native error type. One half of projects having 0 as success return type and the other having 1 as that isn't cool and then building your own error handling with labels and gotos isn't that cool tbh. And then always having to propagate results with pointers in the arguments isn't either
I'm a bit torn if strings are char pointers with the nul terminator should be listed here, as one can work around it in their own project. But the entire ecosystem works the other way.
Any thoughts for first projects or first things to try? There is value in writing something like a graphics engine or something like a graphics engine that has a bit of added functionality similar to a game engine. I mention this specifically because it might come in handy for another project that I would like to do eventually.
Hm, I'm a bit torn. At least I have always struggled getting back to lower languages like Zig or C after working in Python and Javafor long, just because there are less helpers or the helpers aren't as easy to integrate.

At what level are you thinking? Linking against SDL2? Or more linking against X/ wayland and operate that way?
 
I would rather learn Zig over either but I talked to people who have learnt C after learning something like Python or Java they tell me there can be really strange things going on that you don't really understand until you have really learnt the language.
I don't know exactly what strange things they're referring to, but it's a fair bet they'd also apply to assembly. Really, don't touch asm until you're comfortable with C.
Zig's not a serious language, there's nothing written in it.
 
Something you may not have thought about is compatiblity with drivers in robotics. It's all fine and good and easy to make things light up on an Arduino or a Raspberry Pi using Python or assembly. The issue is that as you extend past your microcontroller hardware, drivers written by the manufacturer or community for other devices tend to be written in C. For example, I once worked with a sensor that didn't come with a signal documentation. It did however come with drivers in C which I used.
 
don't touch asm until you're comfortable with C
I wouldn't recommend touching assembly blind, but if you find a decent course or video on it, understanding assembly can do a lot to contextualize what C is doing and understand why the language's rules are what they are (and why certain things that might seem illegal actually arent, like switching into the middle of a while loop)
 
Only at the first glance I'd put C as "portable assembly".
I intended it as a surface level statement, as do most others who call it that. It's "portable" in the sense that you don't need to learn 100 different flavors of assembly to make a program that works across multiple CPU architectures. Cross-platform work was arguably the main impetus behind the language's design and creation. Any application of the descriptor beyond that becomes an argument about compiled languages as a whole and levels of abstraction, and that's not really how it was intended. I don't really see how those 5 points challenge this idea as opposed to just being valid criticisms of the language itself. Perhaps it's a matter of how I'm interpreting this. As big of a pain in the ass as C can be at times, assembly cranks up these problems to their logical and practical extremes.

Regardless, I have some thoughts on a few of those points:

Defines overriding imported stuff and more.
Isn't that what #ifdef and #ifndef are for?

And while one can use the preprocessor to define generic types it isn't exactly handy or easy to use in editors/ IDEs
C, with its relatively minimal levels of abstraction (even compared to C++), doesn't lend itself well to the idea of generic types. C is best when it's predictable, and the same goes for assembly. This is kind of the whole point of the language, and is one of the numerous factors that make C++ a sort of antithesis to C as opposed to an extension of it.

Importing other projects. Sure, the direct way is to just put "apt install curl" in the README, but it's very annoying when compared with any other language where it's established to list dependencies in the build system.
I agree to an extent. A lot of these language-specific dependency managers are complete trash (e.g. pip) and often promote centralization. While most dependency managers support third-party repositories, almost no one actually uses them in practice, and they inevitably die from lack of adoption. This promotes dictatorial mindsets that lead to disgusting shit like crates.io and their thick, robust CoC.

I bring up crates specifically because Rust's very design strongly discourages anything but strict conformity to a set of rigid and subjective policies, and this mindset is pervasive among their community. They even outright say in their first paragraph on the page I linked that they're a "critical resource for the Rust ecosystem".
Rust trannies said:
Short version: crates.io is a critical resource for the Rust ecosystem, which hosts a variety of packages from a diverse group of users. That resource is only effective when our users are able to work together as part of a community in good faith. While using crates.io, you must comply with our Acceptable Use Policies, which include some restrictions on content and conduct on crates.io related to user safety, intellectual property, privacy, authenticity, and other limitations. In short, be excellent to each other!
The broader, more vocal parts of the Rust community react with hostility to anything that disrupts their illusion of consensus. Polemics is core to Rust's philosophy, and it has resulted in one of the most famously hostile communities in CS. I don't want to get political in a post about programming, but it's unavoidable when talking about newer languages like Rust; this is the very problem.

That said, dependency management can be done well. I think Go's is fantastic, and I believe this is a good illustration of it. Go's packaging system simply indexes public git repositories, and you can just directly link to repositories you want to include in your project without anyone telling you "No. Fuck off, you hateful piece of shit."
 
Something you may not have thought about is compatiblity with drivers in robotics. It's all fine and good and easy to make things light up on an Arduino or a Raspberry Pi using Python or assembly. The issue is that as you extend past your microcontroller hardware, drivers written by the manufacturer or community for other devices tend to be written in C. For example, I once worked with a sensor that didn't come with a signal documentation. It did however come with drivers in C which I used.
This is ultimately a fatal point I think. This means I basically have to learn C. Well thanks this is part of the reason I asked the questions I did. I wanted to learn this stuff sooner rather than later.
Zig's not a serious language, there's nothing written in it.
Uber uses Zig as does Tiger Beetle which is one of the fastest databases around for certain things. You are right that it has a really low adoption rate though and I don't think there is any hardware that uses it for example.

But I'm doing my own thing if the thing @macrodegenerate mentioned wasn't true it wouldn't matter.
I wouldn't recommend touching assembly blind, but if you find a decent course or video on it, understanding assembly can do a lot to contextualize what C is doing and understand why the language's rules are what they are (and why certain things that might seem illegal actually arent, like switching into the middle of a while loop)
There is a videogame by Zach Barth(Zachtronics) called TIS-100 that would function as a great introduction to this concept which is why I'm not too worried about touching ASM. I have been in many a situation in other subjects where knowing the underlying reason things are the way they are is very helpful. In addition I tend to learn better when I can see the whole picture.
At what level are you thinking? Linking against SDL2? Or more linking against X/ wayland and operate that way?
Probably SDL2 I'm building this not for a windows machine but for android though. I managed to find one of the actually useful things VR/AR could do but I am sick and tired of trying to make it work with Unity and if I want to do anything that a company could ever use I would need it to not be in Unity. I'm not working on that project atm but If I build skills that eventually help me that would be good.
 
There is a videogame by Zach Barth(Zachtronics) called TIS-100 that would function as a great introduction to this concept
I disagree I have found it gamifies it in weird ways that aren't a problem you have to deal with in real life and make it feel crippled compared to what it really is. Learning real assembly would in general be a much better idea.
 
Fucking regex is so confusing. I'm trying to make a palindrome checker that ignores special characters so my function only reads the letters in the string and I just can't figure out how it works because I'm so god damn fucking retarded.

I have a function that reversed the string with a for loop that works.

If you type in a palindrome it will tell you that it is indeed a palindrome.

But I'm trying to make it so if you put _racecar or ey.e or something like that into the text input, the function will still return nigger.innerText = `${word} is a palindrome`;

I've learned most of the basics to this bullshit and Im almost to the point that I might be able to start doing freelance work, but this fucking regex bullshit is making me feel like I'm literally too fucking stupid to be a programmer.

:lossmanjack:

Fuck my life dude...god. fuck my life. Im gonna Fuck dude! Fuck my life dude!
Dude fuck my life. Im gonna fuck! Fuck my life dude! Dude fuck my...DUDE! IM GONNA ...FUCK A DUDE!
 
Fucking regex is so confusing. I'm trying to make a palindrome checker that ignores special characters so my function only reads the letters in the string and I just can't figure out how it works because I'm so god damn fucking retarded.

I have a function that reversed the string with a for loop that works.

If you type in a palindrome it will tell you that it is indeed a palindrome.

But I'm trying to make it so if you put _racecar or ey.e or something like that into the text input, the function will still return nigger.innerText = `${word} is a palindrome`;

I've learned most of the basics to this bullshit and Im almost to the point that I might be able to start doing freelance work, but this fucking regex bullshit is making me feel like I'm literally too fucking stupid to be a programmer.

:lossmanjack:

Fuck my life dude...god. fuck my life. Im gonna Fuck dude! Fuck my life dude!
Dude fuck my life. Im gonna fuck! Fuck my life dude! Dude fuck my...DUDE! IM GONNA ...FUCK A DUDE!
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems"
On topic, if you have a functioning palindrome checking function, simply sanitise the string/strip all the symbols from it before feeding it into that function?
 
On topic, if you have a functioning palindrome checking function, simply sanitise the string/strip all the symbols from it before feeding it into that function?

I was trying to do that but you still have to use a regular expression. Atleast, I'm pretty sure you do.

If I can't figure it out I'll probably just do something niggerlicious like making an entire array with the alphabet in it, and using a loop to check each character in the string against the array because fuck regexpressions.

Edit: In fact. I might just sit down and write the niggerlicious array string function tomorrow as a shitpost.
 
I was trying to do that but you still have to use a regular expression. Atleast, I'm pretty sure you do.

If I can't figure it out I'll probably just do something niggerlicious like making an entire array with the alphabet in it, and using a loop to check each character in the string against the array because fuck regexpressions.
What language are you working in? You mentioned .innerText before so I will assume HTML/JavaScript. You can do as you have mentioned here and simply do a for loop over an array of 'accepted' characters.

You could also use a regex directly on the string.replace() function with
Code:
/[^a-zA-Z0-9 ]/g
as the pattern. That would match and replace (with nothing) anything that IS NOT a letter/character or number, including a " "/space character. This is from a quick google as no one should ever know how to do regex from memory as that would make them tainted.
 
Back