[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - daily programming thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 23
File: performance.png (31 KB, 819x424) Image search: [Google]
performance.png
31 KB, 819x424
Kernel hacking edition

Old:
>>54555253

No languages higher than C allowed. C++ is neither allowed see: http://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: http://koblents.com/Ches/Links/Month-Mar-2013/20-Using-Goto-in-Linux-Kernel-Code/

Place your opening bracket on the same line: https://www.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: https://www.gentoo.org/downloads/
>>
>>54562244
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
>>
File: 1463003778018.png (461 KB, 720x688) Image search: [Google]
1463003778018.png
461 KB, 720x688
2nd for reasonable adults
>>
>>54562244
>No languages higher than C allowed.
>>
>>54562244
Why is ext2 so god damn fast?
>>
>>54562422
Simplicity, no journaling for example.
>>
Is there something like numpy for C++?
>>
File: 1458834596527.jpg (18 KB, 500x381) Image search: [Google]
1458834596527.jpg
18 KB, 500x381
>>54562244
>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?
>>
>>54562612
>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 https://www.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?
>>
>>54562612
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.
>>
>>54562808
>>>/v/
>>
>>54562388
Lisp is allowed, as is Haskell, so we're good
>>
>>54562841

Haskell is trash and Lisp is good, but that still misses most of the languages that people actually use.
>>
>>54562841
Please ignore that trip.
>>
>>54562819
>I don't know how to argue a simple fucking solution and my computer is a pile of shit.
>>>/out/
>>
>>54562819
>if you're not having problems with windows you must be a /v/ermin 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
>>
>>54562934
no
>>
>>54562950
pajeet detected
>>
>>54562244
real thread

>>54562664
>>
>>54562934
>superset of the basic opcodes
kid, can you even into avg2int?
>>
>>54562976
sure i can, my professor taught me

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#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;
}
>>
>>54562612
IoT axe when
>>
>>54563002
kid, we already rekt you, so...
>>
>>54562728
>am I wasting my time?
yes
>is javaFX just some meme GUI software
yes
>>
>>54563002
it's not even correct
>>
>>54563019

what an innovative solution
>>
>>54563031
>>54563053
as i said when i posted it originally, it's the idea that matters, not the actual implementation
>>
>>54563065
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
>>
>>54563033

Ok, what can I use that is better

I'm not trying to make >muh games, I just want to do some thinking
>>
>>54563079
or use BigInteger, might be funnier
>>
>>54563079
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?
>>
>>54563106
freebsd is not a kernel
>>
dat boi absolutely BTFO
>>
>>54563135
FreeBSD has a kernel
>>
>>54563141
of course
>>
>>54563136
kys
>>
>>54563136
kys
>>
>>54563136
kys
>>
>>54563168
>>54563161
kys
>>
>>54563136
>>54563161
>>54563168
>>54563172
>>54563173
kys
>>
>>54563136
>>54563161
>>54563168
>>54563172
>>54563173

kys
>>
>>54563173
kys
>>
>>54563161
>>54563168
>>54563172
>>54563173
>>54563176
>>54563177
>>54563178
MODS, please!
>>
>>54563136
>>54563173
>>54563187
kys
>>
are java servlets/jsp's still being used in web development?
>>
>>54563187
kys
>>
>>54563187
kys
>>
>>54563192
replaced by jsf
Can't comment on how it differs to jsp because I never did anything with it
>>
NEW THREAD

>>54543664
>>54543664
>>54543664
>>
File: intelligent.png (127 KB, 700x612) Image search: [Google]
intelligent.png
127 KB, 700x612
>>54562244
>http://harmful.cat-v.org
the search continues
>>
>>54563226
kys
>>
What is the best way to learn ASP.NET if I already know programing in other languages? Any good tutorials?
>>
>>54562808
>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.

>>54562819 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?
>>
>>54563002
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;
}
>>
>>54563430
With the += operator, and a for loop
>>
>>54563463
>for loop
>optimization

