[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 / qa] [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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


What are you working on /g/?
Old:>>102092039
>>
>>102112993
Registry dumper
>>
>>102112993
failed normie OP
>>
File: 1662384321592561.jpg (143 KB, 1024x1020)
143 KB
143 KB JPG
>>102113023
I honestly wish that was the case. It's lonely at the top.
>>
>>102112993
>11. SIMD Programming on the SPU
Like many developers, I didn't learn SIMD (Single Instruction, Multiple Data) coding until after college. And like many SIMD programmers, I quickly became an intolerable snob. "Your code only processes one scalar per cycle?" I'd ask. "You only perform one comparison with each loop iteration?" I came to look down upon scalar coders and wondered if they needed their fingers to count to ten.

Now that I've learned the Cell, I've become worse. "You mean your code only runs on one processing unit and it only has one pipeline?" Single-core coders defend themselves with statements like "Speed isn't everything," but compared to me, they might as well be turning beads on an abacus.
>>
is there a fizzbuzz type milestone for writing your own programming language?

at what point do you call it version 0.1?
>>
You need software to work, that which is too slow to accomplish its purpose is software that does not work.
That which is fast enough works and what works is complete software, which may in the future become obsolete, and in that future will be made to work again.
>>
>>102113108
Once it generates vector instructions well.
>>
File: 1722770614465062.png (1014 KB, 2048x1434)
1014 KB
1014 KB PNG
What do elite devs do to jumpstart their side projects? Specifically for react+node?

I have an idea in mind but I don't want to be setting everything up from scratch when there's probably some github repo that did 80% of the job for me.
Do I just browse through repos until I find something suitable and build on that? What do you guys prefer to do?
>>
>>102113164
>elite devs
>react+node
Does not compute.
>>
>>102113108
after you have implemented a syscall() builtin (gnuniggers still cant into this.) you should be looking at adding builtins to further users' freedom. Some examples are:
__builtin_frame_address
__builtin_return_value
__non_temporal (gnuniggers couldnt)
and support for using assembly instructions with C syntax, regardless of whether the instruction is explicitly "supported" by the compiler
eg. RDFSBASE(&var)
would return fs into the var register (your language treats '&' as a reference and not a pointer, right?)
>>
>>102113164
If you have any chance of success you'd already be familiar with the state of the art.

If you're talking about general libraries to do things irrelevant to your actual project, What are you building and what do you need?
>>
>>102113050
>It's lonely at the top
Yeah i can see you down there on that rock.
>>
File: 1700772858896747.gif (572 KB, 540x601)
572 KB
572 KB GIF
>he's so mentally ill he doesn't even know what "top" means
>>
>>102113340
sexo with black satania onee-san
>>
>>102113050
>he is literally >
wild hallucinations, your dreams are not reality
>>
Good thing they're not dreams then.
>>
>>102113404
satanegrichia
>>
>>102113200
I'm building a novel commissioning webapp that's pretty simple in concept, but I need it to be highly (like very highly) responsive and customizable in terms of UI (Think something like Duolingo). I don't really know which librabraries to pick for animations, responsiveness, customizability, because there are hundreds of them and most have very shit documentation. Would probably waste a whole month browsing around for something that I could work with.
>>
http://www.afjarvis.org.uk/maths/jarvisspec02.pdf

Neat algorithm for finding square roots:

def sqrt(n: int) -> int:
a = 5*n
b = 5
while b < pow(10, 101):
if a < b:
a *= 100
b = ((b // 10) * 100) + 5
else:
a -= b
b += 10
return b


I thought it would also work in base 2:

def sqrt_binary(n: int) -> int:
a = 1*n
b = 1
while b < pow(10, 101):
if a < b:
a <<= 2
b = ((b >> 1) << 2) + 1
else:
a -= b;
b += 2;
return b


but it doesn't. Did I make a mistake or does it have to be 5/10?
>>
>In C if you want to do anything more than print to the console and generate random numbers you will need libraries and getting libraries in C is pain
Cbros....are we gonna heckin let them get away with this.......
>>
>>102114552
>we
Speak for yourself, retard.
>>
>>102113513
>jumpstart
next.js
>animations
it's literally called React Spring
>>
>>102112993
Tetris in TempleOS.
>>
>>102114552
>What is cmake fetch content
>>
>>102114763
a massive pain in the ass for anything that isn't also using cmake and mangles your URL if you use a variable for it
>>
>>102114552
vcpkg or conan are an option.
I also forgot that you could use vcpkg with raw build commands, but you lose the ability for vcpkg to copy the library DLL beside the exe.
>>
Trying to twach myself
BFS
Djikstras algorithm
A*
Non-/Recursive Shadowcasting
Bresenham' algorithm
>>
how to graphics programming
>>
>>102113513
If you don't already know the answer to that question and you're asking us, then you'll give up on your "novel" project in a week. There was a slight chance if you were able to google "react+node frameworks". But if you were unable to perform such a simple task there's no way you'll be able to do anything else yourself
PS there's no such thing as a novel webapp

>>102114552
If it's not a stb style header it's not worth using

>>102115000
What do you mean "trying". You literally learn all of that in algorithms 101. Why are you here if you don't already know how to program A*

>>102115051
https://vkguide.dev/docs/introduction/vulkan_overview/
>>
File: Untitled.png (21 KB, 692x679)
21 KB
21 KB PNG
>>102112993
How do I compile C in windows?
I've been using Linux (mint), and the way I build shit is in VScode terminal (bash) I just type "make filename", then run it with "./filename".

I have to use Windows now because reasons, the terminal is powershell. brehs,,,
>>
>>102115262
make
./filename

Is this really the post quality of the average /dpt/ poster?
>>
>>102115262
You open Visual Studio and compile/debug in that. Or if you don't want to use it, there's a bat file called vcvarsall in the VS folder that sets the variables. It also comes with make.
Or there's git bash for gcc.
>>
>>102115316
I'm not the average /dpt/ poster. I literally just started learning a couple of week ago. I'm a 3rd year law student, I'm doing this because I'm bored. I'm not here to steal your junior dev job lmao.
>>
>>102115387
literally summerfag tourist

> I'm not here to steal your junior dev job lmao
I earn $200k a year at fanng
>>
>>102115387
Ok in that case simply install Visual Studio and use that for now.
>>
>>102115262
the only time I suggest people to use mingw (msys2) is if they spend 90% of their time on linux.
but mingw does not support address sanitizer so it's very painful to write any code in it.
read this:
>>102109857
>>
When you think about it your own custom language frontend that transpiles to C would be the perfect language.
>>
Just started my C class in community college and I am zooming through this class absorbing KNOWLEDGE like a sponge

scanf("%d", &foo);
printf("%d", foo);
BY HAND
IN PENCIL
ON THE CHALKBOARD
IN FRONT OF THE CLASS
>>
>>102115477
*actually I don't think anything is stopping you from using clang-cl from visual studio and use make from msys2 (but cmake is better than makefiles when you use libraries because vcpkg is convenient, the problem with msys2 is that you could accidentally use a package manager library that links to 80mb extra bloat, for example freetype loading ICU harfbuzz etc and libzip loading openssl and etc, vcpkg does not load load those dependencies for those libraries by default, and you have the option to enable them, and you can pick which version and etc).
however I don't like clang-cl because it uses a different asan DLL binary than msvc and they both have the same name (msvc developer console will load the msvc asan dll), clang-cl + debug(/MDd) + asan + vcpkg does not compile (this is why I don't use clang-cl, I think vcpkg static linking works?), and clang-cl's address sanitizer does not stop the debugger in IDE's (unless you disable the useful report and force asan to trap or something, I think?). On the bright side clang-cl supports ubsan...
>>
Maaaaaaaaaaaaaaaaaaaaaa hey maaaaaaa I have refactored the code again.

So would you just copy the code in tkc_create_ 17 times or accept the additional function call and return. DRY has caused this dilemma.

inb4 >no free()
The OS janny is dealing with it.
>>
File: 1722864003802574.png (181 KB, 500x500)
181 KB
181 KB PNG
He's an Israeli but his videos are very good and informative
https://youtu.be/-i-YcX-qd2E?si=tfvtTDEb3sH9shNt
>>
>>102116011
The additional call makes it simpler so do that
>>
>>102112993
Started following along with crafting interpreters using Go. So far it's a lot more fun than I expected.
>>
>>102116289
Ive started learning go as well recentely. Did you read the blue book or do the tour or anything like that? Or just jumped right in?
>>
>>102116517
I just jumped in. Go is a really simple language. Keep tour of go handy when you get stuck.
>>
>>102116697
Based, thanks
>>
Packer and the QEMU plugin is giving me the biggest fucking headache. I'm trying to make some VM images based on Alpine with them but it's just not sticking. Basically the problem is that the virtio disks don't persist after reboot, so none of my provisioners. Also, half the time it seems like Packer can't ssh into the VM either. I also feel like some firewall setting is preventing me from using the http_directory thing. And of course VNC just refuses to connect. The entire thing seems super brittle. Also, the Packer page on AlpineWiki is like 3 years old and it's config doesn't work.
>>
>>102106432
this is amd's guide
https://gpuopen.com/learn/how_do_you_become_a_graphics_programmer/
i'd say it's okay
>>
>>102117015
not sure if this of any help, but i've had success with building QEMU images using supermin to script them from the inside instead of over SSH or VNC.
>>
>>102116011
>he needs a janny to clean up after him
Bleak.
>>
>>102116153
Not even once
>>
sunpro assembler doesn't support .word
is it ok to use .size x, 4 if I target x86 only?
>>
>>102116011
How explosive would you say this is? It removes a size_t declaration, 2 calls to snprintf, and 2 mathematical operations.

I thought of this idea while in the shower.
>>
>>102118321
malloc(0)?
>>
>>102118663
Probably for realloc. Which tells me all I need to know about his internal memory management.
>clusterfuck doesn't being to describe it
>>
>>102118663
>>102118756
wrong, read the console output.

All it is is a unique reference for the tcl interpreter to identify widgets. It does not get reallocated nor should it be freed until the program exists.

It's literally just an identifier.
>>
>>102118809
NULL?
>>
>>102118814
It is a char *.
>>
File: 1715448113211608.png (120 KB, 325x213)
120 KB
120 KB PNG
I'm calling all Rust shills on deck here, I come in peace.

First a little background. I'm a C++ dev with 2 years of experience writing safety critical code for embedded system, nearing my 3rd. I hate the options for error handling and memory safety. Exceptions are out of the question unless it's a beefy linux device, so it's all error codes. To ease the pain a little I thought I could copy Rust's ? operator with a TRY/VALIDATE macro, but the seniors HATE macros and told me if(err) or go fuck yourself. Memory safety is RAII on steroids and understanding the quirks of C++.

Now, unironically I know absolutely nothing about Rust besides /g/ memes and that you are all troons. When I tried to search for information, guy like No Boilerplate, but I found out he came from Python. Any other web content creator I found are all web shitters. I refuse to learn from these people on how to write safe programs. I ask that you please share ONE resource from a experienced embedded developer. Doesn't need to teach me Rust, just a copy of Effective C++ for Rust. I'm already combing though Rust by Example to learn the basics.
>>
>>102118931
Rust is just repeating the same mistakes C++ and the generic malloc allocator in C made. If you're on Linux you want to look into mmap.
>>
>>102115176
I got an E in algorithms 101
>>
File: mem.png (85 KB, 475x1261)
85 KB
85 KB PNG
from now on this is how I manage memory and there's nothing you can do to stop me
>>
>>102118951
what is the difference between for example malloc an array of data, to mapping it in virtual memory? Either way I need to manage lifetime of that data.
>>
>>102118931
The literal book https://doc.rust-lang.org/book/

Also just use C. Everything else just tries to abstract away the problem. The entire Rust standard library is written in unsafe {}.
>>
>>102118967
>brk
>not MT-safe
>syscall for every single bit of allocation
Why would anyone stop you? You've just created your own hell.
>>
>>102118976
>The entire Rust standard library is written in unsafe {}
if that is true, and as I said earlier I have 0 knowledge of Rust, that is a huge red flag for me
>just use C
There are a lot of QoL features that C++ provides, most of the code I write is C-style but compiled with g++. It also makes the error handling worse with my only option being int/enum instead of a custom user type.
>>
>>102118971
We just had a discussion about that the previous thread:
>>102104998
>>102105073 (still sort of true for Linux if you want to avoid unnecessary mode switches: >>102105334)
>>102105419
>>
File: 1712147966040917.png (169 KB, 500x350)
169 KB
169 KB PNG
post what you listen to while coooding
https://www.youtube.com/watch?v=eEcPakW42JU
>>
File: 1724794075589025.png (6 KB, 794x624)
6 KB
6 KB PNG
>>102118952
bro you are retart liek me
>>
>>102119010
This seems like an autistic optimization to me and a unneeded minor memory saved. Even in memory constrained devices, the limits are well defined, and so this is a not a problem to begin with.
>>
>>102119041
Define "autistic".
>>
>>102119062
If we are talking worthwhile optimization I'm better off putting all effort into the CPU rather than how malloc manages memory for me. Plus, with a custom allocator like the arena you cross-linked I can do it fast and easy with malloc. Once I exhaust all my options, even then I probably wouldn't since I see no speed benefit, I can switch over to mmap.
>>
File: almost_32_bytes.png (24 KB, 840x302)
24 KB
24 KB PNG
>>102119093
>I'm better off putting all effort into the CPU rather than how malloc manages memory for me.
What makes you think malloc doesn't have CPU overhead? Dunno what libc you're using, but glibc's malloc has atomic reads and arena iterations: >>102105660
And you probably know more about your problem than the people whose job it was to provide a generic solution, not a specific one. If you ever have the time you want to look at how memcpy isn't the actually fastest way to copy things from A to B.

>I can do it fast and easy with malloc
Do you have a bunch of reallocs as well? Because those can trigger relocations, which can trigger memcpy. Doesn't happen with mmap.
>>
does anyone have any experience in targeting the JVM as a compilation target? is it significantly easier/more difficult than targeting BEAM?
>>
>>102118931
if (err) is perfectly fine. People like to meme on Golang a lot for it but the explicit nature of it is honestly a good thing. Rust's error handling is notoriously dogshit with many different 3rd party crates that try and fail to solve the problem. The ? operator is similarly bad because it hides the problem and makes it too easy to kick the can down the road.
>>
>>102119150
I should also ask about graalVM because I'm also reading about this truffle, which seems targeted as an easy entrypoint in the graal ecosystem
>>
>>102117589
>he doesnt munmap() his stack, errno and thread local storage
grim
>>
>>102119396
>he uses TLS
ngmi
>>
>>102119466
can you even opt out?
>>
>>102112993
>doing pointer arithmetic to pass struct pointers within other structs
hardest shit evar bruh
>>
>>102119480
Sure, if you just use kernel interfaces.
>>
File: based_js.png (33 KB, 797x310)
33 KB
33 KB PNG
>GUI app in 12 loc
can your language beat that?
>>
>>102119490
you cant opt out at runtime for the main thread retard, you would need to tinker with elf
>>
I don't understand all this shit. Rectangle Symmetry Reduction? Jump Points? Preprocessing? Better heuristic? What is all this A* cope??
>>
>>102119543
>you cant opt out at runtime for the main thread
Says you. But did you know I don't have to link against a libc?
>>
>>102119589
tell me right now linux doesnt automatically give you a stack, do it faggot.
>>
>>102119595
>a stack == TLS
That's not how that works, retard.
>>
>>102119605
then does it not automatically give you tls?
you know, there needs to be an ldt in the first place
>>
>>102119640
>then does it not automatically give you tls?
Where, do you think, are TLS objects stored? Hint: it ain't the stack.
>>
Wow, this is the most embarrassing dunning kruger moment you have ever had buddy
>>
File: void_ptr.jpg (48 KB, 535x372)
48 KB
48 KB JPG
>>102119483
I will never understand how pointers filter new devs
>>
>>102119819
low IQ prevents people from conceptualizing even most trivial of things
>>
>>102119819
never said i was being filtered, it is just that debugging
 [thread->parent->descs.pool[desc].findex 

over 56 files is not the most fun thing
>>
>>102119886
have you considered not doing that, then?
>>
>>102116153
i found out about this guy recently:
>wow this is a really good video
>woah this guy has more videos
>subscribe
>wait, "Lichman"?
>"Nir"?
>channel country is israel
>yep, it's over
>unsubscribe
I'll just read the windows internals book instead, thanks.
>>
>>102119980
No wonder the jews are kicking ass if people are too butthurt to listen to them.
>>
>>102120121
the jews are kicking ass because windows is used at all
>>
>>102120161
Blame the goyim.
>>
>>102120180
I already did in my post, in case your english is really that bad.
>>
>>102120191
>autistic
That means the jews are not the ones to blame here.
>>
>>102120121
I'm sorry for opposing genocide, as he is not only Jewish but an Israeli citizen, all of whom the government has made sure to implicate in its military decisions thanks to its conscription policy. In any case, I don't think his videos contain any information that I couldn't find in books like Windows Internals and so forth.
>>
>>102120200
never implied otherwise, your low IQ is how I know that you cannot be jewish and how I also know that everything wrong with this world is your fault
>>
>implying
>>
>>102120223
>sorry for opposing genocide
Genocide is reserved for human beings.

>>102120234
>everything wrong with this world is your fault
That makes me happy.
>>
>>102120254
I'm not interested in conversating with demonic beings.
>>
>demons are real
Why didn't you mention you were schizophrenic?
>>
>>102120305
people with an iq over 100 (for real) dont feel the need to announce all of their shortcomings.
>>
>>102116153
>Israel shill leaves the source identifier in the youtube URL
every time.
>>
How do I learn modern C++ without fiddling with build systems forever? I want a just werks setup like rust + cargo?
>>
>>102120514
learn how to use GNU Make and you will never fiddle with a build system again in your life
>>
>>102120527
windows support?
>>
>>102120540
use something else than MSVC and all commands and workflow are exactly the same, because wintoddlers are the only ones who can't design a working compiler
>>
>>102120555
clang should work right? because I don't want to fiddle with msys2.
>>
>>102116153
Jew usually means competent (in terms of non-whites, only Jews and Italians are competent).
>>
>>102120574
msys2 just worked on my machine when I was a wintoddler
>>
Frontend is aids... WIthout WordPress I'm expected to build websites? I hate it, I just want to code... Obviously I can write HTML and CSS 'cause I made my living wage from WordPress sites for over a decade, but from scratch creating a web UI is ridiculous.
>>
File: japanese game heroines.jpg (377 KB, 1851x1024)
377 KB
377 KB JPG
>>102120621
Japs are more competent than most Whites desu
>>
>>102120574
Yeah clang is officially supported in Visual Studio. It uses the same standard library as MSVC.
>>
>>102120725
Yeah, Japanese also. Oddly the only non-Anglos who are competent are Axis countries (Germany, Japan, Italy, all synonymous with quality)... I guess it's to do with pride. They have pride in their country so have pride in their work also, since their work reflects their country?
>>
>>102120725
i think the right side shows more technical proficiency desu
>>
>>102120638
okay. but how do I do libraries with makefile?
>>
>>102120752
Just because something is technically difficult it doesn't make anything better, especially with the end product being shit. In fact, doing more with less is far more impressive and desirable. Technology is a tool, not an end it itself.
>>
>>102120850
By setting appropriate CFLAGS and LDLIBS as always?
>>
>>102120725
left side looks like ass except for 2b
right side mid left and top left look pretty good, top right also ain't bad
>>
I feel stuck design-wise.
Exhibit A: a class managing GUI.
Exhibit B: a class hierarchy where each class is managing some data.
Inside A, I want to populate a context menu with different entries depending on which B is being clicked. Doing "if typeof B is ..." inside A is retarded, but using virtual methods inside B to populate the menu looks bad too, since B shouldn't be dealing with GUI. What do?
>>
Has anyone tried to reverse engineer what exactly DefWindowProc is doing for WM_NCPAINT et. al. if you naively treat is like a normal GDI surface it fucks up 100 different ways that aren't documented, there are other APIs you can use to draw there but I assume they all eventually compile in to win32 eventually which is what I am curious about. It's mostly just a curiosity as most sources recommend don't even bother trying, which is why I don't want to do it myself.
>>
File: japaneseJewDemons.jpg (254 KB, 750x813)
254 KB
254 KB JPG
>>102120752
>>102120925
you completely misunderstand the picture.
It has nothing to do with raw technical aptitude.
Rather, the Japanese have shown themselves to be reasonably competent at preventing the Jew from subverting their culture.
>>
>>102120875
easy friend, does any package manager exist with good integration with make
>>
File: 1715408014267.png (104 KB, 500x397)
104 KB
104 KB PNG
>>102121092
>preventing the Jew from subverting their culture.
clueless
>>
My dream job?
Working on tools that format code.
That would bring such joy to my autism, doing two things that I love - programming and formatting code correctly (in the objective sense).
>>
>>102121107
Didn't Japanese get their character set from the Chinese which predates Hebrew by 10,000 years?
>>
>>102121140
They have 2 alphabet sets and chinese kanji to boot. Baically Japan of today is the Europe in 100 years, except native japanese were replaced by gooks instead of muslims.
>>
>>102115262
use codeblocks
>>
I really want to get into lower level languages like C and Assembly, do I need to know electronics for that ? And by that I mean do I have to know hardware engineering or is it enough to understand mathematically how a CPU or other components work ?
>>
>>102121436
>do I need to know electronics for that ?
no.
>>
>>102121462
I'm asking because I asked on leddit and almost everyone said yes, and I wanted to be very clear I am not interested in creating my own microcontrollers or whatver, I am interesting only in programming for them, maybe get a job in the aerospace industry or whatever
>>
>>102121507
>I asked on leddit
that's where you fucked up, anon, you should know better. you don't need to know anything about hardware to code in asm, and even less in case of C. but still, you will likely pick some knowledge related to hardware along the way.
>>
>>102121545
so math is enough ? i really don't want to spend a few semesters taking physics courses just to waste my time
>>
>>102115681
>BY HAND
>IN PENCIL
>ON THE CHALKBOARD
>IN FRONT OF THE CLASS

Nice, that must've felt good. Honestly, real intro to programming classes need this now more than ever. Everything is an online remote Python course these days.

If I ever end up teaching I don't care if it's a remote class, I'm hosting 1 session a week where paper and pen are required.
>>
File: 1724848485148.gif (171 KB, 480x480)
171 KB
171 KB GIF
> going through programming book
> need to turn constructor into primary constructor
> Alt + Enter, convert to primary constructor
God I love good IDEs.
>>
>>102121575
Stop trusting reddit. C is a high level language, as is Assembly frankly. They are both built on top of the ISA abstraction that insulates programmers from hardware implementation details.

Modern CPUs do insane shit to go fast but you don't need to know about it to write programs in either C or assembly.

Pointers are also a software abstraction btw, if that's what people on leddit are referring. They hide a lot of what the hardware is actually doing.

Point being, just start. There are no prerequisites aside from basic software and programming knowledge.
>>
>>102121668
fucking thanks, funny how 4chan actually gives me a straight answer without bollocks
>>
>>102121103
Portage sets all of these automatically, naturally.
>>
>>102121436
You should at least read this: https://people.freebsd.org/~lstewart/articles/cpumemory.pdf
>>
>>102121668
pointers arent a high-level abstraction though, it is a universally supported system in embedded controllers (eg. ps2 controller)
Really the only thing that the isa abstracts is the serial protocols
>>
>>102121815
so what's the size of the pointer? How many memory accesses are performed through any pointer? Be objective and conclusive, no ors nor ifs, just give me two hard numbers.
>>
Any tips to better myself at not being distracted by the internet and code as mush as possible for a period of time (from 30 minutes to 2 hours). It's like the last thing preventing me from becoming this ultimate dev I have in my mind.
How can I actually train my focus and kill that desire to something unproductive instead. It's literally ruining my life.
>>
>>102121862
suckstart a shotgun and if you survive, the tumor in your brain will be gone and you will be able to use the rest of it without being distracted
>>
>>102121877
It could resolve some issues but not the one I'm asking about
>>
>>102121815
An ISA is an standardized interface to the hardware. The amd64 ISA (or whatever you want to call it, let's not argue about irrelevant technicalities) is the reason your code probably works on this generation of Zen processors and the one before and the one before that (modulo maybe certain SIMD instructions and other extensions).
Pointers to virtual memory can actually map to different things on the hardware side, notably, actual physical pages in RAM or memory-mapped IO.
Both of these things do not map exactly to what the hardware is doing.
>>102121837
A pointer is 8 bytes (i.e 64 bits) on 64-bit platforms. The actual number of accesses to physical memory performed by the hardware when you perform a load on a virtual memory address depends on address translation (TLB) technicalities and implementation details, sorry.
>>102121767
This is a useful paper but it is not necessary for getting started. He can read it later if he finds that to be more suitable.
>>102121862
Do something you are passionate about and you will find that easy.
>>
>>102121733
Discard everything he wrote except the last line
>>
>>102121907
I accept your concession.
>>
>>102121918
>>102121911
fyi this larper has been here for a while just ignore him
>>
>>102121931
pathetic fail
>>
>>102121907
>Do something you are passionate about and you will find that easy.
I'm beyond that. I have this gamedev project that I fucking love but requires to put in effort and work. And that's where I suck. Even when I love something, I'm not strong enough mentally to force myself to make some efforts.
>>
>>102121575
>so math is enough?
you don't even need that. just start and it will click pretty fast.
>>
>>102121941
Well, I guess there are two (or more? I don't visit this thread much anymore) of you here. Both very annoying. Anyway, feel free to rephrase what I just said to stroke your ego.
>>102121963
It works for me personally. Beyond that it's just discipline I'm guessing, there is no "how".
>>
>>102119519
>can your language beat that?
Xaml and C# can, but it's like 20 if you ignore the boilerplate the project generate
>>
>>102121436
>low level languages like C and Assembly, do I need to know electronics for that ?
No.
>do I have to know hardware engineering or is it enough to understand mathematically how a CPU or other components work ?
Well you do have to understand how these components behave in the system known as the computer. But you don't need to know anything about how it's actually implemented in the hardware. You just give the CPU commands in a language, and the CPU does what you tell it to. In assembly, the commands are very simple and are practically the smallest units of instructions you can give the computer, that's why it's called low level. The computer is an abstract system you can operate through programs.
When you go
>mov byte ptr [rax], 99
you don't care how it's implemented on the CPU. Different CPU models (I mean Intel 386, P4, i7 xxxx, AMD Ryzen xxxx, etc.) do a bunch of different things to achieve this under the hood in hardware, but you don't care about that, if they are compatible with your architecture (x86 PC), the result is the same.
>>102121575
>so math is enough ?
You don't need math, you need logical thinking.

Literally just start by learning the basics of C first, learn how to manage memory and use pointers, then learn the basics of assembly.
>>
File: 1722773241331.jpg (349 KB, 1050x1377)
349 KB
349 KB JPG
>>102121436
Read picrel. You can get into the basics of C before that.
>>
>>102121837
this is protocol dependent, what you said is still nonsense so i pointed it out.
>>
>>102121907
a pointer is not 64bit on the current hardware... 47 or 56.


it is always the guys who dont pay attention to the conversation lol
>>
FAT
>>102122222
>>
>>102122225
It's 48 lanes.
>>
>>102122214
I accept your concession nocoder, by the way, it wasn't me who wrote whatever and it's not relevant to the fact that pointer is an abstraction and not a thing in hardware.
>>
>>102122247
pointers are a thing in hardware... you know nothing about embedded programming
Seriously did you even think before typing.. any of the multiple times you did type?

>>102122245
no but i am not going to spoonfeed anything


just die already
>>
>>102122278
>muh embedded programming
okay retarded nigger, show me, in C code, how far and near pointers look like
>>
>>102122278
I can't wait for you to be turned into a piñata.
>>
>>102122290
god you are actually brainwashed by x86 LMAOOOOOOOOOO that is so pathetic i am actually embarrassed for you
O-K-su,
i am not going to reply to you until the next thread, feel free to samefag or argue with the paid amd shill (let us not argu irrelevant technicalities, oh white god!) or whatever
>>
>>102122308
this has nothing to do with x86, show me in C code what far and near pointers look like for your architecture
>>
>>102122308
>paid amd shil
?
>>
Can someone mentally stable talk about programming please?
>>
>>102122320
I do, but only on reddit, I will gladly follow the rules and not bully trannies because at least retarded faggots like everyone ITT cannot avoid spedding out and getting banned eventually.
>>
File: final_version.png (35 KB, 1530x968)
35 KB
35 KB PNG
>>102122320
Registry dumper.
>>
>>102122334
which subs?
>>
>>102122320
I did but then they seethed at me for doing so.
Latest example being (>>102122308) accusing me of being a "paid AMD shill" (if that isn't schizophrenic then I truly don't know what is).
There's a reason I don't go here anymore.
>>
>>102122354
Don't tell him, he'll ruin that as well and drive everyone out until there's nobody but him and another retard arguing forever and ever and ever.
>>
>>102122366
i dont even engage with the registry dumper schizo, the only interesting "conversation" (more of a brief shitfling) i have had in weeks was with the 32bit OS schizo
>>
>>102122384
>registry dumper schizo
>the 32bit OS schizo
Loooooooooooooooooooooolm´,
>>
>>102122354
the good ones
>>
are they the same person?
>>
Akshually intel x86 is just an abstraction over shuffling electrons around, it's not even real, let alone low level.
>>
File: 1715846638304081.png (151 KB, 1747x453)
151 KB
151 KB PNG
>>
File: 1717216706191341.png (30 KB, 726x330)
30 KB
30 KB PNG
>>102122649
>>
File: 1724573249847915.png (54 KB, 749x512)
54 KB
54 KB PNG
>>102122704
>>
File: 1581183782273.jpg (176 KB, 800x449)
176 KB
176 KB JPG
QT Question:
Is there a way to format number inputs with a space every three digits like so?
>50 000 000
>>
>>102122937
On the code side it's just 50'000'000 of course, but you likely mean the displayed side... Which I don't know.

I know you could do it in a hacky way by converting to a QString and iterating through, and converting it to a character array (you could determine where to put the spaces with modulo of 3), but C++ almost 100% certainly has a simple standard library thing that can convert the number exactly as you want without all of this nonsense. I.e., ask GPT.
>>
File: 1722885616687128.png (62 KB, 940x403)
62 KB
62 KB PNG
>>102122847
>>
>>102123028
Yeah on the display side. A user typing in a lineedit for example.
>>
>>102123119
why are you posting this?
>>
File: 1695762467145194.png (6 KB, 267x46)
6 KB
6 KB PNG
>>102123321
>>
>>102123333
checked
take up all the trannyjanny bandwidth you want for what i care
>>
>>102122937
Connect &QLineEdit::textChanged and format manually, then format back when you get the output. Or make your own class.
>>
Shouldn't you be busy getting turned into a piñata?
>>
>>102122704
>int x; int y;
absolutely niggerlicious, you can declare multiple variables of the same type with comma
>>
>>102123431
>>int x; int y;
>absolutely niggerlicious, you can declare multiple variables of the same type with comma
absolutely niggerlicious, such things do not matter.
>>
>>102123507
t. forever unemployed nocoder
>>
>>102123536
how ironic lol
>>
>>102123557
>mad
>>
>>102118874
Well it's compiler/standard library specific behaviour. On another platform it may absolutely return null
>>
I still dont understand Djikstra. How does it solve the non-uniform cost problem?
>>
>>102123777
The same way you solve sudoku.
>>
>>102123798
I ... I can't solve sudoku..
>>
>>102123827
then start from that
>>
File: 1701856785802986.jpg (33 KB, 641x481)
33 KB
33 KB JPG
>>102123798
It can't be very good at what it does then
>>
>>102118951
Well Rust has the Allocator trait. I think this works similarly to the Allocator template parameter on C++'s containers. You could absolutely mmap within an specific allocator
>>
>>102123837
well yes, if you cared about good things, you'd be looking at A* as bare minimum
>>
>>102123840
every struct/reference is implicit allocation
>>
>>102123777
Same as BFS, but with cost added.
>>
>>102120540
WSL
>>
>>102118971
none for big allocations, meaning malloc is overhead for no benefit, and yes, your allocations should always be big, if you make small ones you're doing it wrong.
>>
>>102120527
>>102120540
Or just use CMake like everyone else. Problem solved. You people make things complicated
>>
>CMaketard talking about complicated things
>>
>>102123431
Multi declared variables is even more niggerlicious
>>
>>102123988
this
CMake && (Conan || vcpkg)
>>
Hey, the creator has to sell his book about cmake somehow, ok? Nobody would buy that if cmake was intuitive.
>>
>people are starting to realize CMake was a mistake
the world is healing
>>
>>102124027
I didn't need to read a book about GNU Make and I didn't finish reading GNU Make documentation because I only needed few simple features that fit every usecase
>>
>>102124052
yeah, you don't need much to get those jeetcode projects compile on every platform
>>
>>102124071
considering Linux is the only relevant platform...
>>
File: 1647865264345.jpg (120 KB, 600x600)
120 KB
120 KB JPG
I'm testing my program, converting 1000 images to webp using the default settings (quality 75, lossy) made an 840mb folder a 61mb folder
Using quality 100 and lossless made a 400mb folder, webp is superior
>>
File: 1703625705041998.png (67 KB, 800x595)
67 KB
67 KB PNG
>>102124257
Which universe again?
>>
>>102123798
What the fuck are you talking about
>>
>>102124370
The one where I program important things instead of Fortnite for toddlers like you?
>>
>>102124399
Ah. The one where your schizo voices scream hysterically against anything even remotely resembling reality, got it.
>>
>children playing fortnite is important for our democracy
>>
Yeah, like that.
>>
>>102124370
>Normie desktop OS chart.png
>>
>>102124370
Who buys all that electronic waste? Do Americans really use that many chromebooks?
This is impossible, I basically never see anyone use it or talk about it online.
>>
File: toku.png (6 KB, 384x364)
6 KB
6 KB PNG
>>102124545
People don't pay you for software that doesn't run on their system, and there's a lot of people running Windows. It's just good business.
>>
>he NSA recently published a Cybersecurity Information Sheet about the importance of memory safety, where they recommended moving from memory-unsafe programming languages (like C and C++) to memory-safe ones (like Rust). Dr. Bjarne Stroustrup, the original creator of C++, has made some waves with his response.
>To be honest, I was disappointed. As a current die-hard Rustacean and former die-hard C++ programmer, I have thought (and blogged) quite a bit about the topic of Rust vs C++. Unfortunately, I feel that in spite of the exhortation in his title to “think seriously about safety,” Dr. Stroustrup was not in fact thinking seriously himself. Instead of engaging conceptually with the article, he seems to have reflexively thrown together some talking points – some of them very stale – not realizing that they mostly are not even relevant to the NSA’s Cybersecurity Information Sheet, let alone a thoughtful rebuttal of it.

Why are they like this??
>>
>>102124627
both sides are retarded, still using C++
>>
>>102124627
Have you seen his recent presentation? Him getting his PhD convinced me early on that academia is just a bunch of grifters siphoning off as much research money as possible for themselves: https://www.youtube.com/watch?v=I8UvQKvOSSw
>>
>>102124627
Rust's new borrow checker can test if you're using an unsafe feature like a penis
>>
>>102124627
Do chinks (the #1 tech country today) use pust? No? Then think about (((who))) wants to push it down your throat and why.
>>
>>102124289
Are you the bulk-encode webp warcriminal anon? Keep up the warcrimes, maybe soon they will hold a Nuremberg trial just for you.
>>
>>102124673
Leave the old man alone. He's just coping with the fact that C++ is not actually amazing for everything. It's still a very useful language, but he can't stand the thought of another low-level language replacing it in some areas.
>>
>>102118931
depending on the c++ version you're using, you can use a variant: std::variant<T, Err> where T is a meaningful value and err is an error code. Although C++ lacks pattern matching making this pretty annoying
Another option is to do this:
if (int *value = function_call(); value & 0xFF)
{
// Some error happened, error code stored in the lowest byte
}
else {
// Safe to dereference value
}

Depending on the executable format, there is some reserved memory space from 0x0 - 0x40000 where no pointers can point to. Another option is to have your function take an lvalue to a default-initialized object, but there would be some overhead
>>
>>102124809
yet all relevant software is written in it
>>
>>102124889
or just use exceptions because errors never happen?
>>
File: part_of_the_problem.png (397 KB, 828x683)
397 KB
397 KB PNG
>>102124890
That would explain so much.
>>
>>102119819
how can they understand what an array/table is without understanding what a pointer is? It's literally an index in the memory table
more specifically it's a typed index but you get the idea
>>
>>102124916
yes, it explains anti-C++ shilling, when my server written in C++ can handle tens of thousands of connections and use only 8MB of RAM
>>
>>102124945
your server sounds like a whore
>>
File: what_the_actual_fuck.png (42 KB, 1076x952)
42 KB
42 KB PNG
>>102124945
When was the last time you ran a tracer and made sure you weren't doing unnecessary stuff? Or would that break the illusion?
>>
>>102124986
I'm not a wintoddler so I don't need to run a debugger to find out what's going on machine that I myself configured.
>>
>>102121668
this is true, most people don't realize that the kernel is also doing a lot of abstraction. For instance you never directly access memory it's always through virtual memory, allocations (mmap/virtualalloc) don't actually allocate anything unless you write(linux) read(windows) to the memory. But you don't need to know any of these things to program in C, hell you may never have to know what the abi is doing under the hood once your progam is linked against other libraries
>>
File: cpp_is_garbage.png (44 KB, 1532x932)
44 KB
44 KB PNG
>>102124998
>he confuses tracer with debugger
So you haven't. Sounds just like your averagely incompetent C++ dev.
>>
>>102125016
linux will commit on reading.
>>
>>102124024
That's wrong
Cmake && git submodule add <url> libs/<libname>
ADD_SUBDIRECTORY(libs/<libname>)
>>
>>102125045
I'm not a wintoddler, I don't need to trace shit wintoddler games and cope about shit code I didn't write.
>>
>>102125016
>But you don't need to know any of these things to program in C
Only if you don't mind wasting memory or constantly copying data on Windows. malloc is forced to commit any memory it returns.
>>
I'm deciding the structure of my vm "value pointer" (not really sure how to call it); I have 8 bits for the type and the rest for either the heap pointer or the value itself, for stuff like bools, chars, ints.
now, my lang is pretty simple type wise, so there's no way in hell I'll use all 8 of my bits for types, I don't think I'll go over a dozen in total even if I put some exotic ones.
given that, would it be a good idea to take 2 bits away from this type representaiton to handle option types? basically they would be 2 flags, one is saying whether that type T is actually an option<T>, and the other would signal the None value
>>
>>102124370
the universe where every program is becoming SaaS webapp meant to run on phones, if you look at SO developers surveys most developpers have linux as their primary target, even if they don't use it
>>
>>102125090
option<option<T>>?
>>
>>102124890
I'm not ragging on it.
>>102118931
>I refuse to learn from these people on how to write safe programs
Good choice. I once watched a video from the "No Boilerplate" guy and it was riddled with errors and misconceptions. He has no right to be making educational videos about Rust. Just read the Rust book btw.
>>102124889
std::variant sucks
>>102118976
Wrong. Most standard library code is safe. Some unsafe is used with extreme caution and special care so that any dumb shit you do in *safe* code will NEVER-UNDER-NO-CIRCUMSTANCE lead to the unsafe code performing undefined behavior. This is the key part about Rust. No matter what you are doing, if it's not in an unsafe block, it will never-ever-ever-ever cause your program to exhibit undefined behavior PROVIDED that your unsafe code has been written "correctly" (this is obviously non-trivial) and that your program was not miscompiled etc. This guarantee is what makes the language actually useful.
>>
>>102125071
Conan and vcpkg do that for you if you want
>>
>>102125075
Seeing as you've just admitted that you don't even know what code you're invoking (because you never traced through any abstractions) your opinion is completely worthless - just as most C++ code.
>>
>>102125090
look up NAN tagging if your vm also has supporting for floating point.
>>
>>102124643
I learned both languages, and Rust doesn't add more to memory safety than common sense RAII. In modern C++ (>=c++11) you may never even see a pointer, never having to call new/delete and rely on smart_ptr+move semantics to achieve perfect memory safety. All of it at the cost of 0 overhead
>>
>>102125123
I build the abstractions, I have the code, why would I need to trace? I'm not a wintoddler who can't wade through pile of shit that is his "Visual Studio Solution".
>>
>>102125103
I would have to rely on SO for self-promotion too, if I only ever wrote code for Linux.
>>
>>102125137
>smart pointers
>move semantics
they have overhead and I don't use them, because I can simply write better code that never requires any moving.
>>
File: ntcreatefile.png (23 KB, 1038x724)
23 KB
23 KB PNG
>>102125138
>why would I need to trace
Because you don't know what you don't know. How many people on the Windows side know that CreateFileW invokes memory allocations before even entering the kernel? Well, now you know. And a tracer would tell you even more things.
>>
>>102124903
>yeah rape performances so you can error handle
>>
>>102118931
I write C++ like it's Rust at work, without having to deal with weird Rust syntax. I'm fortunate to be able to use C++23 so I can use std::expected all over the place. The Rust approach might translate the best - use std::expected, and make an error type which inherits std::error_code or std::error_condition.

What you really shouldn't do in Anno Domini 2024 is make thin wrappers around OS functions, which return error codes and write out to arguments. Or retrieve errors from errno/GetLastError. These two approaches are what's prevalent in C but they don't scale and just bring so many bugs.

If you're interested in embedded Rust, there's the Rust Embedded Book as well as the Embedonomicon, which covers more of the technical details behind the scenes. I think something like Embassy (embassy.dev) is a good example of what's possible with embedded Rust. If you're using C++ on top of something like FreeRTOS or Zephyr, I would honestly consider switching to something like Embassy instead, not because muh memory safety, but because it's just nicer to work with. Embedded Rust is pretty mature on popular platforms like STM32 or NRF. Don't expect a fun time on anything which is not ARM, RISC-V or PowerPC. There's also a safety-certified Rust called compiler called Ferrocene.
>>
>>102125163
I know everything about my code, keep projecting
>>102125164
>optimizing case (errors) which never happens because I make no mistakes and my system isn't broken
sorry I don't care about irrelevant edge cases like user having 3rd world internet connection stability or xer disk dying....
>>
>>102125164
c++ exception overhead is actually quite low in terms of runtime performance. the problem is binary size and correctly unwinding things (writing 'exception safe' code, which is basically impossible for any mortal being)
>>
>I know everything about my code
Now you just sound like a raving lunatic ready for the funny farm.
>>
>>102124889
>std::variant<T, Err>
I believe we have std::expected for that.
>>102125113
>std::variant sucks
why?
>>
>>102125090
You can simply use 1 bit for option type
and instead of storing a value directly, you can store a pointer to it, using the nullptr for none
IIRC that's how rust handles the Option enum instead of storing a field for the currently selected variant (like Err<T, E>)
>>
Been automating stuff with codegen. It's crazy how shit websites are. For example, I'm writing an automation to register product warranties. Enter info, click next page, enter info, click next page. Over and over. Why can't it be a single page with all required fields? Who is responsible for this dogshit paradigm?
>>
>>102125185
>the problem is binary size
it isn't a problem anywhere, exception code is stored in entirely separate pages which are only loaded if user is retarded or xer machine is broken and system errors are thrown all around
>b-b-ut muh 2 megabytes on disk
I don't care, spend $5 extra for another terabyte of storage.
>>
>>102125156
i'll give you that making shared_ptr atomic by default is retarded, but unique_ptr has literally no overhead
template <class T>
struct unique_ptr
{
T* data = nullptr;
unique_ptr(unique_ptr&) = delete;
unique_ptr(unique_ptr const&) = delete;
~unique_ptr()
{
if (data)
delete data;
}
};
>>
>>102125207
Playwright codegen*
>>
>>102125221
what you wrote has one branch worth of overhead and assumes that allocation was made with new, which I also never use because it's terrible
>>
>>102125192
std::variant is exactly what rust's enums are except C++ lacks pattern matching, making it difficult to match over a std::varient, performance wise it's what you'd except from a union + size_t to know the currently selected variant
>>
Tell you what: I'll start using C++ once the compilers start using LOOP instructions again.
https://uops.info/table.html?search=loop&cb_lat=on&cb_tp=on&cb_SNB=on&cb_IVB=on&cb_HSW=on&cb_ADLP=on&cb_ADLE=on&cb_ZEN2=on&cb_ZEN4=on&cb_measurements=on&cb_doc=on&cb_base=on
>>
>>102125221
>if (data) delete data;
bloat, it's safe to delete nullptr
>>
>>102125233
that's just a mockup, a real implementation would simply forbid you from default-initializing (never null), also you can pass the allocator as a template parameter. But what's one branching of overhead compared to one syscall?
>>
>>102125192
Because c++ doesn't have pattern matching and the compile times for std::variant are terrible in my experience. The interface is awful as well and the performance probably isn't that great because it's all implemented in user code with no compiler support which might have lead to better IR being generated. std::variant is a very sorry excuse for a "sum type". The C++ committee need to get their shit together. They keep adding trash that nobody asked for or that people asked for but have now gotten the bastardized, perverted, and molested version of.
>>102125217
the original context of the discussion is an anon working in embedded.
>>
>>102125233
>autism engaged
>>
>>102125266
my real implementations require explicit initialization that's non-null
>>102125277
when you're coping in embedded, there's no errors, only states, not relevant
>>
>>102125107
I could signal nested optionals with the fourth flag combination and require a pointer to the rest of the value, with its inner type
>>102125132
I looked it up but it didn't make me snap my fingers
>>102125197
I see your reasoning but making option<int> stack allocated without indirection sounds attractive to me, worth the second bit to explicitly indicate the none
>>
>>102125300
eh? Errors exist for any real-world program. Failure to perform some operation is an error.
>>
>>102125300
explain to me how listening on a socket can never produce any error
>>
>>102125314
there's no failures in aircraft controller
>>
>>102125277
C++ DOES have pattern matching for variants. It's called std::visit.
https://youtu.be/et1fjd8X1ho

also see example code here: https://en.cppreference.com/w/cpp/utility/variant/visit
>>
>>102125314
error is failure, yes, failure of you, the programmer, in embedded everything is your decision, it works or not, calling it success or failure is subjective as long as it follows the spec, even if an operation fails, if it fails successfully, it succeeds
>>
>>102125330
microcontroller software has no operating system that tries to tardwrangle soidev programs, it only has your code, your code never errors, only waits or sends data, anything else is a bug.
>>
>>102125337
Don't spoonfeed the nocoders, their shitposts would be harder to distinguish from coders.
>>
>>102125337
anon, this is the "interface" I was referring to. it makes my eyes hurt. sorry but it's unreadable garbage compared to "match" and "if let" in rust.
>>
>>102125371
>nocoder
Fuck off
>>
>>102125354
yeah so if I listen over a socket and the socket suddenly send garbage data my program is supposed to carry on usual business? That doesn't make sense.
>>
>>102125371
what even is a nocoder anymore? someone who disagrees with you?
>>
>>102125389
garbage data is not an error, and it can be handled on the spot by simply being ignored
>>
>>102125397
so if that data is originally supposed to impact the state of your program, it's ok for your program state to become garbage too? sounds like you just created a bug by not writing error checks anon
>>
>>102125377
I agree it's not as tidy as in Rust, but I feel like it's more powerful and robust because the visitor object can be literally anything. And if you use the template that's shown in that video, it's only a little more code than in Rust. This should also work with concepts/enable_if in theory, SFINAE will just find the closest specialization for each possible variant, rather than having to match each specific variant.
>>
>>102125460
retarded nocoders will go out of their way to come up with a billion reasons to avoid OOP and polymorphism lmao.
>nooo, you don't understand, my heckin switch statement IS faster than virtual call, I know without even benchmarking, ok???? And branching all over the place totally won't ruin my performance anyway...
>>
>>102125481
I don't know if I would call this OOP, std::variant is not virtual. Really this is possible just because C++'s metaprogramming is so powerful. I don't know of any compiled language which does metaprogramming as well as C++, other than Dlang
>>
>it's switch statement vs virtual call
So how heavy was the anvil that your parents dropped on your head in order to retroactively abort you, and why the fuck did you survive?
>>
>>102125460
I think it's a cope but whatever...
>>102125481
Anon you are so fucking braindead it's hilarious. neither Rust enums nor C++ std::variant use "OOP" or "Polymorphism". Operating on either is more akin to using a switch statement than a virtual call. The irony of you calling others "nocoders" is palpable. Please never post here again, you retarded nocoder.
>>
@102125508
@102125523
LLMs still fail at basic reading comprehension
>>
>>102125542
sneed retard you just exposed to everyone how much a fraud you are.
>>
>>102125552
yes it's my fault that you nocoders are so afraid of OOP to the point where you can't even comprehend using it instead of whatever tranny shit you're discussing now, so you need to responnd with LLM tier niggerbabble about how it is indeed not OOP, I know, ifi t was OOP, it would be good, unlike your tranny idea of reimplementing vtable manually.
>>
I love how the nocodeshitter is having a complete meltdown.
>>
>>102125523
Virtual calls can be inlined by the optimizer, they're strictly faster as long as you don't use dynamic dispatch, rust has dynamic dispatch so it's slow
>>
>>102125614
lmao malding
this nigga is probably underage and he's already balding
>>
>>102125660
the tranny case that these nocoders are trying to use std:;variant in is the type where virtual call wouldn't be inlined, but that's not relevant
>>
the damage control ITT
>>
>>102112993
>go patch syntax mistakes and other nonsense
>spot 4 vulnerabilities, 9 possible additions and 2 optimizations
sigh, it never ends does it?
>>
>>102125660
you mean devirtualization? yes but I wouldn't really count on it. compilers are excellent at peephole optimizations but larger-scale stuff like this is more difficult because it requires interprocedural analysis if you want to do it really effectively.
>>102125675
There is no virtual call happening in the example. The type provided to std::visit is statically known, as are the concrete implementations of its methods.
>>102125705
indeed
>>
How would you write this in Rust? This is pretty readable to me

#include <variant>
#include <cstdint>

using my_variant = std::variant<int, uint64_t, float, double>;

struct visitor {
void operator()(std::integral auto& r) {
r += 3;
}

void operator()(std::floating_point auto& r) {
r += 3.14;
}
};

int main() {
my_variant v1 = int(1);
my_variant v2 = uint64_t(0xFFFFFFFFFFFFFFFF);
my_variant v3 = float(1.0);
my_variant v4 = double(1.0);

std::visit(visitor(), v1);
std::visit(visitor(), v2);
std::visit(visitor(), v3);
std::visit(visitor(), v4);
}
>>
>>102125750
I know Rajesh, lack of virtual call IS the problem there, you wouldn't be coping about syntax if you just realized that virtual calls cost absolutely nothing
>>
>>102125753
how about (int64_t)-1?
>>
>>102125797
It doesn't have the same energy
>>
>>102125797
how about ~uint64_t{}
>>
>>102125753
rust doesn't have traits to for integral or floating point. You literally need a dependency for that
>>
>>102125807
I'm more for
uint64_t(~uint32_t{}) << 32 | ~uint32_t{}
>>
>>102125819
Well you need C++20 for concepts, so you need a relatively recent C++ compiler too.

Also I could have added a couple of static, constexpr, noexcept, etc, to make sure it would all be inlined but you get the idea
>>
File: peepo.jpg (12 KB, 217x232)
12 KB
12 KB JPG
>compiler from 2017 is "recent" to /g/
>>
>>102125924
I'm on C99, but I respect the C89 fags, so yes, 2017 is recent.
>>
>>102125753
enum Value {
Int(i32),
U64(u64),
Float(f32),
Double(f64)
}

fn visit(value: &mut Value) {
match value {
Value::Float(x) => *x += 3.14,
Value::Double(x) => *x += 3.14,
Value::Int(x) => *x += 3,
Value::U64(x) => *x += 3
}
}

pub fn main() {
let mut v1 = Value::Int(1);
let mut v2 = Value::U64(0xFFFFFFFFFFFFFFFF);
let mut v3 = Value::Float(1.0);
let mut v4 = Value::Double(1.0);

visit(&mut v1);
//visit(&mut v2); this overflows btw. you can use wrapping_add if it is intended behavior.
visit(&mut v3);
visit(&mut v4);
}

I'll bet it has much nicer error messages if you make a mistake in your code and it comes with all the nice features of match statements like exhaustiveness checking and so on. Probably generates better code as well.
>>
>>102125943
*match expressions
>>
> //visit(&mut v2); this overflows btw. you can use wrapping_add if it is intended behavior.
>>
>>102125961
>program correctness and explicit intent is... le bad
>>
>>102125898
C++ has concepts since c++98, through the form of "enable_if" but they tend to be quite ugly and less powerful than c++20's concepts. Also <type_traits> has been a thing since c++11
>>
>>102125981
uint64 wraps around to 0 and that's standard and expected behavior, having to jump through hoops just to get it is indeed bad
>>
>>102125943
I definitely agree about the error messages, but there is one crucial flaw here. If I added, for example, int64_t, to my C++ variant, I wouldn't need to change anything and it would just work, whereas in Rust, I would need to define a new variant for int64_t
>>
>>102125943
your code doesn't handle all floating point types and all integral types. You can rely on the num-trait crate for that but I agree it's more convenient in c++
>>
>>102125997
I think you should specify the wrapping behavior if you want it desu senpai
>>
>>102126028
g++ -fwrapv, a lot of people forget that all architectures don't deal in 2's complement
>>
>>102126028
Yes that's what I do in C++, otherwise it's implied that it's not supposed to overflow at all, which is the case every single time, tranny paranoia about things overflowing is just trying to put a bigger problem under the rug
>>
>>102126009
True. This doesn't come up for me usually though.
>>102126011
Traits wouldn't help here. You need the separate branch because the extracted value is of a different type. You can't do
Value::Int(x) | Value::U64(x) => *x += 3,
because x is a different type between the two patterns.
>>
>>102126055
I never use this, if I need wrapping I will use builtins to wrap explicitly where it matters
>>
>>102126055
I thought c++20 made it standard? Anyway I was talking about it from a behavior specification perspective, like telling the person reading your code "yes, it's okay if this overflows, that is to be expected"
>>
>>102126115
I assume that people reading my code aren't retarded, but I guess that's a bit too much of a leap.
>>
>>102126162
Why do you have standards for others you can't hold yourself to?
>>
>>102126201
Because I'm only human and flawed, I cannot be a perfect wintoddler such as yourself.
>>
And here I thought you knew everything about your code.
>hahaha
>>
>>102125924
most shops still use C+11/14
>>
>>102126253
most shops also use windows, how is that my fucking problem?
>>
Every single time I write Windows code I just want to fucking delete it all and rewrite it from scratch using NT APIs. If you look at the Windows Terminal code, half of the shit is implemented using undocumented NT functions
>>
>>102126284
If you think that's already bad you don't want to know what a complete mess DirectX is.
>>
>>102126261
what does that have to do with peoples usage of the word "new" with various compilers
>>
>>102126308
wdym direct3d is fine. aside from the COM mess it's actually better than vulkan (not that that's a very high bar)
>>
File: vs_the_mess.png (25 KB, 600x968)
25 KB
25 KB PNG
>>102126320
>aside from the COM mess
Exactly.
>>
>>102126343
There is not enough Ex and W and A here
>>
>>102126313
because windows is stuck in fucking 80s, future is conversing with AI assistants in realtime while using rudimentary pointing via touchscreen for things that cannot be expressed yet with motion detection in 3D space
>>
>>102126091
then make sure to use -ftrapv which treats overflows/underflows as errors
>>
>>102126366
W and A only exist for non-Native-API functions. The kernel usually talks in UTF-16 unless a function accepts LARGE_STRINGs, which have a flag per object indicating if it's ANSI or no.
>example
https://doxygen.reactos.org/dd/d79/include_2ntuser_8h.html#a4fa159c31e2077dbf152829e2d7ffe54
>>
>>102126392
not going to do that because there's no usecase in being paranoid mentally ill freak like rust devs who turn all of these things on yet their stdlib is still full of severity level 9 bugs
>>
>>102126366
>xhe doesn't about IDXGIFactory6
I envy you. Ex/W/A suffixes are logical compared to that BS.
>>
>>102126416
>doesn't
doesn't know
>>
>>102126414
what was that 9.8/10 cve in windows ipv6 stack about?
>>
>>102126414
how even their code even run? unsafe instruction casues crash, stdlib is unsafe, why it does not crash on start?
>>
>>102126416
I almost thought it was like Prolog where the arity is part of the function name, and that was a way to make overloaded functions in C, but no, Microsoft is not that smart
>>
>>102126457
never heard of any ipv6 bugs, in fact I'm not sure what ipv6 even is, did you mean ipv4?
>>
ohzrlss
>>
>>102126482
https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-38063
>>
>>102126507
>>102126507
>microsoft
didn't read, not relevant to me what all saars wagie teams fuck up daily
>>
NtHireH1BEmployeesExW
>>
I love how the nocodeshitter is actively discrediting himself now.
>>
>>102126460
anon didn't take his meds before posting
>>
>>102126549
you are honestly feeding attention to the registry dumper schizo, he probably lives with his parents don't let him live rent free in your head.
>>
>>102126681
He lives in the registry, he breathes the registry
>>
>>102126681
to my knowledge the one who keep saying "nocoder" and the one who keeps saying "nocodeshitter" are different autists who despise each other
>>
File: absolutely_disgusting.png (90 KB, 1903x970)
90 KB
90 KB PNG
>>102126681
How can I be feeding attention to myself?
>>
>>102126703
both are in fact the wintoddler, I haven't used "nocodeshitter" for like 50 threads now, it simply lives on rent free in his head
>>
>he doesn't realize that his own creation has been turned against him
>>
"nocoder" is video dev bullshit that doesnt belong here
>>
>>102126703
unironically it is all the wintoddler
I think sometimes he forgets he is talking to himself and gets in his own head
>>
>>102126845
vidya development is the onlt based development
>>
>there's only one person ITT who likes money
The nocodeshitters make up the darnedest things.
>>
>he lurked for hours in wait for this moment
trips dont count.
>>
Yeah, like that.
>>
>>102123431
/*I know, but If i wasn't being lazy I would still write
int x;
int y;
because it's easier to read, but int x; int y with such short programs seems fine*/



[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.