[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: 19
File: yuki.jpg (104 KB, 984x927) Image search: [Google]
yuki.jpg
104 KB, 984x927
Old: >>52957993
What are you /g/ays working on?
>>
C++17 get
>>
File: ;D.png (57 KB, 800x334) Image search: [Google]
;D.png
57 KB, 800x334
Fizz digits get
>>
im gonna bump this thread in a minute
>>
Learning Ruby so I can use my RC Drone that I got for Christmas but haven't been able to use yet. Why choose such a shitty scripting language when there is Python or Lua?
>>
>>52962684

Andrei will make programming great again.
>>
>>52962742
D still has no macros and shit nogc support
>>
Is this correct thread? :3
>>52961986
Is it possible to jam WiFi with a normal laptop?
>>
>>52962777
That depends on your wifi hardware, but that's very likely impossible with commodity hardware.
>>
>>52962777
read up on slamming wifi
check if your hardware can do that
>>
>>52962777
What you can do is run a Wifi deauth attack against anyone in sight though.
Also, nice digits.
>>
File: 2TMkscH.jpg (102 KB, 959x538) Image search: [Google]
2TMkscH.jpg
102 KB, 959x538
>>52962777
>>
In C how can I test if a forked child process is running in the background or is finished running if I know its PID?
>>
>>52962758

Be patient.
>>
i set up my visual studio c# project on git by putting it in the folder with the .csproj, but any nuget packages i have are in the parent folder to this directory

should i move the package folder from parent to what im in right now, or is it normal (like in python) to just give instructions on what packages to install with nuget? should i have started the git project in the parent directory instead?
>>
Learning some ARM64 assembly and fucking with UART / Qemu VGA / Ethernet stack right now. I am thinking of going to google play store and crack every poo2loo's software and give it for free just to collect the poo flavored tears
>>
>>52962851
>patient
>15 years later
srsly?
>>
In Java, how can I get this regex to check if the string is not a positive double? Right now it just checks for double format
\\d+|\\d+[.]\\d*|\\d*[.]\\d+
>>
>>52962833
is_forked_child_process_running_in_the_background(pid)
>>
>>52963012

Perfection takes time.
>>
Is there a way i can call the totalRain method for the total variable and use it for the avg method?
public static void totalRainFall(double x[])
{
double total = DoubleStream.of(x).sum();
System.out.println("The total rainfall is "+total+" inches.");
}

public static void avrgMonthlyRainFall(double x[])
{
double total = DoubleStream.of(x).sum();
double avg = total / 12;
System.out.println("The average rainfall is "+avg+" inches per month.");
}
>>
>>52963030
if (Double.parseDouble(str) == null) ?
>>
>>52963045
What are you trying to ask here
you could just pass x to the totalRainFall and call it there
>>
File: 1404169921001.jpg (278 KB, 800x600) Image search: [Google]
1404169921001.jpg
278 KB, 800x600
/dpt/ I wanted to ask you about licenses.
I am planning to develop an open source project but I wanted to use a License that allowed people to use the source code freely, but they should mention it wasn't developed by them, it was developed by someone else (in this case, me).
What license should I use? Apache? Could you guys teach me about open source licenses?
>>
>>52963045
public static double totalRainFall(double x[]) {
/* ... */
return total;
}

public static void avrgMonthlyRainFall(double x[]) {
total = totalRainFall(x);
/* ... */
}

Like that.
>>
>>52963045
yes, by making your methods not void and make them return doubles. don't make your functions purpose to be printing things out.

also java makes me want to barf every time i see it
i can't believe i even use it at work
also the fucking standard abbreviation of the word average is avg
>>
>>52963082
https://opensource.org/licenses/BSD-3-Clause
>>
>>52963030
if(Double.parseDouble(string) < 0){
// Do whatever you want
}
>>
D's compile time regexes still can't be evaluated at compile time
The fuck
>>
>>52963109
but wait im giving the user options to choose from " do you want to see average rain fall, total rainfall, most rain, least..."
>>
>>52963110
Thanks a lot.
I just need to add to all my source code the the license template that is typed after "Here is the license template:"?
>>
>>52963059
>>52963122
Doesn't parseDouble only convert a preformatted string to a double? The string is user input so I need to make sure it doesn't contain alphabetic characters, etc. I can check if it's positive after I confirm it's a double, but it would be cool if I could check for a positive double in one regex
>>
>>52963182
yes, it is
>>
>>52963209
http://stackoverflow.com/questions/9619603/no-tryparsedouble-in-java

Alternatively switch to C# which has a Double.tryParse() method because it's not shit like java.
>>
>>52963209
Why don't you ask the user to type a double value, not a string?
>>
>>52963167
What are you talking bout, both your questions are jibberish, just total jibberjabber
>>
>>52963167
so? calculating the average is a separate concern from telling the user you calculated it. there's no reason to bind them together.
public static double totalRainFall(double x[]) {
return DoubleStream.of(x).sum();
}

public static void main (String[] args) {
System.out.println(String.format("The total rainfall is %.2f inches.", totalRainFall(rainfall));
}
>>
I feel like my programming skills have atrophied after being a devopsman for the last 6 months. What should I do to recover?

As an aside, because there isn't a daily sysadmin thread: is there a way of using lets encrypt with a mail server? The standalone version doesn't like a mail. subdomain even though the dns is all pointed right.
>>
>>52962938
i know c# is a meme language but surely someone uses it and git and knows package convention
>>
>>52963232
Thanks again anon.
>>
>>52963364
>i know c# is a meme language

dead wrong and now I won't answer your question.
>>
>>52963364
Lots of people use C#, but no one uses nuget. Anyway if I had to guess, just leave it as is and tell people in the FAQ/readme of your repo about the prerequisite nuget packages.
>>
>>52963434
you wouldn't and weren't going to anyway so i dont really care
>>
>>52963437
is there a more popular/accepted package manager? i'm not too proficient at c# but any basic google search always leads me to using nuget
>>
>>52963043
not gonna live that long
>>
File: Capture.png (11 KB, 377x256) Image search: [Google]
Capture.png
11 KB, 377x256
I have a switch statement thats in a loop and gives the user options on what to see, but for some reason it shows the old choice when the user presses a new one?

boolean choice = true;

while(choice)
{
System.out.println("\nEnter \'v\' to view the monthly rainfall."
+ "\nEnter \'t\' to find the total rainfall...."); //etc etc
char user = input.next().charAt(0);

switch(user)
{
case'v': monthlyRainFall(month, rain);
break;
case't': totalRainFall(rain);
break;
case'a': avgMonthlyRainFall(rain);
break;
case'm': mostRainFall();
break;
case'l': break;
case'u': break;
default: choice = false;
break;
}
}


>>52963303
but that would clog up my main
>>
>>52963467
>is there a more popular/accepted package manager?
Not really. I rarely need anything from nuget, C# comes with a pretty massive library. Maybe my projects just aren't cool enough though.
>>
>>52963495
Because your avgMonthlyRainFall method calls totalRainFall, which has a print statement.
>>
/dpt/ need your help to understand this in C.

while(c = getchar())
if(c == '\n')
/* works as intended */


while(getchar())
if(getchar() == '\n')
/* **ERROR** infinitive loop */


c = getchar();
-----
while(c)
if(c == '\n')
/* **ERROR** infinitive loop */
>>
>>52963531
What the fuck are you trying to do?
>>
>>52963528
ah yes, damn i should just stick to my gut
>>
>>52963531
char c = 'a';
while (c != '\n') {
c = getchar();
}
>>
>>52963531
What do you mean, help you understand, the behaviour is self explanatory...
>>
>>52963502
it's not anything crazy, just a html parser library with an api that is a little more intuitive than the natural library

i guess i'll just include the library i use in the readme? i dunno, i guess that'll be fine
>>
>>52963550
it was simple program that was counting how many words and at what length they were added.

This is just simplified version, i was debugging it for 30 minutes i did (c = getchar())
>>
>>52963531
Block 1 updates variable c with each while iteration, while Block 3's variable c never changes.
Block 2 does work, but you'll only read every other key (typing "Asses\n" reads "Ass" and waits for a new line), not an infinite loop)
>>
>>52963531
>while getchar
>if getchar
are you retarded
>>
Hey gee, why don't you average 2 ints in C?
>>
>>52963592
>>52963592
You look like a beginner, stop trying to get cute with your code.
>>
>>52963647
>>52963577
>>52963550
Are you people idiots?
It's obvious that he's trying to create a loop to read chars 1 by 1 until the user hits enter.
Solution is >>52963575
>>
>>52963685
It's obvious what he's trying to do, he asked to help him understand it, you utterly illiterate fuck
>>
>>52963575
>>52963647
>infinite loop
>>
>>52963594
Thanks,

>>52963647
it's only way I know.
>>
>>52962938
just include the packages.config file
>>
>>52963445

The truth is that you're just supposed to list the nuget packages they need.
>>
Might be a dumb question, please be gentle.
I am developing an Android App and my Java files are organized in the picture related way.
Now I am going to add a IntentService, Broadcast Receiver and an AlarmManager to periodically check an API for status updates and I am wondering: Where should I put this files? Should I create a "services" and "receivers" packages?
>>
>>52963760
Put them in the trash
>>
>>52963621
int avg = (a >> 1) + (b >> 1) + (a & b & 0x1);
>>
>>52963785
That might be a good alternative.
>>
>>52963866
>complicating things for no reason
int avg = a + b / 2;
step it up, feg!
>>
>>52963911
b-b-but th-th-the OVERFLOW!!
>>
>>52963531
>infinitive
>infinitive
What the fuck does this even mean?
>>
Can I get some tips for a programming assignment?
Trying to manage multithreading in Java, having them add and subtract values, without using the synchronized statement. Any guides anywhere on the use of locks for my threads?
>>
>>52963911
Are you fucking dense?
>>
Attempting to write OO matlab. LOL pls kill me
>>
    (defun try-me-1 (a-list)       
(cond ((null a-list) 1)
((atom a-list) 0)
(t (max (+ (try-me-1 (first a-list)) 1)
(try-me-1 (rest a-list))))))

Can someone help me comprehend this piece of lisp? If I put in a list (a b c d e f) I get what looks like a return value of 1, but I have no clue if I'm reading the trace right.
>>
>>52962758
>nogc
GOTTA PROGRAM CLOSE TO THE METAL MY ANIMU PICTURE VIEWER MUST BE EMBEDDABLE NO MEMORY LEAKS I NEED EVERY FUCKING CYCLE
>>
>>52964074
https://en.wikipedia.org/wiki/Infinitive
>>
File: magician.jpg (3 MB, 2448x3264) Image search: [Google]
magician.jpg
3 MB, 2448x3264
>>52963911
:^)
I know it's bait and you are mad because you got BTFO by C again, and your ass hurts because you will never be able to do anything more than a python script to fix your arch config
but I'm bored so I'll explain where you are wrong
someone else might find this information useful, eventhough it was explained about 10 times in this and the last thread already

>int avg = a + b / 2;
firstly you only divide b by two
not the sum of a and b
that's just a dumb error and I guess that's part of your ebic troll

so let's correct that
>int avg = (a+b) / 2;
now you still have the problem that the sum of those two integers inside the parenthesis has to be between −2147483648 and 2147483647, otherwise you get an overflow/underflow

alternatively you could divide the ints directly
>int avg = a/2 + b/2;
but in case a and/or b are not evenly divisible by 2 they get rounded and you lose that information and the result will be wrong
you could do something like
>int avg = (int) ((long double) a / 2.0 + (long double) b / 2.0)
that would work but you could still lose information due to the cast to a floating point number

I'm happy I could help

the solution posted above also only needs one cycle so it won't get any more efficient
>>
What's the best way to store a cookie that will show the last 5 searches?

I think the best way to do it using an array, and appending to the array. This way I can keep it at a length of 5, and iterate through it easily.

I tried creating an array, then pushing the search ID to the array, then setting the array to the value of the cookie, but obviously the array will reset on refresh.

I then tried setting the array to the value of the array on load. But what if the cookie doesn't exist yet? So I added an
if not null
check. Surely there's a better way though?

I want to achieve something like imdb's recent history: http://www.imdb.com/profile/recently-viewed
>>
>>52964216
>one cycle

...
>>
>>52964216
how the fuck does that clusterfuck use one cycle I'd like to know
>>
>>52964249
>>52964261
http://www.google.com/patents/US6007232?hl=de&dq=6007232
I didn't invent it
>>
>>52964216
nice blog, weeb
>(long double) a / 2.0
learn C first, pajeet
>>
>>52964272
>I can't tell the difference between hardware and software
that's why you're shit tier webcuck
>>
>>52964277
but that's perfectly fine, John Smith
maybe you learn C first, burgerclap
>>
>>52964277
>long double

yay, now you have cut range of 8bit int in half on this AVR. good job on being retarded with your code.
>>
>>52964272
kill your self, baitman
>>
>>52964146
When did car and cdr become "first" and "rest"?

Anyway, consider this:

(try-me-1 '())
1

(try-me-1 '(((()))))
4
>>
>>52962684
What language?
>>
>>52964277
>(long double) a / 2.0
>perfectly fine
back to /wdg/
>>
>>52964305
>I use random shitty architectures and so I program in roundabout ways to support them even though exactly zero other people use them.
>>
>>52964320
>When did car and cdr become "first" and "rest"?

first and rest are as old as car and cdr.
>>
>>52964342
C code needs to be portable, if it's not, its a shitty code.
>>
>>52963721
>>52963720

hey i came back later in the thread, so heres both of your thank yous
>>
>>52964329
WE ARE THE D
>>
>>52964353
Port your C code to my hard, throbbing cock.
>>
>>52964320
Thank you, I knew I was missing something. The combination of parens up the ass and recursion makes lisp kind of a doozy for me.
>>
>>52964330
>>52964315
>>52964249
OSGTP I already knew you are a fucking idiot who doesn't know the slightest shit about anything remotely related to technology, only shitposting 24/7 in /dpt/, but now you're just spouting out how stupid you are
go kill yourself, fucking idiot

prove me wrong otherwise
>>
>>52964457

Easy there, chief. Why don't you explain why you're mad?
>>
>>52964457
you seem a little angry..
>>
>>52964457
>prove me wrong meme
so edgy! fuck off fucboi
>>
>>52962833
I think you can do kill with signal 0 or maybe wait with non blocking option
>>
>>52964249
>>52964261
Your x86 cpu since Nahelem can actually do 8 averages (8 packed 16 bit integers) in one cycle (half a cycle even, can issue two of them per cycle)
>>
>>52964739
>can actually
not at all
>>
File: you are this mad.jpg (102 KB, 707x403) Image search: [Google]
you are this mad.jpg
102 KB, 707x403
>>52964457
>>
>>52964752
Yes it can.
Look up pavgw in your favorite instruction latency table.
1 cycle, 0.5 reciprocal throughput.
>>
>>52964783
pavgw only works with unsigned you fucking retard
>>
>>52964783
>pavgw
>rounding towards zero
memejs DESIGNATED
>>
>>52964804
It would not be any problem adding a signed version, sign tests in hardware are basically free, you just route the sign bit into the next gate input.
>>
>>52964860
>not be any problem adding a signed version
add it and then we can talk
>>
>>52964860
>just route the sign bit into the next gate input
ask me how I know you're clueless
>>
>>52964881
The only reason they haven't added it is because it's not a useful operation so it would waste opcode and die space, but doing it in 1 cycle is no problem.
>>
File: Capture.png (12 KB, 581x211) Image search: [Google]
Capture.png
12 KB, 581x211
I have a string array and i want it numbers through 1-12, how is this even possible?
>>
>>52964933
>doing it in 1 cycle is no problem
bwahahahahaha; please, you're embarrassing yourself
>>
>>52964933
totally, same with verifying if a number is prime, 1 cycle! no problem, just route some bits! it's just not that useful
>>
>>52964117
TIL matlab classes are immutable by default. I don't like that..
>>
>>52964971
Why wouldn't it be possible?
See Fig 2 in the patent linked.
Those "is signed?" tests just involves routing the signal to two different branches of the circuitry based on the sign bits.
>>
>>52964958
>month[i] = i + 1
what are you trying to acomplish with this line?
>>
>>52964958
you are giving us an XY problem http://xyproblem.info

your actual issue is that you want to...what...record some rain values for a given month?
>>
>>52965053
>Those "is signed?" tests just involves
you have no idea what you're talking about do you?
>>
File: stop.png (25 KB, 640x394) Image search: [Google]
stop.png
25 KB, 640x394
>>
>>52965003
Adding new instruction typically has to be motivated by some use case.

But sure, you could do prime tests in one cycle, but it would be a very long cycle and everything else would be scaled back to it, or you'd need an insanely deep pipeline to get conventional throughput out of it at that clockrate.
>>
>>52965116
I see you continuously fail to provide any points at all, which leads me to believe those are projections.
>>
>>52965185
>projections
is this the best you can meme?
>>
>>52965197
Heh, case in point.

>I see you continuously fail to provide any points at all
>>
>>52965084
make all those months 1-12 instead of 0-11
>>52965104
what i want is the user to enter rain values for each month, and then he will have a list of options to choose from like the total amount of rain, least, average.....and the last one update.

on the update option, he can update the value of rain on the month he chooses. But he has to choose months 1-12. If he chooses 0, thats wrong and he has to choose again.

Do you see it now?
>>
>>52965185
>fail to provide any points at all
>your x86 can do average in 1 cycle
>no it literally CAN NOT
>well... it could!
>no it couldn't
>I'm right and you're wrong
pajeet it's time to go back to editing that css
>>
>>52965226
>String[] month = {"January" ...
what are you trying to acomplish with this line?
>>
>>52965343
I was thinking of this, but isn't there another way
>>
>>52965245
>your x86 can do average in 1 cycle
It can though (unsigned 16 bits).

And here's a patent describing exactly how to do a signed version in one cycle:
http://www.google.com/patents/US6007232?hl=de&dq=6007232
What about it is it your're having trouble understanding?

And I don't even understand why you think doing an integer average in one cycle is such an amazing feat, it can do other more intrinsically complicated things in half a cycle like fmas.
>>
>>52964958
>>52965369
String[] month = {"Futa Cocks", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};


wait, fixed it
>>
>>52964739
>Your x86 cpu since Nahelem can actually do 8 averages (8 packed 16 bit integers) in one cycle
>>52964752
>not at all
>>52964860
>It would not be any problem adding a signed version
dat backpedalling
>>52965053
>just involves routing the signal
maximum damage control
>>
>>52965390
>I don't even understand why you think doing an integer average in one cycle is such an amazing feat
maybe because it can't? because it doesn't have an instruction for it? btw, we're talking about the average of 2 signed integers rounded towards 0: there is NO WAY to do it in 1 cycle on an x86 cpu
>>
how do I code an spiral movement for a 2D enemy?

have no clue over basic trigo.
>>
Hi, /vg/.


namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("a = ");
int a = Int32.Parse(Console.ReadLine());
Console.Write("b = ");
int b = Int32.Parse(Console.ReadLine());

int add = new Program().AddValues(a, b);
Console.WriteLine("Ad = {0}", add);
}

private int AddValues(int a, int b)
{
label();
return a + b;
}

private void label()
{
Console.WriteLine("Nice!");
}
}
}


Can someone tell me why do i have to call a new instance of Program in this line
int add = new Program().AddValues(a, b);


While in this part i don't have to call a new instance to access the method "label"?

 private int AddValues(int a, int b)
{
label();
return a + b;
}
>>
>>52965425
Even something which needs multiple instructions can be done in one cycle (i.e a throughput of <= 1 cycle).
>>
>>52965464
>have no clue over basic trigo.
Are you really qualified enough to be a programmer, especially one working with something graphics related?
>>
>>52965226
Think -
month [i+1] = month [i] 


Right now you're inserting a double in the string-list.
>>
>>52965555
tl;dr Because main is static.
If you make both of the other methods static you won't have to call new Program()

It's kind of convoluted and hard to explain, it'll make more sense when you get into OOP more.
>>
>>52965565
>Even something
more backpedalling; we're not talking about "even something", we're talking about averaging 2 signed ints, you fucking inbred muppet! show the code for averaging 2 ints that runs in 1 cycle and be done with it; otherwise, fuck off already
>>
>>52965566
>tfw will never be a good programmer because I hated math in school
>>
Where do you guys store your code for employers to see?
>>
>>52965659
Take a week(end) and study basic math, then develop your mathematical knowledge as you need it. Basic math is certainly easy than developing fibonacci for the first time.
>>
>>52965771
my employers wouldn't be interested, I work in a warehouse, when I applied to work developing at the company I work for, they passed me over for some Lithuanian
>>
>>52965226
>make all those months 1-12 instead of 0-11

what for? just make the check -1 and there you go.
>>
File: Capture.png (10 KB, 443x169) Image search: [Google]
Capture.png
10 KB, 443x169
>>52965823
just did that but something just fucks up
public static void updateRainFall(String y[], double x[])
{
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of the month to update (1-12):");
int user = input.nextInt();

if(user<1 || user>12)
{
System.out.println("Invalid month number.");
}else if(user>0 && user<=12)
{
System.out.println("Enter the new rainfall for "+y[user-1]);
int update = input.nextInt();
x[user-1] = update;
}
}
>>
>>52965884
ints only can have whole numbers. try nextDouble()
>>
>>52965884
make
int update = input.nextInt();
// change to
double update = input.nextDouble();
>>
>>52965956
>>52965915
oh yes, i forgot about the double. ty
>>
Fucking SDL2 has this dumb delay when resizing windows, it waits like two seconds after i let go of the mouse button when finished resizing, and rejects all input until then.
I want to receive resize events plus input events continuously as the window is resizing.
I've googled it and found nothing useful, surely there's a way to fix this considering there are people who use SDL2 for actual things.
>>
>>52965991
You're probably doing it wrong, because SDL2 has no such delay.
You sure you're not doing something retarded like sleeping or starting a slow computation in the resize event handler?
>>
>>52965991
post you're code
>>
File: 1451376048947.png (31 KB, 499x333) Image search: [Google]
1451376048947.png
31 KB, 499x333
>>52966011
>>52966018
Nothing retarded happening here.
>>
>>52966039
post update and render
and learn to use switch statements and not use {} for one-line things

>e.type == SDL_KEYUP ? 1 : 0
>graduate.png

Man, you suck.
>>
>>52966039
Gotta love the inconsistent K&R/Allman braces.
So far it looks sane, so post the rest
>>
Hey /dpt/, I'm writing an openGL visualizer tool. Is there any advantage to rolling my own platform layer, or can I just use glfw? Seems like glfw is pretty cross-platform and "good enough" for my purposes. What do I miss out on by not manually going through the hassle of writing a Windows/Linux openGL layer?
>>
>>52966061
>and learn to use switch statements and not use {} for one-line things
>>e.type == SDL_KEYUP ? 1 : 0
Nothing wrong with either of those things.

void update_objects()
{
view_x += pan_speed_x;
view_y += pan_speed_y;

for (size_t i = 0; i < objects_size; i++){
struct object *o = objects[i];

if (!o)
continue;

if (o->update)
o->update(o);
}
}


void render_objects()
{
SDL_SetRenderDrawColor(r, bg_col >> 16, bg_col >> 8, bg_col, 0);
SDL_RenderClear(r);

for (size_t i = 0; i < objects_size; i++){
struct object *o = objects[i];

if (!o)
continue;

int x = (int) o->x - (int) view_x + window_w / 2;
int y = (int) -o->y + (int) view_y + window_h / 2;

SDL_Rect rect;

for (size_t i = 0; i < o->ro_size; i++){
struct render_object *ro = o->ro[i];

if (!ro)
continue;

int rx = x + ro->x;
int ry = y - ro->y;

rect.x = rx - ro->w / 2;
rect.y = ry - ro->h / 2;
rect.w = ro->w;
rect.h = ro->h;

SDL_RenderCopy(r, ro->hwsprite, 0, &rect);

// debug
rect.x = rx - 2;
rect.y = ry - 2;
rect.w = 4;
rect.h = 4;
SDL_SetRenderDrawColor(r, 0xff, 0, 0, 0xff);
SDL_RenderFillRect(r, &rect);
}

// debug
rect.x = x - 2;
rect.y = y - 2;
rect.w = 4;
rect.h = 4;
SDL_SetRenderDrawColor(r, 0, 0xff, 0, 0xff);
SDL_RenderFillRect(r, &rect);
}

SDL_RenderPresent(r);
}

I don't see how these functions are relevant to my problem.
>>
>>52966097
>Nothing wrong with either of those things
The second one is stupid. Just use e.type == SDL_KEYUP
>>
>>52966113
Yeah well I haven't slepped so forgive me.
>>
>>52966089
GLFW is objectively shit. It's only like 1000 LOC to write your own implementation. Stop being a shitter and just do it.
>>
>>52966125
No, you had the audacity to claim you hadn't done anything wrong when someone told you your mistake. Fuck you.
>>
>>52966146
Chill, anon.
>>
>>52966146
You didn't tell me my mistake, you just said it was stupid, you didn't tell me why it was stupid. Fuck you.
>>
>>52966097
>if (!o)
> continue;
> if (o->update)
> o->update(o);
You could just do
if (o && o->update) o->update(o);

In general it seems that you are overusing continue.

What is o->update usually?
Are you sure that objects_size and o->ro_size are small enough to not cause lag?
>>
>>52966162
>You
:^)
>>
File: nobully.jpg (387 KB, 1154x1154) Image search: [Google]
nobully.jpg
387 KB, 1154x1154
I am not working atm. Just woke up.
What should I work on now?
>>
>>52966173
>>if (!o)
>> continue;
>> if (o->update)
>> o->update(o);
>You could just do
if (o && o->update) o->update(o);

