[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / 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 acceptance emails will be sent out over the coming weeks. Make sure to check your spam folder!


[Advertise on 4chan]


File: wo.png (9 KB, 600x600)
9 KB PNG
I want to learn C but I don't know what to use it for.
I know this is a good low level language, but I don't own any micro controllers and I don't have any hardware to tinker with. I don't see myself building my own drivers for fun, or any of those kinds of hobbies. I'm also already secure financially so I'm not really looking to switch careers (Graphics Designer, and I know CSS and JS).

But the language itself interests me, if that makes sense?
So I want to learn C, but I have no usecase for it.

I know there's nothing wrong with the pursuit of knowledge for the sake of the knowledge itself, but I keep hearing that the best way to learn a language is to actually apply it on projects, and right now I don't know any C related projects that I would actually have any use for.
Would I be wasting my time?
>>
>>109507037
>Would I be wasting my time?
no, its a gateway to many abilities some would consider... antisemitic

like programming in cuda, or opencl
or going lower level and learning asm, but with a context
or having a good comprehension of many constraints in programming because you deal with many of them explicitly in c
or learning a set of primitives that are applicable to many high level languages

in short
its not without reason that c appears in the curriculae of serious courses, even if its never to be used again
>>
>>109507037
Find a rust program and rewrite it in C.
>>
>>109507037
>I keep hearing that the best way to learn a language is to actually apply it on projects, and right now I don't know any C related projects that I would actually have any use for.
This is a very accurate situation. Using C for solving actual tasks is a humiliation ritual and you're better off using any other language if you have an option (you usually do).
Check out harvard's cs50 course, it has good problem sets that use C and the system checks your solutions (they're actual problems for solving a task, not jeetcode). If you know that much C, you get most of the benefits of knowing the language and will make you a better programmer.
>>
>>109507130
>Humiliation ritual
it has some rough edges, but i wouldnt go that far
especially its briliant when you deal with low level shit (the picrel is to document the former, dw)
>>
>>109507161
It is a humiliation ritual to use it for actual tasks (i.e. tasks 99% of people actually need to solve).
>when you deal with low level shit
Yes, but that's exactly my point. Low level stuff like that is not something most people need to deal with. If they do, they already know C and don't have to ask about it on /g/.
Still, learning some C is very good for learning. In fact, going a step further and learning some assembly too after C is very useful too (far fewer people do that).
>>
>>109507219
>Yes, but that's exactly my point. Low level stuff like that is not something most people need to deal with. If they do, they already know C and don't have to ask about it on /g/.
valid.
were just looking at things from a different perspective
for me using c for stuff you could easily use python for is a design error, using a tool outside its usecase

i completely agree with the rest
>>
>>109507037
>I wanna learn C but I don't know what for
You'll learn how 'puters werk.
>>
File: 1770360713929629.png (1.06 MB, 1600x1200)
1.06 MB PNG
>>109507037
C is basically the platonic ideal of what a programming language should be. It's very, very hard to improve on which is why it persists to this day. Everybody should learn it and understand it. Especially pointers. People not understanding that memory is just a bunch of bits and bytes and pointers are offsets is how you end up with abortions of languages that won't let you pull funny bithacks.
Also, C23 is garbage for what it did to empty prototypes.
>>
>>109507037
its useless.
just learn rust for new projects that actually require you to use a no gc language.

C is very high level either way
>>
File: bot-something-retard.jpg (123 KB, 1074x348)
123 KB JPG
>>109507362
>t.
>>
>>109507248
>design error, using a tool outside its usecase
Yeah, that's the best way of looking at it.
>>
>>109507362
Ultimate /g/ redpill.
>>
>>109507362
Rust might as well be a GC'd language. It's just GC'd at compile time instead of runtime.
>>
>>109507389
Bot or not, he's right though.
If you think C is low level, you're fucking stupid or have never worked a real job or wrote any software of substance.

You're like the retards who make support tickets against clang because you believe C is a "portable assembler" and are shitting and pissing yourself in rage because you need to write exactly 8 bits to some watchdog register, which you do in C and then wonder why clang emits code that stores into the register as 32bits. C is not assembly and has zero mapping between hardware ASM and code. If you need real low level, you need to handwrite assembly. Period.

Your shitty C code will compile to the same code as a structurally equivalent C++ or Rust program that is generated from LLVM.
>>
File: dk.jpg (56 KB, 700x586)
56 KB JPG
>>109507454
c is low level.
just as it isnt.

ever heard of a concept called "abstract machine"?
>>
>>109507484
>can't refute or make any intelligent comment
Are you a bot?
>>
>>109507522
i did refute your retard noises
it just flew right past you
>>
>>109507315
>Also, C23 is garbage for what it did to empty prototypes.
it's now the same as c++
same people that want c/c++ interopability complain about this.
>>
>>109507037
Yes it makes sense you are what is called a "larper" you have no identity or sense of meaning so you think performing and saying "I learned C" makes you feel assured because it has an allure around it
you are a faggot. C is meant to actually do things for and it's used by people who want to actually do things which you clearly don't.
>>
>>109507645
C++ is shit and has been shit since C++07 when the boost faggots started slipping all their overdesigned dogshit into the standard library.
Empty prototypes should have remained unspecified in C instead of being implicitly void. This shit is fucking STUPID.
>>
>>109507037
Some people like writing useless shit just for the fun/sake of it--a project can be something entirely contrived or unoriginal. You can make your own text editor or web server or write an emulator for some old CPU or reimplement a coreutil from scratch or whatever the fuck. I came across this video recently and I think this kid is a good example: https://www.youtube.com/watch?v=I7CeqmFiWYY , he's learning C in a very autistic way just for fun.

