/dpt/ - daily programming thread

Kernel hacking edition

Old:
No languages higher than C allowed. C++ is neither allowed see: harmful.cat-v.org/software/c /linus

Overly bloated and abstracted OOP is terrible. If you want to go higher level than C, use Haskell or Lisp.

Embrace the goto and don't be an anti-goto cargo-cultist: koblents.com/Ches/Links/Month-Mar-2013/20-Using-Goto-in-Linux-Kernel-Code/

Place your opening bracket on the same line: kernel.org/doc/Documentation/CodingStyle

Finally, if you're a Windows user, you will be laughed at in this edition. It simply is a defective OS and its filesystem is a fucking joke that continues the tradition started with FAT. See pic.

Please upgrade: gentoo.org/downloads/

Other urls found in this thread:

youtube.com/watch?v=HQYsFshbkYw
harmful.cat-v.org
twitter.com/NSFWRedditImage

hot opinions sperg

==4907== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==4907== at 0x4C2ABD0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4907== by 0x4EC193F: pool (eh_alloc.cc:123)
==4907== by 0x4EC193F: __static_initialization_and_destruction_0 (eh_alloc.cc:250)
==4907== by 0x4EC193F: _GLOBAL__sub_I_eh_alloc.cc (eh_alloc.cc:326)
==4907== by 0x400F499: call_init.part.0 (in /usr/lib/ld-2.23.so)
==4907== by 0x400F5AA: _dl_init (in /usr/lib/ld-2.23.so)
==4907== by 0x4000DC9: ??? (in /usr/lib/ld-2.23.so)

>Valgrind

2nd for reasonable adults

>No languages higher than C allowed.

Why is ext2 so god damn fast?

Simplicity, no journaling for example.

Is there something like numpy for C++?

>It simply is a defective OS and its filesystem is a fucking joke

I know this feel. I decided that I wanted to play some GTA V last night / morning, and rebooted into Win7 from Debian. Updates disabled etc, started Steam and let all the 20 game updates run (only boot Windows a handful of times a year). I gave up and went to bed after TF2 took 50 minutes to install it's updates, and CS:GO was 30 minutes into it's update (with no end in sight, game would run like shit with slow disk read).

The updates would download at 8MiB/s, but the disk usage was just going nuts.

Oh well, at least it's better than the last time I booted into Windows in December last year for Fallout 4; Windows update took an hour and a half to run, 20 minutes to "finish" updating on reboot, only to tell me that it had installed incompatible updates and needed to revert, which took another 15 minutes, then another 15 to take another step back. Finally I was on the home stretch another set of reboots and updates after disabling to problem update and installing the ones that were supposed to come after it failed.

All in all it took over 3 hours for me to give the game developer/publisher my money. Why do they choose Wangblows again?

>Why do they choose Wangblows again?

Because, in the beginning, there were no other options. DirectX was king.

I'm having a pretty good time learning java so I can take the AP computer science test

I'm basically to make a version of this youtube.com/watch?v=HQYsFshbkYw in a javaFX jframe

am I wasting my time? is javaFX just some meme GUI software or can I do some reasonable graphics calculations?

My updates complete almost instantly after they finish downloading. They always have, on both mechanical drives and SSDs.

Moreover, you have the ability prioritize updates on steam. You didn't have to update any game other than the one you wanted to play.

You, sir, are an idiot.

...

Lisp is allowed, as is Haskell, so we're good

Haskell is trash and Lisp is good, but that still misses most of the languages that people actually use.

Please ignore that trip.

>I don't know how to argue a simple fucking solution and my computer is a pile of shit.

>if you're not having problems with windows you must be a Sup Forumsermin teehee xddddDDD

get blown scrub
guess you just suck at computing

quick, write a virtual machine for a superset of the basic opcodes (mov, add, etc) of the x86 architecture in your language of choice in under 10 minutes to prove you're not a cancer on this general

no

pajeet detected

real thread

>superset of the basic opcodes
kid, can you even into avg2int?

sure i can, my professor taught me

#include
#include
#include

#define JAVACODE "public class Average {\n
public static void main(String[] args) {\n
int a = Integer.parseInt(args[0]);\n
int b = Integer.parseInt(args[1]);\n
int c = (a + b)/2;\n
System.exit(c);\n
}\n
}"

#define JAVA_CMDLINE "java Average %d %d"

int main(void) {
FILE *fp = fopen("Average.java", "w+");

if(NULL == fp) {
return -1;
}

size_t javacode_len = strlen(JAVACODE);
fwrite(JAVACODE, javacode_len, 1, fp);
if(ferror(fp)) {
return -1;
}

fclose(fp);

system("javac Average.java");

puts("Please provide two integers to average, separated by a newline:");
int a, b;
scanf("%d", &a);
scanf("%d", &b);

size_t buf_size = strlen(JAVA_CMDLINE) + 1 - 2;
char buf[buf_size];
sprintf(buf, JAVA_CMDLINE, a, b);
char const *aux = buf;

int c = system(aux);

printf("Result of averaging %d and %d: %d\n", a, b, c);

return 0;
}

IoT axe when

kid, we already rekt you, so...

>am I wasting my time?
yes
>is javaFX just some meme GUI software
yes

it's not even correct

what an innovative solution