uhhh
>>
int average(int a, int b)
{
int sum;
sum += (a & b);
sum += (a ^ b) / 2;
return sum;
}
>>
>>54563430
By using C instead of C++.
>>
>>54563463
Retard alert
>>
>>54563475
>I don't know anything about compilers
>>
>>54563475
There's nothing wrong with a single for loop.
Also, your compiler will unroll it anyway
>>
>>54563235
>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.
>>
>>54563463
(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
>>
>>54562612
>took hours to download several gigs worth of game updates
>must be because of windows
>>
>>54563430
use mmx

but it's possible that compiler already did that for you
>>
>>54563430
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;
}
}
>>
>>54563085
Then it shouldn't matter whether something is a meme or not.

You can always apply the mental routine to other memes.
>>
>>54563530
>Linus is a retard now
>sizeof really is a function
seems so
>>
>>54563498
Thanks for making your presence known.
>>
>>54563430
by adding
v.vec[3] = vec[3] + rhs.vec[3];
>>
>>54563475
>>54563498
>>54563535

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.
>>
>>54563636
hehe xd
>>
>>54562728
>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?
>>
>>54563647
It's a vec3, not a vec4. Retard.
And how the fuck would that optimize it?
>>
>>54563663
I meant the former.
>>
>>54563692
>not a vec4
use a vec4 then
>how
seems like you're the retard
>>
>>54563530
>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
>>
>>54563716
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.
>>
>>54563713
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
>>
>>54563744
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.
>>
>>54563770
swap 2 ints
>>
>>54563739
>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
>>
>>54563770
Implement double linked list without bugs.
>>
>>54563799
>Adding more useless shit to stuff makes it go faster
Ok.
>>
>>54563818
>makes it go faster
yes
>useless
it's not useless if it improves performance
>>
>>54563782
,>,<[>>+<<-]>[<+>-]>[<+>-]<.>.
>>
>>54563818
>Performance is useless.
Webkids should just leave /g/.
>>
>>54563770
void swap_ints(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}

>>54563800
shieeet that one will take a long itme
>>
>>54563852
bf meme is no more funny
>>
>>54563844
Ok, now explain how it improves performance.
I'm listening, if you explain it I'll understand.

Otherwise you're obviously full of shit.
>>
>>54563430
a for loop is not really appropriate in this situation, the code is too small.
>>
>>54563716
>>54563799
fucking retard, a vec4 takes more memory, and memory access is the main performance concern for today's machines
>>
>>54563844
Wait, let me guess.
Is it because of SSE? I could see how adding a fourth element might make the compiler generate SSE instructions.
Is that correct?
>>
>>54563935
yes
>>54563931
you don't actually know how computers work
>>54563891
see >>54563935
>>
>>54563530

Linux only gained popularity because the BSDs were wrapped up in legal trouble when Linux appeared. It has nothing to do with skill or technical superiority. Linux is utter shit compared to BSD but Linux happened to appear at the right time. Linus got lucky.
>>
>>54563951
Ok, I understand now.
Sorry for doubting you before.
>>
>>54563951
kill yourself arrogant idiot

you have NO relevant benchmark to show for it
>>
File: 9sL6Xil.png (21 KB, 1600x900) Image search: [Google]
9sL6Xil.png
21 KB, 1600x900
What's a good java reference manual/book?
>>
>putting the * next to the identifier not next to the type

Fucking why, it makes no sense? I don't give a shit if great coders prefer that, I need a good explanation of why would you put * next to the name of a variable, and next to a type.
>>
>>54563975
https://docs.oracle.com/javase/tutorial/
>>
>>54563975
Core Java for the Impatient. It's perfect
>>
>>54563996
Because writing
int * x
doesn't mean that "x" is a "int *"
it means that "* x" is an "int".

That's why you must put * near the name and not the type
int* x is incorrect
int *x is correct
>>
>>54563996
int *a, b, *c;
>>
>>54564016
Dammit, I meant to say: next to the name of a variable, and not next to a type.
>>
>>54563996
There's no good reason.

>>54564016 is retarded because it's all valid

>>54564019 shows a use case of the syntax that also doesn't make much sense

Why can't I declare three int pointers like so:

int* a,b,c;


The real answer is that it's just the way it is and you're free to not do it, but don't expect any open source projects to accept code in that style.
>>
>>54564055
If you want int * to be a type you can do
typedef int *intptr;

