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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: jeet.png (469 KB, 1900x1004)
469 KB
469 KB PNG
Post the best
>>
blue board, racism is against the rule. I beg you to please stop this nonsense
>>
>>101547496
kek someone post the pajeet kid coding "netflix" from scratch for hours
>>
#!/bin/tail +2
Hello, World!
>>
>>101547578
I will never understand these natural language esolangs
>>
>>101547532
You only get banned for insulting jeets, not for the N bomb.
>>
>>101547532
nigger
>>
>>101547626
normally I'd report any post like this on a blue board BUT I like /g/ posters so I won't do it this time
>>
>>101547496
you should multiple the string beforehand in C, DUMB NIGGER
>>
>c printing a million times is faster than a single print in python
>>
>>101547532
Good morning sir
>>
>>101547619
But that's exactly what op did.
>>
>>101547496
Why jeets always name variables "val", "n", "x" and they put a comment above describing what this variable holds? I keep seeing shit like this

# this variable is the sum of elements in the list
val = sum(someList)

Also for/while loops that always return on first iteration.
>>
if you finna say nigger at least use it right lmfao
>>
>>101547881
For the jeets who don't understand what is wrong with that snippet:
aryan programmers who read clean code will instead use descriptive variable names and will turn it into
val sumOfElementsInTheList = sum(someList)
>>
>>101547675
That was from a Python thread where some stupid nigger tried to show the world that Python is faster than C
>>
>>101547920
Actually, clean code would use this:
val thisVariableIsTheSumOfElementsInTheList = ... 
>>
>>101547920
>>101548099
you mad jeet?
>>
>>101547496
Thanks for proving Python superiority over those archaic needlessly complicated languages, sir
>>
>>101548164
don't enrage me bloody or I'll be extra rough with your mom tonight ;)
>>
All you need to do is post the correct C equivalent and we can end this horror.
>>
>>101547496
Buttmad Nigcel detected
>>
>>101548164
Sorry but the Jeets code was actually clearer and more concise in this case. Long ass variable names are for low IQs
>>
File: hindflea.png (228 KB, 536x600)
228 KB
228 KB PNG
>>101547496

#include <iostream>

typedef struct human {
char race;
sex is_female;
}

void main(int argc, char **argv){
person = (human)argv[1];
while (person.race = 'W' && person.is_female = true){
request_bobs_and_vagene();
}
}
>>
File: IMG_1672.jpg (32 KB, 326x326)
32 KB
32 KB JPG
>>101548478
#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int64_t i=1e6;char const *s="retard";char *a,*b=malloc(__builtin_strlen(s)*i+1);a=b;while (i--) a=stpcpy(a,s);puts(b);}

it's as fast as it can get, now fuck off
>>
>>101548478
Hello sir, I don't know about C but please kindly consider this implementation in Rust programming language
fn main() {
println!("{}", "Hello, world!".repeat(1_000_000));
}

Kind regards
>>
>>101548945
>null terminated strings
>strcpy
>as fast as it can get
faggot
>>
>>101548193
>Python superiority
almost every scripting language could achieve this in one line and if you take performance into consideration, "Python superiority" or whatever is absolutely useless.

bash
printf 'Hello, World!%.0s' {1..1000000}


and even lisp
(loop repeat 1000000 do (format t "Hello, World!%"))
>>
>>101549258
Odin counterpart would be
main :: proc () {
for _ in 0..=1_000_000 do fmt.printf("Hello, World!")
}

>>
on my machine such large malloc is actually almost as slow as IO in a loop. single digit percent difference
>>
>>101549764
Could any scripting language help you understand sarcasm, autist?
>>
File: file.png (38 KB, 168x248)
38 KB
38 KB PNG
>>101547581
>>
>>101547581
>You will watch again.
>You will understand.
>>
>>101547532
>I beg you to kindly stop this nonsense
ftfy
>>
>>101550146
maybe eso langs ccan
>>
>>101547532
Blastard!
>>
>>101549764
Both the examples you posted are more complicated than Python, couldn't care less tyey execute it 0.001 ms faster than Python. Python is a programming language made for humans, unlike the others
>>
File: IMG_1121.jpg (122 KB, 1920x1075)
122 KB
122 KB JPG
>>101549341
it's stpcpy, why do you think i keep assigning to a? also do you think strcpy uses lodsb/stosb like it's the 90s? it's as fast as memcpy.
the absolute state of /g/
>>
>>101550715
stpcpy as in the posix routine that returns the null terminator's address instead of the firsr character*
>>
>>101550238
what's this kid's channel again? I need a good laugh
>>
>>101547532
OP is a bloody bitch bastart BENCHOD!
>>
>>101550764
Iballdesigningdeveloper
>>
>>101550917
>Iballdesigningdeveloper
at first I thought you were fucking with me because that name is retarded but yup, that's it. thanks
>>
>>101547496
These don't do the same thing. Python one allocates (13 * (sizeof(char) + (whatever python overhead in it's string data structure)) * 1000000) for that one big concatenated string and dumps it all at once. C on the other hand prints only a single string at a time in a loop. If you watch memory usage the python one will be fucking enormous. Their speed is so close, because python trades space for time here.
>>
>>101547647
nigger
>>
No pastabowl example but they used a static variable as an accumulator in a method that was used by multiple concurrent threads to aggregate line items owed to retailers that was then used to issue payments, so there was "an obscure bug" that occasionally part of one retailer's payments would be paid to another retailer. We're talking hundreds of thousands of dollars deposited in incorrect accounts for individual manifestations of this problem. They only learned about it because one of the companies that was given something like $400k extra let them know.

