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

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

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


Janitor applications are now being accepted. Click here to apply.


[Advertise on 4chan]


File: re.jpg (42 KB, 736x491)
42 KB
42 KB JPG
What are you working on, /g/?
Previous: >>106596041
>>
First for C++ supremacy
>>
For me it's C with GNU extensions
>>
Thinking of making my own virtual table top as a first project. Nothing but a day dream so far.
>>
Haskell
>>
>>106617257
Spew some wisdom, haskell wizard.
>>
>>106613979
>std::vector is dogshit and if you think it's good then that says more about you as a programmer than anything else
vector is good for C interop + it's small.
std::deque is better in most situations, but the memory is not in a single block of memory so you can't pass it into C functions that expect an array, and different C++ standards implement it differently so it has different performance characteristics, but the great thing is that deque doesn't reallocate, so you can use references/pointers without worrying about invalidation (as long as you only use it as a stack or queue).
and with certain C++ debug features, such as MSVC's iterator checking (on by default on a debug target), it will prevent you from doing something stupid like inserting/erase and using an invalid iterator after (which address sanitizer/etc won't catch, because you are accessing valid memory).
I think a lot of C programmers think that vector is the only way to make a dynamic array in a C++ RAII way, but you can also use a std::unique_ptr<char[]> but it's not actually dynamic, it's basically just malloc (new char[X]) with RAII.
(side track skip this)
And I personally hate C++ exceptions, I have always hated them, but I will admit, I have starting thinking about how you would handle a fatal error inside of a thread worker (that you can recover), and what is the most graceful way of handling that.
Normally if your release build is going to disable assert (or the unsafe [[assume()]] optimization), it makes sense to just let assert end the program.
But if you keep assert in a optimized build, if you were 100% certain the thread is non-critical and you can restart it without issue after breaking assert (all possible resources are cleaned up, plus show error), the assert throwing an exception will unlock mutexes, which will save you from a deadlock.
And for debug reports, you could use crashrpt or bugsplat or sentry to manually report.
And with vector, you could use .at() for exceptions.
>>
I want to learn to code, how can I?
I want to play around with cellular automata too
>>
>>106617461
I learned python with Automate the Boring Stuff and Python Crash Course, and then went through cs50x from Harvard to learn how to learn the stuff that real programs are made out of.

I'm still in my Dunning Kruger"Mount Stupid" phase, but picking up things as needed is doable now.
>>
>>106617411
unique_ptr is equivalent to std::vector in this context, the only difference is that mask is off and we don't pretend anymore that memory is dynamic, because it is not, std::vector allocates new block and copies everything, then runs destructors on old allocation. I hope I don't have to explain why that's incredibly retarded.
>>
>>106617188
a from-scratch "more" program, for an environment that doesn't have curses. Surprisingly more complicated than expected. Unbuffered input from stdin: arg!

OP's pic is comfy.
>>
>>106617411
>And with vector, you could use .at() for exceptions.
Well. I will admit this contracticts
>use crashrpt or bugsplat or sentry to manually report.
MSVC has an async exception handler that you can use to make that report contain the full stacktrace (and glib has a hidden debug thing that prints a stacktrace inside the C++ exception message, I think?), async exceptions does have a pretty large performance penalty, and it also catches more than just C++ exceptions (stack overflow, invalid memory access, etc), and if you start using the custom assert with exceptions, using noexcept for optimizations would now be problematic with the custom assert (it will still work, but instead it will just terminate, which will trigger the crash reporter).
>std::vector allocates new block and copies everything, then runs destructors on old allocation
this is C++03 logic, in C++11 the objects are moved, which still means the memory gets copied, but the difference is that it's 1000x faster because it doesn't need to alloc + copy + delete every element.
But of course, maybe you are talking about the redundant destructor call, which won't exist for is_trivially_copyable (optimized out), but otherwise I guess you are wasting like maybe 10 nanoseconds for every element to check if(ptr != nullptr){delete ptr;}. this is the last issue you would need to worry about, since most people are doing unholy things like std::vector<std::unique_ptr<VirtualBaseClass>>, which the redundant destructor (even virtual destructor) is a fraction of the issue of the bigger problem.
So just don't store arrays of a struct with a std::string and use static_assert(std::is_trivially_copyable<someclass> == false).
>>
>>106617501
>>106617641
*edit: == true)
>>
>>106617641
>words words words
How about just mmap a buffer so big that you will never fill it completely and then you aren't wasting anything at all? Virtual memory is free, 64 bit is older than everyone on this site. Fuck you.
>>
>>106617498
Thank you, thank you!
I had the idea to start with python, I tried C and well...not that good of an attempt.I'll check this out.
>>
>>106617373
why bother when 99% of languages dont have higher kinded or ranked types
>>
>>106617736
I recommend you do both. Focus on Python but do at least basic C stuff in parallel. Just read K&R and do exercises.
This is in order to:
>get an appreciation for how much Python does for you and what exactly is it
>get a perspective on memory management that's somewhat closer to the reality
>not get filtered in the future when having to work with low-level stuff
>be able to rewrite parts of your Python code in C if necessary. Python and C play very well together and many high-performance Python libraries are actually C with a Python interface. This is not black magic, you can do it too.

