[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: dpt_java.png (420 KB, 1000x850)
420 KB
420 KB PNG
What are you working on, /g/?

Previous thread was deleted
>>
>>106865000
nice trips for troon-free thread
>Previous thread was deleted
good
>>
>>106865000
Why did the last thread get deleted?
>>
>>106865000
Is there a way to actually implement a custom polymorphic allocator in C without violating strict aliasing rules?

The majority of real-world examples I've seen (such as Doom) are backed up by a large chunk obtained by malloc anyway, which works because of an exception in the standard: memory allocated via malloc, calloc et al has no "effective type" until you actually write to it.

But what if malloc isn't an option and your only choice is a static array? On an embedded project at work, we use a basic unsigned char array as the backend of a bump allocator and compile with -fno-strict-aliasing. In practice, this works, but DO-178 certification authorities are starting to get really anal about it. Is there truly no strictly conforming way?
>>
>>106865338
I don't know of a pure standards-compliant way to do it, but you shouldn't run into problems if you disable LTO and have your allocator function in a separate C file from the code that calls it.
Another option would be an inline ASM statement to "launder" the pointer.
>>
strict aliasing can fuck itself
>>
>>106865338
memcpy the allocator parts into each type
>>
File: 1741456890954722.jpg (135 KB, 1344x968)
135 KB
135 KB JPG
Why do these two always argue?
>>
>>106866972
>We deserve better.
jesus christ
>>
>>106866972
I think Theo has some pretty good accolades, but really his big hit was being a reply guy and making UploadThing which is just a really fancy wrapper for web tards.
>>
File: 1760296701819.png (145 KB, 1308x763)
145 KB
145 KB PNG
>>106865000
When I am recording, my cpu usage always spikes and if I use nvenc, it just lags my entire computer to the point that it is not usable anymore.
I could record in raw format but that takes too much space. So I decided that I will make my own way for recording a terminal
I forked suckless terminal and I essentially dump the whole glyph matrix every time the draw function is called.
Now I just need to make a program to rerender it and feed it to ffmpeg.
Each frame has a timestamp so it should be easy to reconstruct.
Hopefully, this will allow me to get 60fps even on a shitty computer
>>
>>106867601
Why not asciinema.org?
Assuming you have your reasons, why not output the diff between draw calls instead of the whole thing every time? I presume st already calculates somewhere what has changed to reduce draw calls to the screen.
>>
>>106865338
Not possible. Until the retards in the committee remove this retarded requirement in a future revision of the C standard, go ahead and ignore it.

Standards are worthless when they conflict with real world requirements.
>>
i don't get go. i don't understand what anything does. why do i need a buffer for a buffer to read something. let me just make a buffer and you can put all the data there. why do i need a buffer for a writer for a buffer for a file pointer. let me just write the data there.
>>
>>106867601
did you try changing the default preset from slow to something else?
>>
>>106867680
It doesn't have timestamps in the format so I wouldn't be able to use it to sync the voice. It also operates inside the terminal, so I assume it is reading character by character using a pty or something, but that is also relatively slow.
>>
>>106866972
>we deserve better
no, we dont
>>
>>106865000
>What are you working on, /g/?
An interval timer for working out.

I need to completely overhaul the way my program draws to the screen because I did not take into consideration that the terminal window can be smaller than the output.
>>
Erlang is king!
>>
I feel like the ternary operator should be
(condition) ? a || b

instead of
(condition) ? a : b
>>
>>106868970
what do you do with it?
>>
>>106865000
Where do I go after learning Python basics?
Web dev? Game dev? Go master Python even more? What's the best most fun path?

I don't really need it for work, I don't care about getting a tech job (I'm a 3rd year law student), I just picked it up for fun.
>>
>>106869203
>retarded syntax "innovation"
ah yes, it's been a while
>>
>>106869251
>Could state why it's : instead of ||
>tries to insult instead.
never change /g/.
>>
>>106869244
Make a game and share it.
Automate a need you have.
>>
>>106869277
|| is an operator and : is not
>>
>>106869277
It's ambiguous. How would this be parsed?
(condition) ? a || b || c
>>
>>106866972
he's right. I tried to add support for my own codec to ffmpeg once, but they don't offer any plugin API. I had to build the entire thing and hardcode everything in like a nigger.
>>
Disillusioned with Vulkan. Gonna try DX12 and just give up if it's too shit.
>>
>>106869277
because || is already an operator, a logical operator nonetheless even, that is also expressing a conditional construct
also this >>106869338
>>
>>106869374
>filtered by 1 trillion LOC to draw a triangle
>>
>>106866972
How is this possible? How did they manage to support so many codecs without the capability in the API to "plug in" another codec?
>>
Are there any string manipulation functions (like wsprintf) in the Windows standard library or Win32 API that would be affected by the currently selected code page? I'm trying to reverse engineer something and I'm noticing different behavior if I set the program to use UTF-8 (i.e. codepage 65001) via a custom manifest vs using the default OEM code page.
>>
>>106869441
they just pull in fuckton of dependencies and integrate everything in a single binary.
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_id.h#L49
>>
>>106869512
Why is this a bad thing? Shouldn't people upstream their codecs if they want FFmpeg to support them?
>>
>>106869566
I don't want to deal with powertripping smelly nerds just to release my software.
>>
>>106869575
you will comply with GPLv3 chud
>>
>>106869575
Then release your software. (You) don't need to put it in FFmpeg.
>>
>>106869600
I did both. just forked it. it's still shit architecture.
>>
>>106865338
This lil language called Rust solves this issue, or so I've heard.
>>
>>106869689
fuck off
>>
>>106865256
Because it was full of retards misgendering based Laurie.
>>
>>106869698
fuck off
>>
>>106869695
Are you telling me to fuck off, generally, or are you reacting to my sentiment towards based- and safety-ness-ed-ness of Rust?

Either way, I shan't comply.
>>
>>106869698
this. some retards thought he was a woman.
>>
>>106865000
Making my own templeOS Paint and it was good progress
>>
File: thinking-emoji-goth.png (530 KB, 1024x1024)
530 KB
530 KB PNG
>>106869705
Hm... I'm starting to believe anon has an issue with me...

Oh, well, can't win 'em all.
>>
>>106869738
Can you screenshot your code? I wanna see what HolyC looks like.
>>
When will regdumper come back? His schizophrenia was better than this iranian's schizophrenia.
>>
>>106869748
https://gitgud.io/ZekeRedgrave/ZEKEHC/-/blob/master/Sample/TempleOS%20Paint/ZEKEInit.HC?ref_type=heads

Here is the file if you wanna peek my code
>>
>>106869738
Neat.

I tried to get TempleOS up and running once, but the VM was just unusably laggy and slow.
>>
>>106869203
Why do retards put parentheses around the condition?
>>
>>106869767
Bro try AIWNIOS if you wanna use and do programming in HolyC
>>
File: Laurie.png (1.21 MB, 864x1184)
1.21 MB
1.21 MB PNG
>>106869698
>>
>>106869766
Looks more modern than I assumed.

Does the compiler do any optimizations?
>>
Terry left nothing but good in this world.

A generation of self-taught coders, dead-tired of webshit, got interested in low-level dev because of him.
>>
>>106869849
The compiler is already optimize and assemble just in time but if I wanna squeeze even more then I must use the assembly syntax asm{} in HolyC already
>>
File: Laurie2.jpg (945 KB, 896x1152)
945 KB
945 KB JPG
>>106869698
>Laurie is literally too powerful for /g/ when she wears a maid dress
>>
File: output.webm (2.08 MB, 1920x1054)
2.08 MB
2.08 MB WEBM
>>106868842
After overhauling my renderer to fix the drawing issues my interval timer is complete and ready for me to never actually use it.
https://github.com/aussie114/interval_timer
>>
>>106869993
frigid clothes
>>
>>106869993
that's a man no one can convince me otherwise. larry i know you are reading this. show your penis.
>>
Finally found a use-case for the "volatile" keyword.

Do other languages even have this concept? Does rust even support that?
>>
>rust
>>
>>106870083
Rust has no "volotile" variables or types. Instead, any pointer can perform a volatile operation using read_volatile/write_volatile methods. It's a more low level api.
>>
>>106870083
>>106870449
>>
>>106870461

the best way I've heard volatile described to me is that it "forces the compiler to never assume the state of a variable"
made me realize how over-complicated people try to describe it
>>
File: 1731830100987858.png (290 KB, 608x541)
290 KB
290 KB PNG
I hate looking at my own code. I constantly get analysis paralysis over whether or not I'm doing it right.

I've been programming for over 10 years.
>>
>>106870640
does it do what it's intended to do? then it's right
even if it could have been better, if it works as intended, it's better than "beautiful" code that doesn't actually deliver functionality

it is an actual skill you have to practice, to say "good enough" and move on to the next task
>>
>>106870597
>the best way I've heard volatile described to me is that it "forces the compiler to never assume the state of a variable"
It's more than that. It also forces the compiler to always do the writes you tell it, even if it thinks they'd be useless.
volatile u32 *var = 0x12345678;
*var = 5;
*var = 6;

If that variable wasn't volatile, the compiler would be allowed to remove the first write, but volatile forbids this. This is really only useful for programming hardware registers to a sequence of values.

Basically, volatile forces all reads and writes to happen exactly as your code says.
If you have a memset, like:
volatile u8 arr[1024];
while (i < 1024)
arr[i++] = 0;

Then the compiler will set arr to 0, one byte at a time. It won't make optimizations like calling memset instead, setting it 16 bytes at a time, or something really clever like pic rel.
>>
>>106870760
Appreciate that. Thank you.

I guess there's always bound to be better, no matter what you're doing. Any other wisdom?
>>
>>106870797
watch other people debug their own code. holy shit i get angry at their stupid mistakes.
>>
>>106870640
You just gotta get good so you can write perfect code without much headache.
>>
File: file.png (136 KB, 1914x709)
136 KB
136 KB PNG
You don't need AI to learn progrmaming. You just have to write a cli script that writes to a temporary files, compiles it and run it. Then it's easy and quick to make a few tests when you have a doubt.
>>
>>106869714
> rEwRiTe eVeRyThInG iN rUsT
To the nuthouse with you.
>>
>>106871791
>reddit case
>>
"Overload" a function by return type:
https://godbolt.org/z/jYfK1W68j
#include <iostream>
class Caster {
const char* str;
public:
Caster(const char* str) : str{str} {}
template <class T>
operator T() const {
std::cout << "Not implemented: ";
return {};
}
operator int() const {
std::cout << "int: ";
return std::stoi(str);
}
operator double() const {
std::cout << "double: ";
return std::stod(str);
}
operator std::string() const {
std::cout << "std::string: ";
return str;
}
};

auto f(const char* str) {
return Caster{str};
}

#include <iostream>
int main() {
int i = f("34");
std::cout << i << '\n';
double d = f("2.3");
std::cout << d << '\n';
std::string s = f("text");
std::cout << s << '\n';
bool b = f("true");
std::cout << b << '\n';
}
>>
>>106870797
>Any other wisdom?
use an IDE. learn your IDE. watch update videos about your IDE to learn about new features and improvements

so often people do things manually (and many times with mistakes) that could've been done in three seconds with one or two keystrokes or a menu click, or switch between three different programs to do two things when they could've done it all from their IDE
>>
I have an idea for cryptocurrency ledger. Instead of blockchain, we make two chains of transactions.
One is for mining blocks using Proof of work. Emission is infinite since there is coin destruction(see below).
The other is for sending coins. In order to prevent spam user must destroy some coins, and writing to chain is encouraged by fees to the first one who wrote it.
Questions: Can two chains be reconciled to show correct balance? Also, is fee necessary? Since there is destruction they can't keep sending the same coins back and forth. And miners still need second chain on the internet to transfer their coins.
>>
>>106872406
>mining blocks
mining coins
>>
>>106872207
that's the proxy design pattern
>>
>>106872207
God, I forgot C++ has implicit conversions and implicit copies. What a bizarre thing for a system PL to have. Imagine looking at a simple assignment and having no idea if it does allocation/IO/whatever or not.
>>
>>106872406
> 2026
> still taking blockchains seriously
All the FOMO-chasers have switched to LLM grifting like 2 years ago.
>>
>>106873323
NTA, but just because you only cared about it because of hype doesn't mean people can't genuinely be interested in the technology itself. This is a technology board.
>>
>>106873292
explicit keyword exists
abusus non tollit usum
>>
File: GctH2usWwAEIYj_.jpg (495 KB, 1284x2778)
495 KB
495 KB JPG
>>106873292
I always find it funny how C++ programmers talk how slow Rust code is because compiler is not guaranteed to optimize checks away etc etc, and then someone post their C++ code and it clones and allocates strings on every function call like it's nothing.
And then you end up with 25000 allocations per keystroke on Chrome kek
>>
>>106873424
Yeah but if you don't write sloppy code that creates these pathological cases then it's not an issue.

FWIW in my C++ code bounds checks are always on (yes, even in release mode) for my Span type and I even have a helper that does safety checking for casts. Modern CPUs are insanely fast and they handle branches that are never taken really well. Compilers are also smart (sometimes too smart, you could argue) so very often the bounds check will be eliminated anyway. The benefits outweigh the miniscule cost most of the time. Rust 100% made the right call in that regard.

You might want to disable this kind of stuff in only the innermost hottest loop (after thorough verification that your code is actually correct and doesn't have bugs), but other than that you definitely always want it on.
>>
>>106873492
>Yeah but if you don't write sloppy code that creates these pathological cases then it's not an issue.
If you don't then you don't. But people do it all the time and that's what I am talking about.
>>
>>106873492
BTW if you don't believe me this is literally what the WebKit people decided to do as well and they measured basically no real performance regression: https://www.youtube.com/watch?v=RLw13wLM5Ko&t=939s
>>
>>106869441
>>106869350
You are supposed to use gstreamer for more complex shit, retards
>>
Some idiot was talking about using 2 pages to implement a ring buffer the other day, he was proud that it was "fast".
Somebody tell him about the modulo operator.
>>
Why am I always tired. Am I just old? I'm only 37. I used to be able to program all night.
>>
>>106873798
Go to a doctor, check your thyroid gland.
>>
>>106873770
They're not wrong. I wouldn't very confidently say it's faster (maybe? your mileage may vary) but it simplifies implementation since you don't have to split your reads and writes if you have variable-sized entries in your ring buffer.
Either way you have to do a modulo operation for wrapping the start of your read/write but if you use that approach then you don't need to split your reads/writes to avoid going past the end of the buffer.
>>
Just literally always write perfect code. It's not that hard.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.