The company knew about this issue for over a year and the jeeta dev never figured it out. I figured it out within 1 hour of being told about the issue on my second day there. I explained to the jeettess what the problem was and she had a shockingly blank look; she didn't understand any of it.
>>
>>101550715
mine's faster
but thats bc i use my cache instead using the heap to buffer the output

what i dont understand however, is how stpcpy (strlen + memcpy) is faster than casting the word "retard" as a long and copying it that way
>>
>>101550715
>>101552363
(cont.)
there must be some advanced compiler chicanery going on behind the scenes
ill try with intrinsics maybe thats the thing
>>
>>101552491
>>101548945

(final)
intrinsics are way faster actually

heres a sample:
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <x86intrin.h>

#define iterations 2000000
#define n_iterations 15625
#define buff_size 12000000

int main()
{


const char word[8] = "retard\0";

char *_buffer = malloc(buff_size + 1);

unsigned char lword[768 + 1];
unsigned char *lword_0 = lword;
unsigned char *lword_1 = lword + 256;
unsigned char *lword_2 = lword + 512;
unsigned char *temp = lword;

int i = 0;
while (i++ < 128)
temp = stpcpy(temp, word);

i = 0;
temp = _buffer;

while (i++ < n_iterations)
{
_mm256_store_si256 ((__m256i*)temp, _mm256_load_si256((__m256i const*)lword_0));
_mm256_store_si256 ((__m256i*)temp, _mm256_load_si256((__m256i const*)lword_1));
_mm256_store_si256 ((__m256i*)temp, _mm256_load_si256((__m256i const*)lword_2));
temp += 768;
}

write(1, _buffer, buff_size);

}


~0.5 s for twice the chars printed.
so memcpy is not about intrinsics.
there must be some advanced optimizations going on with memcpy
but avx intrinsics are ~3x faster
>>
>>101554331
(and theres an error)
it should be thios in the last loop:
    while (i++ < n_iterations)
{
_mm256_store_si256 ((__m256i*)temp, _mm256_load_si256((__m256i const*)lword_0));
_mm256_store_si256 ((__m256i*)(temp + 256), _mm256_load_si256((__m256i const*)lword_1));
_mm256_store_si256 ((__m256i*)(temp + 512), _mm256_load_si256((__m256i const*)lword_2));
temp += 768;
}


