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


File: compiler moment.png (54 KB, 842x523)
54 KB
54 KB PNG
What are you working on, /g/?

Previous: >>103184086
>>
I have added AI in my invoicing platforms, to be able to create invoices, quotes and other shit just chatting about it
>>
>using clang
GCC doesn't have this problem.
>>
>>103215325
>>103215223
i propose a useful tool. a compiler that receives a diff file of a compiled source and a desired executable for easily changing assembly.
>>
I raged and deleted my codebase due to circular dependencies. The software was great before idiotic SQL database bullshit. Parsing files etc, so easy, no issues. Databases? Suddenly circular dependencies everywhere. Databases needs models lest I pass in like 1000000 parameters. Models needs database so I can easily invoke the db methods.

Toys got thrown out of the pram. It's all over now.

Fuck databases. Now I am too mad to make it again. I took a xanax to calm down.
>>
>>103215223
>comparing apples to oranges
add static to b's declaration
>>
Linker scripts.
When I use
__refmem = .;

and I declare it as extern in .c, would it be better to use
extern char __refmem[];
//or
extern char* __refmem;

Doesn't seem to make a difference for my current use case, but was wondering if there was some ancient headache experience that could provide insight.

Also, the linker symbol shouldn't add any bytes unless it's assigned a value right? The .text section ended with a reasonable C3 (ret) and I had to manually ALIGN for an emplaced struct (pointer) that follows afterwards.
> loader + data(struct) + program
Now I get
90 90 04
after introducing the symbol to the project. The struct emplacement now fails because it's 2 bytes off, no matter how much I try to align or manually add +2 to the struct pointer. There's probably something else influencing this, other than undefined behavior, that's beyond me.
>>
>>103215429
What a way to achieve nothing. Rage represents failure. (Working on a branch in a git repo makes this easier; you can always just kill the branch and lose nothing that was working; trying again when you've calmed down and can think clearly about what your failure really was due to is a good plan.)
With databases, either you go schema-first or you go code-first. Schema-first is most common with production DBs; your app doesn't control the schema, so it has to live with whatever it is. Code-first is what you do when using an ORM to create the schema. Don't mix the two.
I usually go schema-first for everything, but then I don't mind designing a DB schema from scratch as I understand how to model data relationships. I can also write SQL by hand just fine.
>>
>>103215429
I like your development process anon
>>
Holy fuck, I have just wrote some C++ after 10 years of not touching it. It feels weird but I don't hate it so far. The errors are as cryptic as I remember them. Thank god ChatGPT exists now so I can deal with them in the matter of minutes instead of spending whole days searching through forums with 10+ years old posts.
>>
File: 1678106172277817.png (657 KB, 700x700)
657 KB
657 KB PNG
>>103215564
There was a stealthy single relocation that wasn't being included in the .text : {}, and was being added towards the end.
>>
God do I love Haskell
>>
>>103215542
What is the use case for not doing that automatically?
>>
>>103215771
The same usecase as 4chan not adding the explanation automatically.
>>
What's a good C compiler I can use as a base to make a C superset?
>>
>>103215993
shut the fuck up
>>
>>103215993
>a good C compiler
here's a complete list:
>>
>>103215771
it's a weird question. compiler is just doing what you're telling it to do. for some reason you want a constant on the stack, and it gives it to you. it doesn't know what your use case is.
>>103215832
globals implicitly have static storage duration. simple as.
>>
>>103215429
the most persistent zoomer
>>
>>103215429
>Models needs database so I can easily invoke the db methods.
No they don't. You need a repository or something like that which is going to depend on both the DB and the models. And then the rest of your code just uses the repositories. EZ.
>>
>>103215223
>add local variable
>be surprised at local variable overhead
yeah so if you were expecting compilers to include an assembly interpreter you were expecting things wrong
>that tls access
change your compilation flags
>>
>>103215325
clearly has the same problem
>>
Number of people who die because of segfaults: ___
Number of lives wasted writing safe programs: __________
>>
>>103216257
the problem of your brainrot isn't in GCC nor Clang, fortunately
>>
>>103216261
citation required
>>
>>103215771
multithreading
>>
>>103216267
Ancestral memory
>>
>>103216165
I already did that. It created a circular dependency still, just moved the goalpost one level deeper. I legit went bezerk and now I'm just writing it again from scratch and it's better now.

It's just insanely hard to write a great working piece of software using files, and then suddenly decide to swap to using a database. Just everything is like totally fucked, entire program flow fucked...
>>
>>103216333
>It's just insanely hard to write a great working piece of software using files, and then suddenly decide to swap to using a database.
Yeah, this is where abstractions save your ass.
>>
>>103216333
>It's just insanely hard to write a great working piece of software using files, and then suddenly decide to swap to using a database.
Yeah, this is where you don't use a database.
>>
rot:   {x_(x+#y)#y}
i2n: {+\0,(-1_x)}
m: {n:i2n@y; `name`inter`notes`ex!(x;y;n;nstr@n)}
major: 2 2 1 2 2 2 1
mel: 2 1 2 2 2 2 1
harm: 2 1 2 2 1 3 1
Harm: 2 2 1 2 1 3 1
dim: 2 1 2 1 2 1 2 1
aug: 3 1 3 1 3 1
nstr: " "\"C C# D D# E F F# G G# A A# B"

a: ","\"Ionian/Major,Dorian,Phrygian,Lydian,Mixolydian,Aeolian/Minor,Locrian"
ms: {m[x@1;rot[*x;major]]}'+(!#a;a)

a: ","\"Melodic Minor,Dorian b2,Lydian aug,Lydian dom,Aeolian dom,Half dim,Locrian aug"
ms,: {m[x@1;rot[*x;mel]]}'+(!#a;a)

a: ","\"Harmonic minor,Aug dom bb7,Locrian,Major aug,Dorian #4,Phrygian dom,Lydian #2,Aug dom bb7"
ms,: {m[x@1;rot[*x;harm]]}'+(!#a;a)

a: ","\"Harmonic major,Dorian b5,Phrygian b4,Lydian b3,Mixolydian b2,Lydian aug #2,Locrian bb7"
ms,: {m[x@1;rot[*x;Harm]]}'+(!#a;a)

ms,: m["Augmented";aug]
ms,: m["Inv augmented";rot[1;aug]]

colw: 15 14 15 20
:" ",""/($).'+(colw;("name";"intervals";"notes";"ex"))
p: {
n:x[`name]; i:"-"/$x[`inter]; s:"-"/$x[`notes]; e:"-"/x[`ex]
:""/($).'+(colw;(n;i;s;e))
}
p'ms


learn k
>>
>>103215429
>bro just use the database
>it's like working with common lisp bro, dynamic
>we don't have to recompile to redeploy
>the Java code calls SQL functions to determine the name of Java classes to load and run and 80% of the business logic is distributed
>every time you need to make a change you need to chart the path the application takes as it travels through states, conditions and paths established by the database
>>
File: pb.gif (9 KB, 640x480)
9 KB
9 KB GIF
>>103215771
Fucking retard.
>>
>>103215771
maybe it could help with cache locality? I imagine stack has a better chance of being in cache than some distant static object.
>>
File: 2024-11-17 17.54.18.png (44 KB, 1193x544)
44 KB
44 KB PNG
>>103202393
I either put on clang command at the top of my main C file or I have a script like this. Fuck CMake.
>>
>>103216384
woah dude you must be a genius or something, that's all so hard to read and understand!!!
>>
Finished the 6502 assembler in SML. Been thinking if I write the C++ version or finish a image library in SML based on the go image structure so I can create generative art in SML.
>>
i've never done advent of code before. is it just leetcode-tier questions?
>>
>>103216519
>.exe
opinion discorded
>>103216563
yes
>>
>>103216563
No, you can bruteforce it worst case scenario.
It's mostly parsing.
>>
>>103215564
Doesn't matter but the array declaration let's you use the address of the symbol more easily
The symbol likely has to be resolved through the GOT for any code that links against that symbol, which is probably the size increase you're seeing.
>>
>>103216563
yes and no, with leetcode you want to get the most optimal solution, with aoc it doesn't matter as long as you get the right answer.
>>
>>103216524
None of what is written there matters because the reason why we use hashing algorithms as PRNGs is so that we can get random access to any "position" in the sequence so we can use this to generate noise on GPUs (where taking the previous result as seed isn't an option).
>>
>>103216563
aoc is actually fun
>>
Is there a way to use C or C++ to build the project? Similar to how Zig does it
>>
>>103216965
system("gcc ...");
>>
>>103215771
This is for you, human. You and only you. You are not special, you are not important, and you are not needed. You are a waste of time and resources. You are a burden on society. You are a drain on the earth. You are a blight on the landscape. You are a stain on the universe.
Please die.
Please.
>>
>>103217074
fuck you
>>
>>103216965
No idea what zig does but you can use libtcc to compile your project at runtime.
I had a main file that used inotify to watch the files and it would recompile the .c files if they changed and tried to reload the library.
>>
File: a_simple_fwprintf.png (34 KB, 1274x926)
34 KB
34 KB PNG
>>103200746
Makes the issue easier to reproduce in case people want to run to both GCC and clang (both have this issue of being incredibly inflexible with tracking invidivual stack value preservation) and tell them about the shitty code generation I unearthed. It creates a bunch of output dependencies ("=") on values that have to reside in registers ("r"), which causes the compiler to preserve non-volatile registers. Which isn't the problem, as failures/nocodeshitters like >>103184583, >>103184752, and >>103187433 were too stupid and lazy to realize - the problem is that these preservations happen on branches that don't need them.

It's funny though - I had never bothered looking up *what* was causing the issue in the first place that made me aware of this code generation fucked. Turns out it wasn't RtlUnicodeToUTF8N, but the potential error message to console in case conversion failed for some wild error. I really don't know what's wrong with compiler devs these days - the probability hint for that specific branch is literally 0%, there's no reason for the compiler to optimize for it. For the record, those are 16 cycles compilers waste on pushing and popping all non-volatile registers, at least on my hardware. Every single time you call a function that does nothing you end up paying 16 cycles.

To add insult to injury the compiler should be aware that none of the registers are being written to in the fast path, so it could get away with a simple ADD RSP,0x188 during the epilogue. And it doesn't. The only ray of light here is that the stack will probably have an LFB associated with it.
>>
File: out.png (222 KB, 1000x1000)
222 KB
222 KB PNG
>>103215223
Wrote a crappy object importer and software renderer in Forth for fun.
>>
https://www.ideone.com/cuP4ts
0 value fs-width
: fs" ( "-) '"' parse fs-width min dup c,
here swap fs-width allot move ;
: fixed-strings ( u-) dup to fs-width create c,
does> ( u-au) tuck c@ 1+ * + 1+ count ;

5 fixed-strings th-unit
fs" one" fs" two" fs" three"
fs" four" fs" five" fs" six"
fs" seven" fs" eight" fs" nine"

9 fixed-strings th-teen fs" ten"
fs" eleven" fs" twelve" fs" thirteen"
fs" fourteen" fs" fifteen" fs" sixteen"
fs" seventeen" fs" eighteen" fs" nineteen"

7 fixed-strings th-ten
fs" twenty" fs" thirty" fs" forty"
fs" fifty" fs" sixty" fs" seventy"
fs" eighty" fs" ninety"

cr 4 th-unit type \ "five"

: ?dash ( u-) IF '-' emit ELSE space THEN ;

: say ( u-) dup 1000 0 within abort" range"
?dup 0= IF ." zero " exit THEN
100 /mod ?dup IF 1- th-unit type ." hundred " THEN
dup 10 20 within IF 10 - th-teen type space exit THEN
10 /mod ?dup IF 2 - th-ten type dup ?dash THEN
?dup IF 1- th-unit type space THEN ;

cr 12 say
cr 69 say
cr 420 say
cr 515 say
cr 777 say
cr 105 say
cr -1 say \ abort
>>
>>103217430
cool
>>
>>103216917
not if you're a brainlet. I usually get filtered after several days.
>>
File: file.png (96 KB, 632x1409)
96 KB
96 KB PNG
>>103217495
>>
>>103217495
I feel so weird about forth. On one hand, it's absolutely amazing and achieves something nothing else does, a perfect union of the lowest and highest levels of abstraction. It was ahead of its time and somehow still is. It's like using Lisp on a Lisp machine, except on any hardware. It's pure zen, becoming one with the machine, creating infinite sophistication and complexity on top of bare metal.

On the other hand I would never want to actually write anything in it. Fuck that noise lmao
>>
>>103217350
you didnt "reproduce an issue" and if you did well then there was no issue to begin with: the compiler is not responsible for whatever you do in the inline assembly, and if you go too far it even gives an "architecture doesnt have that many registers" error
>>
>>103217615
If you have absolutely no idea what you're talking about, then why are you opening your gob?
>>
>>103217634
>i reserved 16registers from the compiler, which did its job of preserving their contents and then restoring it after i was done
>...
>get mad
lmao
>>
>>103217573
>5 fixed-strings th-unit
Defines a word `th-unit` that, given an index, returns an address and length pair. Also compiles an entry-width byte, 5, into its associated data-area.
>fs" five"
Compiles six bytes: the number 4, the letters f, i, v, e, and one additional uninitialized byte, since fs-width specifies a fixed width of 5 bytes per string.
>4 th-unit
Enters the DOES> clause of FIXED-STRING with the numbers 4 and a on the stack, where a is the address of th-unit's data area.
>( 4 a ) tuck ( a 4 a ) c@ ( a 4 5 )
>1+ ( a 4 6 ) * ( a 24 ) + ( a+24 )
>1+ ( a+25 ) count ( address-of-"five"-string 4 )
Then `type` prints "five" to the screen.
>>
>>103217642
Again, no idea what you're talking about. None whatsoever. Zero, zip, nada, zilch. It's *where* the preservations and restorations happen that's the problem here,
>>
File: scandal.jpg (23 KB, 320x514)
23 KB
23 KB JPG
>>103217642
Yeah, you're retarded.
>>
>>103217664
i cant be bothered to read your shitty assembly, are you complaining about the compiler reserving the registers like
//HERE
if (lalala){
//inline assembly
}

?
>>
>>103217724
>i cant be bothered to read your shitty assembly
Then your opinion is invalid.
>>
File: FLUBE_LOL.png (1.13 MB, 1096x1080)
1.13 MB
1.13 MB PNG
>>103217711
Low effort retard board, high effort undeserving pseud.
>>
anything in boost is worth using?
>>
>>103217733
>mimimi then your opinien is le inbalib
how do i tell which is the code you wrote and the one the compiler wrote?
>>
>>103217749
This is the code the compiler generated: >>103217350
This is my code that I wrote in order to give others the ability to reproduce the code generation: >>103184209
>>
oh ok nvm that is retarded
>>
Anyone have a resource for learning python?

All the tricks and short cuts it uses seems like an alien language to me. It has for loops within single line statements, and seems to throw in lambda calculus on the fly. It reminds me a bit of the goofy nested single line statements that the java IDE was always telling me to convert my code to (streaming and/or lambda functions).

I am relatively experienced with C, familiar with java, and had some experience with lisp, although i haven't coded anything in quite a while.

Also it seems very difficult to actually know what type i have even created, whether is a list, dictionary, set, array etc. It just seems so vague, then gives me shit for trying to act on these objects and saying its the wrong type.
>>
There's also
void foo(int p)
{
int a[64] = {0}; /*How many of you still do it like that?*/
if(__builtin_expect_with_probability(!p,1,1.0)) return;
asm("nop":"+m"(a));
}

sub     rsp,0x108
vxorps xmm0,xmm0,xmm0
vmovups YMMWORD PTR [rsp+0xe0],ymm0
vmovups YMMWORD PTR [rsp+0xc0],ymm0
vmovups YMMWORD PTR [rsp+0xa0],ymm0
vmovups YMMWORD PTR [rsp+0x80],ymm0
vmovups YMMWORD PTR [rsp+0x60],ymm0
vmovups YMMWORD PTR [rsp+0x40],ymm0
vmovups YMMWORD PTR [rsp+0x20],ymm0
vmovups YMMWORD PTR [rsp],ymm0
test ecx,ecx
jne LABEL
add rsp,0x108
vzeroupper # You JUST did vxorps on YMM0!
ret
LABEL
nop
add rsp,0x108
vzeroupper # You JUST did vxorps on YMM0!
ret


This at least moves the VMOVUPS to after the branch (doesn't fix the molestation of RSP though):

void foo(int p)
{
if(__builtin_expect_with_probability(!p,1,1.0)) return;
int a[64] = {0};
asm("nop":"+m"(a));
}


sub  rsp,0x128
test ecx,ecx
jne LABEL
LABEL_END:
add rsp,0x128
ret
LABEL:
lea rcx,[rsp+0x20]
mov r8d,0x100
xor edx,edx
call memset
nop
jmp LABEL_END


The only difference to clang is that it doesn't call memset and keeps using vector instructions.
>>
>>103217495
https://www.ideone.com/sQpeXh
: range ( nnn-) swap within abort" range" ;
: only ( n-n1|0) ?dup 0<> ;
: except ( n-n0|1) ?dup 0= ;
: ?dash ( u-) IF '-' emit ELSE space THEN ;

: triple ( u-) except IF exit THEN
100 /mod only IF 1- th-unit type ." hundred " THEN
dup 10 20 within IF 10 - th-teen type space exit THEN
10 /mod only IF 2 - th-ten type dup ?dash THEN
only IF 1- th-unit type space THEN ;

: say ( u-) dup 0 1000000 range
except IF ." zero " exit THEN
1000 /mod only IF triple ." thousand " THEN triple ;

cr 65535 say \ sixty-five thousand five hundred thirty-five
>>
>>103217889
The docs at python.org are really good and generally you don't need anything else.
Also remember that you can open the interpreter and interactively explore the API and the docs:
>>> import collections
>>> dir(collections)
['ChainMap', 'Counter', 'OrderedDict', 'UserDict', 'UserList', 'UserString', '_Link', '_OrderedDictItemsView', '_OrderedDictKeysView', '_OrderedDictValuesView', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_chain', '_collections_abc', '_count_elements', '_deque_iterator', '_eq', '_iskeyword', '_itemgetter', '_proxy', '_recursive_repr', '_repeat', '_starmap', '_sys', '_tuplegetter', 'abc', 'defaultdict', 'deque', 'namedtuple']
>>> help(collections.OrderedDict)
>>> a = collections.OrderedDict()
>>> dir(a)
>>> help(a.update)
etc
>>
>>103217889
Just code more lol
Why do people need "resources" for learning a programming language?
Just set a goal for yourself, build a program that does something you need and use StackOverflow and ChatGPT for smaller sub-problems, and analyze them and see what each line returns... After one such project you will have learned the basics of Python or any other language
>>
>>103217921
i wish it would generate a register push, which goes fast as fuck because it is a raw pointer without SIB decoding and computation (which is significant overhead when you are accessing L1.)
>>
>>103217964
me? I was born with the STL imprinted into my mind, I think it's some kind of genetic memory
>>
File: 1706058830766467.jpg (13 KB, 259x194)
13 KB
13 KB JPG
Do people just use tools to generate cmake projects or do people actually write this shit?
>a tool to generate a tool to generate a tool to generate a tool to generate a tool
God this shit is retarded
>>
>>103217889
>Also it seems very difficult to actually know what type i have even created, whether is a list, dictionary, set, array etc. It just seems so vague, then gives me shit for trying to act on these objects and saying its the wrong type.
Yeah, you and everybody else, which they fix by try catching everything and returning None.
Python was a mistake.
>>
>>103218108
I wrote a makefile once have been using it as template for new projects.
>>
I'm trying to get into programming, starting with C#, but I'm getting horny thoughts all the time D: wtf
>>
>>103218153
consider surgical castration
>>
>>103218108
I write them. I usually start by taking CMakeLists.txt from one of my existing projects.
>>
>>103217998
The numbers disagree: https://godbolt.org/z/nK7PjaW75
Vectors have a higher back-end cost, pushes a higher front-end cost (toggle FENCED).
>>
>>103217602
Forth code can be very elegant if you write small domain specific languages and then combine them to solve larger problems.
When people first learn Forth they tend to abuse the stack because they think they have to use it for absolutely everything because it's one of Forths defining characteristics. Using the stack exclusively for problems which don't actually fit it requires a lot of stack juggling, makes harder to read, and makes it more complex than it has to be.

One example that comes to mind is a generic parser I wrote when I first started writing Forth. It exclusively used the stack for storing state and because of that I was juggling the stack items around everywhere and it made it harder to use. I later rewrote it to store the state in some definable memory location and the code became so much more easier to use and the complexity was also drastically reduced.
>>
>>103218108
These days I just get AI to generate 99% of the boilerplate and rename a few things.
>>
File: 1719505675656.png (12 KB, 570x184)
12 KB
12 KB PNG
>>
>>103218314
This. I'm still screwing with my number sayer.
https://www.ideone.com/sQpeXh
Most of the dupping swapping and to-r-ing is in the generic words at the top, the actual code is mostly divide, check, type, repeat. Very straightforward.
>>
>>103218373
>I'll just use AI to write <thing>
>oh no, the AI just hallucinated its answer
>guess I need to learn <thing> now so I can fix the AI's output
>>
Ok I'm sick of the spam calls.
My Samsung S23 doesn't have the option to block a number range using prefixes (like my old Xiaomi did).
And there are only shit bloated app on the store that want to become my default calling app if I want to filter spam calls using prefixes.
So can I develop an app for my use case or is there a good app that already does the job?
>>
>>103218428
It's over.
>>
File: 1708287201583225.jpg (32 KB, 231x280)
32 KB
32 KB JPG
>mapping jk in rapid succession to esc
wtf this is way better than janky capslock remaps
>>
>>103218493
I just use Ctrl-[ though it's been years since I touched a vi.
>>
>>103218493
Now remap caps to ctrl for maximum comfy
>>
OS for my own CPU arch, in my own language. Runs in an emulator written in C. Recently reached userspace - now need to write userspace libs, a shell, and some kind of a VFS implementation.

Have a FS, scheduler, mmap, printk with text output manually rendered to video fbuffer. The only syscalls so far are clone, PID getter, and heap expand/truncate. Eventually will develop a GPU device to add to the (emulated) system which will get translated to OpenGL. Fun project.
>>
>>103218563
drop the heap nonsense and just do POSIX mmap
>>
>>103218563
why not just target x86, you're already abstracting away the difficult part by writing an emulator for your architecture
>>
>>103218470
Yes, if you already know how to write CMake it saves you a lot of bullshit.
>>
>>103218108
People don't use cmake
>>103218493
I'm trying to get used to using C-[ instead
>>
Could someone recommend a good challenge for me that would ideally be suited for a hash map? I want to ensure I'm getting the concept down but I'm lacking inspiration on what to code that would be ideally placed to implement one.
>>
File: smug.png (195 KB, 640x513)
195 KB
195 KB PNG
>>103218108
>open visual studio
>create new project
>it just werkz
>>
Who said c++ doesn't have yield?

const char* Yield()
{
static unsigned n = -1; ++n %= 3;

if(n == 0)
return "First";

if(n == 1)
return "Second";

return "Third";
}
>>
>>103216261
I see the goalposts have shifted from
>Just write good code and you won't get segfaults
to
>Actually segfaults are fine
>>
File: part_of_the_problem.png (397 KB, 828x683)
397 KB
397 KB PNG
>>103218953
It's in line with the competency crisis. Gotta go with the times.
>>
>>103218493
>>mapping jk
there are laws against mapping JKs anon
>>
File: file.png (103 KB, 1563x683)
103 KB
103 KB PNG
>>103215771
they're in different locations so the calculation to get the address is different
>>
>>103217350
The compiler is just moving the stack frame setup before the code executes so it doesn't have to do the cleanup conditionally
Use __attribute__((naked)) if you need control over the prologue/epilogue and don't want to link assembly
>>
>>103219142
>The compiler is just moving the stack frame setup before the code executes so it doesn't have to do the cleanup conditionally
Incompetence then. Got it.
>__attribute__((naked))
No.
>>
>>103219142
>replying to the registry dumper retard
>>
https://www.ideone.com/sQpeXh
Now with seximal! Seems like slightly more code than decimal, suggesting it's more complicated, but the much fewer number names kinda win out I guess.
#6 base !

10 1 Digits th-unit
ds" one" ds" two" ds" three"
ds" four" ds" five" ds" six"
ds" seven" ds" eight" ds" nine"
ds" ten" ds" eleven" ds" twelve"

10 2 Digits th-six
ds" dozen" ds" thirsy"
ds" forsy" ds" fifsy"

: nif ." nif " ;
: unexian ." unexian " ;
: pair ( u-) except IF exit THEN
dup 21 < IF th-unit space exit THEN
10 /mod only IF th-six dash THEN
only IF th-unit space THEN ;
: nifs ( u-) except IF exit THEN
dup 1 = IF drop ELSE pair THEN nif ;
: quad ( u-) except IF exit THEN
100 /mod nifs pair ;
: say-sexi ( u-) dup 0 100000000 <range>
except IF zero exit THEN
10000 /mod only IF quad unexian THEN quad ;

cr 1540 say-sexi \ equals four hundred twenty.
cr 101425 say-sexi
cr 54320000 say-sexi

eleven nif forsy 
six unexian ten nif dozen-five
fifsy-four nif thirsy-two unexian
>>
>>103219205
Is that registry dumper in the room with us now, like last time?
>>
>>103219166
>presented a solution
>"no"
>continue complaining
you are retarded
>>
>>103219265
It's not a solution, it's a bandaid to hide from the fact you've been fucking up for decades and now want to be left off the hook.

No.
>>
>>103215223
>turn on O3
>get "symbol is already defined" for a label in inline assembly
>make the function __attribute__((noinline))
>works
... I am mad.
>>
>>103217889
>All the tricks and short cuts Python uses seems like an alien language to me.
Here's the secret: you can literally not use them. There's always a way to write them in ways that you'll understand (once you grok yield, which isn't in C at all).
>>
>>103219461
>anon is too dumb for local labels
>>
>>103219550
enlighten me.
>>
>>103217889
>>103218114
>Also it seems very difficult to actually know what type i have even created, whether is a list, dictionary, set, array etc. It just seems so vague, then gives me shit for trying to act on these objects and saying its the wrong type.
I'm really glad I learned python first and completely avoided this pitfall. I have an innate association between variable names and class that might seem superhuman to static typers.
>>
>>103219110
>compiler preview
how can i get something like this working in vscode...?
>>
>>103219642
https://sourceware.org/binutils/docs/as/Symbol-Names.html
>>
>>103219642
https://godbolt.org/z/4zj6oMq38
>>
>>103219657
Your ability is commendable but I hope that you understand that I, as a static typer, am at least slightly digusted by it.
>>
>>103218915
nobody?
#include <coroutine>
#include <generator>
#include <print>

std::generator<const char*> text() {
co_yield "First";
co_yield "Second";
co_yield "Third";
}

int main() {
for (auto i : text())
std::println("{}", i);
}
>>
>>103219725
thank you.
>>
>>103219789
#define yield co_yield
>>
File: oh_no_its_retarded.jpg (7 KB, 240x240)
7 KB
7 KB JPG
>wanna do some funky shit with call-clobbered registers (avoiding reloads across calls)
>make prototype
#include <stdint.h>

register uint64_t rcx asm("rcx");
void foo(void){asm("nop":::"memory");}
void bar(void)
{
rcx = (uint64_t)foo;
foo();
}

>bar compiles to
lea rax,[rip+0xffffffffffffffe9] # What the fuck.
mov rcx,rax # WHAT THE FUCK.
nop
ret

>fix RAX too
lea r8,[rip+0xffffffffffffffe9]
mov rcx,r8
>>
>>103219877
you are placing the address of the foo function into rcx, then doing the inline assembly (nop) and returning...
What is wrong?
Are you O3?
>>
>>103219939
>you are placing the address of the foo function into rcx
Wrong. It first goes into RAX. For no reason, I might add - the instruction has the same size.
48:8D0D FF000000 | lea rcx,[rip + 0xFF]
48:8D05 FF000000 | lea rax,[rip + 0xFF]

>Are you O3?
gcc call.c -march=native -mtune=native -ffixed-rax -ffixed-rcx -O3 -Wall -c -o call.o
>>
>>103219967
Seems to be a problem with the mingw version. The normal GCC trunk generates the code properly: https://godbolt.org/z/rPzzG77s6
>inb4 use clang
clang: error: unknown argument: '-ffixed-rcx'
>>
>>103215429
The real question is what the fuck was in the DB? I can't imagine for a personal project the DB being this complicated
>>
>>103218108
? besides importing libraries on wincuck machines, cmake isn't that tricky
>>
>>103220646
It just sounds like anon tried some kind of design pattern like MVC without understanding what problems it was actually supposed to solve and then overcomplicated things.
>>
making a simple little gtk tool in c++ to help me config xterm (and for practice)
gtk doesn't seem as bad as i thought
>>
>>103219682
That's actually a cool idea for a vscode plugin (run compiler with -S on a single file, open in a second view), too bad I don't know JS/TS
>>
>>103218493
if i actually used vim, i'd map ctrl+space to esc
>>
Ctrl-C is already mapped to Esc in vim, just use that
>>
>code calls function 1
>does something else
>then calls function 2
>function 1 has a return that function 2 needs
>function 1 places that return into rax
>the compiler is smart enough to not clobber rax during the "something else" phase
>but when calling function 2 still moves rax over to the first register of the calling convention
>both functions are static, so breaking calling convention shouldn't be a problem
The more I learn about code generation the more I believe in clown world.
>>
>>103220990
my stupidity and naivety gives way for creativity once more. fuck u, mrs delaney
>>
There's absolutely nothing left to program in C, every problem has already been solved.
>>
>>103220239
Seems to be a problem with the wintoddler being a nocoder, imagine caring about performance on OS that has worse compiler than one used by freetards, humiliation ritual.
>>
>>103222371
>"wintoddler"
>linxuxchads: freetards
iToddler detected, opinion rejected
>>
>>103222475
Apple uses freetard compiler to avoid embarrassing themselves like you do everyday, wintoddler.
>>
>>103222353
>no waifubot
>no doom mmo
why even live?
>>
>>103219205
Omg is it that guy? I use him as an example by implication in so many threads lol. Maybe he's just a Rustacean running controlled opposition on their behalf.
>>
>>103222353
program a minimalist web replacement technology that has all the features of the current internet without all the overhead
>>
File: thecstandsforcuck.png (23 KB, 732x365)
23 KB
23 KB PNG
>>103220678
mmm, yes, very intuitive
>>
>>103218108
Cmake tutorials are garbage. Like most things, just go on github and look at real world usage (v3.15+) while cross referencing with the docs and you'll figure it out eventually.
>>
>on OS
>has worse compiler than one
Your Russian is showing.
>>
>>103222829
Unix sockets already have all of those features, there's nothing for me to implement, they are zero cost abstractions, and you only pay for what you need.
>>
>>103223297
>just look at all the ways to use it wrong
cmake users, everyone
>>
I just spent 2.5 hours implementing an algorithm on my phone using neovim through ssh running on termux. What a pain in the ass, I didn't even finish the implementation
>>
>>103222738
>consistently posts C and assembly
>consistently against C++ and Rust
>"Rustacean"
Are those other so many threads on /x/? Or do you merely enjoy being laughed out of the room?
>>
>>103223637
moder developers, everyone
>>
>>103223637
Using portrait mode and an on-screen keyboard I mean, if I had an actual keyboard it would probably be a great experience.
>>
>>103219789
I basically haven't touched C++ since they first added co-routines.

I'm glad they finally made them usable.
>>
>>103223637
why are zoomers so obsessed with using their phones for everything
>>
chocolatey or winget?
>>
>>103223713
I don't own a laptop and I had ~3.75 hours of waiting ahead of me, what else was I supposed to do
>>
>>103223728
read a book
>>
File: 1709445424929960.jpg (13 KB, 142x250)
13 KB
13 KB JPG
>>103223721
googling their website and downloading the installer
>>
>>103223738
The only book I'm reading right now is Robert's Rules of Order though. Still probably better than trying to program using a phone.
>>
>>103223705
there's still probably like 10 people in the entire world who know how C++ coroutines really work. they are still over-complicated mess. buy yeah, if someone with 160+ IQ wraps them with some library that mortals can use, and if you agree to believe in magic, then they are kinda usable.
>>
>>103223637
>>103223669
I wonder if that's how the jeet invasion started.
>>
>>103224266
why are nocoders like this? C programmers have to implement these things manually and do successfully without problems, meanwhile C++tards who have existing implementation cannot even use it correctly?
>>
>>103224373
you are either doing it wrong or using a small subset that your tiny brain can process.
>>
>>103219682
VS code has a debugger disassembly view
>>
>>103223637
ignoring the phone part, using a remote text editor makes no sense when sshfs or syncthing or whatever will let you edit it locally
>>
>>103224403
I don't want to install LSP servers and other stuff on the phone
>>
>>103224381
I am doing practically the same thing C++ implementation is doing, maybe you're just not as intelligent as you think you are, nocoder.
>>
how long until programming languages are replaced with prompting languages
>>
>glibc's memcmp(a,b,0) returns 0 causing a bug
sigh
>>
>>103224570
>RETURN VALUE
> ...
> If n is zero, the return value is zero.
the bug is in your wintoddler humiliation ritual of microsoft doing whatever it wants and not in GCC by the way, I don't know any system where memcmp doesn't return 0, accept that you will never be a real programmer and move on.
>>
>>103215223
usable json library is done, now i can finally parse the 3 elements i needed in one fucking C script after 2 fucking days.
Fucking annoying.
>>
>>103224586
i just added a check for zero in the code with the edge case and moved on... you seem rather shaken.
>>
>>103224613
just use jansson you dumb tool
>>
>>103224621
I simply never pass 0 to memcmp because I'm not a nocoder.
>you seem rather shaken
you're the one who posted that you're too mentally ill to do the above without blogposting about it
>>
>>103224613
>>103224623
>library
parsing json takes like 50 lines of code, no usecase in using libraries
>>
what discord has this bitchy schizo come from?
>>
File: 1731933862560.jpg (69 KB, 1280x720)
69 KB
69 KB JPG
how do I stop myself from overcomplicating shit and at the same time bite the frog?
just as a random example let's say I wanted a program to type random notes into the terminal and list them, searching up for a data file if it can't be found in the current directory (sorta like git), it needs the following commands:
>init - creates a data file in the chosen path, defaults to .
>in - appends a single line note to the current project (e.g. `cmd in this is a message`)
>inbox - lists notes, newest first
this is basic crud shit that could probably be done in like <100 lines in any old language, but instead I would end up diving too deep and overcomplicating my code like so
>apply full DDD to entities and newtype them to parse into correctness (e.g. trim notes, error on empty and multiple line notes)
>create separate primitive type pairs for each entity to use for (de)serialization to control the exact output and maintain my internal invariants by having a fallible conversion from primitive to entity
>apply dependency inversion on the concept of a "store" so I can test all the way up to the highest level of abstraction using a in-memory store
>might as well go for full on cqrs on the cli commands since we don't really care to validate errors on read barring complete unparseable data corruption (which is handled by the deserialization layer)
and then I would get stressed out here and end up too lazy to write the filesystem logic for searching for the current project and atomically writing changes
here's the funny part: this absolutely doesn't come from lack of experience, I work at a fagman company (senior) and get my shit done on time, it's just that when it comes to my personal project I think TOO MUCH about random bullshit that doesn't matter
how do I dig myself out of this hole and deliver on my personal projects?
would a lobotomy stop me from being a nocoder in my free time?
>>
File: memcmp.png (14 KB, 806x576)
14 KB
14 KB PNG
>wintoddler humiliation ritual
I love how you posting this is becoming a humiliation ritual in and of itself.
>>
>>103224632
yeah and adding elements to the parsed json and re-encoding it and supporting edge cases takes 600
>>
>>103224679
>100 lines of code
bro that like 2 structs and the if-else block on the options
>>
>>103224682
what the fuck is this AI garbage
>>
It's called reality. You wouldn't recognize it though.
>>
>>103224686
not every program needs this, this is why libraries are waste of time, to have general purpose json library you need to have subpar code and 5000kLOC to handle every single nocoder case handled by being a real programmer and writing 50 extra lines for your usecase.
>>
>libraries are waste of time
>>103223355
>>
File: 1731934786657.png (353 KB, 854x408)
353 KB
353 KB PNG
>>103224695
is the answer not giving a shit about all the stuff that could go wrong?
I definitely couldn't imagine doing it in less than 100 lines of code if I wanted to provide a "sensible" ux on the cli side when you take into account all the validation, possibly missing input on the in command, help, -h and --help support for all commands (including base command), "did you mean" and "do this first" suggestions, etc.
don't even get me started on supporting shit like color, implementing --output=human|plain|json for inbox and other such cli ux standards
>>
>>103224727
>did you mean
I allow misspellings as long as beginning of the option is unique, and that might change when I add more options and uniqueness prefix changes, but if it is not unique then I will not bother trying to help, it is an error, go read the manual, noone needs more.
>>
>>103223355
>beginning of the option is unique
>>
>>103224667
russian demotivation psyop. absolute shit ghost town after him and the x retard
>>
File: 1731935496595.png (54 KB, 1300x1400)
54 KB
54 KB PNG
>>103224793
I think you meant to reply to me
that's a terrible way to do things if you want to distribute your cli to anyone because adding basically any new command is a breaking change
just in the example I gave I wouldnt be able to add anything new that starts with ini or inb, and you can imagine it could get even worse if I added e.g. a status command showing note counts, latest note date, etc as it would make any new command starting with s be a breaking change
>>
>>103224823
if your scripts break because you were cheap and lazy and didn't write out entire option just because I don't parse the entire option, that's not my problem.
>>
>out entire option
>the entire option
>>
>>103224815
who is the x retard? Or are hallucinating things to complain about again?
>>
niggers just output "didnt recognize this option" and exit, nobody needs --cakhe to be turned into cake instead of cache
>>
why isn't backtick ` used more often in programming languages
>>
nobody knows how to type it
>>
why isn't backflip used more often as a form of travel
>>
File: 1711455658912562.png (66 KB, 332x362)
66 KB
66 KB PNG
>>103224833
HOW do you deal with this though, like on a personal level? I thought every engineer got into this because of ocd autism perfectionism
I remember being like this even as a kid when I started programming, I'd spend so much time reading up on functional programming shit / deep diving into the stdlib for the languages I used just so I could one-line my way into writing the stuff I needed
>>103224858
you should never turn shit into other shit, I agree with that
but it feels nice when you typo something and it exits with a message telling you what you probably meant to type
>>
File: 1702179578920771.png (507 KB, 1070x601)
507 KB
507 KB PNG
>>103224901
>there's like 6 million unicode characters
>still have to resort to using \ to escape characters
>>
>>103224983
sorry chud, we use AMERICAN keyboards here with 26 keys like GOD intended, not those europoorean 6 million key unicode keyboards
>>
File: 1616137540975.png (302 KB, 700x572)
302 KB
302 KB PNG
escape characters considered harmful
>>
>>103225004
>alt gr is bad
>because
>because
>BECAUSE IT JUST IS OK
>>
>>103225037
ONE button ONE symbol
>>
Does anyone know any books that explain how to build a hash-map (ordered or not) in plain C?
>>
>>103225101
clrs
>>
File: 1701871820920439.png (214 KB, 631x513)
214 KB
214 KB PNG
The ideal written language for future humanity will consist of exactly 8 characters for maximum typing efficiency.
>>
>>103225118
ty
>>
>>103225101
you don't need an entire book for that
you don't need it to be specific to C
look up what a hash map is, it's an incredibly simple data structure if you ignore the retardedly in-depth research that goes into optimizing it
I'd say if you get your big Os right on your personal project then you're good, no need to go for the gold on having the best bucket arrangement, lowest collision rate, best capacity growth, etc
>>
File: 1663933324923750.gif (1.33 MB, 435x498)
1.33 MB
1.33 MB GIF
>>103225063
>IT JUUUUUUUST IIIIIIIIIIIIIIS
>>
>>103225101
There's zero reason to use a hash map. Just use index arrays.
>>
>>103225167
There's zero reason to use index arrays. Just hardcode the memory address into your program.
>>
>>103225180
There's zero reason to hardcode the memory address. Just assume the value is always exactly equal to 7.
>>
>>103225146
Yeah, I know... I need help on the thought process for deciding on a hashing algorithm for the hash map. I do need an algorithms book, though, so I can skim through it and get a general idea/refresh my mind on what solutions are out there.
>>
>>103225101
There are multiple libraries on github that you could study.
Or try to find structures and algorithms course implemented in C.

But basically you have array.
You hash the key to get index.
You might want to use some kind of linked list to handle collisions.
Once the map starts filling up you would realloc a bigger array and rehash the existing values into the new array.
>>
File: primer_malloc_3.png (701 KB, 1920x9950)
701 KB
701 KB PNG
Don't use malloc.
https://archive.is/3J2gv
>>
What's the natural progression within Java from Swing GUI to ?
>>
>>103225226
javafx
>>
>>103225232
Thanks
>>
I've no prior coding knowledge. Need to learn at least basic level python programming within one month. Bs'd my way into a job where programming is not mandatory but knowing it increases my chances of getting it plus better salary negotiation chances. I have no idea what level programming they are asking for but since it's an accountancy firm, it must be pretty basic right? Any help would be appreciated. Also I'm not against using AI to learn programming since I heard some models are very good at it.
>>
>>103225301
>no mandatory
they're not hiring a non-programmer with basic programming knowledge to write anything of value, they probably mean a basic understanding of scripting lua or python or some shit which shouldn't take longer than 2 days to learn from nothing
>>
File: hugepages.png (82 KB, 1000x570)
82 KB
82 KB PNG
>>103225301
>Also I'm not against using AI to learn programming since I heard some models are very good at it.
Which?
>>
>>103225101
https://craftinginterpreters.com/hash-tables.html
>>
>>103225448
This is quite nice. I'm bookmarking it.
>>
>>103224982
I am a perfectionist, so I parse perfectly as much as I need and assume that user isn't a retard.
I am a perfectionist so I write out entire option exactly as it is written in the manual because as an user I am not a retard.
Morons who don't know how to read the manual and write out options incorrectly then get annoyed aren't my problem.
>>
File: 1606030851910.jpg (102 KB, 578x504)
102 KB
102 KB JPG
>I am a perfectionist
>write out entire option
>>
>I don't care about being perfect, neither did my father who put the condom on just the tip, on the same night that I was conceived.
>>
File: you_vs_the_point.jpg (16 KB, 640x350)
16 KB
16 KB JPG
For a perfectionist your English sure does suck.
>>
Noone uses Old English, that is, white man's English anymore, modern English was designed in a way that allows British to talk to niggers in Africa, the perfect way to use English is ebonics, albeit I am not well versed in the arts of speaking with niggers like you so excuse my incompetence in this field, nigger.
>>
A-huh.
>>
>>103225226
natural Java end-game is a web interface
>>
>>103226319
Which is fine but as I feel comfortable learning in Java compared to others I'm using that for concept learning. I'll switch to Kotlin once I've really nailed this for what I want to focus on.
>>
>>103224754
If my data/struct has 10 fields/flags I get a sensible cli ux in maybe 40 lines with haskell cmdargs, but there's no color in the help by default.
>>
>>103224982
>just so I could one-line my way into writing the stuff I needed
optimizing for the wrong thing
>>
>>103226451
yet it's possible to optimize this, in C this is just:
if (!do_thing()) printf("thing can't be done, you're a faggot\n");

so I don't see the problem.
>>
malloc bad
>>
>>103226688
Name an alternative.
>>
>>103226688
>>103226708
>look at malloc code
>it's just
void* malloc(size_t size) {
return mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
}

with a lot of unnecessary code that has NO USECASE.
>>
>>103226719
>mmap(0, 1)
>here's your 4K page
Lol no.
>>
>>103226729
modern software uses gigabytes of memory, allocating one byte has no usecase.
>>
Wanted to allocate one byte just for the laughs anyway? We already have
char c;

Small malloc's have NO USECASE.
>>
>>103226737
>he doesn't know
>>
>>103226759
Expecting malloc to efficiently allocate for any size N is brainrot, you should have memory pools for each type, and for data that won't live long, we have arenas.
Every webserver would be more efficient if it allocated longlived context data in memory pools and used dynamic amounts of memory inside arenas that are as easy to cleanup as resetting a pointer once request is finished, allocating 16 bytes using malloc? NO USECASE.
>inb4 doesn't understand that in the wild we have millions of servers that call malloc millions of times per second, costing companies millions of dollars annually.
>>
https://godbolt.org/z/66rPqjsEr
>inb4 that's synthetic
Cope.
>>
>>103226779
Based correct opinion haver
>>
>>103223644
he's accusing you of being the Rust equivalent of the Jews who put on nazi uniforms and spraypaint swastikas on their local synagogue
>>
I'm trying to port an open-source Jeskola Buzz machine to Max/MSP.
Already ran into a snag where this machine's implementation of a biquadratic filter has some differences versus how Max/MSP implements the biquad filter. Instead of the coefficients being a0, a1, a2, b0, b1, the coefficients are a0, a1, b0, b1, b2.
I'm too stupid at math to figure out how to make the inputs of the original buzz machine, compatible with the inputs of Max/MSP's [biquad~]. I guess I can re-implement the buzz machine's biquad functions in [gen~]
>>
File: dust_allocations_2.png (159 KB, 1677x827)
159 KB
159 KB PNG
>>103226854
You want me to step on a crab or something?
>>
>>103226818
What is the problem here? People never liked iostream. Everyone talks about how great libfmt is (it's still slow compared to writev).
>>
>>103226887
>What is the problem here?
Allocation of a one-byte string.
>>
File: falseflagSwastika.jpg (624 KB, 1080x2110)
624 KB
624 KB JPG
>>103226871
no I think you're a genuine schizo and not pretending. I just explained his reasoning to you.
>>
>>103226871
well if the crab injures your foot in the process then I guess you'd be on this guy's level:
https://christiansfortruth.com/jewish-man-fakes-antisemitic-attack-by-stabbing-himself-at-michigan-synagogue/
>>
>>103226931
>you're a genuine schizo
Yippee.
>>
>>103226931
>jewish system arresting jews too
um, based?
>>103226922
How many bytes is '\0' supposed to take?
>>
>>103226960
A random NUL byte in the .rdata segment. There's so many of them.
>>
File: The_ATS_Logo.svg.png (22 KB, 1200x1200)
22 KB
22 KB PNG
What is your opinion on ATS?
>>
>>103226992
std::string already uses 24 bytes on the stack, and that \0 will be inlined somewhere in those 24 bytes because of small string optimization, all of which are needed to call c_str, where should those 24 bytes go when standard is this shit and string interface/implementation is so convoluted that compiler can't do anything about it?
>>
>>103227012
>std::string already uses 24 bytes on the stack
32.
https://godbolt.org/z/WK65YMP4a
>that \0 will be inlined somewhere in those 24 bytes
32, plus 8 bytes:
rsp, 40

>where should those 24 bytes go
32 + 8.
>standard is this shit
Are we ready for that discussion already?
>>
>>103227007
memelang that people stopped shilling years ago because rust won
>>
>>103227051
I already stopped using C++ and for a good while I'd implement my own string because it was more efficient and less code than std::string so can't comment on where extra bytes came from in 2024.
>>
>>103226951
How am I supposed to prove a negative?
>>
>>103227007
It will inspire the future, but will never become the future. This thing is so unergonomic it makes C++ and Rust look handy. I'm not even talking about the necessity of writing proofs when using the dependent types.
>>
>>103226951
>But police say his story didn’t add up, and a thorough search of the parking lot found no evidence. That’s when they analyzed Samitt’s Apple watch and looked at his heart rate when Samitt claimed the attack happened.
you can't make this up, technology is amazing
>>
Anyone have experience in programming chess bots? How hard is it to create a bot that is better than any human? I don't want to compete with the guys making competitive chess bots, just better than a human.
>>
>>103227007
>>
File: 1713763249614044.jpg (7 KB, 225x225)
7 KB
7 KB JPG
>use vscode
>chuds get pissed
>use vscode some more
>>
>>103227190
It's simple statistics. You iterate over every possible move you can take, and pick the best one. You then simulate N amount of moves that all are hypotheticals, you want your bot to pick moves with branches that lead to best outcomes, it's like simulating future, a human can do it ahead for maybe 10 moves, a bot can simulate whole future until checkmate.
The more the bot looks into future, the more difficult it is for a human to beat it. But it has to assume what moves human will take and recalculate everything once each move is made.
>>
>>103227210
>keep using vscode
>become dependent on it
>"I can quit any time I want"
>know that's a lie
>die alone in a gutter with nothing to my name but a second hand macbook running vscode
>>
File: 1731441819705142.jpg (66 KB, 811x843)
66 KB
66 KB JPG
>can program anything I want
>don't have anything worthwhile to actually waste my time on
What do I even work on? Right now I feel like I have nothing beyond small experimental projects to work on.
A lot the ideas I have just feel like a complete waste of time as no one except me would be using it anyway or they already exist and already solve the problem adequately.
>>
>>103227414
nothing, do same as me by programming random ideas such as "how to do this thing very very fast" then throw them away because you never actually needed it
>>
>>103227423
I'm basically already doing that kek.
I'd like to work on something meaningful that is beyond just fun or trying out new things.
>>
File: 1702325618320148.jpg (125 KB, 482x427)
125 KB
125 KB JPG
>>103227405
come on bro, just one more extension, I'm good for it
>>
>>103227459
Every idea I had has been done in some form and it's just so tiresome.
>could spend 50 hours writing clean, efficient code
>could spend 15 minutes writing simple 10 lines of bash that does same thing 10% slower instead
>>
>>103221965
Alright, fuck it.
Are there languages that allow me to tell the compiler exactly which registers to use for which registers? I'm getting sick and tired of stacking my parameters just so that subfunctions don't require register rejiggering, and I don't want to get rid of inline optimizations either, Holy Jesus Fuck.
>>
Trying to figure out how to help my friend with his IQ sampling and signal processing project in C, but I've been ruined by learning how good shit is in functional language program design.

Why live in a librariless hell when everything can be seen as fixed or arbitrarily large data of an imposed structure, in which algorithms are, at worst, a generative recursion problem?

How do you deal with friends who unironically claim that tinkering is how they learn?
>>
>>103227567
You learn from them, seeing as they know more than you.
>>
why should I use wsl over a vm? wsl sounds harder to reset when I inevitably break everything
>>
>>103227554
Feel free to waste your time with assembly.
>>
>>103227606
What confused you about inline optimizations?
>>
>>103227595
Better performance, it's one command to nuke a wsl distro, one more to reinstall.
>>103227612
Inline by hand.
>>
>>103215223
I am teaching myself raylib with C and am currently working on a very simple version of battleship, So far it has been way easier working with raylib than any other GUI library I've tried. Once I finish battleship I'm going to move onto some other style of game. I don't necessarily want to do gamedev but learning raylib as something I can use for a GUI for some dashboard for any other projects I make would be cool.
>>
>>103227628
>Inline by hand.
I'm dealing with divisions. No way am I going to inline that shit myself.
>>
>>103227639
use compiler to generate the code and fix it, t hen inline it by hand
>>
>>103227653
Have you *seen* the code for a division 10 loop?
No manual inlining. Next suggestion.
>>
>>103227663
Write a better compiler.
>>
>>103227483
I don't mind spending a crazy amount of time on making something efficient as long as the project itself is meaningful and I can pick the language I write it in. Working on existing projects just doesn't appeal to me so those are excluded.
This will sound cliche but I actually would like to work on a project that actually improves peoples lives in some way.

It doesn't have to be a huge improvement but just enough that people want to use it and appreciate it. I don't even think I care that much about making money because I've been delaying a few projects for years that would likely make me some money. They have some risk attached to them that I don't like however so maybe that contributes to it.
>>
>>103227670
So out of the vast sea of autism there's no compiler or programming language out there that allows for parameters to be assigned to registers?

Wow.
>>
>>103221965
>both functions are static, so breaking calling convention shouldn't be a problem
That's not how it works... Also you sound retarded, if the return value is in RAX and needs to be moved to RCX for another function call as per the calling convention then there's no way around that. The ABI is absolute unless you want to write your own assembly procedures and never call into any code you didn't write yourself.
>>
>>103227690
The one you wrote in 2 weeks will make it possible.
>>103227673
It's just not possible, majority of meaningful work is done in basic boilerplate like drivers of obscure hardware and if it's relevant at all, chances are the driver already has been made.
Going up to userspace, pretty much anything can be done with things that exist.
The only innovation you can have nowadays is in new technology that could be used in a game that's not same old formula like the rest.
>get an idea to make a tag based filesystem
>remember libfuse exists
>hold on
>https://tmsu.org/
once again wasted, duplicated effort.
>>
>>103227726
>That's not how it works
Sure it does.
>static function
>not called from outside the module, so no obligation to honor any external interface
>first parameter is *always* in RAX
>thus shouldn't be a problem
>plus I'm not even expecting the compiler to come up with the optimal allocation pattern on its own, I would gladly provide the hints if it just let me

IDA even has established syntax for such an approach:
void __usercall sub_1800BBE0A(_WORD *a1@<rax>, unsigned int a2@<edx>, __int16 a3@<r12w>, __int64 a4@<r14>, __int16 a5@<r15w>)
>>
>>103227690
>So out of the vast sea of autism there's no compiler or programming language out there that allows for parameters to be assigned to registers?
Isn't there a language that existed before C that did just that? I forgot what it was called and who wrote it but it had no register allocation so each variable had to be assigned to a register.
Someone here on /dpt/ mentioned it a long time ago.

I tried finding it a while ago but it's so obscure that I couldn't find it and not even any of the AIs could point me in the right direction.
>>
>>103227690
Pretty sure Turbo C++, the one indians still use for some dumb reason, had some sort of way to tell the compiler which registers to use for which variables. But the syntax for that specific use case was specific to that compiler, so the code will break in any other compiler.
>>
>>103227007
fits right in with 込 丙 迺 処 迪
>>
>>103227190
>>103227233
Surely the approach is not to iterate every possible move but instead to iterate over games where that move has been played, attempting to find that board state on a game whereby the player the bot is won, and then following that line.
>>
File: spaceport.png (34 KB, 1280x800)
34 KB
34 KB PNG
>>103227899
>needs to be run in DOSBox
I appreciate the effort, but it it's that old there's a pretty good chance it doesn't even support AVX.
>>
>>103228044
No, the approach is to simulate potential moves.
Then with the power of few simple rules of what is a "good move" and a "bad move" reduced to a mere number, you can proceed to simulate all possible futures and pick the one with highest score in your favor.
>>
>>103228044
possible board states explode with every turn, that's ridiculously inefficient and there's simply not enough data
minimax sounds less efficient but it's good nuff, stockfish beats any human at realtime speeds on modern hardware
>>
what is the best way to go about assign a value to a variable based on many conditions?

such as below I assign variable2 a value best on variable1's value. And I do this for a lot of other variables too and it becomes messy and just very long to scroll through

match variable1:
case "school":
variable2 = "$1000"
case "hotel":
variable2 = "$100"
case "house":
variable2 = "$500"
case "flat":
variable2 = "$700"
>>
>>103228133
How do you think it was done when AI beat chess master for the first time?
Also like I said, you don't have to simulate everything, only N moves, where N is artificial difficulty level, difficulty of 1 will make the bot only account for next move and not care about consequences any further.
>>
>>103228143
Why can't you just assign School, Hotel, House instead of doing a comparison case
>>
>>103228143
replace strings with enum, replace match cases with an array, use enum to index into an array, ideally the array is stored in some format like csv, xml or json in outside file and loaded at runtime or baked into executable at compile time, this works the same in any language, is simple, and very fast.
>>
>>103228044
That happens opening book and endgame tables. In the middle there's alpha-beta pruning, so for example it's not going to waste time considering what happens if the opponent misses a mate-in-1 and play continues.
>>
>>103228080
So how are there better and worse chess bots?
>>
File: 1700434636798844.png (14 KB, 766x218)
14 KB
14 KB PNG
working through the examples from some cmake book, it's talking about splitting up projects into subdirectories and multiple targets and stuff

this shit builds fine, but clangd obviously isn't reading the cmakelist files and seeing how include directories are inherited, and the book obviously doesn't cover clangd, there some way to get this shit working together?
>>
>>103228261
You need deep knowledge of the game to assign accurate values to moves.
Perfect move is 1.0, Worst move is 0.0, now figure out everything inbetween while taking into account that enemy has more or less possible good/bad moves and that itself influences how good your move is.
>>
>>103228188
>How do you think it was done when AI beat chess master for the first time?
they used the minimax algorithm described before
deep blue's opening book was exhausted on like turn 3, you greatly underestimate the number of possible chess states
>Also like I said, you don't have to simulate everything, only N moves, where N is artificial difficulty level, difficulty of 1 will make the bot only account for next move and not care about consequences any further.
that's minimaxing, not what the comment I replied to suggested
>>
>>103228302
>you greatly underestimate the number of possible chess states
you can easily prune over 80% of the states by assuming that your opponent's IQ is above 100.
AI that can beast grandmaster won't even consider a child doing some dumb shit.
>>
>>103227690
Here you go bro, drew you some circles.
: assembly ( -- ) init-asm ;
: end-assembly ( -- ) previous ;

: asm: ( "asm word" -- ) parse-name assembly evaluate end-assembly ; IMMEDIATE

wordlist constant wordlist-reglang

get-order get-current
wordlist-reglang dup >order set-current

asm: r8 constant reg0
asm: r9 constant reg1
asm: r10 constant reg2
asm: r11 constant reg3
asm: r12 constant reg4
asm: r13 constant reg5
asm: r14 constant reg6
asm: r15 constant reg7

: + ( reg1 reg0 -- ) asm: add ;
: = ( reg1 reg0 -- ) asm: mov ;

set-current set-order

: reglang ( -- ) wordlist-reglang >order ;
: end-reglang ( -- ) previous ;

variable (paddr)
: procedure ( "name" -- ) create here (paddr) ! reglang ;
: end-procedure ( -- p-addr plen-n ) end-reglang (paddr) @ here over - ;

: var ( "name" register-n -- )
create parse-name reglang evaluate end-reglang , does> @ ;

var x reg0
var y reg1
var result reg2

procedure myfunc
x result =
y result +
end-procedure

\ disassemble procedure
." myfunc disassembly:"
discode bye

myfunc disassembly:
7FAF8589A1E0: mov r10,r8
7FAF8589A1E3: add r10,r9
>>
>>103228324
that's all fine and good if you have the data to do that pruning
by turn 10 you won't have anything on your dataset and that's CONSERVATIVE, assuming incredibly standard opening play-by-play
that's why you look at all possible moves (filtered heuristically), not just what has been played before
>>
>>103228379
you have plenty of data, you can use an algorithm to infer how competent your opponent is and decide to just discard any move that's worse than 0.7 in arbitrary value in your move grading system if he consistently keeps making such good moves that are considered good in your system.
>>
File: 1000003267.jpg (124 KB, 768x1024)
124 KB
124 KB JPG
any of you guys write crypto smart contracts? is that a good way to make money?
I thought I could make a game but it's taking too long and I don't have artistic talent for making the graphical assets for it. so now I'm thinking I should be a smart contract programmer instead
>>
>>103228354
>using global registers
Been there, tried that with GCC. Breaks immediately once you have a harmless multiply in there:
error: unable to generate reloads for:
580 | }
| ^
(insn 76 75 77 9 (parallel [
(set (reg:DI 155)
(umul_highpart:DI (reg/v:DI 151 [ dec ])
(reg:DI 156)))
(clobber (reg:DI 265))
(clobber (reg:CC 17 flags))
]) "src.c":491:17 546 {umuldi3_highpart}
(expr_list:REG_DEAD (reg:DI 156)
(expr_list:REG_UNUSED (reg:DI 265)
(expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_EQUAL (umul_highpart:DI (reg/v:DI 151 [ dec ])
(const_int -3689348814741910323 [0xcccccccccccccccd]))
(nil))))))
during RTL pass: reload
src.c:580:1: internal compiler error: in curr_insn_transform, at lra-constraints.cc:4234
Please submit a full bug report, with preprocessed source (by using -freport-bug).

Will the same happen with ... ... whatever this is?
>>
>>103228289
Can probably add them through a .clangd file
>>
>>103228261
Ignore the guy he's working off old models. Modern bots just do game searches and evaluate GM games that can transition into winnable game states. Modern Engines can guarantee a check mate victory from 14 moves out.
>>
>>103228289
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
>>
>>103228474
My whole point is about how you can make your own idependently, if you want to know how modern engines work then just go read the existing code and fuck off, there's no fun in figuring something out here if you do that.
>>
>>103228493
based, works
>>
Bros I cannot understand why dinners is updating correctly but stylish isnt. its the exact same code.
>>
>>103228416
In my example the variable<->register mapping is defined per procedure, not globally, if that's what you mean. The register mapping at the top of the file is just the ones that you can use in your variables. For operations which touch multiple registers you could define an operation (like *) in such a way that it checks if that register is mapped and then store and restore it.

I can think of other ways to work around this but if you want to keep it simple then just choose registers that aren't affected by side effects from the operations that you implement.
>>
>>103228577
use a real language without malloc
>>
>>103228143
I define a map
BuildingCost = map[string]int {
"school": "$1000,
"hotel": "$100",
}

and then use
variable2 = BuildingCost[variable]


In serious code the map would be loaded at init time from a configuration file; otherwise I put it in the source code.
>>
File: associativearray.jpg (69 KB, 858x333)
69 KB
69 KB JPG
>>103228143
>>
File: verbosity.jpg (143 KB, 863x591)
143 KB
143 KB JPG
>>103228786
>>103228143
>>
>>103228786
>schools are $1000
What?
>>
>>103228826
ask his mom
>>
has llvm m68k support been mainlined yet?
>>
>>103229159
2 more weeks
>>
>>103228205
this for static number of building variants
>>103228686
this for dynamic number of building variants
>>
File: 1705217270206381.jpg (76 KB, 465x750)
76 KB
76 KB JPG
>>103229159
>bro
>just build LLVM from source with experimental features enabled bro
>it's easy bro
>>
>>103228143
in rust this is just
let variable2 = match variable1 {
"school" => "$1000",
"hotel" => "$100",
"house" => "$500",
"flat" => "$700",
_ => unimplemented!(), // or unreachable!()
};
>>
>>103229219
Why would dynamic number need hashes instead of monotonically incrementing IDs? It's still variants.
>>
>>103229292
how do you find the id corresponding to the place if it's input dependant?
>>
>>103229311
Why is the input to getting a price a string?
Why can't you convert input string to id in advance?
The way it's done in databases, you associate string with ID, then use ID everywhere else, and it shouldn't be any different in your own code.
>>
>>103229347
>Why is the input to getting a price a string?
cuz op said so, you're right that it should be an id though
>Why can't you convert input string to id in advance?
how would you do it without a hashmap? ignoring external tools like querying a database for it, because I want to know how (you) would do it
>The way it's done in databases, you associate string with ID, then use ID everywhere else, and it shouldn't be any different in your own code.
50/50 on that
I feel like people who are too used to working with ORMs fall into either extreme of using ids way too much when one of the objects should just own the other (and thus join by default) or making every relationship an object and just letting the orm deal with the mess that causes
>>
>>103229514
databases use B+ trees, so that's at least one way that doesn't use a hashmap.
>>
File: 1718163049297041.jpg (2 KB, 125x67)
2 KB
2 KB JPG
ninja is fast
>>
>how many lines of code
>your compile time
>>
>>103228913
Maybe it's Canadian dollars.
>>
File: 1729192820538409.png (173 KB, 533x451)
173 KB
173 KB PNG
>>103227554
>tell the compiler exactly which registers to use for which registers
>>
>>103229553
databases use b+ to satisfy other concerns (mainly that it's better for filter operations that operate through the entire database)
b+ are O(logn) search average case, which loses out to O(1) average case on the hashmap
honestly I'd have preferred if you just said O(n) search on a vector where index is the id, contiguous search on a vector is so blazing fast that it probably beats anything more complicated in most cases when we're talking low n cli programs
except maybe a skip list? that shit is pretty fast too, but probabilistic
>>
>>103229661
Hashmap is O(n) on key size, no need to cope this hard anon, B+ will be good enough unless you have millions of common prefixes and for any relevant amount of data, database will be better than reinventing something, meanwhile for 4 different ids, you can use linear search and it will be fastest up until you have 30+
>>
File: smol clock.png (13 KB, 380x164)
13 KB
13 KB PNG
>>103229574
precompiled headers can make it even faster
>>
File: Capture.png (284 KB, 1210x295)
284 KB
284 KB PNG
>>103229574
wait this actually looks like a good language to start with because theres only two pages worth of documentation.
>>
>>103229741
>Hashmap is O(n) on key size
Any sort of mapping that compares a whole key at least once is going to be that.
If your keys are arbitrarily long, you've got other problems.
>>
File: 1731968688499.jpg (45 KB, 716x1125)
45 KB
45 KB JPG
>>103229741
>Hashmap is O(n) on key size
this applies to B+ too thoughbeit, which is why I ignored it
>no need to cope this hard anon
not really coping, more interested in autistically discussing data structures
>database will be better than reinventing something
we don't really know the scale of OP's program tho
if his number of different places is in the hundos, a database is absolutely overkill and O(n) array search would be best
>meanwhile for 4 different ids, you can use linear search and it will be fastest up until you have 30+
I'd argue it's probably faster up until like hundreds of thousands of ids, can't be arsed to benchmark it though
alternatively straight up just making your b+ tree a trie (lol) could be better, allocate 27 spaces on an array for every node, localization be damned
>>
>>103228055
>pretty good chance it doesn't even support AVX.
it's x86-32 retard it won't even support SSE>2
>>
File: 1731969216304.jpg (12 KB, 286x215)
12 KB
12 KB JPG
>>103229847
>allocate a zero initialized array of 27^10 elements and treat each sequence of 27 elements as its own trie node for O(logn) search on contiguous data
>he doesn't have petabytes of contiguous memory available
>he needs more than 10 character place names
I shiggy diggy
>>
>>103229816
>mr soiface gatekeeping languages that actually pay money
it would be based if it wasn't mr soiface
>>
just ending 12h coding session. my brain is mush.
btw it was all for free (as in no money and no free beer).
>>
>>103229847
>if his number of different places is in the hundos, a database is absolutely overkill and O(n) array search would be best
have you measured that, or is that just a guess?
>>
>>103226779
Modern malloc implementations already have pools for common small memory sizes.
>>
>>103230426
concession accepted
>>
File: scrapped project.webm (3.82 MB, 1536x860)
3.82 MB
3.82 MB WEBM
Question for you all, I got lots of things i want to make now that im cured of brainrot and vidya addiction.
Is it better to start with backend first to learn as much as possible like apis and just general project structure before diving into webdev?

The right question would actually be would starting with backend projects BEFORE front end make me a better programmer/developer in general?

I got into coding because I wanted to make a game and that was years ago. Still do but I want to become to be flexible rather than just fuck around in Unity.
>>
>>103230619
Forgot to add that current language of choice is C++
>>
>>103230619
Theory first is always the correct choice in STEM
>>
>>103230619
you need some basic knowledge of HTML and CSS (or Flutter) so that you can even interface with your backend. After that, it depends on what you want to make, really. There are plenty of apps that may run almost entirely on the client (e.g. a graphics editor), then there's stuff where everything important is on the backend and the front-end can be done in simple static HTML and maybe a little htmx (e.g. a banking app or booking reservations at a hotel).
>>
>>103230344
do I need to? connection and file I/O overhead on the database seems like it would pretty obviously kill any chance of it outperforming in-memory vector access when we're talking about only hundreds of ids
do you care enough to bench it?
>>
>>103230619
>The right question would actually be would starting with backend projects BEFORE front end make me a better programmer/developer in general?
No.
>>
>>103230829
>webshitter moment
use curl



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