Even if you don't become a C wizard, understanding its memory management model is very helpful for understanding computers in general
>>
>>106617736
Enjoy bro!
>>
How do I stop watching amateur and candid porn during my free time and instead spend it programming?
>>
>>106618173
If you can't control yourself with pornography, you're probably stressed from unrelated reasons
Learn to guide yourself instead of controlling yourself, and try finding programming ideas that are fun to write
>>
>>106618173
Threading
>>
>>106618173
find a wife and waste your time on her instead, your son will have some free time to program
repeat ad nauseum
>>
>>106618173
kill yourself
>>106618259
or do anything except this, but suicide is an answer to every single problem, you aren't suffering if you wouldn't hang yourself in 5 seconds if handed a noose.
>>
>>106618284
>suicide is an answer to every single problem
lmao
>>
>>106618389
>my life sucks
just don't be alive to experience it
>>
File: 1714197240550699.gif (744 KB, 503x387)
744 KB
744 KB GIF
>>106617188
>>
Publish straight to prod, no need for git or branches
>>
File: Tohru5.jpg (168 KB, 850x600)
168 KB
168 KB JPG
>>106617188
Working more on the MAIDS programming language. I fixed the pattern capture bug and wrote most of the manual. I am refactoring a big class called CombinatorsForMAIDS because it is about 10k lines long and nightmarish to work inside. Once it is refactored and the manual completes I will release it to Public Domain, along with an example program that generates all possible character sheets for the game Maid along with backstories for the characters.
>>
>>106617188
ProTracker Audio Player
>>
How did you guys get good at large projects? I understand modular design, etc. but in the actual process do you just bang out code and iterate?
>t. analysis paralysis-suffering retard
>>
>>106620253
practice, practice, practice
>>
File: onelife.jpg (90 KB, 1107x1036)
90 KB
90 KB JPG
>>106620270
Thank you, I appreciate it.
>>
>>106620253
Just bang some shit together and refactor it later. Unless you already have a deep understanding of whatever you're doing (which you almost never do, unless it's a rewrite), creating some overly elaborate and excessively structured project is almost never going to actually fit and just going to cause more problems later.

"The lack of structure is better than bad structure."
>>
How to make a programming circle?
Like the GNU project
>>
>>106620429
As retarded as it sounds, part of the issue is giving myself permission to write "bad" code. Will try this, thank you
>>
>>106620456
first you need a name and a logo
>>
>>106620429
>creating some overly elaborate and excessively structured project is almost never going to actually fit and just going to cause more problems later
I did this exact thing while writing an OS
After spending some time without writing it, I have no clue how to go back since the structures were so complicated
>>
>>106620469
The important part is to actually refactor it later to make it not shit.
There seems to be some kind of misconception/myth that skilled programmers just write everything perfectly the first try, which is definitely not the case. Good code is refined.
>>
>>106620469
The retarded abstraction you write today and try to fit everything into to "reuse code" IS the bad code.
Duplicate yourself three times then the refactor will be obvious. Do some shit pattern because you're some hot shit enginigger and now I'm stuck using your unextensible faggot module and introducing 5 edge case bugs because of corporate policy to reuse code.
>>
>>106620478
True, I'm gonna admit that I don't have that yet!
But what if I had it? What would be the next step?
>>
>>106617411
Why make use of all modern c++ bloat when you’re in system dev? std::exception for instance where both winapi and linux have their own error handling.