Because I might add more things that would need to execute regardless if the object has an update function.

>In general it seems that you are overusing continue.
I don't think so.

>What is o->update usually?
Right now? updating coordinates and randomizing a texture.

>Are you sure that objects_size and o->ro_size are small enough to not cause lag?
If it was, it would be lagging at all times.
I think we've gone a bit off topic here, the problem is not in my code, the problem is SDL2 is delaying window resize events, I've confirmed this by putting a puts statement in the
if (e.window.event == SDL_WINDOWEVENT_RESIZED)
block and it never prints during resizing, only 1 or 2 seconds after i let go of the mouse button.

I have noticed that SDL_WINDOWEVENT_EXPOSED happens continuously during window resize and i tried using that to update window dimensions, and it works, but SDL2 still blocks keyboard input until the SDL_WINDOWEVENT_RESIZED event comes in.
>>
>>52966244
>Because I might add more things that would need to execute regardless if the object has an update function.
And I might come into your house and rape your grandmother, but I am not doing that.

>I don't think so.
If you use continue at all, it is overuse. You kike nigger.
>>
>>52966271
>And I might come into your house and rape your grandmother, but I am not doing that.
Except I probably will add more things to that function, nigger.

>If you use continue at all, it is overuse.
You sound like one of those HURR DURR GOTO IS BAD XD retards.
Fuck off.
>>
>>52966283
Except that goto is actually useful as it might make your life easier in certain cases, continue is not.