'forgot about the offsets to temp
>>
>>101551106
kek
>>
>>101548945
>>101554331
>>101554375
actually scratch that
im way too distracted to do anything properly today
latest test yielded that intrinsics are slower
i dont have the mindset to check what im actually doing rn
>>
>>101547532
shitskin.
>>
>>101547496
All I was trying to say is that Python's speed is not so bad if you use its inbuilt features like you're suppose to.
>>
>>101551020
So what you're saying is that the abysmally slow C function printf being called a million times is faster than one single memory allocation and one print call in python
Yeah I'm still sticking with C
>>
>>101557496
>10_000_000
???
>>
>>101557496
>python's speed is not so bad if you delegate everything to built-in functions that execute native code
Wow!
>>
>>101557703
that's not really what happens though. Compilers optimize in a way that only allocates memory once and printf basically always gets replaced by things like puts anyways
>>
>>101558178
>Compilers optimize in a way that only allocates memory once
how is that relevant to what i said? printf is still a horrifically slow function.
>and printf basically always gets replaced by things like puts anyways
no it doesn't? i even typed OP's program into godbolt and despite using GCC with the -O3 it's still a printf call
>>
File: anonymous.png (391 KB, 672x492)
391 KB
391 KB PNG
>>101547532
(You) you YOU you (YOU ) youyouyou
>>
>>101557884
Tell that to the people reinventing the wheel every time in python and then crying that it's slow.
>>
File: 2024-07-25 005047.png (58 KB, 1182x619)
58 KB
58 KB PNG
>>101547496
>>
>>101549258
fixed for gorgeous execution, can push asap @/g/ @moot
>>
>>101557707
It's for human readability.
The interpreter ignores underscores in numbers.
>100
>1_0_0
>1_00
>10_0
Are all the same to the interpreter.
>>
File: 2024-07-25.png (18 KB, 445x321)
18 KB
18 KB PNG
>>
>>101562549
you call hello(c) more often than necessary, you could let it first print and then afterwards check for if (c > 1) {hello(--c)}
>>
>>101547619
I talking shit about pajeets and niggers all the time. Also a white nationalist. Never been banned for it.
>>
saars?
>>
>>101547496
Python has its many uses, such as spamming Hello World.
>>
>>101563063
>>101547496
Slow, but no vectorization yet...
>>
>>101564464
I wrote C version, it has similar time...
>>101563063
What CPU do you have Anon?
>>
File: 1721641613893685.gif (2.69 MB, 640x640)
2.69 MB
2.69 MB GIF
Why is an 80 IQ race so drawn to technology? I don't get it.
>>
>>101564497
The needful is a Ryzen 5 2600X
>>
>>101564513
I measured times in >>101564464 >>101564497 on Intel i7-4600U (4 cores), 3.300GHz... Old ass CPU, support ended in 2021.
>>
>>101564512
You can often tame a caveman with just a bit of fire.
>>
it's faster on loonix than on wangblows
why
>>
>>101558467
of course it does
https://github.com/gcc-mirror/gcc/blob/061c331bec278599a7b60609ae46260d17878662/gcc/gimple-fold.c#L3230
>>
>>101547532
But isn't technology inherently racist? Technology as tools is literary the instrument of racism. Why would I need more fps and less latency if not for removing the weaker races? Or better bullets.
>>
We had this thread yesterday
>>
>>101564512
Technology and especially programming is a low IQ domain.
>>
>>101564464
>using the protected mode registers for no reason instead of the long mode ones
You absolute 32-bit dalit benchod.
>>
>>101565854
Are you sure that you know what are you talking about?
Objectively speaking, you said nothing wrong, but why waste bytes and speed?
I have Intel CPU, Haswell:
mov al,  1 - 2 uops - B0 01
mov ax, 1 - 2 uops - 66 B8 01 00
mov eax, 1 - 1 uops - B8 01 00 00 00
mov rax, 1 - 4 uops - 48 C7 C0 01 00 00 00

I'm using small values in registers except 'rbx' and 'rsi', they can fit into 1 byte.
However, it's slower on my CPU, and it uses more bytes to encode.
For this test, I wrote assembly aimed for speed, if I wanted size, I'd use al, dil and dl.
You can inform yourself about it on uops.info, to fact-check it.
And I'm not a retard to "xor rax rax inc rax"...
>>
>>101564512
Programming has been promoted as low barrier to entry, high payoff. This would ultimately result in a pathway to migration for someone living in a literal shithole. They see the thousands being imported into first world country and they want a slice of that cake.
>>
I'm learning programming. These threads give me anxiety that I'll inadvertently end up writing jeet code.
>>
File: 1691574019529227.gif (1.47 MB, 236x250)
1.47 MB
1.47 MB GIF
>>101566022
>it's slower on my literal decade old processor
Both Agner Fog's guide and that website measured one micro-op for
MOV r64, i32/i64
on your vintage electricity wasting architecture that's probably inside a used ThinkPad. Doesn't change for the smaller registers.
>>101566490
If you're already here, it's your destiny.
>>
>>101551100
Kek
Ahh nigger
>>
>>101566513
You're right only about "inside a used ThinkPad" and "slower on my literal decade old processor".
You haven't taken into account throughput, which is bigger for 64 bit instructions, but whatever.
I'm going to drink now, when I finish some stuff I have planned, I'll measure it with proc again.
--
Hope to see you in some thread X days later Anon.
Me: Are you sure that you know what are you talking about?
You know, but you're not completely correct, even tho you're better than 95% of /g/.
>>
Need not redeem
>>
Jeet code has to be in Java
package mumbai;

import java.util.Scanner;