Any STL container is replaced by sys queue or windows own circular queues. What’s the benefit of c++ in this case, except for auto, namespace and templates?
>>
>>106620253
a lot of people aren't ready to hear this, but the only way to legitimately get good with large projects is to join teams using massive monorepos with tens of years of tech debt, fully immerse yourself into the codebase, and learn how it all works together
hard mode: then measurably improve it

ask me how i know
>>
>>106620517
Then you quit maidposting or kill yourself.
>>
what's stopping me from just manually building a frame and putting a false MAC as a the source?
>>
>>106620702
That's a very passive aggressive way of saying you don't like maidposting, specially against the only maidposter that doesn't delve into the saccharine delusions
>>
File: Tohru3.jpg (1022 KB, 2800x4000)
1022 KB
1022 KB JPG
>>106620742
They'll always hate you for being a maid. It doesn't matter how you behave, or if you view yourself as somehow superior to the other maids. It doesn't matter what you create. They will still hate you for being a maid.
>>
>>106621121
And who are "they", anon? One or two obsessed haters, along with normal people who feel nauseated by the saccharine delusions?
>>
why come the prototype of memcpy doesn't indicate it needs pointers? i get that it's used for strings but i want to copy a struct

void *memcpy(size_t n;
void dest[restrict n], const void src[restrict n], size_t n);
>>
>>106621152
Parameter dest[restrict n] is a pointer
The [restrict n] part is a compiler promise that dest doesn't overlap src and is n sized, mostly for optimization