>Except I probably will add more things to that function, nigger.
I doubt that you know how to do that.
>>
>>52963012
Well Duke Nukem Forever finally released. Have faith.
>>
>>52966300
Continue is more useful than goto.

How do you propose i skip the loop iteration if o is null huh faggot?
Enclosing everything in a dumb if block is not a solution.

>I doubt that you know how to do that.
If I see that I need to do something else in that function, I will do it and I'm sure I won't have much of a problem doing it dicknugget.
>>
Is there any Java framework Rest which doesn't suck. With Jersey when I get to write the authentification filters it breaks. Spring documentation is a mess between the version changes.
>>
>>52966339
>How do you propose i skip the loop iteration if o is null huh faggot?
Put a label at the top of the loop you dumb assbee.

>Enclosing everything in a dumb if block is not a solution.
It is
>>
>>52966300
How would you write this without continue?

String[] s;
/* ... */
for (int i = 0; i < s.Length; i++) {
if (s == null) continue;

/* ... */
}
>>
>>52965007
neat plot d00d
>>
>>52966361
>Put a label at the top of the loop you dumb assbee.
That's retarded and not even equivalent.
>>
>>52966361
>Put a label at the top of the loop you dumb assbee.
That's beyond retarded, I've realized now that you're just baiting me.
Congratulations, you've baited me and I feel angry.