However, if you have a hard time keeping yourself motivated unless you can apply what you learned in some immediately useful way, then you'll probably be better served learning just about any other high level language.
>>
>>109507037
>user case
Doens't has, C is more to undertsand the computer and how the things really work. Or if you want create clean softwares, C is the best choice, is more straight than Rust. It's an opportunity to do a different exercise.
>>
>>109507037
Dev boards for Cortex-M chips are really cheap. If you don't want to do that you can use qemu-system-arm with an appropriate board—just ask AI to help you get set up on that front.
All that said, writing C even on your host system is still be plenty low level: you're not fiddling with peripherals—just... memory.
>>
>>109507037
>what to use it for.
literally any application you can think of
>>
>>109507454
volatile exists for a reason
>>
>>109509476
and unions as devices to swap between types are supported by compilers.
and inline asm is a thing
and also self modifying code if we rally want to bypass whatever the compiler might have produced

the other anon is a fucking retard
as is usually the case with rabid c-haters
hes got fucking filtered
and now he wants to punish everyone else for his own failings

the worst part is that c really isnt complictated
and if by common sense you arrive at a certain pattern,
you can be sure the compiler people have got your back and your program is gonna perform like expected

>just dont be a fucking retard
is a pretty low bar, isnt it?
>>
>>109507219
>Low level stuff like that is not something most people need to deal with.

This mentality leads to jeetcode. And jeetcode leads to jeetbloat.

Don't be this guy.
>>
>>109509550
Also if C++ is considered mid-level then there's no chance in hell that C is high-level.

It used to be high-level back in its day, but definitely not now.
>>
>>109507037
You're wasting time coming to 4chan. Just go and learn C already, it's not that hard (if you have at least mild autism).
>>
>>109507219
>It is a humiliation ritual to use it for actual tasks (i.e. tasks 99% of people actually need to solve).
it can be a humiliation ritual if you don't play by C's lower-level nature and don't pick a set of quality libraries for various datatypes like vectors or linear algebra primitives, but it doesn't have to be that way. i'm actually way faster working with C than with rust. C23 also helps a lot with things like typed enums and a dedicated nullptr_t type. i'm making a game engine in C and i'm having a blast. the lack of generics may be a pain point but it's better than coping contagious borrow by spamming refcells everywhere and making my code less readable like i have to do on rust
>>
>>109507037
go to the sticky
go to the wiki
go to books
go to C
download King's A Modern Approach to C
thank me later famistan

thats where im at
you will learn gnu tooling later
>>
>>109509782
it *is* high level
it really is
pointers are completely abstract
and the libc exists to allow you to avoid putting your hands into the nitty gritty implementation details...
...but only if you dont break out of the abstract machine.
once you do, youre programming along the rules of bare-metal programming

in the most bare-metal uses dereferencing null yields a value because its just another address

the compiler/standard people really put alot of effort to allow you to program and dont care about implementation details, at all

but yeah, most of the useful c code out there doesnt follow these rules
and implementation details leak into the abstract machine in certain cases anyways, like with endianness difference between two machines, communicating through a stream
>>
>>109507315
>C23 is garbage for what it did to empty prototypes
i'm quite fond of C23 myself. what could you do with unspecified empty prototypes in C that now you can't do in C23? i personally think C did worse things like VLAs (which i always disallow in my projects with -Werror=vla)
>>
>>109509889
>hates vlas
if you cant understand why vlas are a thing
you shouldnt talk about c at all

even cs 101 students are confronted with cases where vlas absolutely shine and are an essential feature

how bout you go back to your sepples, where you belong, eh?
>>
>>109507389
>fn something(Arc<Rc<&RefCell<MyType>>: the_struct) -> Result<Option<MySomething>, u32>
>>
>>109509912
>brackets, the language
>>
>>109509910
>just let the stack grow to whatever bro... just don't have proper bookkeeping for your runtime-changing array bro... why? because...j-just do it, y-you're sepples!!!1!
not an argument anon. even cs 101 students can find better and more appropriate way to solve these cases without VLAs. VLAs are a thing because some ISO commitee people want dynamically sized arrays but without wanting to do heap allocation nor do proper tracking of a pre-sized array.
>muh embedded
in embedded environments you're expected to know your limits anyway
>>
>>109509889
>>109509910
ok, i waited long enough
>vlas, why?
recursion.

yeah, lets overallocate thousands of bytes so that we can recurse 50 times instead of 10000
cs 101 stuff
if you cant realize how vlas help here
you truly shouldnt be giving your opinion on c
>>
>>109509967
>but muh embedded
*especially* in embedded youre gonna care about this

you really dont know what youre talking about
>>
File: 1781551219922986.jpg (56 KB, 600x600)
56 KB JPG
>>109507037
>I know this is a good low level language
do you?
>>
>>109509927
exactly, i got filtered by rust's ugly ass syntax

>>109509972
why would you do recursion over a few times? you're wasting the bytes except that instead of "overallocating" you're wasting your stack's bytes. compiler optimizations and safeguards cannot really predict the depth of your recursion either
>>
>>109509983
i know anon and this is why i don't expect you to give me a sound answer on why VLAs are needed. this is where tracking is needed the most and if you don't realize it you're having a dunning-kruger moment
>>
>>109507037
I found it to be helpful for better understanding stack vs heap memory and the challenges of managing your heap memory
With that knowledge you can appreciate what will effect the garbage collector in say Java or appreciate the performance boost from python reference counting

I like how low level it is
>>
>>109510004
sometimes you have to
i believe its adjascent to p vs np problems
some stuff can only be solved with deep recursion
c gives you that power