Just do memcpy(&a, &b, sizeof(struct something))
Or even a = b
>>
>>106621152
In C function arguments, arrays decay into pointers and are exactly equivalent. They're just using array syntax instead of pointer syntax because they're using the (non-standard) size_t n; forward declare thing and it lets you know how much memory the array needs to point to.
>>
>>106621175
>>106621180
thank you, i'll make a note of it for future man pages.
>>
>>106621152
>void *memcpy(size_t n;
I've got the same fuck up, pisses me off. Any idea why the man pages are broken?
>>
>>106621322

>>void *memcpy(size_t n;
in reference to the first argument? i don't know what that is. i just ignore it and refer to everything passed the ;.
i think it just means the variable type the prototype is expecting as parameters where indicated in the rest of the function
>>
>>106621344
>in reference to the first argument?
yes
>i think it just means the variable type the prototype is expecting as parameters where indicated in the rest of the function
no idea what you mean
>>
>>106621359
this part, right?
>>
File: 1727932579494782.png (68 KB, 1584x552)
68 KB
68 KB PNG
>>106621322
>Any idea why the man pages are broken?
i've got no clue what you mean
>>
I started documenting some code I wrote and with every line of documentation I truly wonder what crack I was smoking when I wrote it. The sheer simplicity of what I was actually doing compared to the rats nest of my code was stark.

It is amazing how documenting my own code is better code review than all my coworkers put together.

I’ve also been trying some agentic coding and for the most part I’m just amazed at how bad it can truly be and how much time I can waste.
>>
File: broken.png (34 KB, 992x384)
34 KB
34 KB PNG
>>106621403
in reference to the first argument?
>>
>>106620569
>what's the benefit except those ones
kill yourself
>>
It struck me lately that the float comparison with epsilon makes little sense, yet is taught all the time.
since floats work like scientific notation with fixed fraction digits, the larger value float holds, the larger the step of least significant bit is. So if you have two large floats but the epsilon is smaller than the LSB step then it has no meaning.
And the selection of right epsilon that has any effect heavily depends on at least one of the values.
Why not just mask out one or two LSB to ignore rounding errors and then compare bitwise? Seems trivial and obviously works and is agnostic of magnitudes, yet never seen this recommended anywhere. Am I the crazy one or is everyone else wrong?
>>
Everytime I use lldb I get a literal headache after an hour or two. All debugging tools are garbage. No wonder most people prefer print debugging.
>>
>>106621622
because when you use floats, you don't have large values, unless you're retarded.
>>
>>106621633
We prefer print debugging because using a debugger is print debugging in slow motion for people who are so slow that it doesn't matter.
>>
>>106621344
it's declaring what the type of n is inside void dest[restrict n] and const void src[restrict n], you might be like but anon it's already declared in the last parameter, and no it isn't because the last parameter depends on the size of the array and not vice versa
>>
>>106621633
#define errigger(NIGGER) do {printf("failed here because %s on line %d\n", __LINE__, NIGGER);} while(1)
>>
>>106621756
>needs to be reminded which line he put a printf on
cniles...
>>
>>106621639
Basically this. Make a logger that can change its logging level at runtime, enable and disable in the sections you want and you're set.
>>
Thoughts on Zig and Carbon(the new Microsoft lang)
>>
>>106621800
Just be happy I didn't include the filename too
>>
>>106621633
in theory you could gather all the data you want with tools like DynamoRIO, but I don't know if they work well with x86
>>
>>106621800
>runtime
kys
>>
>>106618210
I'm not the other faggot but I've definitely noticed this about my own habits. distractions are just stress relief or stress avoidance.
>>
>>106621152
pointers of n elements and pointers of 1 element are all the same in C.
>>
>>106621596
U don’y even code cuz
>>
>>106621803
Carbon is by Google and vaporware

Zig has good ideas but some of the "clever" syntax they have is Rust tier insanity. Out of the C replacement languages I prefer Odin
>>
>>106621877
>hes too stupid to use the preprocessor
>>
// Best approach: perfect forwarding with template parameter
template<typename F>
void execute_lam(F&& lambda) {
std::forward<F>(lambda)(); // Perfect forwarding
}

LLM hallucinations are getting more and more deranged.
>>
>>106621986
it's right except for not using std::invoke
>>
>>106622038
Where is the lambda being forwarded to? dumb nigger
>>
>>106622046
struct X {
void operator()() &&;
};

dumb jeet
>>
>>106622057
>dumb jeet
that's what you are
>>
>>106622064
I denounce vishnu
>>
>>106622068
Don't all kikes do? You aren't special.
>>
File: app.webm (1.13 MB, 988x944)
1.13 MB
1.13 MB WEBM
>>106617188
app
>>
>>106620669
>join teams
n-no... I can't... I won't!!
I refuse.
>>
File: tenor.gif (88 KB, 220x220)
88 KB
88 KB GIF
just got the call: I got hired
>>
File: noa.jpg (372 KB, 712x712)
372 KB
372 KB JPG
>>106616929
https://pastebin.com/3Wkm3sWE
>>
>>106622136
haha balls
>>
>>106617188
Learning literate programming, it's fun but I don't know if the shit am doing is correct or not.

I do like the idea of writing both the code, the documentation, the QA, the tests, and my own notes all at the same time. But this setup took me so long to get running, and I can still see a million ways I can improve it... I will be spending more time tweaking my programming process than actually writing lines of code at this point.
>>
Searching for where SOCK_STREAM is defined in linux uapi.
>>
>>106623563
ctrl+click
>>
>>106623658
retarded nocoder
>>
>>106623661
?
are you not looking for the macro define?
>>
>>106624099
How do you know that it's a macro or that it even exists?
>>
File: Tohru4.jpg (1.86 MB, 2531x3599)
1.86 MB
1.86 MB JPG
>>106619235
>I am refactoring a big class called CombinatorsForMAIDS because it is about 10k lines long and nightmarish to work inside.
I have completed this refactor. But now I also have to refactor the processor to accommodate it. I was able to make the CombinatorsForMAIDS an order of magnitude smaller by using a switch.

>Once it is refactored and the manual completes I will release it to Public Domain, along with an example program that generates all possible character sheets for the game Maid along with backstories for the characters.
This part will be next. I am trying to convince somebody really good at Pet Theory and writing proofs to help me write up the math parts. If she agrees, I will list her as a co-author of the manual. If she does not agree, I will do it but it will be slower.
>>
>>106624127
if it didn't exist your code wouldn't compile in the language server (you would have incorrect error squigglies).
the language server should be able to analyze the code using the exact same settings your compiler is using (like clangd, but intellisense on vscode would work as well on linux).
I assume it's a macro because of all caps, but it could be an enum (it's the same thing to me, but I imagine the coding standards would require macros instead of enums, because you can use the macro as a feature check, but it's probably not important for such an old API since you can't really use sockets without SOCK_STREAM I guess, and I don't know if there is any extensibility to that type, assuming it's a type).
>>
>>106624217
You should know things before you talk about them, you know.
>>
>>106624226
sorry I should have googled that for you.
Yep, it's a type and it's extensible. Sorry about that.
>>
>>106624244
What do you mean by that? Did you even try doing exactly what I wrote and not what you hallucinated that I wrote?
>>
>>106624257
Sorry, What should have I known before talking about it?
>>
>>106624281
Don't worry about it.
>>
>>106624290
Ok?
>>
I can slice a contiguous subset of an array in-place in constant time by incrementing the pointer and decreasing the length variable. Is it possible to free the portions I don't need?
>>
>>106624744
You can free the latter part if you realloc but it's likely faster to just use the array and free it once when you are done.
>>
>>106617461
I found a C coding for dummies book and it has been pretty helpful.
>>
>>106624744
No, also allocations below page size are free.
>>
>>106624970
>allocations below page size are free
wat?
>>
File: 1753918812127629.png (41 KB, 1774x306)
41 KB
41 KB PNG
Fucking land already god dammit.
>>
>>106623022
Literate programming is great but it's the precise opposite of prototyping, and since I don't do a second pass over my hobby projects I never really bother. But if I ever wanted to make a demonstration out of a module or a program, then yeah literate programming is neat.
>>
>>106624744
depends how it's allocated
if you aren't privy to that then no
>>
>>106617188
Making Vidya. It's in java because classes. And no it isn't like the stupid fucking project you want to make.
>>
File: 1755895783159125.jpg (83 KB, 642x480)
83 KB
83 KB JPG
>>106625350
>Making Vidya
>It's in java because classes
Thanks for the laugh anon.
>>
It's here
https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/

>LLD is now the default linker on x86_64-unknown-linux-gnu
>u{n}::{checked_sub_signed, overflowing_sub_signed, saturating_sub_signed, wrapping_sub_signed}
>const <[T]>::reverse and float rounding functions
>>
>>106617528

More progress on my minimal "more" program. I got the input tweaking working, so that input is not echoed and my program sees each input character right away, with no waiting for the user to press enter or return. Let's see if I have "code" tags working this time.

The key parts of my program, stdin-setup-wise ...

  struct termios cheese, baloney; /* so i'm bad with names */

...
  /* tweak keyboard/stdin for non-echo and not line-buffered */
if (setvbuf(stdin, NULL, _IONBF, 0)) {
fprintf(stderr, "error: can't change stdin buffering mode\n");
exit(DOOPS);
}
/* the setvbuf didn't have any effect. Do this ... */
tcgetattr(STDIN_FILENO, &cheese);
memcpy(
&baloney, /* save it here */
&cheese, /* save this */
sizeof(struct termios)
);
cfmakeraw(&cheese);
tcsetattr(STDIN_FILENO, TCSANOW, &cheese);

... when about to exit:
  /* restore keyboard/stdin to as it was */
tcsetattr(STDIN_FILENO, TCSANOW, &baloney); /* set tty/stdin back to normal */
if (setvbuf(stdin, NULL, _IOLBF, 0)) {
fprintf(stderr, "error: can't set stdin buffering mode back\n");
exit(DOOPS);
}
putchar(13);
fflush(stdout);
>>
>>106626155
In C# this is just
Console.ReadKey(intercept: true);
>>
>>106625582
Multi-target workspaces when
>>
>>106624744
Depends on the allocator
>>
File: 1730110569776652.jpg (429 KB, 2582x1930)
429 KB
429 KB JPG
Does the professional world actually care about <80 character lines and other style guidelines? Like will recruiters/employers not even bother with me if they see my code doesn't follow the style guide?
>>
I'm going to create a musical project in which the computer is the central instrument. I mean to process recorded audio through it, using the browser as the platform so that the performer can activate and interact with the audio while live in concert. I'm very comfortable doing this with vanilla html css and javascript, I've done a project like this already. However I wonder if using React or another framework might work better for the time-sensitive properties of sound (up until now I've been abusing the await function of javascript).
I insist on using the browser rather than something like max-msp or supercollider since I can manipulate the interface to be as user friendly as possible, so that anyone can perform this piece.
Would react work better for this project? (I'd like to point out that I'm an actual idiot programming, I'm just a musician exploring stuff in a very amateur way)
>>
>>106626455
Why not use a DAW?

Yes, React is fine for writing WebApps like this. No you are not going to get live music production tier latency with JS no matter the framework. Your interface should only be there to set up things beforehand and maybe control some effects, not to time stuff at runtime.

Kind of related, I made graph based audio system for by bot in React.
>>
>>106626556
I want to integrate things like typing produces sound at the same time that it shows on a projected screen, the sound is visualized with different properties on the screen, mouse movements also affect or trigger different audios, literally make the action of using a computer a musical instrument. Kind of like a computer concerto (there will be other instruments playing as well.)
>>
I want to use JSON5 to create a quasi-DSL for GPU stuff. LLM came up with this example.
{
// Comments are allowed, which is great for documentation!
title: "My Deferred Rendering Graph",
author: "User",
version: "1.0",

// Define all the passes (nodes) in the graph
passes: [
{
name: "G-Buffer",
type: "graphics", // Or "compute", "transfer"
shaders: {
vertex: "shaders/gbuffer.vert.spv",
fragment: "shaders/gbuffer.frag.spv"
},
inputs: [],
outputs: [
{ name: "albedo", format: "RGBA8_UNORM" },
{ name: "normal", format: "RGBA16_SFLOAT" },
{ name: "depth", format: "D32_SFLOAT" }
]
},
{
name: "Lighting Pass",
type: "graphics",
shaders: {
vertex: "shaders/quad.vert.spv",
fragment: "shaders/lighting.frag.spv"
},
inputs: [
{ name: "albedo", source: "G-Buffer.albedo" },
{ name: "normal", source: "G-Buffer.normal" },
{ name: "depth", source: "G-Buffer.depth" }
],
outputs: [
{ name: "final_color", format: "RGBA8_SRGB" }
]
}
// ... more passes
],

// Define the connections between passes (edges)
// This can be implicit in the 'inputs' fields of the passes
// or explicitly defined for clarity, like in a 'dependencies' array.
dependencies: [
// This connects the output of G-Buffer to the input of Lighting Pass
{ source: "G-Buffer", target: "Lighting Pass" }
]
}

Would be cool to have a schema too for validation, automatic type generation, and IDE tooling.
Any ideas/suggestions/related work?
>>
>>106626425
the professional world uses IDEs with auto-formatting
you import a company's style configuration and hit one key shortcut to fix it

for aspects that recruiters might actually look at, work on proper naming things, and well thought out organization of code (ie. split stuff into functions/methods that are easy to read and use)
>>
>>106626425
><80 character lines
No
>other style guidelines
Yes
>Like will recruiters/employers not even bother with me if they see my code doesn't follow the style guide?
No one cares.
In practice, it's up to team lead to decide on the linter/prettifier config and hook it into git pre commit and it just works automatically.
>>
>>106626665
Kind of like DirectX .fx files. If you want to write these by hand, I'd recommend YAML personally. Less verbose but can do the same thing as JSON (and more)
>>
>>106626591
Sounds like reinventing midi controller + daw/DJ/VJing setup.
>>
anyone ooooooopdate rust?
new lld default linker for linux still seems slow for full fat LTO builds.
>>
>>106626994
I didn't consider Vjing. I'll look into that thanks
>>
>>106626665
What is the point for this dsl?

Are you generating c code for vulkan / opengl or what?
Is it doing anything a good higher level library wouldn't solve?
Could you get the same results with just standard embed lua or json?

If you're planning on implementing what format will it target for output or will it be interpreted?
Any optimizations performed like dead code, procedural inlining, peephole, and loop unrolling?
Stack based or some other method?
Parser that works best with the answers from the above questions?
Are you just going to load JS into data structures and call it a day?
Stop at a just a serialized data format or add some depth?

I suggest going through and thinking of questions like this before implementation.
That is unless it is a pure time wasting project or learning project.

As it stands from the example, it looks like you just used json to serialize a bunch of data structures.
No real logic or anything that would require or benefit from the use of a custom dsl.
Perhaps look into sexpressions, toml, or yaml?
>>
>>106626425
>Does the professional world actually care about <80 character lines and other style guidelines?
They want their code to all look similar so that it's easier for someone else to read (and for you to read someone else's code; it goes both ways). You're not normally programming totally on your own in the professional world.
On the 80-col limit, it lets you fit more files across your screen at once. There isn't a world newline shortage.
>>
>>106626665
>using JSON5
that's not a DSL then
>>
why come I can't define a packed struct with just an empty array, but it works if i fill it with other defined bit sized elements?
struct doesntwork {
int arr[];
}__attribute__((packed));