void stupidfunction (void) {
intptr a, b, c;
}
>>
>>54564038
You also mean the brackets for arrays I guess? Because in that case you don't even get to choose... think about it
>>
>>54564078
>if I want more consistent behavior I have to do some shady shit
>>
>>54563952
>wrapped up in legal trouble
please stop with this bullshit excuse; the lawsuit only lasted for 2 fucking years, it ended in '94; '94 linux market share was shit; why don't you also mention linux's legal truble with sco? why didn't that boost bsd above linux?
>has nothing to do with skill or technical superiority
no argument there
>utter shit compared to BSD
yes, the code is not as nice as bsd's because it's written by joe random with no centralized design; it's stupid easy to contribute to linux while bsd is cathedral style; sure, this doesn't guarantee high quality code, but on the other hand, maybe this has something to do with everyone contributing to linux instead of bsd?
>Linus got lucky
yes, with the development model and with the license
>>
>>54563973
no need to get angry for losing an argument on an anonymous image board
>>
What's a good resource to learn as quick as possible to use threads in c ? I'm mainly interested in implemeting the quicksort algorithm using a thread pool.
>>
>>54564055
>There's no good reason.
Yes there is: Keningham and Ritchie decided that the syntax for the type should resemble the syntax for what you can do with this type. Do you think
VAR x: PTR INTEGER
 is more elegant and intuitive than int *x; ? No you don't, so that's why.
>>
>>54563800
#include <stdio.h>
#include <stdlib.h>

#define ITER 10

typedef struct node {
int data;
struct node *prev;
struct node *next;
} NODE;

NODE *init_node(NODE *prev, NODE *next)
{
NODE *node = malloc(sizeof(NODE)); //God says it won't fail.
node->prev = prev;
node->next = next;
return node;
}

void free_node(NODE *node)
{
if (!node) return;
if (node->prev)
node->prev->next = NULL;
free(node);
}

void iterate_from_top(NODE *node)
{
while((node = node->next) != NULL)
printf("%d\n", node->data);
}

void iterate_from_bottom(NODE *node)
{
while((node = node->prev) != NULL)
printf("%d\n", node->data);
}

int main(void)
{
NODE *top = init_node(NULL, NULL);
NODE *cur = init_node(top, NULL);
top->next = cur;
int i;
for(i=0; i<ITER; i++)
{
NODE *tmp = init_node(cur, NULL);
tmp->data = i;
cur->next = tmp;
cur = tmp;
}

iterate_from_top(top);
iterate_from_bottom(cur);

//iterate and free all nodes
while((top = top->next)) free(top);

return 0;
}


pls be gentle
>>
>>54564172
https://computing.llnl.gov/tutorials/pthreads/
>>
>>54564016
>int * x
>doesn't mean that "x" is a "int *"
m8...
>>
>>54564158
you're fucking delusional
>>
>>54564200
He's right though.
SSE would speed it up.
>>
>>54564186
Please code insert and remove
>>
>>54564200
>still mad
ok
>>
>>54564207
>>54564210
you have no proof, in any reasonable application it would just take up more memory
>>
What engine would you suggest for a side scroller 2d game? Also would you suggest java or c++? I'm not interested in python.

Tutorials would be nice as well. I'm guessing a lot of you have been into this kind of thing so I'm asking here.

I'm a backend webdev but wanted to this for fun this summer with a couple mates.
>>
>>54563730
>I'll just be over here waiting for gc
ftfy
>>
>>54564221
>in any reasonable application
I doubt a person with your lack of experience knows what a "reasonable application" is
>>
>>54564221
post code for vec3 so we can play around
>>
>>54564263
The person you are responding to is not the person who posted the vec3 snippet.
>>
>>54564262
kill yourself delusional retard
>>
>>54564232
Just use gamemaker desu. That's what all the profitable 2d indie games use (Risk of Rain, Hyper Light Drifter, etc).

It depends though. If you're more interested in learning about programming than making something playable, you could use slick2D or whatever game libraries people use nowadays.
>>
File: pham.webm (2 MB, 688x288) Image search: [Google]
pham.webm
2 MB, 688x288
Ask your much beloved programming literate anything (IAMA).

