[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: 1550094465777.png (938 KB, 850x1200)
938 KB PNG
What are you working on, /g/?
Remember, no side effects

Previous thread: >>109027960
>>
Bewbs...
>>
Revised my resume and marveled as a company's resume importer somehow managed to add skills that weren't there. I wrote that I used HDF5 (Hierarchical Data Format 5) in a project, and the importer thought it was HDFS (Hadoop Distributed File System).

Also realized I could use more personal projects.
>>
>>109067579
I took the liberty of doing a saucenao on OP's image, and found it to be the character Sagisawa Fumika from Idolm@ster. I then checked the project-imas.wiki website and found her to be 19 years old.

That's a grown ass adult. That's a college aged woman's titties pressed up against a Haskell book. In fact, her wiki page says she IS a college student.
>>
Autism: 109067579
Autism^Autism: 109067607
>>
  struct fw_entry_json {
const char *version; // points into parse_buf after json_obj_parse
int32_t size;
int32_t chunks;
};

And why we immediately strncpy into the fixed-size output struct before parse_buf goes out of scope:

strncpy(out->versions[i].version, ver ? ver : "",
sizeof(out->versions[i].version) - 1U);

>sizeof on char pointer
thanks claude
>>
File: screenshot-places.png (226 KB, 822x906)
226 KB PNG
Still working on getting my first user, wish me luck.
>>
>>109067635
The fact it's using strncpy is dubious as fuck too.
>>
fucking autist coping and trying to defend his pedo tendencies.
Get rek'd
>>
File: Klee-KissNahida.jpg (363 KB, 2048x2048)
363 KB JPG
>>109067711
Actually, I'm gatekeeping. OP enjoys clearly adult-looking characters that are also canonically adults. Meanwhile, I enjoy lolis.
>>
>>109067737
being a pedo is not funny or edgy. Not even in this shithole. Go get a doctor.
>>
>being a pedo is not funny or edgy
That's something only a complete autists who NEEDS to be fed to cows would say.
>>
>the autist is also a pedo
Why am I not surprised?
>>
>projecting autist projecting autism
>a tale as old as time
Why am I not surprised.
>>
>the factorio schizo gave me his brain bug
Motherfucker, I knew nothing and was happy but now I can't ignore all these little inefficiencies, it's like they're taunting me.
>>
>>109068041
Autism is contagious.
>>
>Stop replying
>The autist keeps talking to himself the whole day
Damn, that's some determination
>>
good morning sirs
does your IDE or editor get as nice update overview videos as Eclipse IDE?

https://www.youtube.com/watch?v=4w6Y3RVd5Hc
>>
Is it possible to code on an ipad (pro)? Don't feel like spending money on a laptop right now.
>>
>>109068477
it wouldn't be practical at all
find the cheapest, beatdown but still working laptop you can find on craigslist or some flea market and it'll be a better experience
>>
>>109068477
>>109068630
>find the cheapest, beatdown but still working laptop you can find on craigslist or some flea market and it'll be a better experience
this. I got a 8gb i5 thinkpad for $50 and its been pretty good for programming mostly everything. Even godot and blender seems fine for low poly junk.
>>
volatile unsigned v1;
volatile unsigned v2;
volatile unsigned v3;

void updateSwitch(unsigned angle) {
switch(angle) {
case 0:
v1 = 0;
v2 = 0;
v3 = 0;
break;
case 90:
v1 = 1;
v2 = 1;
v3 = 0;
break;
case 180:
v1 = 0;
v2 = 1;
v3 = 1;
break;
case 270:
v1 = 1;
v2 = 0;
v3 = 1;
break;
default:
break;
}
}

void updateTern(unsigned angle) {
v1 = angle == 90 | angle == 270 ? 1 : 0;
v2 = angle == 90 | angle == 180 ? 1 : 0;
v3 = angle == 180 | angle == 270 ? 1 : 0;
}


I thought switch was supposed to be faster than if. the ternary version of this function uses nearly half as many cycles with O3 (30% less without). what gives?
>>
>>109069856
They have different behavior.
>>
>>109069856
No fucked up branch prediction due to jumps:
cmp     edi, 90
sete dl
cmp edi, 270
sete al
mov ecx, edx
or ecx, eax
cmp edi, 180
movzx ecx, cl
mov DWORD PTR "v1"[rip], ecx
sete cl
or edx, ecx
or eax, ecx
movzx edx, dl
movzx eax, al
mov DWORD PTR "v2"[rip], edx
mov DWORD PTR "v3"[rip], eax
ret
>>
>>109069902
oh you're right. still thought I delete the 0: case and move that content to the default: to fix the behavior and the ternary is still significantly faster
>>
>>109067480
To my surprise, last week I found myself inspired and starting dev on a video game, with shocking levels of motivation to see it through. Went through a prototype phase, then basically game jammed over the weekend on a proper first draft design. Barely slept, I was so focused on what I was doing, couldn't stop thinking about it. Got a lot done. Eventually I did have to crash but the motivation remains and I'm still waking up each day with new ideas and have been writing code for it at least a few hours every day. I'm gonna do another big sprint later today and get my next bunch of tasks done, and get ready to tackle some harder stuff next weekend.
>>
>>109069980
I have seen too much shitware with great ambition and zero technical knowledge to be impressed.
>>
>>109069991
I'm not trying to make a AAA FPS.
>>
>>109070072
You don't understand. I have seen 2D games that *struggled* to maintain 15 FPS that are still actively being updated, where the developer will just tell you
>lol I dunno what to do I guess I'm just incompetent
, and that's that.
>>
>>109069919
so basically, the if statements are being converted to math but the switch statement is forced to use jumps which is making it slower because of the branch predictor?
>>
File: 1733758303525032.jpg (430 KB, 2048x1536)
430 KB JPG
>>109070083
>the if statements are being converted to math
No, the if statements are being converted to instructions that don't rape your superscalar pipeline by constantly flushing it.

>the switch statement is forced to use jumps
Well ... it's not that the compiler is "forced" to use jumps, it's just that compilers are garbage.

>because of the branch predictor
More like "branch misprediction". The predictor tries to not flush the pipeline.

>spoiler: it probably fails
>>
>>109067506
they're space leaks
>>109067737
based gatekeeper anon
>>
>>109068041
Don't look at the inefficiencies. Look at their sources.

Look at the autism.
>>
File: 1767505856529375.jpg (133 KB, 828x811)
133 KB JPG
>>109067480
I downloaded a book from Anna's Archive about hashes and HMACs in C. It's not much, but it should be enough for an exam I'll have to take.
>>
Suppose I have a C struct that contains an integer array and bool member. If I declare a struct object, will the elements of the array be initialized to zero and will the boolean member be initialized to false?
>>
>>109070492
i think you have to explicitly zero initialise it with {0}, if its dynamic memory use calloc rather than malloc etc
>>
>>109070492
global / static yes, all other (function local) no
>>
>>109070492
>Suppose I have a C struct that contains an integer array and bool
Does it contain an integer array or a pointer to the first item in the integer array?

>will the elements of the array be initialized to zero and will the boolean member be initialized to false?
No. C never initializes anything for you. You must always (unless it does not matter in your particular use-case) zero out or null out everything yourself.
>>
>>109070550
Ahh okay, that's why the members were initialized to zero and false. Thanks for reminding me.
>>
>>109070492
in C++ it will be zero if you initialize it with std::make_unique or you use the {} initializer (I think?).
But I assume you are using C because a struct in C++ is just a class but public by default, there is no difference.
You can use -ftrivial-auto-var-init=pattern if you want your code to have a predictable pattern for memory to be uninitialized in.
>>
>>109070082
Not him, but with solo game developers, if you're not cutting at least some corners, you're not shipping a game. There's often too many tasks to work on that "premature optimization is the root of all evil" becomes relevant.
>>
>>109067480
AWOOGA
>>
>using calloc
>when the NT/Linux/Mac/BSD/general-UNIX kernel will already zero out pages
That is the kind of autism that makes people hate autists, in more ways than one.

And yes, I have run onto that particular bottleneck.
>>
>>109071272
>you're not shipping a game
You can ship your 10 FPS game all you want, but I'm going to refund it, and you can suck my 7-inch cock about it. I simply honor my time too much to tolerate complete garbage.
>>
>>109071288
If the memory you receive from your allocator is a fresh page from the OS, this is relevant. But you have no reason to assume that you aren't instead going to receive a recently freed allocation instead.
>>
>>109071343
Why would I assume my allocators to be garbage?

... oh, yes. That's right, because they're written by autists who cannot into interfaces. Never mind.
>>
>>109071416
If allocators had to do a syscall to get a fresh page from the OS every single time, they'd be garbage. Consider the case of allocating a linked list. Every node wants a separate allocation, and those allocations aren't going to be very large. About 16 bytes for the first/last pointers, plus whatever type it's a linked list of. How many of these nodes can fit into a 4 KB page? Suppose you free 5 of them, then need to allocate another. There's free memory in that page, so why ask the OS for more?
>>
>>109071594
>If allocators
Stopped reading there.
The fact that you're STILL talking implementation details says it all.
>>
>>109071624
>Hurr why calloc if fresh pages are zeroed
>Noooo, why are you explaining about things work the way they do?
>>
What confuses you about
>Stopped reading there
, autist?
>>
>>109067607
>having to look up her age
big boobs = not pedophilia by definition
>>
>>109071297
10 FPS would honestly be plenty since it's a turn based strategy game. And who the fuck said I was going to sell it to you or your 7 inch cock? I'm just having fun making a game I want to play, you don't have to get so mad about it. What's your coding project this week? Are you doing anything?
>>
>>109072539
>10 FPS would honestly be plenty since it's a turn based strategy game.
NTA but that makes no sense. Animations would look horrible. camera rotation would look horrible.
>>
>>109072599
What animations? And why the fuck would I rotate a camera?
>>
>>109072626
Is your turn based strategy game lichess?
>>
>>109072636
No, but that is an apt analogy. It's sprites on a (hex) board. Gameplay's quite a bit deeper.
>>
File: pepe+.png (275 KB, 580x449)
275 KB PNG
>>109071272
Anon is not even optimization. Your retarded O(n*n) shit version of an O(1) algorithm is killing the environment. You should be in prison.
>>
>10 FPS would honestly be plenty
Lol
Lmao
Tooltips and scrolling will look like complete ass.
>>
malloc
>>
free
>>
>>109067480
I look like this irl
>>
>>109075380
>>109075394
free_sized
>>
>>109075461
>Possible implementation
void free_sized(void* ptr, size_t /*size*/)
{
free(ptr);
}

You gotta be fucking kidding me.
>>
>>109075983
While that is a valid implementation, some allocator designs can actually make productive use of the size there.
>>
>>109076028
Show'em.
>>
>>109076033
According to the proposal that made it into the standard, for allocators that don't store the metadata next to the allocation itself, if it decides to just go with it and trust the user, it can skip the metadata lookup and could be like 30% more efficient.
Or alternatively on the other end, it could be used for verification and code hardening.
>>
>>109076045
>it can skip the metadata lookup
Nah, you're only moving the lookup from inside the call to outside the call. You're still going to store the size *somewhere*, right? Right?
>>
>>109076062
>You're still going to store the size *somewhere*, right?
It's application-specific, which is kind of the point.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2699.htm
>>
File: Untitled.png (103 KB, 300x400)
103 KB PNG
>>109075983
>Possible implementation
void free_sized(void* ptr, size_t /*size*/)
{
return;
}

Much better.
>>
>>109076087
>Looking up the size given just a pointer requires walking a hashtable or radix tree
Didn't make it further, this isn't how allocators do it nowadays for exactly that reason.
>how do they do it then
Ever wondered why your pointers are never 64-and-up aligned? The metadata is in a block right *before* the pointer it hands out to you.

This is cope.
>>
>>109076104
Well, that's not what jemalloc does, apparently.
>>
>>109076123
Not for speed, but for muh security. Makes buffer overflows less catastrophic. Same story as mimalloc, and we all know MS has deliberately left many ulcerations in their code base because they are still recovering from being pwned so often.
>>
>>109068477
Get a keyboard and you can. Just start cooding
>>
Anybody else have a custom container that combines std::deque and std::set? I have one in my Minecraft clone because marking a mesh dirty means marking its neighbors dirty so to avoid a chunk going in the meshing queue multiple times I involve a set.

In my architecture I use an unordered map <glm::ivec3, chunk class> to store chunks but all logic (which chunks are in proximity of the camera, which chunks should be meshed, which chunks should rendered) is juggled using various containers of glm::ivec3 that way I never ever have to move the chunk objects. I simply identify them by their vec3 positions and can get a reference from the unordered map when need be.
>>
>>109076867
Poor cache.
>>
>>109067737
why do loliggers always feel the need to bring up their gay fetish, like dude nobody cares lmao
>>
>>109077013
You need to go back.
>>
>>109077024
Brown hands typed this
>>
>>109077024
>you need to go b-ACK!
>>
>>109076911
Do you have any recommendations?
>>
File: peek_resized.webm (1.4 MB, 2000x1662)
1.4 MB
1.4 MB WEBM
>>
>>109077172
Two arenas with huge VAS reservation.
>>
>>109076867
>Anybody else have a custom container that combines std::deque and std::set?
What exact operations do you want to support? (+ desired complexity)

If you want both deque sequential access and fast random access by some other key, then some combination of a hashmap and linked list might make most sense.
>>
>>109077172
Ignore him, he has no idea what he is talking about.
>>
>autists interjecting
A tale as old as time. It's why we put you in cages.
>>
are you guys ok with rust? i'm learning it right now
>>
>>109077520
I have been using Rust for like a decade. Do you want to to know anything specific?
>>
File: 1597561699112.png (1.87 MB, 2048x1614)
1.87 MB PNG
>>109077520
>>
>>109077539
nice. i'm still early, learning through a small cli project after mostly doing typescript
no specific issue right now, but if you have any "wish i knew this earlier" rust advice, i'm all ears
>>
>>109077641
Get a good ide, RustRover has good macro support and debugger.
Option<T> is IntoIter<Item=T>, you can just
vec.iter().chain(Some(value))

When combining/morphing iterators, options, results, etc try to think about what kind of operation you want to do on a type level and its intent, rather than actual computation(which sometimes might be just noop), there is tons of methods like .transpose, .is_some_and, .skip_while that can do exactly what you want without writing everything as ifs and matches.
Don't be afraid to use std::mem::swap, Option::take, Option::replace, Rust types are all meant to be moved unless they are pinned. Option::take is especially useful if you want to temporary disconnect some part of the struct and have mutable access to both independently. For example if you have an App holding a Renderer with a method
Renderer::foo(&mut self, &mut App)
. Just wrap Renderer into an Option and Option::take it before calling that method. Put it into Box if Renderer is too big to move freely.
Cargo has a lot of features most people don't know about. You can define multiple executables/binary targets, examples and tests that will share or all of the code.
Files inside your-crate/tests/ directory are automatically treated as integration tests. You can refer to the main create using use your_crate::whatever from within them.
You can define some crates as childs of your cargo workspace. You can specify some dependencies and metadata on workspace level and then refer to them in your child crates using
[package]
name = "whatever"
version.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
some-dep.workspace = true
some-dep-2 = { workspace = true, optional = true }
some-dep-3 = { workspace = true, features = ["some_feature"] }

This helps you keep everything consistent across multiple crates in a single project.
>>
>>109077641
Using plain Cell is an easy solution if you are writing single threaded stuff and struggle with mutable references. Using indexes to some container instead of references can help too. Atomics can be pretty good if you want the same in multi threaded context, but lock-free concurrency is still tricky so Mutex makes things easier.
Zero sized types (eg
struct Foo;
) can be useful for defining behavior for some generic code. For example when making a game you might write a struct GameRoom<GM: GameMode> { game_mode: Box<GM>, .. }. A zero sized Box like that doesn't even do any allocation, it just inline stores the pointer to virtual table implementing GameMode for your type GM for dynamic dispatch. However you can also use an enum as an alternative, it has it's pros and cons.

That's all from the top of my head I guess.
>>
File: 1752293477791734.png (355 KB, 1024x838)
355 KB PNG
>build a tree with recursion
>easy to read
>but passes all test cases in 377ms

>flatten the tree into an array
>use some complex array indexing I can barely explain
>definitely wont remember what the fuck I wrote 2 months from now
>32ms
very cool how after half a century recursion still sucks and hasn't been solved
>>
>>109077980
just apply the Facade pattern and create a tree interface for your array with complex indexing
>>
File: verse.png (172 KB, 844x286)
172 KB PNG
UE new programming language
>>
>>109077980
Anon, there is a language feature called comments.
>>109067879
>>109077013
>>109077103
Nobody cares about your micro penis opinions.
>>
el cheapo tv likes h264 files

find . -type f -iname '*vp8' -print0 | xargs -0 -P 1 -I {} ffmpeg -i {} {}.h264
>>
Is VS Code spyware? I want to learn how to code and it seems to be the most recommended IDE.
>>
>>109078142
>UE
unity engine?
also looks retarded
>>
>>109078294
Never mind. I think I'll just try neovim.
>>
>>109078142
The syntax is dogshit idk what they were thinking
>>
>>109077822
>>109077905
thanks anon, saved this. some of it is still a bit over my head right now, but that's exactly the kind of stuff i wanted to know about so i can come back to it later
>>
>>109078472
use lazy.nvim instead of wasting time on configuration
>>
>>109068477
laptops are cheaper

you can get a free i7 8700 one from e waste. I got two
>>
File: 1759266842491471.png (150 KB, 823x873)
150 KB PNG
>>109078181
>Anon, there is a language feature called comments.
>>
File: file.png (66 KB, 834x675)
66 KB PNG
Is there a point trying to fully internalize and understand what the fuck is going here because i feel a bit retarded rn.
>>
>>109079340
This is async code that spawns a task for each element of files (&str, u64), and each of these tasks sleeps for some milliseconds, locks mutex, adds to it that milliseconds values and then the main task awaits for all of them.

It's pointlessly complex and suboptimal. Use atomics instead of Arc<Mutex> for simple counter like this. It also talks about files and sizes but it doesn't read any files nor measure any size, just sleeps and adds.
>>
>>109079254
What's the point of var and let outside of Javascript?
>>
File: 1781740186530765.png (182 KB, 1920x1055)
182 KB PNG
makedir
inb4 no -m -v -p, yeah not shit.
>>
>>109080491
He's gonna make all his own system tools to minimize syscalls next.
>>
File: images.jpg (18 KB, 299x168)
18 KB JPG
>>109080651
I WILL NOT SUBSCRIBE TO THE RELIGION THAT IS RUST.
It's only a matter of time before the entire C standard library is rewritten in rust and you're literally forced to use it.
>>
File: dust_allocations_2.png (159 KB, 1677x827)
159 KB PNG
>>109080694
I can't wait. It's gonna make autists even more hated and will accelerate the coming of the Day of the Cow.



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