as i said when i posted it originally, it's the idea that matters, not the actual implementation

it misses the entire point if it doesn't even work, the joke is ruined, you should cast to long or something in the java code

Ok, what can I use that is better

I'm not trying to make >muh games, I just want to do some thinking

or use BigInteger, might be funnier

it's not a joke, but fine, i'll get around to fixing it and asking my professor to review the fix and post it here (sometime)

anyway, no one has done the challenge yet

Which is the comfiest kernel to hack on? Linux? FreeBSD?

freebsd is not a kernel

dat boi absolutely BTFO

FreeBSD has a kernel

of course

kys

kys

kys

kys

kys

kys

kys

MODS, please!

kys

kys

are java servlets/jsp's still being used in web development?

kys

kys

kys

replaced by jsf
Can't comment on how it differs to jsp because I never did anything with it

NEW THREAD

>harmful.cat-v.org
the search continues

kys

What is the best way to learn ASP.NET if I already know programing in other languages? Any good tutorials?

>Moreover, you have the ability prioritize updates on steam. You didn't have to update any game other than the one you wanted to play.

I know, but it just shouldn't have been an issue in the first place.

is not me

vec3 operator+(vec3 &rhs)
{
vec3 v;
v.vec[0] = vec[0] + rhs.vec[0];
v.vec[1] = vec[1] + rhs.vec[1];
v.vec[2] = vec[2] + rhs.vec[2];
return v;
}

I'm new to C++, how can this be optimized?

void read_number(int *ptr)
{
int result = scanf("%d", ptr);
if (result == EOF)
exit(-1);

if (result == 0) {
while (fgetc(stdin) != '\n')
;
}
}

int main(void)
{
int a = 0;
int b = 0;

read_number(&a);
read_number(&b);

char buffer[1024] = {0};
snprintf(buffer, 1024, "python -c \"import sys; print(int(sys.argv[1]) + int(sys.argv[2]))\" %d %d", a, b);

system(buffer);
return 0;
}

With the += operator, and a for loop

>for loop
>optimization

uhhh

int average(int a, int b)
{
int sum;
sum += (a & b);
sum += (a ^ b) / 2;
return sum;
}

By using C instead of C++.

Retard alert

>I don't know anything about compilers

There's nothing wrong with a single for loop.
Also, your compiler will unroll it anyway

>Linus is a retard now
I guess you're more intelligent than him. What have you done in your life that is has relevant as the linux kernel ?
There's pros and cons, but one must admit that most high level languages are fucking garbage. Few of them might solve and make coding faster, but you realize fast enough that it is just trash.

(manually) unrolling loops is faster because no comparison instructions
i dont know how branching works so i might be wrong on taht though
+= is really the same as example posted

>took hours to download several gigs worth of game updates
>must be because of windows

use mmx

but it's possible that compiler already did that for you

Fucking hell... oh my stars... the constructor and destructor calls in this shit. Pajeet, kill yourself immediately.

Guys I wrote a function to average 2 ints!

void swap(int *x, int *y)
{
int tmp = *x;
*x = *y;
*y = tmp;
}

int average(int x, int y)
{
if (x > y) {
swap(&x, &y);
}

while (x < y) {
x++;
y--;
}

if (x == y) {
return x;
} else {
return y;
}
}

Then it shouldn't matter whether something is a meme or not.

You can always apply the mental routine to other memes.

>Linus is a retard now
>sizeof really is a function
seems so

Thanks for making your presence known.

by adding
v.vec[3] = vec[3] + rhs.vec[3];

Did me mean optimization like run time efficiency, or not looking like shit to read? I assumed the latter because the former is impossible to take any further.

hehe xd

>I'm having a pretty good time learning java so I can take the AP computer science test
m8 wasn't that like a few weeks ago?

It's a vec3, not a vec4. Retard.
And how the fuck would that optimize it?

I meant the former.

>not a vec4
use a vec4 then
>how
seems like you're the retard

>but one must admit that most high level languages are fucking garbage
okay dude enjoy jerking off to those buffer overflows :^)
ill just be over here suffering from the lack of bugs

I don't want to use a vec4, I don't need to.
Now explain to me how adding an extra element and doing useless operations on it would somehow improve performance. Go on.

In that case ignore my advice, I think you've already taken it as far as you can go (then again, I don't speak CPP).

someone give me a problem that involves lots of pointer shit
im not good at it

Well, I was mostly interested in the C++ side of things.
Example, I noticed how every operation will create a new object and copy it out of the function, so I was wondering if there's a way to optimize that, because that could possibly destroy performance.

swap 2 ints

>I don't want
you don't want it to be faster?
>I don't need
ok, if you don't need performance
>explain
seems like I'd be wasting my time since you don't seems receptive to knowledge

Implement double linked list without bugs.

>Adding more useless shit to stuff makes it go faster
Ok.

>makes it go faster
yes
>useless
it's not useless if it improves performance

,>,>+[-].

>Performance is useless.
Webkids should just leave Sup Forums.

void swap_ints(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}

shieeet that one will take a long itme

bf meme is no more funny

Ok, now explain how it improves performance.
I'm listening, if you explain it I'll understand.

Otherwise you're obviously full of shit.

a for loop is not really appropriate in this situation, the code is too small.