Bye.
>>
>>52966362
if (s != null) like any sane person being
>java/c#
>>
>>52966361
>Put a label at the top of the loop you dumb assbee.
https://en.wikipedia.org/wiki/Label_%28computer_science%29
?
>>
>>52966379
Enjoy your }}}}}}}}
>>
>>52966376
>waaaah! bye.
Go back to tumblr bitch.
>>
>>52966379
for (...) {
if (cond1) {
if (cond2) {
if (cond3) {
...
}
}
}
}

No thanks
>>
>>52966391
Better than jumping around.
>>
>>52966362
String[] strings;

// Why you have nulls? Use empty strings for EMPTY strings.

for (String s : strings) {
}
>>
>>52966397
What a retard
for (...)
if (cond1 && cond2 && cond3)
/* ... */;
>>
>>52966392
At least I can actually find my way to tumblr since I don't have to wade through 10 billion levels of conditional blocks.
>>
>>52966399
>Better than jumping around.
What do you think your statement compiles to?
Hint: jmp
>>
>>52966410
I left them separate because there could possibly be some error handling or other code snippet that would only run if a particular branch failed.
Even then, your shitty "le goto is bad" solution still indents it one further than it should.
>>
>>52966413
Why are you using a high level language if you aren't going to use its features? Just write directly assembly.
>>
>>52966413
His architecture natively supports conditional blocks obviously.
>>
>>52966409
>// Why you have nulls? Use empty strings for EMPTY strings.
Okay now do it with
class Dog { }
>>
I have code that I want to put on GitHub, why can't I just copy and paste it onto there? Instead you have to screw around with scripts. No this is not bait.
>>
>>52966425
>le goto is bad
I think you are confusing me with the other person that claims that continue is better than goto. I never claimed that goto was bad.
>>
>>52966362
Depending on task, I'd use the null-conditional operator. There's probably a better way to write that code anyway, you omitted too much.
>>
>>52966426
>if you aren't going to use its features?
Features like continue?
>>
>>52966432
git good.
No, really.
>>
>>52966434
>other person that claims that continue is better than goto.
I think you're refering to me, I never said goto is bad, goto is fine, I'm just saying that continue is usually more useful than goto.
>>
>>52966362
Not familiar with the language but couldn't you do this?
String[] s;
/* ... */
for (int i = 0; (s && i < s.Length); i++) {
if (s == null) continue;

/* ... */
}
>>
>>52966450
>I'm just saying that continue is usually more useful than goto.
This is exactly what I said that you said.
>>
>>52966451
Nah if you check for s there you fall out of the loop on the first s that's null. You want to keep going through the loop but skip over all s'es that are null.
>>
>>52966413
It actually compiles to je, jne, etc.
nice try.
>>
>>52966460
You implied that I implied that goto was bad.
>>
>>52966468
That's true, I misunderstood the question.
>>
>>52966362
I just noticed that you're checking whether the whole array is null. Why having it in loop at all then? Write two loops.
>>
>>52966479
You are right my bad, it's late here. I meant s[i]...
>>
>>52966474
No, I didn't. Are you hallucinating?
>>
File: big dog.jpg (36 KB, 450x345) Image search: [Google]
big dog.jpg
36 KB, 450x345
C++ is the best programming language for the vast majority of non-trivial tasks. Prove me wrong... or... right.
>>
String[] s;
/* ... */
for (int i = 0; (s[i] && i < s.Length); i++) {
/* ... */
}