>>54563996
because in C, the declaration mimics the evaluation.

>>54563573
Nice (∩_∩ )

>>54563430
By using the compiler builtin vector types and builtin operators ?

>>54562244
NTOS concurrency is much better than linux. (Cutler > Torvalds ?)

>>54564186
>not using a double pointer

http://wordaligned.org/articles/two-star-programming
http://grisha.org/blog/2013/04/02/linus-on-understanding-pointers/
>>
File: IMG_20160515_131306555.jpg (3 MB, 4160x2340) Image search: [Google]
IMG_20160515_131306555.jpg
3 MB, 4160x2340
>>54564186
Make a separate insert function, init_node does a pretty poor job of that
>>
number of benchmarks showing that vec4 is faster than vec3 when you just need vec3: 0
>>
>>54564194
he's right though, it means that x is an int * and *x is an int
>>
>>54564309
>he's right though, it means that x is an int*
>>54564016
>doesn't mean that "x" is a "int *"
>>
nested 
 code  block 
>>
File: 1463031615690.gif (897 KB, 800x430) Image search: [Google]
1463031615690.gif
897 KB, 800x430
>>54564338
>>
>>54564182
If I may interrupt you two, I think int* x is more logical than int *x because it kind of corresponds to the way people think about stuff.
In the first case the thing on the left completely describes the thing on the right
>its a pointer to a number called x
The second case kind of breaks the flow, even though the visual difference is pretty small.
>>
>>54564281
>>54564297
at this point you're just embarrassing yourself
>>
I want to read last modified date using either my own code or the C standard library (no C++ standard library).

I don't have to go to the Windows API for this I hope.
>>
>>54564208
//from = base ptr
//where = how far to go
//data = data to insert
void insert_node(NODE *from, int where, int data)
{
int i;
for(i=0; i<where; i++) from = from->next;
NODE *new_node = init_node(from, from->next);
from->next = new_node;
new_node->data = data;
}

//from = base ptr
//where = how far to go to remove node
void remove_node(NODE *from, int where)
{
int i;
for(i=0; i<where; i++) from = from->next;
NODE *tmp = from->prev->next;
NODE *tmp2 = from->next;
free_node(from);
tmp->next = tmp2;
tmp2->prev = tmp;
}


maybe my code wouldnt be so pajeet if i hadnt skimmed k&r
>>
>>54564361
you're a fucking joke dude get a grip
>>
take a hypothetical example of adding 30 GB worth of vec3s vs adding 40 GB vec4s... which do you think will be faster... idiots
>>
>>54564381
>my ass hurts so bad right now
if you're so salty maybe you shouldn't get into internet arguments when your knowledge is lacking
>>
>>54564373
Have you test it? Check for every memory leak? Etc?
>>
>>54564407
the second one
>>
>>54564408
>>54564426
stay delusional retard
>>
>>54564415
no i dont know how to use debuggers
>>
>>54563187
jys
>>
Just because Java is an OO language doesn't mean you have to write OO code.

Ignore the side-effect meme. Use only pure functions
>>
>>54564443
You don't need a debugger to debug a program. Who taught you programming?
>>
>>54564407
If you write code properly vec3's is faster. If not and you just write the simplest thing in simd/have it happen on the GPU, and assuming it's float/double stored in the vectors then vec4 is potentially the same speed.
>>
>>54564476
youtube and lurking dpt/prog
>>
>>54562244
what if i'm generating C code from lisp?
>>
>>54564492
Try to debug without a debugger. You need that skill before complex things
>>
>>54564474
If you're gonna go with functional why even write Java?
>>
>>54564186
Your goal: if it's done right, the user of the library, main in this case, shouldn't have to manually adjust the next and prev pointers, the node function should do it correctly automatically. We're far from that tho. Here it's scattered around, with e. g. free_node removing itself from its prev but not from its next. Also why didn't you use it in "iterate and free all nodes" ? You have two nodes more than there are data also, and if init_node inits a node, it should update the next and prev pointers of its prev and next, respectively: it's just easier that way. Finally, your model is strange because of what >>54564295 pointed out.