and thats what c is about
just dont be a fucking retard and write a condition that checks how much stack you will be allocating before you do

the real reason c++ doesnt have vlas is to protect the integrity of sizeof
it has to be resolvable at compiletime
but vlas are not

the reason c++ doesnt allow vlas is purely bc theyre pussy ass bitch autists who sacrificed performance on the altar of, quite literally, (semantic) conformism
>>
>>109510011
fuck your tracking when you have 64kb of memory to work with
>but my company does things this way
then sorry to announce you that:
but your company is incompetent
>b-but i work at boeing
<boeing

boig corpo is the worst example because they normalize towards the lowest common denominator
>>
File: syndrome.gif (2.85 MB, 374x211)
2.85 MB GIF
>>109509870
If C is high level, what isn't?
>>
>>109510036
this one stack smasher who insist on using VLAs anywheres thinks he should have an opinion of C

>>109510040
>just dont be a fucking retard and write a condition that checks how much stack you will be allocating before you do
and that's where you can use alloca instead anon, it may not be standard but unlike VLAs it makes the usage requirements explicit

>>109510061
you can absolutely do tracking with 64K of memory, even if you have to do it in a more primitive way. with 64K of memory stack smashing becomes even more of a risk which makes your argument invalid. about boeing don't worry, i'd rather starve in the streets or live in some slum than work for israel.
>>
>>109510095
cpu microcode.
even asm is an abstraction
ops get reordered, and it wouldnt surprise me if some get even replaced with vector ops when applicable
>>
>>109510101
>risk which makes your argument invalid
it doesnt
it turns it into a skill issue on the part of non vla-ers
>alloca
never used it, bc i have vlas
but i heard its the devil crossed with nentanyahu crossed with political islam
>>
>>109510141
im at page 1 of King's A Modern Approach to C and what is this final boss gradspeak
>>
>>109507362
Trying to learn Rust without knowing C first will just make your life more difficult for no reason.
Similarly to C++, Rust expands on top of C. It just has chosen FP path instead of OOP.

>>109507454
>Your shitty C code will compile to the same code as a structurally equivalent C++ or Rust program that is generated from LLVM.
This. Modern compilers and language versions/extensions are so powerful that a good code written in all of them will produce same binary quality.
It all boils down on what libraries/tools/ecosystem you want/need and whenever you rather to reas about your program as set of objects with SFINAE and concepts, set of structs with traits and lifetimes, or can't handle higher level concepts and can only think in terms of imperative code and basic structures.
>>
>>109510207
dw, youll get there
an important optimization technique in learning is limiting the scope of what youre trying to understand

like what bruce lee said-
>i fear more the guy who trained one punch 10.000 times, than the guy who trained 10.000 punches, but each one of them only once
or something, im bad at quotes

but the idea is that you should master basics, before you go further
because otherwise youll need to check up the wording every two line, and youll end up remembering nothing because you jumpt between 20 different contexts

to reassure you- im self taught too
you'll butt your head against various problems enough times, and youll get there too
>>
>>109510207
>>109510238
plus:
thats not even being the final boss, anon
i have tons of shit i will have to learn yet

this is journeyman level
but dont get impressed
think of the power it provides, and this should motivate you when youre running low on determination
>>
>>109510207
>>109510207
you know what?
heres another reason why you should never let go of the steak:
OPENCL

its a turbo namedrop
but learning c is an introduction to gpu programming
in opencl as well as in cuda

dont ever let go of the steak
and if something sounds impressive, know that the only diffrence bw you and that
is time
but only if you remain consistent in your pursuits
>>
btw
>opencl reduced to 5 lines of boilerplate
ill post it for you anons
im sure some of you would love to run some stuff on your gpus, but dont want to bother with the boilerplate (150 lines. and then various ops, error checking, logging... including opencl in ones project can easily account for 500-700 slocs, if not better)

i will post my lib to whoever wants it
even in its current state
but its still a wip with rough edges
ilike i have implemented callbacks for everything but the cleanup functions
and i probably should expose properties for queues
plus i have yet to write some form of documentation
and i have to use it myself to at least get a feeling how my interfaces work together

but otherwise- yeah
opencl, made easy
fukken number crunching 500 gb/s lfg, ytf not?
>>
>>109510115
Midwit alert.
>waffling about microcode
Microcode isn't a language, it's an integral part of the processor itself.
>hurr asm isn't low level either
Your definition is meaningless.
Compiled non-GC languages are low level, compiled GC languages mid-level, interpreted/JIT are high level.
>>
>>109510445
no, its a language
>filtered off being a valuable input, immediately, in the first line
the "Operation" section is said microcode

if you spent less time being a sad sack of shit you could have learned that yourself
>>
>>109510207
yeah, look at this faggot, anon
>>109510445

this is what you dont wanna do
you dont ever want to rest on your laurels because you deem that what you learned is hard.
thats how you end up being a sad sack of shit envious of others, and sabotaging their efforts, whenever *possible
not applicable
not reasonamble
fukken *possible


you dont want to be that guy
always ask for more
and pay for that with your effort
and never stop
never, ever, ever stop
>>
File: hardware.png (39 KB, 878x310)
39 KB PNG
>>109510464
>executes in six cycles, can execute one every cycle
Midwit diagnosis confirmed.
That's not microcode, it's pseudocode so mouth-breathing retards like yourself can understand what the HARDWARE does. It doesn't actually run a program with those lines of code, and if you think it does, you need to get out of here now.
>>
>>109510545
i picked a random instruction
this is more like my code
audit this, casual:
https://files.catbox.moe/9n9agi.c