public class CircleArea {

private Scanner s;

CircleArea() {
this.s = new Scanner(System.in);
}

public void go() {
System.out.println("Hello, Saar!");
System.out.println("We will calculate area of circle for a given radius!");
System.out.print("Saar, you need to enter radius: ");
double radius = Double.NaN;
try {
radius = s.nextDouble();
} catch (Exception e) {
System.err.println("Saaar?! What have you done?! Saar!");
System.exit(-1);
}
double area = radius * radius * Math.PI;
System.out.println(String.format("Saaar, redeem the beautiful result area: %g!", area));
}

}
>>
>>101547581
kid you not Google censored results for this ~3 years ago
>>
>>101557496
Less about using built ins and more about not wasting time and space with a list when you can just use a generator.
>>
>>101547581
https://youtube.com/watch?v=7PtTLHfaYWs
>>
all these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDDall these nocoders benchmarking their terminal emulator draw performance instead of the actual code XDDDDDDDD
>>
>>101568958
Or you could just look at user like a non-autist.
>>
>>101547532
you are mentally ill
>>
File: 1709747629294980.webm (568 KB, 1080x1440)
568 KB
568 KB WEBM
>>101547532
>sar blue board sar, racism is not redeemable here sar. I beg you to do da needvul and please stop this nonsense bich bastard sar
>>
>>101547496
Anything on codewars.com
This is the only competitive programming website I've seen that doesn't show performance when you've made a solution and just lets people rank solutions based on however they feel about it, so usually just LOC.
No one explains their solutions with comments or formats them in a readable way because then they won't get updoots. I have seen multiple O(1) solutions with no votes while shittier O(n^2) solutions get votes for having less LOC. Not even inherently shorter, just no comments and lines that are too long.
>>
/g/eets I kneel.

I admit that I was wrong and hope you can find it in your heart to do the needful and forgive me.
>>
>>101571806
The Indian apex predator has another successful hunt. Nature is beautiful.
>>
>>101547532
>>101547581
pajeets made me hate 'em, and I'm from south america
>>
>>101566733
>You haven't taken into account throughput, which is bigger for 64 bit instructions
Bigger, yes, but long mode instruction variants are going to be used more in a modern program so you want to keep them in the i-cache over antiquated shit.
If you're using ADD a lot, then it's better to do an increment with it over INC unless you explicitly don't want to touch the CPU flags.
>>101572327
>Python 2
>C compiler definitely constant folding away the loop's computation into a MOVABS $YOUR_GAY_REGISTER, 499999999500000000
Stop.
>>101572392
You should hate yourself too by that account.
>>
>>101572779
It's not python 2 there is no python 3 specific syntax highlighting in my text editor.
>C compiler definitely constant folding away the loop's computation into a MOVABS $YOUR_GAY_REGISTER, 499999999500000000
That would take <1ms not 2298ms.
>>
>>101547496
Which one is Pajeet code? I'm new to coding and I'd like to know what to avoid.
>>
>>101562875
thi way it only prints the message if c > 0, if I put the printf outside the conditional it will print even if if I call hello(0), and I donĀ“t want that.
>>
#include <stdio.h>

#define STR2(x) x x
#define STR5(x) x x x x x
#define STR10(x) STR2(STR5(x))
#define STR1K(x) STR10(STR10(STR10(x)))
#define STR1M(x) STR1K(STR1K(x))

int main(int argc, char** argv)
{
fwrite(STR1M("Hello, World!"), 1, sizeof(STR1M("Hello, World!")) - 1, stdout);
}
>>
>>101573302
Just checked. Only -O0 will not compile down to a MOVABS.
>>
>>101574298
as per my comment if it was just using movabs it would take a millisecond not 2000+.
>>
>>101568953
https://www.youtube.com/watch?v=nP5dlQXba90

Do the neeful and get ripped sar.
>>
>>101564464
>syscall in the main loop
Holy shit, /g/ is full of nocoders. MAKE THE WHOLE ARRAY (hint you only need 21 compares), THEN SYSCALL the first million bytes of the array.
>>
>>101547532
lol no
>>
>>101574620
That's a waste of memory, and the way you explained it sounds wrong... (:
>>
File: uncle bob.png (22 KB, 715x223)
22 KB
22 KB PNG
>>101548099
>clean code
>>
File: 8tl6c.jpg (40 KB, 494x639)
40 KB
40 KB JPG
>>101557496
Your shitpost should have put the underscores 00_00_00 like this for maximum replies
>>
>>101577409
I prefer if (true == condition) over if (condition) or if (condition == true)
>>
File: code.png (102 KB, 1266x808)
102 KB
102 KB PNG
just werks
>>
File: 1710351382840631.jpg (10 KB, 141x142)
10 KB
10 KB JPG
>>101547532
Oh you!
>>
>>101547532
absolutely agreed, this conduct just proves that indians are much more civilized then westerns
>>
>>101573953
This is so cool, binary would be like ~13 MB. Congrats, saar.



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