>>54564373
What if where is too big? Why are you updating from->next but not the next node's prev in insert? What is with
tmp = from->prev->next
? It's no different from
tmp = from;
here. In short: absolutely haram.
>>
>Understanding pointers
Why is this so hard for people?
I really don't get it. They're the simplest thing imaginable, have an intuitive name and almost every explanation I can find is dead simple.

Is it the star for deference syntax that fucks with people?
>>
File: the_search_continues.png (1 KB, 87x92) Image search: [Google]
the_search_continues.png
1 KB, 87x92
>>54563530
>Linus linked to cat-v
>Linus in charge of PL design
>C not garbage
the search continues
>>
>>54564511
>that skill
Not sure what you're on about but there's no real reason not to use a debugger unless you're moving to a platform where you won't be able to use one.

Anon catching logic errors can't be accelerated in any way. Relying on debuggers doesn't hamper that progress at all. More information is always good when learning to deal with issues.

Why would a debugger somehow not learn him the same things? If he steps through his code using the tool or steps through the code in his head does it matter? Why not just let the computer do the math? That's really the only difference.
>>
>>54564534
people are retarded

the majority of people have an IQ below 110
>>
I made a Qt Widgets application on windows but i want it to look appealing, is it possible? how should i go about this?
Did i fuck up?
>>
>>54564570
>no real reason not to use a debugger
I totally agree, but it's not the same thing as not knowing how to debug without a debugger.
>>
>>54564534
They say it's the basic test for abstraction: if you don't get it, you won't be a programmer.

Can't find the source again tho. Also to broaden the topic:
Why is recursion so hard for people?
I really don't get it. It's the simplest thing imaginable, has an intuitive name and almost every explanation I can find is dead simple to me.
>>
>>54564580
>but i want it to look appealing
Leave that for artists.
>>
>>54564580
Hope this helps: http://de.slideshare.net/qtbynokia/how-to-make-your-qt-app-look-native
>>
>>54564571
>the majority of people have an IQ below 110
Uhh... IQ is normalized. That means the majority have an IQ <= 100, by definition. We could all be geniuses and the median IQ would be 100.
>>
>>54564293
Jesus christ you fag, can you stop writing question marks like this ?
>>
Hi /dpt/, I seek your enlightment
I know the basics of python (all the data types and shit), and I can write simple programs and complex mathematical things with it.

The thing is, I don't know how to build a project at all. I can't use libraries for shit, I have no clue how to interact properly with the user, how to build a GUI, in fact I can't do anything useful.