i didnt even go all in
i stopped when the returns on investment became irrelevant
and thats code from something like 2 years ago
>>
>>109507037
You will find in your life that curiosity opens doors, and expands your sphere of perception.

What im saying is: The answer to your question may be within the question itself - Just go learn C if your mind and soul is telling you to learn C, bro. You'll naturally figure out what to do with it and your 'relationship connections' in your brain will naturally expand as you become more aware of what things you're now able to do with your newfound skill. Have fun.
>>
>>109510545
>>109510583
>moment of realization that my code goes 3.5 times faster than the libc
>>
>>109510545
>>109510624
yeah, now that i think of it
hopefully you dont program in rust

because your lang with all bells and whistles barely competes with canonical c
>but then we enter the implementation-specific world, and turns out a rando anon from 4 chan can easily beat the libc by an order of multiples

and you know whats best?
this isnt genius
this is just being competent at c.
>>
>>109510583
That has nothing to do with microcode, and your use of intrinsics (unavailable in high level languages) if anything, proves that C is indeed a low level language.
>>
>>109510644
yeah but like i said
it IS a low level language, but ONLY when you break the abstract machine

in other words, you go passed the abstraction layer of the libc, and the c standard
then it becomes truly a macro asm

c has two faces so to speak, each with different properties
and at its root, it IS a low level language
and thats why the barrier, the differnce between both can easily be missed
its subtle

basically: theres a difference bw portable c and targetted implementations, and its really enormous
even if subtle at first

like the code i posted
its avx2, if your machine doesnt support it, it wont run
and thats what i leverage.
its, i think, a textbook example of implementation-specific C
-targetted C
bc its not wild shit, like counting on implicit atomicity, its only simd
>>
>>109507130
Using 4chan is a humiliation ritual that advertises more humiliation rituals like C.
>>
>>109510683
>c is freedom
>anon thinks its a humiliation ritual
git gud fgt le mao
>>
>>109509889
C23 has f(...) with the same meaning as f() in older C standard implementations..

The issue is that vararg with to named arguments is not allowed until C23, so if you want to support C23 you are stuck using something like:
```
#if /* C23 */
#define NO_PROTO ...
#else
#define NO_PROTO
#endif
```
Because guess what, even the stuck-up C23 standards committee realizes that unprototyped functions are useful. However, instead of doing the sane thing of making f() standard and removing the deprecation, they decided to add a backwards-incompatible f(...) and change the meaning of f().
>>
>>109510644
>implicit atomicity
im sure youre wondering what it is

well
the c standard allows to attribute a value to a structure, right?
as in
struct = something
right?

and when you want to read that data
youre supposed to just plain read it, right?

what if your structure is larger than the len of a cache line and you work in a threaded environment?

i think you see where im getting at
as per strict standard, youre supposed to put your reads behind a lock too
because you dont know if your int isnt actually 256 bytes long with a cache line of 8
>>
>>109510715
>proves it's a humiliation ritual through attempted humiliation
>>
>>109510789
no, the humiliation is complete
and i didnt have to do anything

youre doing it to yourself because youre seething
i just shine a light on it
>>
>>109507037
Write a kernel that just prints racist messages.
>>
>>109510815
>seething and humiliation are the same thing
>>
>>109507037
Buy the cheapest rpi and try some cool shit with it, they made us write a morse code driver for one in school and it was hella fun
>>
>>109510890
*self humiliation
seething and *self humiliation are *pretty much the same thing
bc you start with a losing position and a sticker glued to your back with "kick me" written on it

its the equivalent to the situation where jensen grabs you by your gamer ass
whispers to your ear "open wallet bish"
and in return you blush and execute

you just invite abuse when you act like that, mang
have some self respect
>>
>>109510968
Seething is natural. Your project mockingbird shame tactics aren't.
>>
>>109511001
no, my tactics are not natural
because deep introspection isnt natural to a normally constituted human

same reason why a stat. significant portion of people go into psy to fix themselves
theres places you go only when youre broken in one way or another
>>
>>109511079
Yeah, you're a project mockingbird sissytwat, a very annoying nuisance that naturally causes lots of seething.
>>
>>109511146
im not related to them
im a free agent just pulling levers and pushing buttons
bc life broke me in just the right way
so as i didnt become a victim, but i saw the other side of the mirror

i would have been a total wreck if i were a mockingbird
they format these people bc why wouldnt you?
and give the last line a proper fink
>>
>>109511146
actually
life broke you in just the right way too
or youre a mockingbird yourself
or we wouldnt be talking about this shit rn
>>
>>109507130
>>109507219
>programming at a low-level is a humiliation ritual
words have lost all meaning
>>
>>109509910
>>109509972
just use an arena and then pop it when you’re done like a normal person you fucking retard
>>
>>109507454
>le jobs argument
sorry but i don't listen to the opinions of goycattle
>>
>>109511146
you re a mockingbird, arent you?
but all you saw is that im a programmer
and thats concordant with the truth
i thought i was a warrior
but yeah, my true talents are in abstract shit, when applied to reality
which gives us- programming
in c.
this should tell you all you need to know about my openness
self coherent even when its not intentional

i legit have nothing to hide
even the fact that i know your tricks better than you do yourselves
i would have existed on ytour radar otherwise
>>
>>109511294
popping arenas you say?
>>
>>109509476
Volatile has nothing to do with this.
>>
>>109511294
and no
thats not what popping an arena means in my book