struct doeswork {
uint64_t x;
int arr[];
}__attribute__((packed));
>>
>>106628356
to expound, would this mean any data in the working structure array would be overwritten as soon as i assigned a value to x.
>>
>>106628356
>why come
unconventional but ill allow it
>>
>>106628356
why not just use int* at that point?
>>
>>106628480
i want to be able to read the struct bit by bit and don't want the value stuck somewhere else in the heap
>>
>>106628495
>__attribute__((packed))

I'm not sure that is doing what you think it is. The compiler directive just removes any structure padding.
It ensures there is no extra bytes placed in the struct for alignment like if you add a char or something
else that throws out the most likely default 4 byte alignment.

If you're really worried about the struct and array it contains being within one continuous memory region
then it'd be best to use a custom allocator that does so. Note that an array by c standards is a contiguous
memory location. Putting it in alone in astruct is rather pointless. Did you mean to be using a union?
>>
>>106628356
Because C doesn't support ZSTs.
It works fine in Rust.
#[repr(packed)]
struct IntArr {
inner: [u8],
}
>>
>>106627223
I want kind of a rendering API and runtime independent thing, though I would be aiming for a Vulkan runtime that interprets these dynamically for hot reload enabled live coding. Someone could take a different approach and generate code off it.
It's not a new idea or anything, render graphs have been around for a while and "Mastering Graphics Programming with Vulkan" covers something similar. The most complete version of this idea I've seen is https://github.com/GPUOpen-LibrariesAndSDKs/RenderPipelineShaders which really is a full blown DSL that compiles a C-like language. Too ambitious for me but maybe you could get close with hooks or interpretable snippets in some embeddedable scripting language.
The point for an advanced system is to be able to do things like automatic resource management and memory aliasing of transient resources, automatic parallelization of command encoding, synchronization, etc. Basically just automating a lot of the tedious boilerplate aspects of modern explicit GPU APIs. This covers a lot of it: https://logins.github.io/graphics/2021/05/31/RenderGraphs.html
>>
File: IMG_1157.jpg (50 KB, 477x567)
50 KB
50 KB JPG
I started learning C yesterday.
I can do
>print’s
>int
>float
>double
It’s not that hard so far. What am I in for?
>>
>>106617188
for all of the neovim chads, how do you setup your :make for different languages? i just recently came across this and it feels like a very convenient thing to use, but i dont really know what the best ways to utilize it are, when youre not actually using a simple makefile (cmake in c++, different ways of compiling for other langs etc)
>>
>>106625373
Stop hurting my feelings deadbeat nigga.
>>
File: 1748474938074511.png (301 KB, 819x827)
301 KB
301 KB PNG
>converting git log to pdf
comfy
>>
>>106628939
learning c then realizing all the compiler directives and standards are a million times more complicated.
>>
>>106628495
Then don't point to something on the heap
>>
>>106626455
This is a waste of time. There's all sorts of stuff already made for this, look into Max MSP, puredata, TidalCycles, openframeworks, and similar tools
>>
>>106629308
i'm not sure how to make a struct with multiple data types ending in a variable sized array allocated at runtime, and have it all be in one contiguous part of memory.
>>
>>106629323
oh nm, figured it out.
>>
>>106629323
You don't use a vla, you alloca the size of your struct + your dynamic buffer and you don't use a pointer or array member at all since the start of your dynamic buffer is trivially &mystruct + sizeof(mystruct)
>>
>>106629375
Sorry, it's + 1 not + sizeof(mystruct)
>>
>>106629200
Would you share a picture of your pdf?
>>
Ok, so i know a fair amount of python and c. Trying to pickup javascript for some things I'm working on.

How did this mess ever become the language of the web? Endless method chains to lambda functions with videos cryptic format strings. It's almost as bad as command line sql.
>>
>>106629323
malloc then memcpy
>>
>>106626155
in BASIC this is justinkey$
>>
>>106629467
>>106629375
what data type for variable length part? it's going to be much bigger than 64 bit
>>
>>106629496
e.g. this obviously doesn't give me what i want and fails to build anyways.

struct pkt_t {
int x;
char arr;
};
typedef struct pkt_t ex;

void main(void){

char st[] = "this is a prawnblem";
uint8_t size = sizeof(struct pkt_t) + sizeof(st);
ex *png = malloc(sizeof(size + 1));
memcpy(png->arr, st,sizeof(st) );
png->x = 10;
printf("size: %s", (char*)png->arr);

}



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