The other day I wanted to do a simple labyrinth game for training, where a labyrinth (#) is displayed in a terminal, and you have to move your character (@) from one end to the other.
I had no idea how to make the character move, how to make sure that he couldn't go through a wall, etc.

So I was wondering : are there any books on how to build a project, how to perform well with libraries, etc ? Cause I know all the notions individually, but I can't seem to interlace them into something consistent.
>>
>>54564615
lrn2read
>remainder: not all people are as intelligent as you are, that's why you personally are high on the relative scale that IQ is
>>
>>54564615
anything below 110 is pretty stupid, above 110 you could be a decent programmer
>>
>>54564534

This.
>>
>>54564607
>recursion
I think maybe people are stuck thinking of their program in a sequential way. Since they always return to their calling site after the function is done I imagine the confusion that you could enter a function twice or more times might be confusing.

I agree it's weird that people don't get it but there's some mindsets you could be in that would make it confusing. Imagine calling functions without a call stack. Then you just picture the function as having its own locations for variables (local variable X is shared between all 'instances' of foo()) it'd make recursion a very confusing concept if you think about it like that.
>>54564615
It's a very dumb statement for sure. But the point is clear. He's saying I'm overestimating normal people.
>>
I legit have 89 IQ
>>
>>54564703
are you a nigger
>>
>http://harmful.cat-v.org

That site thinks Go is a good language. Into the trash.
>>
>>54564703
I sometimes find it hard to believe I've met people like you but you and below are like 25% of the population.

I'd really like to know where you notice it playing a role and how. I have trouble understanding stupid people (no offense).
>>
>>54564703
If this is true, I want to let you know that IQ is pretty much completely bullshit created by insecure fucks that want to feel better about themselves.
>>
>>54564723
no i was in a car accident at the age of 3 and i hit my head in the car door window pretty hard
>>
I've made a relatively simple program, but I don have 6 or 7-fold nests in there somewhere, and other similar crap that looks simply awful, even to me.

Since it's about 800 lines of code, should I fix it, or write a better version from the ground up?
>>
>>54564745
damn
>>
>cat-v

I hope you guys know this is satire, right?
>>
>>54564745
That really sucks dude. So how are you doing now?
>>
>>54564752
Nah rewriting from the ground up is evil. Just rewrite the bit with the 7 layer deep code if it's actually a problem.
>>
>>54564772
They have the entire manpage base of Plan9, that has been useful to me at a time. To what extent is it satire you think? Or are you just trying to smear them?
>>
>>54564736
>>54564781
i am physically healthy but i am having a hard time learning logic and math, it makes no sense to me but after a few weeks it suddenly makes sense out of nowhere and it feels good man, very very good

i am doing this because i normally struggle to pay for things (like rain main, except that i am bad at math)
if i have $20 and i buy something for eg. $7.32
it takes me like 30 seconds to calculate in my head what my change will be

i have a person to aid me but i want to be independent
>>
>>54564822
sorry, I was talking about the harmful section of the website
>>
>>54564752
>but I don have 6 or 7-fold nests in there somewhere
Why would this be important?
>>
>>54564648
>111
>decent programmer
please
>>
Why does frequently syncing reduce I/O performance?
>>
>>54564833
>if i have $20 and i buy something for eg. $7.32
>it takes me like 30 seconds to calculate in my head what my change will be

Mental math is a matter of practice for most, are you sure this isn't the case for you too? In fact I'm sure it's the case. Just practice a lot of this shit and you'll be fine at it.
>>
Why would anyone ever use linked list when dynamic arrays are much faster?
>>
>>54564839
why not?
>>
>>54564839
140+ IQ is pretty rare, you have to balance quality/quantity, 111+ can be code monkeys at least
>>
File: glenda.jpg (527 KB, 1910x2208) Image search: [Google]
glenda.jpg
527 KB, 1910x2208
>>54564834
I see.

Anyone has unbiased info on how 9front is doing? Just asking, I don't expect anything big from it anyway. Their coc: http://9front.org/coc
>>
>>54562244
Dubs decides what I program for 4 hours
>>
>>54564534
Lots of people get into CS for shitty reasons like wanting to make games
>>
>>54564858
As soon as your elements reach a certain size, they aren't.

Fucking CS students and their number games.
>>
>>54564607
>Why is recursion so hard for people?
>I really don't get it. It's the simplest thing imaginable, has an intuitive name and almost every explanation I can find is dead simple to me.
most recursion explanations are shit and use terrible examples that shouldn't even be solved by recursion, like fibonacci
>>
>>54564846
i hope so anon
>>54564740
well i am really stupid and my brother who says he has 130 iq runs his own business and makes a lot of money
>>
>>54564837
But I do* I made a typo, sorry.
>>
File: iq.jpg (40 KB, 887x508) Image search: [Google]
iq.jpg
40 KB, 887x508
>>
File: cianiggers.jpg (321 KB, 1971x1971) Image search: [Google]
cianiggers.jpg
321 KB, 1971x1971
>>54564870
Video player for TempleOS
>>
>>54564870
A C interpreter
>>
>>54564534
>Is it the star for deference syntax that fucks with people?
The C syntax for pointers has nothing to do with the concept of pointers at all.

It's like saying block scope is hard because "var" in JavaScript does it wrong, requiring them to add a new keyword in ECMAScript 6.

This is why schools should use good languages to teach programming concepts.
>>
>>54564870
implement a mouse driver for linux
>>
>>54564903
Never in my life have I seen more bullshit. Please leave and >>>/sci/
>>
>>54564933
I can't, I only have windows
>>
>>54564870
Also a HolyC interpreter (show to terry after and capture his reaction)
>>
>>54564833
I'm also bad at mental math. I just don't care for it though. Like I can figure out that it's 12.68 in maybe 5 seconds or so but I don't get certain of it until maybe 10 seconds.
>>54564858
No reason ever.
Even this guy who knows practically nothing about writing programs (no joke, Sturstrop is retarded)
https://www.youtube.com/watch?v=YQs6IC-vgmo
Says they're bad. You learn them just because people demand it of you at college. They want arbitrary examples for shit.

They do have a favorable deletion pattern I suppose (leaves no holes). Unless whatever you're storing is pretty huge and makes the pointers a negligible storage concern. And you really don't want holes in your vector it could be a good idea.
>>54564879
Doesn't seem like a shitty reason. Tons of money there.
https://www.patreon.com/combin_ation?ty=h (2k+USD for this shit)
Seems like a good side-gig.
>>54564903
/pol/ nobody cares. We judge people on an induvidual level.
>>54564928
Well there's no doubt pointers are associated with C/C++ for most newbies and it's certainly a bit of a confusing syntax.
>>
R8 my 2048, /g/
http://pastebin.com/hRi0v0Wf
>>
>>54564928
What's a good alternative to C?

>inb4 go
>>
>>54564953
a CS degree doesn't teach you how to make/design/program games
>>
>>54564942
Well, you're installing gentoo now
>>
>>54564961
Variable names and comments leave a lot to be desired
>>
>>54564939
https://en.wikipedia.org/wiki/Mainstream_Science_on_Intelligence#Conclusions
>>
>>54564961
what the fuck is u.h?
>>
>>54564840
I/O is more efficient in batches. One large write is much faster than several smaller ones.
>>
>>54564963
Maybe a meme language, but Rust has a lot of potential as a low-level systems language. No GC (unlike go) and it enforces memory safety (no segfaults, no race conditions, etc)
>>
I've done a fair bit of scripting w/ python and javascript, I know java and c# as well

I want something very specific: a 3d plane you can view from any point, and input instructions with your mouse
I assume this is found in C++, right? Does anyone have any tutorials for this sort of thing? I would rather not have a prebuilt engine, this is for more for learning/fun. This isn't really for a game of any complexity, more of a simulation.
>>
>>54565000
Yes, that's from 1994. Good one.
>>
>>54565023
Well, nothing has really changed
>>
>>54565023
>1994
>too old
Anon not that guy but that's a terrible argument. It's not like 1994 was the height of american slavery or anything either.
>>
>>54565016
GLFW+GLEW
>>
>>54565016
This is OpenGL 101, unless you want to do the projection math yourself.

You can easily do it in e.g. Python with pygame, if you don't really want to use c++
>>
>>54564928
>This is why schools should use good languages to teach programming concepts.

Yes, like pascal.
>>
>>54565055
http://antongerdelan.net/opengl/hellotriangle.html
Forgot the tutorial..
>>
>>54564928
What's a better example for pointer syntax?
>>
>>54565007
I find it difficult to understand why this is. Shouldn't the numerous small writes max out the disk anyway? Or are they unable to be sent fast enough because of OS operations?
>>
>>54565059
>>54565055
and C++ has backwards compatability with C, right?
>>
>>54565108
There's a startup and wind down cost to every IO operation. Thus it's most efficient to only flush or msync when you need to.
>>
>>54565141
Thanks
>>
>>54565133
I'm pretty certain this generates an error in C++, and this is everywhere in C code:
int * i = malloc(sizeof(int) * 8);

From my understanding you *have* to cast void * types: there's no automatic type conversion.
>>
>>54565133
C code can be compiled in C++ compilers (generally).

So basically write your code according to your knowledge. There's no reason to use C++ features unless they help you.

And moving from Java to C++ isn't hard.
>>
>>54565078
http://www.kednos.com/pli/docs/reference_manual/6291pro_014.html
>>
>>54564607
>Why is recursion so hard for people?
Non-tail recursion just doesn't appear come naturally to humans[1].

I suspect it didn't come naturally to you either, but after years of programming it feels like second-nature.

[1] https://web.stanford.edu/~roypea/RoyPDF%20folder/A27_Kurland_Pea_85.pdf
>>
File: lol.gif (695 KB, 472x360) Image search: [Google]
lol.gif
695 KB, 472x360
>>54565078
>What's a better example for pointer syntax?
bumping this question, hence the weird pic related. I'm curious but pretty sure there isn't tho.
>>
>>54565192
Ouch that shit is f*cking awful
>>
>>54565209
>CHILDREN'S MENTAL MODELS OF RECURSIVE LOGO PROGRAMS*
That's pretty cool.
>Children who had a year of Logo programming experience were asked to thinkaloud about what brief Logo recursive programs will do
Really cool.
>>54565223
Just using another symbol for deference is better syntax than C.
>>
>>54565192
>BASED (BUF_PTR)

Absolutely based.
>>
What is google ion and why should I program my next mobile app with it?
https://github.com/google/ion
>>
>>54562244
why did no one tell me scheme was comfy? i feel decieved
>>
>>54565209
Good source.

>I think maybe people are stuck thinking of their program in a sequential way. Since they always return to their calling site after the function is done I imagine the confusion that you could enter a function twice or more times might be confusing.
>
>I agree it's weird that people don't get it but there's some mindsets you could be in that would make it confusing. Imagine calling functions without a call stack. Then you just picture the function as having its own locations for variables (local variable X is shared between all 'instances' of foo()) it'd make recursion a very confusing concept if you think about it like that.
I guess my "should be a black box" model protected me from that. Gotta check my oldest code to see how I did things though.
>>
File: sussman.jpg (21 KB, 206x300) Image search: [Google]
sussman.jpg
21 KB, 206x300
>>54565294
What? One of the main tools of the schemer is that Scheme be comfy:

One of the authors of Scheme uses this quote on the first page of his book:
>I think that it's extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customers got shafted every now and then, and after a while we began to take their complaints seriously. We began to feel as if we really were responsible for the successful, error-free perfect use of these machines. I don't think we are. I think we're responsible for stretching them, setting them off in new directions, and keeping fun in the house. I hope the field of computer science never loses its sense of fun. Above all, I hope we don't become missionaries. Don't feel as if you're Bible salesmen. The world has too many of those already. What you know about computing other people will learn. Don't feel as if the key to successful computing is only in your hands. What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more
>>
>>54563876
>Not using xor swap
>>
out of curiosity, is there any language that lets you define new operators like swift, has a default regex type like js and ruby, and has complex numbers like python?
>>
>>54565361
>tfw you interview a candidate and they try to show off by using xor swap
Shig diggi doogie, da dig dop heyy
>>
>>54565403
perl
>>
File: key.jpg (48 KB, 640x481) Image search: [Google]
key.jpg
48 KB, 640x481
Any idea why strncpy segfaults here?

int loop(int sfd)
{
int k = 0;
char buf[513], **message = malloc(513 * 513); /* feed me mem */
char pong[64] = "PONG :";
const char *pass = "PASS finninbin\r\n";
const char *nick = "NICK kek\r\n";
const char *user = "USER kek 0 0 :kek\r\n";

memset(message, '\0', 512 * 512);

send(sfd, pass, strlen(pass), 0);
send(sfd, nick, strlen(nick), 0);
send(sfd, user, strlen(user), 0);

int len = recv(, buf, 512, 0);

for (int i = 0; len != 0; ++i)
{
strncpy(data, buf, 512);

for (int j = 0; j < 512; ++j)
if (buf[j] == '\r' && buf[j + 1] == '\n')
{
buf[j + 2] = '\0';
strncpy(message[0], buf, 0);
puts(message[k]);

for (int l = 0; l < k; ++l)
if (strncmp("PING :", message[l], 6) == 0)
printf(strcat(pong, message[l] + 6));
++k;

if (k >= 512)
message = realloc(message, sizeof(message) + 512);
}

len = recv(sfd, buf, 512, 0);
}

return 0;
}
>>
>>54562244
>Overly bloated and abstracted OOP is terrible.

You don't have to use all of the high level features if you don't want to.
Thread replies: 255
Thread images: 23

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.