Would this through an error if s is null? Would this work?
>>
As expected /g/ gets carried away by stupid shit like continue instead of actually answering the question.
Isn't time you kids advance past fizzbuzz already and pick up a more complex project already?
It would be a good learning experience.
>>
>>52966511
What project should I do? Preferably in the C programming language.
>>
>>52966496
>C++
you mean Java
>>
>>52966511
He was a shitposting faggot anyway.
>>
>>52966509
It will end the loop as soon as it encounters a null value.
>>
File: sucideKillYourself.jpg (314 KB, 1239x795) Image search: [Google]
sucideKillYourself.jpg
314 KB, 1239x795
>>52966522
>>
>>52966525
Who? the guy asking the question?

>>52966519
Virtual machine.
>>
>>52966428
Can't see what the fuck Dog has to do with String bug here you have.
Dog[] dogs;

// Why you have null dogs. use a empty Dog as a null object. Read a patterns book :P

for (Dog d : dogs) {
}
>>
>>52966432
you could just use Gist
>>
>>52966534
>Who? the guy asking the question?
Yes
>>
>>52966534
Too difficult. You realise you just accused me of only doing fizzbuzz? Why would I ever undertake something like a virtual machine?
>>
>>52966532
Java is not painless, nor fast.
>>
>>52966554
>Too difficult
Easy actually, fizzbuzz-tier in fact.
>>
>>52966563
Do it now then, I'll wait.
>>
>>52966556
Yeah I'm trying to end his suffering here.
>>
>>52966546
much appreciated senpai.
>>
>>52966563
Virtual machines are not easy, anon. In fact it's one of the hardest things to do.