thats destroying an arena
popping an arena means moving up a pointer to the slab and outputting a pointer
>>
>>109511349
>>109511294
>popping an arena means moving up a pointer to the slab and outputting a pointer
the other way around ackshually
first you earmark a pointer for output on the slab
THEN you move it up by the size of what youre allocating for
and finally you oustput said pointer
how you make it happen is obviously left to your discression
>>
>>109511315
popping by size means you have to track how much it has grown since the point you want to pop to. a less error prone interface is to save the top, do some work and then restore it when you’re done for popping. since you’re using chunks that means you need to save the top as well as whatever chunk you’re in. I’d recommend moving away from malloc and just feeding it a slab of virtual memory directly with mmap/VirtualAlloc, then it becomes as trivial as a bump allocator
>>
>>109511349
popping means regressing the top pointer/offset. you don’t have to pop to the beginning, you just pop to the point before doing the work you want to do which effectively works just like a stack. resetting would be setting the top to 0 but you don’t want to invalidate all the memory allocated before the function call, you just want to dealloc the memory you needed to do the work when you’re done
>>
>>109511231
Concatenating strings at a low level is a humiliation ritual.
>>
>>109511460
Dealing with strings is a humiliation ritual desu.
>>
>>109511385
no
you have two pointers:
result, and current
current points to the first byte of available memory

like zo:
|................|
^
current


and so what y ou do, is move current to the next available byte
you do current += asked_size
which amounts to passing sizeof of whatever youre allocating (or sizeof * number of elements)

lets say you want an int

so you save result = current
and you move up current by the size of what youre allocating
such as:
|................|
^
result


and then current += size, sizeof(int) in our case
which gives us:
|................|
^
current


and thats pretty much it
you just check available space on top of that
if you dont have enough space, then allocate a new slab, move current to the first byte of your new slab