Emulators are absolutely trivial.
But proper VMs that use VT-x/AMD-v? Ha, good luck with that. The simplest hello world example code is hundreds of lines.
>>
I actually want to get in to programming. Where should I start?
>>
>>52966595
By being 10 years old and having a passion.
>>
>>52966549
He asked a legitimate question though.

>>52966554
I didn't say x86 virtual machine, i just said virtual machine, it can be as simple as you want.
>>
>>52966600
>I didn't say x86 virtual machine, i just said virtual machine, it can be as simple as you want.
What you're thinking of is called an emulator. A virtual machine is the next level (running user code directly on the metal), and almost always involves hardware support.
>>
>>52966570
#include <stdio.h>

enum op
{
op_halt,
op_add,
op_load
};

unsigned char mem[0x100] = {op_load, 10, 1};

int
main (void)
{
for (size_t pc = 0; i < sizeof mem; i++)
switch (program)
{
case op_halt:
return 0;
case op_add:
mem[mem[++i]] += mem[mem[++i]]; /* I know, this is UB but whatever, fix it yourself */
break;
case op_load:
mem[++i] = mem[++i]; /* see above */
break;
}
return 0;
}


Made the above with only one hand while masturbating to anime, didn't test.

>>52966626
>>52966586
You have no idea what a VM is.