>but you waste memory
yes. arenas are not the absolute best you can achieve, theyre a good middle ground with interesting properties like your arena allocated linked list being also semi-array backed
you get lets say 90% of the performance with 1% of the effort
+ its easy and makes C safer because it becomes easier to reason about lifetimes if you consider the arena as a container for those
the only downside to arenas is that you can do better only with truly hand-crafted code.
>>
>>109511471
You aren't using Python. You aren't even using Java. Strings are a solved problem.
>>
>>109511471
So you get the idea.
>>
>>109511425
ok
but i meant it in the meaning of popping the next available pointer.
i pop my shit but when translated to code it works in reverse, no?
isnt that what it is?
>>
>>109511460
90% of the grievances people have for C are skill issues. This is one of those cases.
>>
>>109511489
>strings are a solved prob--
>index into the middle of utf8 sequence
>unpaired utf16 (let's not even mention endianess) surrogates are common
>Grapheme clusters
>duplicate symbols (enjoy normalization, retard)
>Even case folding is a humiliation ritual of insanity
>new fucking emojis, ZWJ emojis even
>zalgo and subscript/superscript autism

Fuck off.
>>
>>109511528
You are the reason Rust exists.
>>
>>109511540
I should add neither C or C++ make any of these easy. Rust makes half of them easy.
>>
>>109511460
please explain in full detail what you think a "humiliation ritual" is.
>words have lost all meaning
>>
>>109511460
>i need high-level features in my low-level language
(You) are a humiliation ritual
>>
>>109511586
Humiliating yourself instead of doing something less retarded.
>>
>>109511528
fr fr no cap
you can concatenate literal strings
you just go
"string1" "string2"

like zo:

#define STRINGIFY(target) (t_str *)(&(const struct { size_t size; char text[sizeof(target) + 7]; }){ sizeof(target) - 1, target "\0\0\0\0\0\0\0"})


>target "\0\0\0\0\0\0\0" turns into "yourstringhere" "\0\0\0\0\0\0\0"
>7 0's bc a string literal already includes null termination, and im padding up to 8
>end up with "yourstringhere\0\0\0\0\0\0\0\0"
thats bc i interpret the string as longs and i dont want to out of bounds
and, obviously, i dont want conditionals bc thats liberalism and the dissolution of societal cohesion
>>
>>109511607
retard. a more proper example in the context of programming would be getting cucked by rust's borrow checker. words have lost all meaning.
>>
>>109511641
>um it's easy bro
>string literals
Sasuga.
>>
>>109511473
yes, I know how a bump pointer works, what I'm saying is rather than arena_pop(arena, size), you should have an interface to load and store current, like

{
arena_offset current = arena_get_top(arena);

// do work
arena_push(arena, ...);
arena_push(arena, ...);

// restore state when finished
arena_set_top(arena, current);
return;
}


this is way less error prone. in your case, arena_offset would have to be a struct containing current as well as the current slab because you are using slabs but the other thing I was saying is that you could remove that requirement entirely if you stop depending on malloc and instead exploit virtual memory addressing to reserve some huge address range like 128gb of memory and then just slowly commit as needed, then you never waste any memory when a new allocation doesn't fit in the current slab, everything stays contiguous and you no longer need to manage some linked list of slabs
>>
>>109511333
Hardware registers are pretty much the ONLY usecase for volatile.
>>
>>109511543
I tried to tell you about the 3 sea shells but you didn't listen, that's your fault.
>>
>>109511660
Not really. The borrow checker is saving you from humiliation. Wasting your time reinventing the wheel only for Anthropic Claude Fable Opus Max Pro 3.5+ flash model to find and publish 5 embarrassingly bad CVEs and generates a humiliating website with a catchy logo.
>>
>>109511679
Reread the post dipshit. If the register is 33bits wide , but you need to write a specific amount to satisfy what the manual says, you write the expected bytes with inline asm. Volatile does not change anything related to what a real world example of what I'm describing. Fucking retard.
>>
>>109511667
im a self taught retard
+ im drunk
heres the struct, do your worst
struct _fn_arena_node_s
{
_fn_arena_node_t *next;
unsigned char data[];
};


typedef struct
{
_fn_arena_node_t *data;
_fn_arena_node_t *last;

size_t block_size;
size_t remaining;

void *current;

} fn_arena_t;


and hers the interfaces
fn_arena_t *fn_arena_create(size_t size);
void fn_arena_destroy(fn_arena_t *arena);
void *fn_arena_pop(fn_arena_t *arena, size_t size);


and i say i dont need more
sorry if i misunderstood you
but im getting really drunk rn
>>
>>109511703
Ask Claude, stop wasting our time.
>>
>>109511716
>our
lol

go bacc
>>
>>109511716
>>109511722 (cont)
gobackli tëpe, my niggero
>>
>>109511687
>humiliation ritual: the post
>>
>>109511696
//volatile uint32_t *reg = SOMETHING;
*((volatile uint8_t*)reg+offset) = value;

Is that really harder than inline asm that generates the same instruction?
>>
C enables CVE ridden slop.
>>
>>109511781
kinda yes
FUCK asm
its something autists do

>C, but with the illusion of control
in the end who the fuck cares when the machine performs:
-just like you want
-and memory(causality) fences are much more obvious tahn in asm

unfuckingironicallly
the abstraction of C help with a better exploitation of the resources at your didposal because data causality is much more apparent
>>
aaaaand youre pretty much *always* memory bound anyways
>>
>>109511884
peak skill issue

rust rewrites have more cves than longstanding c codebases btw
>>
>>109511909
truthnuke
no matter the tool
a shit craftsman will do shit products
and turns out no holds barred-no protection in any way attracts people who dont need these

nay
doesnt attract

if someone needs the bells and whistles they just dont program in c
simple as. hard filter.

the worst part is that coding in c is not even hard
its more a matter of being meticulous than anything else
>>
>>109511884
99% of """CVEs""" are complete nothingburger security theater nonsense
>>
>>109512063
It's a nothingburger if you like getting hacked in the name of C.
>>
>>109512063
TRVTHNVKE
>>
>>109512143
name 5 examples.
>>
>>109507037
Write your own OS. That's its only real purpose.
>>
>>109507037
>I know this is a good low level language, but I don't own any micro controllers and I don't have any hardware to tinker with
Then buy something and start tinkering with it, make something you think is cool or useful eventually. These things can be had for next to nothing and indeed in practical terms this is where you're most likely to use C in the modern world as a hobbyist. The only alternative I can really think of is if you want to make your own video game engine or something, or you want to do some GPGPU stuff, but needing to do either of these for a hobby project is probably far more niche than something MCU-based.

>Would I be wasting my time?
You already have a profession, as you've stated, so this would be a hobby. If you enjoy the time you spend on your hobby then it is not wasted, after all this is literally the point of a hobby in the first place.
>>
>>109510141
it is because you're relinquishing control of your stack to syntax which is easy to get wrong. not to mention accidental VLAs are absolutely a thing. also, just like >>109511294
said, arenas are the better fit for these tasks anyways. you tell me i'm not fit to have an opinion of C yet you fail to use what's given to you to solve problems in a better, more predictable way. with VLAs you just move the problem behind the compiler but it's still there. especially on embedded where you need to be as explicit as possible and again, know your limits
>>
>>109511679
volatile is useful for anything involving arbitrary control flow changes like interrupts or signals. the compiler can't tell something needs to be accessible at all times so you mark your variable as volatile. extremely common on embedded systems.
>>
>>109512483
>just like >>109511294
>said, arenas are the better fit for these tasks anyways.
yeah, use the heap instead of the stack, bc who cares anyways, right?

sigh
paraphrasing the 4 chan special-
write c for at least two years, then come back
>>
>>109512483
>>109512544
dont get me wrong
you can have an arena on the stack
->but why bother when you can just use vlas
->and pay ~50% of your cache in infrastructure
and thats a reasonable estimate
you need 16 bytes per element to be @50/50.
>>
>>109512575
yeah im drunk
nvm that
its not 16 bytes its 8
bc you can arrange an arena with a single linked list, so one pointer
id still havee to figure out the logistics of it
otherwise its a whole pre-allocated chunk you subdivide, with no possibility to grow in size


im too drunk for this, anon
in short: i need a big ditty shapanees gf
anime tits and larger
i need a cow, anon
i do believe that i need a shapanees waguy a5 cow with obscenely huge udders

this may or may not be relevant to the present discussion.
but its a datapoint, verifiably
>>
>>109512544
>>109512575
you use heap memory instead of the stack because it's more suitable for the problem. an arena is basically just its own stack that doesn't have a lifetime entangled with the call stack. the fact that you use heap like it's a dirty word leads me to believe you don't know what you're talking about

>you can have an arena on the stack
yeah, you don't know what you're talking about
>>
>>109512666
>the fact that you use heap like it's a dirty word leads me to believe you don't know what you're talking about
anon
i calculate runtimes in cycles, not seconds

the difference between L1 and a register is significant to me

>>you can have an arena on the stack
>yeah, you don't know what you're talking about
because its a problem to distribute pointers from a pre-allocated space
only that it sits on the stack

look
i know youre gtting paid 100k to program jaaaava
but heres 5 bucks + a beating and you will work in my sweatshop producing nike's for the next week, how bout?
>>
>>109512696
>the difference between L1 and a register is significant to me
the difference between accessing L1 and a register operation is like 3 cycles. that's just a deranged waste of time to worry about generally.

>because its a problem to distribute pointers from a pre-allocated space
no it isn't? what the fuck are you even talking about?
>>
>>109512785
>l1 bs reg is 3 cycles
yes
and no

reg is 1 cycle
l1 is 4

l1 is 4x slower than reg

>waste of time to think about it
>how to tell someone you never dealt with tight loops, without actually saying it

>>because its a problem to distribute pointers from a pre-allocated space
>no it isn't? what the fuck are you even talking about?
you tell me. you acted like its preposterous or something.
its dead easy. you use the exact same struct as you would with the stack

ort maybe the change in tone comes from the fact you consulted chat gpt, lol
>>
>>109512785
>>109512823
cont
im telling you
what youre worth is 5 bucks + a voucher for a beating in exchange for 1 week of work in a rice field

and youre gonna slack it off anyways
i already know it
you fucking waste of space
you fucking special dindu
you fuckken programmatic error

you need to get reeducated, legit
i could make you work
id make you work in construction for one week, and immediately you would learn adequate manners

you complete hooligan, you
you anarchist
>>
>>109512823
im just dumbfounded that someone obsessing so hard over cpu cycles thinks arenas of all things are slow, or that there is some complication from their usage

you strike me as someone who thinks learning assembly is some crowning achievement while never actually having made anything much more complex than a fizzbuzz. the insults about chat gpt slide off like rainwater because I know they're just projection. real programmers who make real software do not obsess over every individual cycle like everything is on a hotpath and arenas are extremely fast and lightweight regardless
>>
>>109512892
i mean
not everyone is a webshitter, y'know?

you were being a nasty faggot
but i just dont care enough to flame back, honestly
>>
>>109512892
>>109512933
maybe you want to see more?
it was kindof a mindfuck if im to be completely honest
im glad im done with this
>>
>>109512892
>>109512951
the most difficult part was collapsing all i could in opencl without actually touching the execution model
thats what took me most of the time

im talking to you because youre my victim now
i dont expect you to understand any of this
OBVIOUSLY
>>
>>109512933
oh, you're the guy that was still using malloc as an underlying allocator for his arena and popping by size instead of how a stack actually pops a frame in practice

yeah, you're inexperienced
>>
Schizo on schizo violence, this is gonna be good.
>>
File: oldman-shrug.jpg (9 KB, 250x203)
9 KB JPG
>>109512969
>t. doesnt even know that malloc allows the os to do its full memory magick
>no, use mmap instead
>nvm amdahls law; not that it matters here

and this is why you do jaaava, and not c.
>>
>>109512996
>bro obsesses over individual cycles but draws the line at malloc, despite it being an over generalized implementation that will naturally be slower than the implementation that meets his minimal needs
why are you allergic to mmap? does the argument list scare you? I promise it's not scary lil bro, you've come this far, you can go a little further
>>
>>109513028
>still doesnt understand amdahl
you should go through cs 101

i didnt but maybe when a phd will tell you youre fucking retarded and you should shut the fuck up and sit down
and you will pay for it
maybe then you will finally listen
>>
>>109513041
sorry, I don't speak hindi

go learn about virtual memory so you can actually make your arenas contiguous and slightly faster
>>
>>109513028
>>109513041
cont
ackshually
nvm amdahl

>t. still didnt ask chud gepetto why its actually a bad idea to use mmap like a fucking tryhard, as opposed to when you have an actual reason to
>>
File: IMG_1405.jpg (21 KB, 387x516)
21 KB JPG
>>109513041
Just because your professor said C is God doesn’t mean it is.
>>
File: pepe-laugh-pepe-lol.jpg (46 KB, 500x506)
46 KB JPG
>>109513059
>amdahl is hindi
>>
>>109513065
>amdahl the hindi
>>
>>109513065
amdahl the fucking hindi, right?
>>
>>109513062
>its actually a bad idea to use mmap like a fucking tryhard, as opposed to when you have an actual reason to
the actual reason is so you have contiguous memory for fucking free, seeing as how you yourself acknowledged the wasted memory from chunking up the arena into malloc'd slabs. And whether you call mmap or libc does, it gets called either way, but if you call it yourself less bullshit has to happen because your needs are lower than a generalized heap implementation

and the less work the cpu has to do, the lower the cycle count, lil bro
>>
>>109513084
yeyeye
dont move
heres the business:
i throw my pocket change at your face
and you smile in return

and dont move faggot
you fukken hindi fukken amdahl keklmao
>>
>>109507037
You should ask ChatGPT about it.
>>
>>109507037
Ask AI to write it in Rust. Then rewrite it in C.
>>
>>109511679
That's what register is for, dipshit. volatile is for when something outside the current execution context can touch a piece of memory or you just don't want it entering cache for some reason.
>>
>>109511460
```
strcat(dest, src);
```
wow that was so humiliating
>>
>>109514336
*notices youre buffer overflow* OwO nice cve 謝謝 sir
>>
>>109513688
This is so wrong I don't even know where to begin.
>>
>>109515813
>so wrong
(You)r live?
>>
>>109515795
A real American patriot will use the standard library for everything because it is providing job security for his fellow security researchers, therefore keeping the economy going.
Only a greedy communist would want to prevent that.
>>
>>109516716
>A real American patriot will use the standard library for everything because it is providing job security for his fellow security researchers
I mean that is true. Most of those fellow researchers live in Israel.
>>
https://desuarchive.org/g/thread/109491157
and
https://desuarchive.org/g/thread/109303943
https://desuarchive.org/g/thread/109303986
https://desuarchive.org/g/thread/106861974
https://desuarchive.org/g/thread/106843778
https://desuarchive.org/g/thread/106554716
https://desuarchive.org/g/thread/106015802
https://desuarchive.org/g/thread/106375037
https://desuarchive.org/g/thread/105155906
also
https://desuarchive.org/g/thread/109491157/#q109505145
>>
<---- namespases in C
>>
>the wiki pdfs are 404'd
>>
>>109521768
withone?
>>
>>109511231
C is not a low level language. It's just a systems programming language with very few features.
>>
I want to unlearn C because having a language based on skill issues is a mistake. Get the filthy C out of my mind. I want purity.
>>
File: Annotation 2026-04-18.png (19 KB, 514x349)
19 KB PNG
>>109522606
import ctypes # this is bullshit
also this:https://desuarchive.org/g/thread/106892385
don having alternative will lead (You) to slavery
>>
>>109522164
lippman c++ primer
>>
>>109508673
I'll bite.
Why does the empty prototypes being implicitly void matter so much?
>>
>>109523867
Having them be unspecified instead of void allows you to call function pointers with arbitrary arguments easily (as long as you understand the calling convention of your platform.)
Now that prototypes are implicitly void in C23, you have to cast function pointers to the correct declaration for the compiler to not spit out an error, and it means that you can't just call things that might be somewhat different but have memory carefully lined up so everything works, you HAVE to cast it to the correct prototype.
The standard effectively removed a whole useful class of coding patterns with that single change, all in the name of things lining up with C++ where that pattern SHOULD be outright illegal since the niche is already filled by classes and generics.
Not only did this break a bunch of my own private projects, it also broke like 8% of my system packages when I rebuilt everything with GCC 16. Also, the changes required to fix this in some packages are non-trivial because they're literally designed around it; to this day, some packages in common use on Linux are compiled with -std=gnu17 because it's impossible to upgrade without rewriting thousands of lines.
>>
>>109524014
Okay, I see.
However it seems that prototypes without any parameter list have been deprecated since C89.
You can either disable that specific error or compile with an earlier C standard. It seems that pretty much every argument in favor of keeping it boils down to convenience.
>>
>>109524014
>without rewriting thousands of lines.
what a bummer, its too bad we cant have an AI fine and replace () to (...), we should invent one
>>
>>109524288
varargs is not the same thing as this. varargs is a specific convention that involves shoving values on the stack one by one and popping them off, not using the platform's calling convention which puts the first few arguments in registers.
>>
>>109524296
>varargs
which require a first argument
>>
>>109524335
Retard.
>>
>>109507037
make a game! make it run in the terminal, or use a graphics lib to display it
>>109507315
i can think of a billion ways to improve C all of its alternatives (cpp rust zig etc) are substantially better. C is just good enough and widely used
>>
>>109507037

I would suggest to install a Linux-based or Unix-like system and start writing basic command-line applications to grasp the idea of the language.

Also, buy/download a book: "The C Programming Language" by Brian Kernighan and Dennis Ritchie. It's small, but a very handful book for this purpose.

Good luck!
>>
>>109508324
>op wants to learn something new because op is interested and understands that learning is good
>replyfag berates op for wanting to expand his horizons, insisting that learning is only for practical applications and anything else must be ego gratification
the fact that i'm on the same website as you slobs is making me rethink my life choices. i hope you change or die
>>
>>109507037
C is a simple language, but beautiful in it's simplicity. You interact with the system on terms it understands. Higher level languages offer convenience at the cost of abstraction which obscures what's really going happening. imho you don't "know" any language unless you know C. That's why us "cniles" advocate for it in most cases. Once you learn C you will realize how retarded Javascript can be and how retarded (You) were for carelessly using arrays and objects.

Also all the people saying >learn assembly instead bro!
That probably wont help you as much. Most compilers already fuck with your code on the assembly level and assembly itself isn't a language, but a loose standard for giving instructions to the CPU that isn't accurate to what most CPUs are doing in the first place.
You don't need to know assembly unless you're a compiler wizard who knows exactly what you need it for, why a C implementation wouldn't be enough and what you're doing.
>>
>>109524524
C would truly be an elegant language if it was complete enough to not require macro hacks all over.
>>
>>109524559
The macro hacks are a feature, not a design flaw.
>>
>>109507037
Disregard all the larpers trying to scare you OP, C is one of the easiest programming languages to learn and use. Its reputation as an elite hacker language has been to its detriment, as demonstrated by this godawful thread.
>>
>>
>>109524715
>>
>>109522164
KN King C and many more
>>
>>109527618
AI best teacher
>>
>>109507037

implement some sort of command line util and make a few syscalls. that or do some opengl stuff.
>>
>>109507161
>:help fold
problem?
>>
>>109528888
The digits have spoken.
>>
>>109507037
mp4 video player
>>
>>109507119
lol, this.

>>109507071
>no, its a gateway to many abilities some would consider... antisemitic
>have you heard of terry a. davis the wise.
>he programmed in an utmost holy language, some even considered, unnatural.
>it is said that he even programmed his own operating system, Temple OS, in one night
>>
>>109524715
>>
any book/course to leraning this shit?
>>
>>109533260
handmade hero
>>
>>109533260
this: >>109524715
>>
>>109524715
>>
>>109524715
>>109524715
>>109524715
>>
>>109524715
>>
>>109524715
>>
>>109524715
>>109524715
>>109524715
>>
blah blah blah

I'm starting to think there are no C experts. Just Ceethers.

t. in the same boat as OP
t. barely knows how to use pointers
t. uses python (Sol) and makes 102k annually
>>
>>109540409
im
>>
>>109542302
no instant message for Ceether
just anonymous bbs



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