>>52966600
>He asked a legitimate question though.
You can ask a legitimate question and still be a shitposting faggot.
>>
>>52966626
>A virtual machine is the next level (running user code directly on the metal), and almost always involves hardware support.
Wrong.
Virtual machine and emulator are interchangeable terms.
I think the term you're looking for is hardware accelerated virtual machine.
Most people just use virtual machine as short term for hardware accelerated virtual machine, but that doesn't make them the same thing.
>>
>>52966665
>switch (program)
switch (mem[i])
>>
>>52966665
How do I become motivated like you? Teach me please. I'll even let you use my body as a masturbatory aid as payment.
>>
>>52962777
>>>/g/sqt would be the correct thread

the answer is no

and you should know that it's highly illegal to jam wireless signals
>>
>>52966684
>motivated like you
I am not motivated, if I was I would not browse 4chan.
>>
File: 1446176256109.gif (319 KB, 640x360) Image search: [Google]
1446176256109.gif
319 KB, 640x360
>>52966665
>
int
main (void)

>
switch (program)
{
>>
>>52966694
You wrote that code while masturbating. If I could do work while masturbating I'd get so much done.

Please I'm seriously having a hard time doing anything.
>>
>>52966704
I wish I could program while masturbating.
>>
>>52966704
>>52966719
https://www.youtube.com/watch?v=D1sXuHnf_lo
>>
>>52966665
>/* I know, this is UB but whatever, fix it yourself */
Kill yourself
>>
>>52966724
aaaand programmers have officially run out of original ideas.
>>
>>52966724
>emacs

get RSI while you get off.
>>
>>52963082
http://choosealicense.com/
>>
>>52966834

Who would need to look at this? BSD or you hate freedom.
>>
>>52966874
Find out your chosen languages methods for filesystem reporting.
>>
>>52966874
>doing this recursively

sounds pretty retarded, m8
>>
>>52966874
Why did you select CS? Did you program before? Are you in USA? What programming language?
In C you would use dirent.h for windows and POSIX
>>
I started learning Python yesterday. Is it a good stepping stone into C/C++?
>>
>>52966984
No
>>
>>52966984
Yes
>>
>>52966984
absolutely not. go with java if you want a stepping stone into C/C++
>>
>>52967035
lol
>>
>>52966984
fuck no
>>52967035
this is what I did, the syntax was similar so somewhat smooth transition.
>>
>>52967051
epic meme faggot python is a gorillion times more disgusting than java and java is probably the best suited programming language for preparing you for learning C/C++ except for maybe C/C++ themselves
Thread replies: 255
Thread images: 19

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.