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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 326
Thread images: 44

File: dpt.jpg (142KB, 682x1024px) Image search: [Google]
dpt.jpg
142KB, 682x1024px
Previous thread >>56019764

What are you working on /g/?
>>
>>56028021
I don't think you understand just how bad community college programming courses are.

In my first semester of the CS track. they forced me to take CS 103, introductory programming logic, where they had us draw UML diagrams for trivial programs in MS visio and occasionally let us "implement" those UML diagrams in visual basic even though the professor never taught the syntax.
I didn't know how to do loops because he never taught them at the time and so i hardcoded all the output and got a passing grade anyway.
It was a real shitshow. Oh, and it's a prereq to all the other courses.

They also highly recommended that new students take, 101 and 102 simultaneously. I refused.

101 had a fancy name, but it was literally "how to use a computer, the class" and 102 taught the names of various computer parts and how to pass the A+ cert, or something.
>>
Posted this right as the old one died.
REPOST:

>>56028671
Think of a packet as a candy, When you send it somewhere at every stop it gets wrapped in another layer of foil saying who wrapped it. Then when a packet is sent back it wraps it in the same multiple layers of foil and as devices unwrap a layer and send it to its next destination.

Going by this analogy when you send a packet saying you want to view google.com it will first say the socket on your PC that wants it (the program on your PC) Then it will say the MAC of your PC (which PC on your network). Than your public IP where you are on your ISP's network, etc.

Did I do good guys? I only took first year of CCNA three years ago and I think I remembered it right.
>>
>>56028612
>implying C++ isn't fucking hideous
>>
>>56028736
Sounds like your CC sucks/sucked massive dick. At mine, we learned the general ideas behind algorithms and computers for the first half of the course and Visual Basic for the traditional things in your average textbook for the second half. My professor was really nice. VB honestly ended up coming in handy much more than I'd like to admit just to know off-hand.
>>
>>56028612
What's with her arms?
>>
>>56028612
Fucking around with an Arduino I got yesterday. I'm making it print a pattern and letting its speed be adjustable by a potentiometer.
>>
>>56028969
>print
I mean, display using LEDs.
>>
>>56028903
what about them?
>>
>>56028796
Well you're gonna get the dress off and discover a huge fucking mess
>>
File: output.png (1MB, 942x512px) Image search: [Google]
output.png
1MB, 942x512px
Building a linify.me clone, right now it's about 3x faster than linify.me.
Speed peaks at 25k-30k tested lines per second(250-300 drawn lines per second with 100 tests per line) on my crusty old Phenom II.
Pic related took 228 seconds to render(36k lines, 100 tests/line, 8 thickness). Such a render would probably take more than 15 minutes on linify.me.
>>
>>56028612
I'm not working on anything now, but I lost the source code for my fan controller's firmware, so I need to get to work to rewrite that shit.
>>
Guys, what's a really good font for editing source code and how would I go about installing it on my linux machine, I'm just about done customizing and I can't figure it out, I'll post code once I can make it look neat
Sorry for being slightly off topic
>>
>>56029009
>comparing your local clone to an online service
>>
>>56029044
Have you looked at the linify.me source code? It's wildly inefficient. Its method of generating lines is to randomly draw lines until it finds the best one.
http://linify.me/javascripts/workerv2.js
>>
>>56029070
Cool.

Have you compared them side-by-side on your machine?

Have you hosted your close on a publicly accessible website with many concurrent users generating images?
>>
anyone willing to help newb reading english book not being a native speaker? specifically C
>>
>>56029099
What do you need help with?
>>
>>56029099
What's your native language?
>>
File: 1470786907394.jpg (130KB, 1085x1200px) Image search: [Google]
1470786907394.jpg
130KB, 1085x1200px
Subject: C, Lua, Entity Component System

It's been like a year since I posted here, I posted here last night but that might have been the wrong time to post; I figure one day is enough for most programmers to see it and then i'll disappear again. It all works great, but I did get busy for a few months so I may have done some code I should not have. Talking to the lua VM back and forth multiple times each frame might not be a good thing. So, I would like to know any opinions on what I can change it to.

Right now the engine has a global
entity = {}
table in lua, and a global
g_entity_t
struct array in C. The C array holds the ID numbers of active indexes in the global table, and runs functions as needed (such as think, collide, etc.), it also holds some other variables like the entities name, the x y offset, the texture index, etc..

How i've been doing this is storing the ID of the index in the lua table in the array AS WELL AS storing that index number (redundantly) in the lua table index. When the internal part calls lua, it just needs to call the index. When the lua part calls an internal function, that function goes down the list and see what internal entity holds that ID and then does it's thing.

The ladder part might be why I have a slowdown. Is there a more optimized way to pass information between C and the VM without having to rely on the ID?

pic unrelated but so that you read this
>>
>>56029031
Fantasque Mono or Source Code Pro. They're perhaps not in your distro's, but in that case there are pages upon pages explaining how to do it manually for both of them anyway.
>>
>>56029117
well ill sound like a total idiot but i have no idea how getchar and putchar works
>>56029131
polish
>>
>>56029185
>polish

That's quite the coincidence, if you leave some contact, I can walk you through it.
>>
>>56029031
Consolas.
>>
>>56029184
great, this is what my system looks like at the moment, and everything but that terminator instance is sexy at this point
>>
File: blocks.png (126KB, 1600x835px) Image search: [Google]
blocks.png
126KB, 1600x835px
>>56028612
I just ironed out some bugs on a script that divides images into blocks. i'm working on some low level line detection.

from PIL import Image
im = Image.open("arrow.jpeg") #build the image object.
pix = im.load() #build the image object this has all the pixels

#Get the width and hight of the image for iterating over and make sure it's devisable by 10.
image_croped_x = (im.size[0] - (im.size[0]%10))
image_croped_y = (im.size[1] - (im.size[1]%10))

#setting some vars.

red = 0
green = 0
blue = 255
image_done = False
line_done = False
block_done = False
y_point = 0
y_count = 0
x_start = 0
x_end = 10
x_point = 0
color_count = 0


while image_done == False:
#print "Here are some stats. image_croped_x =\n image_croped_x: %d \n image_croped_y: %d\n " % (image_croped_x , image_croped_y)
if line_done == True:
if x_point >= image_croped_x - 10:
print "Image is done."
image_done == True
break
else:
x_start += 10
x_end += 10
line_done = False
y_point = 0
#print "here are some stats on the image \n x_start: %d\n x_end: %d\n line_done: %r\n y_point: %d\n" % (x_start, x_end, line_done, y_point )


else:
print "Image is not done - State: %r" % image_done

while line_done == False:
if block_done == True:
if y_point >= image_croped_y - 10:
print "line is Done"
line_done = True
break
else:
print color_count
if color_count == 0:
red = 255
green = 0
blue = 0
color_count += 1
elif color_count == 1:
green = 255
red = 0
blue = 0
color_count += 1
elif color_count == 2:
blue = 255
red = 0
green = 0
color_count = 0
y_count = 0
block_done = False
while block_done == False:
if y_count == 9:
print "block is done"
block_done = True
break
for x_point in range(x_start ,x_end):
pix[x_point,y_point] = (red, green , blue)
if block_done == False:
y_point += 1
y_count += 1
im.show()
>>
>>56029201
>Consolas is a monospaced (non-proportional) typeface, designed by Luc(as) de Groot. It is a part of a suite of fonts that take advantage of Microsoft's ClearType font rendering technology.
https://en.wikipedia.org/wiki/Consolas
Thanks, but no thanks
>>
>>56029185
getchar and putchars are just shortcuts for the fread and fwrite functions to get one character from stdin or print one character to stdout.
>>
>>56029200
write to [email protected] ill send you chat room invite
>>
>>56029031
Anonymous Pro
>>
>>56028612
30th for Go is best lang
>>
>>56029232
see i dont understand even a thing. i started learning few days ago
fucking hell
>>
>>56029271
Maybe you should look into the unix programming environment by kernighan and pike
>>
>>56029212
reformatted
from PIL import Image
im = Image.open("a.jpg") #build the image object.
pix = im.load() #build the image object this has all the pixels

image_croped_x = (im.size[0] - (im.size[0]%10))
image_croped_y = (im.size[1] - (im.size[1]%10))

red,green,blue = 0,0,255
image_done = line_done = block_done = False
y_point y_count = x_start = x_point = color_count = 0
x_end = 10

while not image_done:
if line_done:
if x_point >= image_croped_x - 10:
print "Image is done."
image_done == True
break
else:
x_start += 10
x_end += 10
line_done = y_point = 0
else:
print "Image is not done - State: %r" % image_done

while not line_done:
if block_done:
if y_point >= image_croped_y - 10:
print "line is Done"
line_done = True
break
else:
print color_count
if color_count == 0:
red,green,blue = 255,0,0
color_count += 1
elif color_count == 1:
green,red,blue = 255,0,0
color_count += 1
elif color_count == 2:
blue,red,green,color_count = 255,0,0,0
y_count = 0
block_done = False
while not block_done:
if y_count == 9:
print "block is done"
block_done = True
break
for x_point in range(x_start ,x_end):
pix[x_point,y_point] = (red, green , blue)
if not block_done:
y_point += 1
y_count += 1
im.show()
>>
>>56029185
RTFM or maybe ask a native-speaking community if English is a problem. Fuck do you speak?

>>56029232
No
>>
in haskell, is there a way to select a subset of a list? like some equivalent to list(4:6) in a different language? I see all the different front/back subsetting functions and the singular index selection, but not a way to do longer filtering
>>
File: neuron_diagram.jpg (12KB, 375x374px) Image search: [Google]
neuron_diagram.jpg
12KB, 375x374px
>>56028612
Strong AI.
Can't say more...
>>
>>56028540
this
>>
>>56029304
*teleports behind you*
>>
File: zezu.jpg (55KB, 314x364px) Image search: [Google]
zezu.jpg
55KB, 314x364px
>>56029296
see the problem is i google it all around and i seem to not get a basic answer. everyone is just asking about errors in their code while i want to know what the fuck getchar and putchar does

polish
>>
>>56029301
drop 4 . take 6
, why should we use anything else?
>>
>>56029089
The code on linify.me already runs client-side. It's not node.js/server-side.
>>
>>56029339
Does yours run client-side on all of the major browsers?
>>
>>56029346
My code isn't in JS.
>>
>>56029256
>Anonymous Pro
It's perfect, thanks dude
>>
>>56029304
You're building a robo-waifu aren't you?
>>
File: NX34FMPl.jpg (16KB, 640x79px) Image search: [Google]
NX34FMPl.jpg
16KB, 640x79px
>>56029031
Inconsolata.
>>
>>56029354
Then why are you comparing your code to theirs?

Make it publicly accessible within a browser, or your boasts about your clone being better are just hot air.
>>
>>56029326
>what getchar and putchar do
RTFM. The GNU/Linux ones are even translated in some languages, if you're lucky you'll have it in Polish. (First time I read it I took it for a shortcut for "Polish Notation". Isn't that cool, Poland?)
>>
>>56029178
If you are using c++ i recommend https://github.com/Rapptz/sol
its idiot proof

if C, why not just export object create/destroy methods to lua and handle everything there, on every iteration call from C update, draw. Kinda like love2D
>>
>>56029293
thanks that looks much cleaner. What python are you using tho?

y_point y_count = x_start = x_point = color_count = 0  
^
SyntaxError: invalid syntax
>>
>>56029356
>thanks dude
I'm a girl.
>>
>>56029333
well now i feel like an idiot. thanks
>>
>>56029376
Oops, no Polandball in this one, sorry. Will you believe me if I assure you that I'm not trying to insult you? Honest.

And yes, TFM is good. It's old style to-the-point not meant for retards, which is excellent for people like you and me
>>
>>56029356
np
>>
>>56029397
>I'm a girl.
Whatever man

Alternatively
"Call yourself whatever you like you crazy protestant bastard"
>>
>>56029391
functions not methods...
My point was, just draw in C handle everything else in lua. Your system seems awfully complicated, im doing something similiar with C++
>>
File: dazed.jpg (4KB, 250x179px) Image search: [Google]
dazed.jpg
4KB, 250x179px
>>56029397
>pretending to be someone else on anonymous board
how sad can someone be
>>
>>56029374
Why the hell do I have to abide by your "rules"? I will brag about it being faster all I want and release the source when I believe it's good enough. I'll link the source here for people who might be interested and call it a day. I'm not renting a server or hosting anything because you're telling me to.
>>
>>56029397
GRAYSLAKE

R
A
Y
S
L
A
K
E
>>
File: 1461410919747.jpg (28KB, 500x385px) Image search: [Google]
1461410919747.jpg
28KB, 500x385px
>>56029402
Don't. Idiots can't RTM I'm afraid, and that's irritating. You're welcome Herr Poland.

t. Medkit
>>
>>56029368
No.
10k neuron 'and' gate for testing....

You?
>>
>>56029425
Good for you.

People like me are going to call you a faggot until you can back up your claims.

BTW, I wrote a kernel that's faster than Linux for all conceivable operations.
>>
>>56029395
oops i forgot a equal sign after y_point
y_point = y_count = x_start = x_point = color_count = 0 


i'm using python 2.7, but i have installed python 3.5 too
>>
>>56029430
>>56029419
>>56029408
thanks for the (You)s
>>
>>56029430
YOU
HAD
ONE
JOB
>>
>>56029479
The spam filter ruined my fun
>>
>>56029477
no (You)
>>
>>56029458
>implying the Linux kernel is written in a high-level interpreted language and hosted exclusively online
>>
>>56029425
suggestion: you could use openshift for free, and make a web frontend for your program
>>
>>56029458
>BTW, I wrote a kernel that's faster than Linux for all conceivable operations.

you sure did, hot shot.

post the link so i can see what you got
>>
How would you create a 2D table with variable size fields in C++? More or less like

std::vector<Field> fields;


How would you structure the class Field? As just a raw data type or a struct?
>>
>>56029519
I mean, just for the sake of argument
C CAN be interpreted, it's not usually done as such but C interpreters do exist
and there's git...
So if you consider C high level as opposed to assembly, and git as online hosting...
>>
Will watching Himegoto improve my programming skills?
>>
>>56029538
>missing the point
>>
>>56029588
so where's your kernel?
>>
>>56029582
yes goyim! keep watching anime!
>>
>>56029458
Call me a faggot all you want, I'm not going to give a single shit what you say.

>>56029528
Thanks anon, I'll consider that.
>>
File: the tism.png (30KB, 569x118px) Image search: [Google]
the tism.png
30KB, 569x118px
>>56029598
>>
>>56029628
>am too stupid to like anime
>>
>>56029409
It's not that complicated (to me). I'm going off of how entity management for ID games was explained to me by a programmer. The game runs faster if I keep some aspects internally, and most of those internal aspects are for drawing/calculating interpolation.

I have a snapshot of about a week ago before I added in all the stuff I have, i'll hopefully figure it out at some point.
>>
>>56029009
>linify.meme
literally who
>>
>>56029009
>Such a render would probably take more than 15 minutes on linify.me.
who would use such a shitty website? and do it in opengl you retard
>>
>>56029582
the manga is way better desu
>>
>>56029640
so where's your kernel?
>>
>>56029697
>retard
Excuse me?
>>
>>56029796
kill yourself and fuck off to >>>/g/wdg
>>
>>56029817
It's not a web application you fucking retard. Also, >>56029796 isn't even me
>>
>>56029817
but if i kill myself i can't go to >>>/g/wdg
>>
>>56029843
do it in opengl it would be so much faster
>>
what is a good book to learn android programming?
>>
Does anyone know any good opengl book or tutorial? Preferably with examples
>>
File: 1470903144635[1].jpg (136KB, 960x1280px) Image search: [Google]
1470903144635[1].jpg
136KB, 960x1280px
Since my post was deleted along with the thread...

Quick! Write a program that uses a constant amount of memory to find a loop in a singly-linked list in O(n) time. You cannot modify the list in any way.

Note: "Constant memory" = the memory required for the solution cannot be a function of n.
>>
>>56029946
Or this girl will hack your waifu out of existence
>>
>>56029946
Why? Its such pointless excersise, have 2 pointers one lagging behind another just compare em
>>
File: 1446565171206.gif (47KB, 320x180px) Image search: [Google]
1446565171206.gif
47KB, 320x180px
>>56029946
>pls do my homework
>>
File: hotsummer.jpg (14KB, 234x216px) Image search: [Google]
hotsummer.jpg
14KB, 234x216px
>>56028612
Who is she? Sauce.
>>
So I know python really well.
What language do I learn now? Looking for something not as hard as C, has a ton of libraries, good GUI tools. Is c# worth learning?

I code stuff for mac, linux and windows if that helps
>>
File: npc_steiner_tree.jpg (15KB, 250x250px) Image search: [Google]
npc_steiner_tree.jpg
15KB, 250x250px
>>56029968
Consider your waifu hacked out of existence then.

Here's another.

INSTANCE: G = (V,E) is an undirected graph. R is a subset of vertices V. k is a positive integer.
QUESTION: Does there exist a subtree of G that includes all vertices of R and contains at most k edges?

Example: The graph G below, with R = { 1, 2, 3, 4, 5, 6, 10 } and k = 8, is a "yes" instance.

Prove that this problem is NP-complete.
>>
>>56029946
Let x = the head of the list
Let y = some point on the loop

int findloophead(x,y)
{
pointers t, a=x, b=next(y), c=y

while (1) {
// midpoint (e,f):
// returns the pointer to the middle element
t = midpoint (a,c)
if find (b,t,c)
c=t
else
a=next(t)
t = midpoint (b,c)

// find (e,f,g): returns true if we encounter f
// in a walk from e to g, otherwise false.
if find (a,t,b)
c=t
else
b=next(t)

if (a==b)
return a;
if (a==c) || (b==c)
return c;
}
}

>>
>>56029973
It's from here:

https://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
>>
>>56029904
>>56029922
most tutorials are made by basic normies/newfags and the ones who are good are usually either bad at teaching or they won't teach you ("those who can, do..."), imo your best bet is to go through the official documentations, just one thing at a time as you encounter, like start with a hello world and go from there, like with a opengl hello world just leave the setup code as it is for now and learn vertex buffer objects and then shaders etc
>>
>>56029549
Literally took 5 seconds to google
https://en.wikipedia.org/wiki/C_dynamic_memory_allocation
>>
How big should the data registers be in my scripting language virtual machine, do you think?

Multiple sizes implies a fuckload of instructions (or instruction variants), and 64-bit would be way bigger than most of the shit you'd actually need (consequently, it'd slow down stack pushes and pops, because you'd have more register memory to stash).

32-bit seems right, but I want your opinions.
>>
>>56029996
literally learn C.
>>
I just finished working on this, it's a simple program so I could learn how variables are passed between functions in c
#include <stdio.h>
#include <math.h>
#include <cs50.h>

int getChange (void)
{
printf("What is the price of the item\n");
float priceFloat = GetFloat();
int price = round(priceFloat * 100);

printf("And what is the total payment?\n");
float paymentFloat = GetFloat();
int payment = round(paymentFloat * 100);
int change = (payment - price);
return change;
}

int main (void)
{
int change = getChange();

while (change <= 0)
{
change = getChange();
}

int count = 0;
int quarters = 0;
while (change >= 25)
{
change = change - 25;
quarters++;
count++;
}

int dimes = 0;
while (change >= 10)
{
change = change - 10;
dimes++;
count++;
}

int nickels = 0;
while (change >= 5)
{
change = change - 5;
nickels++;
count++;
}

int pennies = 0;
while (change >= 1)
{
change = change - 1;
pennies++;
count++;
}

printf("The customer will recieve %i quarters, %i dimes, %i nickels, and %i pennies, for a total of %i coins", quarters, dimes, nickels, pennies, count);
return 0;
}
>>
How do I compute barycentric coordinates for an n-dimensional simplex, and also how do I convert them back into regular n-dimesnional Cartesian coordinates?
>>
I really don't like using bash, but i want to find all the files in my download folder that are a specific resolution.

What am I doing wrong?
for i in $(file *.jpg); do
if [[ "400x240" == *"$i"* ]]
then echo $i
fi
done
>>
>>56030209
// Compute le barycentric coordinates (u, v, w) for le
// point p with respect to triangle (a, b, c)
void compute_Barycentric(Point p, Point a, Point b, Point c,
float &u, float &v, float &w)
{
Vector v0 = b - a, v1 = c - a, v2 = p - a;
float d_00 = Dot(v0, v0);
float d_01 = Dot(v0, v1);
float d_11 = Dot(v1, v1);
float d_20 = Dot(v2, v0);
float d_21 = Dot(v2, v1);
float denominator = d_00 * d_11 - d_01 * d_01;
v = (d_11 * d_20 - d_01 * d_21) / denominator;
w = (d_00 * d_21 - d_01 * d_20) / denominator;
u = 1.0f - v - w;
}
>>
>>56029946
too trivial
foff
>>
>>56028612
I just made a minor console program in C++ for 3ds homebrew.

It was such a bitch because of the compiler errors I was getting, but I was finally able to google the problem and fix the answer. Gonna see how much I can evolve this until I get bored.
>>
>>56029996
Literally this
>>56030165
C is not that hard and it'll teach you a fuckton of concepts that are essential to being a good programmer
>>
>>56029991
Clarice Starling
>>
>>56030193
You're probably going to be ridiculed, but since you're clearly a novice, I'll give you a tip. Use integer division and the modulo operator.
>>
>>56030193
Read over this code
Just noticed that in the half hour I worked on it I didn't put one fucking comment

I get that it's simple, but where should I comment here, it all seems pretty self-explanatory, of course I suppose it would, is there anything here that might need clarification?
>>
>>56030241
What part of n-dimensional don't you understand? I need this for up to 10D space.
>>
>>56030279
Example
//78 / 8 = 9 remainder 6
int a = 78;
int b = 8;
int c = a / b; //This is equal to 9
int c = a % b; //This is equal to 6

Figure out how to apply this in your program.
>>
>>56030292
succ my dick
>>
>>56030279
>but since your clearly a novice
I post code in here all the time and get that a lot
/dpt/ is actually full of some pretty cool guys who doesn't afraid of anything
I get what you mean by the modulus operator, but how would I apply that here and this feels like a super dumb question but what do you mean by integer division?
Is it any different from just dividing an integer by another integer?
>>
>>56030193
Don't ever put the body of any function before the body of main, it's really bad practice. You want to put what's called a function prototype at the beginning of your program, which looks something like this.
#include <stdio.h>

int getChange (void);

int main (int argc, char* argv[ ])
{
// code goes here
}

int getChange (void)
{
// more code goes here
}
>>
>>56030319
>'s really bad practice
no it isnt
>>
File: Dolphin1-XL.jpg (176KB, 1024x683px) Image search: [Google]
Dolphin1-XL.jpg
176KB, 1024x683px
I'm working on an application that POSTs feedback to a server. How do I prevent someone from looking at where the packets are sent and then flooding the server with dolphin porn?

I've considered a private key, but I don't see how you could stop someone from finding the key inside the client.
>>
>>56030319
>it's really bad practice.

wut

if anything, put all functions except main in their own separate files
>>
>>56030329
>not putting the function that gets executed first at the top of the program isn't bad practice
Go to bed Pajeet.
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
Is it possible to write a facebook bot?

i heard twitter bots are easy, but not sure about facebook ones
>>
>>56028612
God, I hope she kicks that fat fuck right in the balls.
>>
>>56030319
Sorry, thats a bad habit I carried over from a scripting language I was working in where (due to some shitty work on my part) I couldn't call a function if it was defined after main (that later turned out to be bullshit, combined with a little bit of confirmation bias but it stuck in my head)
>>
>>56030314
See >>56030309

In C, if you divide an integer by another integer, you get the whole part of the division, without any remainder.
98 / 10 == 9

This is very applicable to your change problem.
>>
File: 1470860511069.jpg (59KB, 800x526px) Image search: [Google]
1470860511069.jpg
59KB, 800x526px
>>56030343
>if anything, put all functions except main in their own separate files
>>
>>56030349
>not having header files with all the functions defined
Go to bed Rajesh
>>
File: 1470670460584.gif (565KB, 367x265px) Image search: [Google]
1470670460584.gif
565KB, 367x265px
>>56028612
Cute
>>
>>56030343
Nigger for a single line program you should use function prototypes. If you're looking at somebody else's code you're going to go straight to the main function anyway, so it makes sense to put it at the very top of your program so the next poor soul who has to look at it doesn't have to keep scrolling up and down the file to see the logical flow of the program.
>>
>>56030341
>what are ports
>>
>>56030361
You still won't be able to call a function if it's define after main, that's the purpose of function prototypes.
>>
>>56030357
Facebook posting by bots is extremely limited. There are officially supported apis for messaging, but you must register the bot. I found this useful https://pypi.python.org/pypi/fbchat/
Just be aware that facebook is hostile to your privacy.
>>
>>56030386
For large single file program yes
For doing small projects why bother?
>>
>>56030381
Spot the OOP babby.
>>
>>56030404
thanks for the reply.

so you don't have to register the bot on twitter?
>>
>>56030427
Spot the NEET
>>
>>56030341
You're exactly right. Even if you use a private key, there's still a very good chance they can sniff the packets and reverse-engineer the process. Even HTTPS can't save you, and private keys stored in the client would just be found. For one, letting user's upload files to your server is something you should be careful with. Are you allowing image upload?
>>
>>56030369
I feel like that would only create errors unless...

I'm not sure how to articulate this
if you have an example like 98 / 10 = 9 you've lost that 8 basically to the ether, I can kinda see how if you use that to shave numbers off while maintaining a count this could be applicable, but it just feels like you're asking for bugs
>>56030401
You know I remember seeing that in Programming in C and I kinda glossed over it cause I was looking up how to pass an integer between functions
>>
>>56030432
Twitter's official apis will let you post as yourself. Facebooks only allow message bots that send messages as a bot. The python library I linked allows you to message as yourself, but it is unofficial
>>
File: 1411323879598.gif (242KB, 280x257px) Image search: [Google]
1411323879598.gif
242KB, 280x257px
If you think that you should scatter your source code across as many different files as possible, please make sure that you never reproduce.
>>
>>56030411
What do you mean why bother? Why are you acting like it's such a nuisance to implement functions below the main function? This is literally what you're advocating
void executeLast(void) 
{
// code
}

void executeSecond(void)
{
// code
}

void executeFirst(void
{
// code
}

void executeSecondToLast (void)
{
// code
}
>>
>>56030463
It's not lost. You can do a modulo operation to get the remainder.
98 / 10 == 9
98 % 10 == 8
>>
>>56030401
Sprak didn't support function prototyping, it would just look further down the file for the function
I had a syntax error, something like
void boot); where I defined the function and took that to mean I had to define it above the call, only realizing my mistake much later
>>
>>56030515
Okay I see, I'll try a rewrite later then, I gotta take off in a couple of minutes
>>
File: 1469310869749.png (458B, 391x391px) Image search: [Google]
1469310869749.png
458B, 391x391px
Write a program that will print "C" if compiled as an (ANSI) C program, and "C++" if compiled as a C++ program.
>>
>>56030463
That data won't come up and bite you in the ass later, it's truncated when you cast a float to an int. Here's my ancient example of that same program from when I took CS50.
#include <stdio.h>
#include <cs50.h>
#include <math.h>

#define QUARTER 25
#define DIME 10
#define NICKEL 5
#define PENNIE 1

float GetChange();
/* Ensures the user entered a positive denomination of money */
int PennieConversion(float decimalMoney);
/* Rounds the value obtained from GetChange to the nearest hundreth, then converts
that value to an int representing the amount of pennies owed. Implemented
to ensure there was no inaccurate fuckery on the float from GetChange()'s behalf. */

int main (void)
{
int coinsGiven = 0, penniesOwed;
float desiredChange = GetChange();
penniesOwed = PennieConversion(desiredChange);

while (penniesOwed >= 0) {
if (penniesOwed >= QUARTER) {
penniesOwed -= QUARTER;
coinsGiven++;
continue;
} else if (penniesOwed >= DIME) {
penniesOwed -= DIME;
coinsGiven++;
continue;
} else if (penniesOwed >= NICKEL) {
penniesOwed -= NICKEL;
coinsGiven++;
continue;
} else if (penniesOwed >= PENNIE) {
penniesOwed -= PENNIE;
coinsGiven++;
continue;
} else {
printf("%d\n", coinsGiven);
break;
}
}

return 0;
}

float GetChange(void)
{
float dc; // desired change
do {
puts("Please enter how much change you are owed:");
dc = GetFloat();
} while (dc < 0);
return dc;
}

int PennieConversion(float decimalMoney)
{
int n;
long b;
decimalMoney *= 100;
b = round(decimalMoney);
n = b;
return n;
}
>>
>>56030210
I don't know bash at all but why would *"$i"* represent get the image's resolution?
>>
>>56030516
#TODO: Integrate Hugin's functionality with the rest of the network

ClearText()
Print("Chaos OS v0.5: Damn near Beta edition")

MainMenu()

void MainMenu()
Print("")
Print("Telehack")
Print("")
Print("Boot")
Print("")
string command = Input("Make Selection ")
if command == "Telehack"
Telehack()
else if command == "Boot"
Boot()
else
Print("FUCK YOU")
end
end


void Telehack()
var target = Connect(Input("Who is the target? "))
String remoteCommand = Input("Alright now for a command ")
if remoteCommand == "test"
target.Print("The connection is functioning")
else if remoteCommand == "Locate"
Print(GetConnections())
Sleep(3)
string person = Input("Who are you searching for? ")

#The following commands do not work
target.ReturnLocation(person)
else if remoteCommand == "Slurp"
#Slurp is super cool, it's a function allowing you to physically traverse between computers, basically a network based teleport
#This is in here so I can hop between CentralServer and Hugin to debug the connection
Slurp()
end
end

void Boot()
ClearText()
DisplayGraphics()
Print ("BootLoader")
Print ("==========")
Sleep (1)

if HasFloppy()
BootFromFloppy()
else
Print("Please insert floppy...")
end
end


#This is the code from Hugin
#I've stripped out a useless graphic, you input a character's name
#and the system spits out their current room cell & x,y co-ordinates within that cell


ClearText()

Print("")

var names = GetPeople()

loop
var name = Input("Enter name to look up: ")
Print(GetPosition(name))
end

#I wrote this, it's supposed to be called from the central server, arguements passed on and then a string containing the output sent back
#It works just great, but I can't call it from the remote machine

void ReturnLocation(person)
var target = Connect("CentralServer")
string location = GetPosition(person)
target.Print(location)
end
>>
>>56029262
>30th for Go is best lang

>no generics
>package manager designed to fuck you over
>mandatory Garbage Collector
>no dynamic linking

a worst
>>
>>56030547
out of curiosity, did you write that as an assignment?
I just finished week 1 and I thought greedy.c didn't go far enough, so wrote a bit of a different version
>>
>>56030553
i don't know how to search substrings
>>
>>56029304
>Strong AI.
lol no you're not
>>
>>56030118
>>56030118
>>56030118
>>56030118

Nobody has any answers?

please respond

I'm trying to actually talk about programming rather than just memeing about language wars.
>>
>>56029452
So a 100x100 feed-forward neural net?
>>
>>56030585
I believe so, though I had the tiniest bit of knowledge of C before I started so I may have used a few techniques that weren't taught yet to implement it.

Don't worry about the program (as in, the course) not going far enough though, it'll definitely teach you pretty much all you'll need to know about C by the end of it.
>>
>>56029009
Do it in webgl for speed, and embed it in a webpage.
>>
>>56030617
>>56030118
are you joking or serious? that's not how 64 bit works
>>
>>56030617
Go for 64-bit. The speed difference is either void or negligible.
>>
>>56030546
#include <stdio.h>
#ifdef __cplusplus
#define LANGUAGE "C++"
#else
#define LANGUAGE "C"
#endif
int main()
{
puts(LANGUAGE);
}
>>
>>56030650
I think you're misunderstanding.

Word size would still be 64 bits in size. The data portion of the register, however, would only hold 32 bits. So, anything bigger

This would be an architecture where indirect / address registers would be separate things from data registers, and those would have 64-bit values, naturally


>>56030667
Thanks
>>
>>56030490
yeah I bet you throw everything in one giant header file too
>>
>>56030691
Forgot my code block
#include <stdio.h>
#ifdef __cplusplus
#define LANGUAGE "C++"
#else
#define LANGUAGE "C"
#endif
int main()
{
puts(LANGUAGE);
}
>>
Question.
LSNM2qBNQrIRbGjs9Sgzog==
That hash is from what I can tell, Base64. It comes out to be 'rcmp'.
What I'm wondering is, when I base64 decode it, it gives me binary data. How do I get it to plain text?

Another curious thing, if I put that hash in an md5 decrypter online, it gives me the correct output (rcmp); what I want to know, is how it's getting it.
>>
>>56030633
Yeah I had a bit of programming experience in a whole lot of languages before I started, but nothing more than basic knowledge in any of them
I nonetheless assumed cs50 wouldn't be teaching me anything new untill around week 6

mario.c shows up and I'm fucking baffled, how the shit is the second week of the course going to challenge me that hard?

That said I felt like king of the world when I actually solved it
>>
>>56030720
I see, that doesn't really sound like it'd be worth the performance gain at all
>>
>>56030739
>How do I get it to plain text?
do you mean hexa ?
>>
>>56030727
Alternatively
#include <stdio.h>
#define EXT
#ifdef __cplusplus
#define EXT "++"
#endif
int main()
{
puts("C" EXT);
}
>>
>>56030739
>reverse an md5
rainbow list

basically sits around hashing random shit a billion times a second and making a big "dictionary"

a four character string like that is easily something it would have come across by now.
>>
>>56030319
that's not really any better, trying to read someone's C code can be hell with all the prototypes and functions that are just wrappers for some other function that's hidden in one of the dozens of includes which in themselves have dozens of includes
>>
>>56030812
nah senpai, what I'm saying is, when i put that hash into the md5 decrypter, it actually gets the correct result, even though the hash I posted is clearly not md5.
/how/
>>
>>56030754
Stick with it famalam, if you successfully get through the course without cheating then you'll already be better than 85 percent of people who program for a living.
>>
>>56030866
>md5 decrypter
that's not a thing
>>
>>56030853
>that's not really any better, trying to read someone's C code can be hell with all the prototypes and functions that are just wrappers for some other function that's hidden in one of the dozens of includes which in themselves have dozens of includes
What the fuck are you talking about? Have you ever read C that wasn't written by a curry nigger?
>>
File: Mailbox.png (172KB, 798x600px) Image search: [Google]
Mailbox.png
172KB, 798x600px
I'm trying to learn Java by creating a Email Client. Current problem is that I can't figure out how the hell to make my components the same size.
>>
>>56030866
the base 64 data
LSNM2qBNQrIRbGjs9Sgzog==

is storing the binary data
2d 23 4c da a0 4d 42 b2 11 6c 68 ec f5 28 33 a2
^ this is the md5 hash. Being stored as binary. Shown as hex. The base64 you posted is -binary-

2d234cdaa04d42b2116c68ecf52833a2

is the md5 hash for "rcmp"
>>
>>56030885
oi... I'm aware. That isn't the point.
https://hashkiller.co.uk/md5-decrypter.aspx
I understand that it has to already KNOW the hash. that is not my question.
How, when I enter the base64 hash, does it come to the conclusion that it is rcmp, in md5?
How do you get from that hash, to the md5 hash?
>>
>>56030902
it'll be a bunch of function prototypes and then you scroll down to look for implementations, and then they aren't there, so you look for other files, and when you finally get to the implementation it's just another call to some library function that's never explicitly mentioned in that source file
>>
>>56030927
Ahhh I see.
Thank you.
So in C, how would I convert it? Convert from base64, read in the binary data and print it in hex?
>>
>>56030928
base64 is not a hash.

its a way to store binary data within ascii characters.

the base 64 stores the binary data of the md5 hash.
>>
>>56030955
yea

most implementations convert base64 to a string which you'll then have to convert into the hex ascii characters but that's the general process.
>>
>>56030928
>How, when I enter the base64 hash, does it come to the conclusion that it is rcmp, in md5?
length. sha* are much longer
>>
>>56030787
Further golfed. 70 chars. Can anyone get it in less chars?
#include <stdio.h>
main(){puts("C"
#ifdef __cplusplus
"++"
#endif
);}
>>
>>56030996
What's the point? It already looks disgusting enough that way.
>>
>>56030977
>>56030975
>>56030957
Thanks for all the help.
>>
>>56031014
Codegolf is for fun. Normally, I'd probably write it as
>>56030787
or
>>56030727
but it's fun to see how short you can get it.
>>
>>56030026
Not him but if there's a loop in a singly-linked list how the fuck are you supposed to get a valid midpoint?
>>
Quick

I need a name prefix for a tri-state variable
>>
>>56031086
t_
>>
>>56031088
but t_ is for type
>>
>>56031086
2 bit flipflop
>>
>>56031111
That's _t
>>
Who /rust/ here?
>>
>>56028990
why does she have them
>>
>>56031086
tr_
>>
>>56029178
aaaaaaaaaaaaaa not you again
>>
>>56031160
What is the problem?
>>
>>56030996
wc 2 3 64 test.c
#include <stdio.h>
main(){printf("C%s",sizeof('c')-1?"":"++");}
>>
made my first program that can run from a terminal window
>>
>>56030912

When you click the picture of Clinton, does it delete all your e-mails?
>>
>>56031224
Why Java, tho.
>>
File: 1454350395335.jpg (67KB, 516x440px) Image search: [Google]
1454350395335.jpg
67KB, 516x440px
I need opinions /g/

I've contemplated about switching to full C from C++ due to the fact that I never use the STL and prefer a procedural programming style.

I enjoy low level programming and I absolutely loathe the fact that there's so much, not my words ''''magic''''' going on beneath the scenes in those kind of languages, even in C++.

But still, C++ is standardized in many industries for a reason and it has good features.

Should I go full C or keep writing pseudo-C in C++?
>>
>>56031212
Huh. Nice golfing.
>>
File: dpt.jpg (302KB, 682x1024px) Image search: [Google]
dpt.jpg
302KB, 682x1024px
>>56028612

FTFY
>>
File: derek-jacoby.jpg (74KB, 500x288px) Image search: [Google]
derek-jacoby.jpg
74KB, 500x288px
>>56031241
Nope, but it will now.
>>
>>56031252
Personally, I do pseudo-c in c++. Occasionally I'll use a c++ feature like std::priority_queue, but otherwise, I'll use traditionally C features like printf instead of cout.
>>
>>56031252

> keep writing pseudo-C in C++

Most people that write C++ just write pseudo C with objects.
>>
>>56031283

Thank you for this feature update.
>>
>>56031252
what "magic" do you think is going on with C++

its not like those bytecode interpreted languages or anything it emits basically the same assembly

Only immediate overhead I can think of with C++ is vtables and even then that's something people implement in C with structures full of function pointers

see for yourself
https://gcc.godbolt.org/#

you can just pseudo-c your way and use printf and putc and such rather than std::cout and use C++ features when you need it


C++ is designed to be multiparadigm so you have the entire C-arsenal available to you as well as C++.

Just stick to C++ really.
>>
File: 1470657600468.gif (627KB, 490x248px) Image search: [Google]
1470657600468.gif
627KB, 490x248px
Count to 3 and print to stdout in assembly, /dpt/ (x86, any compiler).

If you can.
>>
>>56031252
Stay with C++ because templates are awesome.
>>
>>56031252
C++ doesn't lack anything that C has to offer, why would you switch? Write code however you want. In any company you'll have to write according to their style anyway.

For personal stuff stick with C++.
>>
>>56030359
Why? She is uncomfortable in the pic but he probably asked before taking the photo.
>>
>>56031249
it's the only one i know
>>
File: 1467835392609.png (263KB, 532x320px) Image search: [Google]
1467835392609.png
263KB, 532x320px
-Ofast or -Os

is smaller/concise code technically faster?
>>
File: ??????????.gif (294KB, 242x333px) Image search: [Google]
??????????.gif
294KB, 242x333px
Trying to learn C++ for the hundredth time.
Take this example code:

class ManagedResourceHandle {
public:
ManagedResourceHandle(RawResourceHandle* rawHandle_) : rawHandle(rawHandle_) {};
~ManagedResourceHandle() {delete rawHandle; }
... // omitted operator*, etc
private:
RawResourceHandle* rawHandle;
};

ManagedResourceHandle handle(createNewResource());
handle->performInvalidOperation();


1.) Why the trailing underscores?
2.) What does the colon operator do here?
3.) What does the tilde operator do here?
4.) Why is createNewResource() called in the constructor for handle?

I'm coming from C so the concept of "Creating" resources seems really hard to understand, why can't you just declare a raw handle as a normal pointer and pass that in?
>>
>>56029333
ah ok after playing with it it'd have to be something like
 take 2 $ drop 4 string

to work, but i guess i could make my own sugar for that with this?
fromTo x y z = drop (y - x + 2) $ take (y + 1) z
>>
>>56031390
-Ofast, -Os can be faster sometimes but you want all the optimizations you can get
>>
>>56031390
Many performance optimizations involve unrolling loops and explicitly repeating code over and over because it's easier to feed into modern CPU architectures.

This results in a larger binary, but it runs faster.
>>
>>56031417
>1.) Why the trailing underscores?
It's one of the conventions to indicate private data members.

>2.) What does the colon operator do here?
It indicates the start of a member initializer list.

>3.) What does the tilde operator do here?
That one indicates a destructor.

>4.) Why is createNewResource() called in the constructor for handle?

It's using the factory pattern, I suppose.

>I'm coming from C so the concept of "Creating" resources seems really hard to understand, why can't you just declare a raw handle as a normal pointer and pass that in?

Read about RAII.
>>
>>56031461
>>1.) Why the trailing underscores?
>It's one of the conventions to indicate private data members.

Ops, that wasn't the case in your code, the person who wrote it actually used it for the constructor parameters.
>>
File: fixed.jpg (140KB, 682x1024px) Image search: [Google]
fixed.jpg
140KB, 682x1024px
>>56028612
fixed anon...
>>
File: Screenshot_2016-08-11_14-44-54.png (28KB, 399x60px) Image search: [Google]
Screenshot_2016-08-11_14-44-54.png
28KB, 399x60px
>>56031322
>>
>>56031322
section    .text
global _start
_start:
mov ecx,14
mov eax, '1'
l1:
mov [num], eax
mov eax, 4
mov ebx, 1
push ecx
mov ecx, num
mov edx, 1
int 0x80
mov eax, [num]
sub eax, '0'
inc eax
add eax, '0'
pop ecx
loop l1
mov eax,1
int 0x80
section .bss
num resb 1
>>
>>56031417
1.) Retarded convention to not shadow a class member variable with a method parameter.
2.) Look up C++ initialization list.
3.) Its the type signature of the deconstructor.
4.) It's not called *in* the constructor it is called as argument to the constructor.
In C++ land people tend to avoid working with raw pointers whenever it is possible and let RAII do most of the work.
>>
How do I learn to touchtype for a US keyboard? It's pretty annoying to not be able to look at the keys as a help. I have to go through the entire rightmost side of the keyboard just to find ;

Any help with this_ (where the fuck is questionmark)
>>
>>56031571
? is Shift+/

I recommend just typing a lot. Look down when you need it until you don't
>>
>>56031513

Loli should be 'Java design philosophy'
HAES should be 'Java in practice'
>>
File: 1326014493984.jpg (17KB, 352x329px) Image search: [Google]
1326014493984.jpg
17KB, 352x329px
>>56031532
>>56031517
And here was i thinking you little shits were just little shits straight outta college shitposting about python and c++.

Congrats /dpt/.
>>
>>56031571
Look up a home-row key training video or something.

You could buy a keycap set and replace yours temporarily.
>>
>>56031615
I'm in college, and I shitpost rust/c, occasionally R.
>>
>>56031591
I didn't make myself clear. I'm using non-us keyboard (swedish) so my keys dont really match the US keymap. But I'm using the US keyboard in the OS. This is all for programming convenience reasons.
>>56031625
>keycap set
Sadly prefer a laptop right now. But yeah I could get an external keyboard and do that.
>>
I'm feeling burnt out on my current project. I think I need a break.

What's a good 1 week fulltime project? Possibly github a issue fix. But I'd rather not spend time involving myself in a codebase.
>>
>>56031609
>grown woman in french maid costume
>Loli
Nah.
This picture does make me rather bothered though.
>>
>>56031571
nigger what the fuck. Your right hand's pinky finger should always be resting on the semi colon.
>>
Any linux assembly actually anything non masm is fine books or tuts x64
>>
>>56031687
Brainfuck interpreter/compiler/transpiler.
>>
>>56029371
My nigger!
>>
>>56031687
Lisp interpreter/compiler/transpiler
>>
I want to make 2d pixelshit video games what language should I learn
>>
>>56031783
c++/SDL
Alternatively, just do it in unity/c#.
>>
>>56031461
>>56031555
Okay let me get this straight, so you pass the actual raw handle to the constructor of ManagedResourceHandle, and then in the initialization list rawHandle gets the value of rawHandle_?

Does the tilde mean that the destructor will get called automatically when the resource is lost or when there is an exception?
>>
>>56030912
Can you give me a basic idea of what and how much do I need to know to create an email client like that with Java? I'm a complete beginner, haven't even finished the first book on the basics of Java and it's my first real language. I'm just trying to get some ideas about what I want to program in the future to motivate me and that seems interesting
>>
File: HOWITYPE.png (301KB, 1000x640px) Image search: [Google]
HOWITYPE.png
301KB, 1000x640px
>>56031710
Well I don't type like that because I didn't learn that formally.
But you're right most of the time my pinky is on the semicolon.
>>
>>56031609
Hey are you the cyberia I think you are?
>>
>>56031828
>Okay let me get this straight, so you pass the actual raw handle to the constructor of ManagedResourceHandle, and then in the initialization list rawHandle gets the value of rawHandle_?
Yes.

>Does the tilde mean that the destructor will get called automatically when the resource is lost or when there is an exception?
It won't "get lost", the destructor gets executed when the object runs out of scope, or in case of an exception.
>>
>>56030490
I have a compulsion to split files longer than 300-400 loc. Past that point they become hard to navigate.
>>
>>56031710
i doubt it because even the mkg fedoras say you have 8 fingers for alphanumerics (thumbs for spacebar)
>>
>>56031828
"Tilde" basically denotes a function that will execute when an object gets out of scope.

Try to build this to illustrate:
struct Test
{
char *member;

Test()
{
fprintf(stdout, "Constructed.\n");
member = new char[1024];
}

~Test()
{
fprintf(stdout, "Deconstructed.\n");
delete[] member;
}
};

int main(int, const char **)
{
Test a();
{
Test b();
for(int i = 0; < 10; ++i)
Test c();
}
return 0;
}
>>
Trying to make a gif of game of life. Is magick++ bad? It takes ~2gb of ram to create a gif of 100 700x700 sized images.
>>
>>56031842
nigga the things sticking out of f and j are guides for where to put your index fingers
>>
>>56031375
Learn C/C++.
>>
>>56028612
The girl is C and the fat guy is C++
>>
>>56031904
100 * 700 * 700 * 4 + headers bytes

Sounds about right.
>>
What's the best way to learn JavaScript as someone who can already program in other languages?
>>
>>56031941
Just do it
>>
>>56031941
By giving the idea up.
>>
>>56031783
Pick a good framework to use and learn that language.
>Angel2D (C++)
>Monogame (C#)
>Gamemaker (GML)
>Unity (C#)
>Libgdx (Java)
But most game engines use C++. So I say use something that uses that. SDL&SFML would be ok to start with but imo using an engine that gets you through the process of making a game is more important.
http://atomicgameengine.com/
This is nice.
>>
>>56031828
The other guys pretty much covered it.

Note that the ResourceHandle class you showed us is basically just a smart pointer.
Consider instead of using some custom built smart pointer implementation you could use the smart pointers provided by STL.
>>
File: C vs C++.png (463KB, 785x678px) Image search: [Google]
C vs C++.png
463KB, 785x678px
>>56031930
>>56031930
better example
>>
>>56031941
Read one of those 10 minute JS tours and google ES6 guides.
>>
>>56032028
Thanks
>>
>>56032028
link? cant find anything
>>
>yfw "Memoization" song set to the tune and meter of Justice's "Civilization"
>>
>>56032098
https://learnxinyminutes.com/docs/javascript/
http://es6-features.org/
https://github.com/lukehoban/es6features
>>
>>56031252
>I enjoy low level programming and I absolutely loathe the fact that there's so much, not my words ''''magic''''' going on beneath the scenes in those kind of languages, even in C++.

When something looks simple, but actually isn't, it's only "magic" and harmful if you don't already know what it really does. When you know what it does, it's just expressive, senpai. :3

although C++ in particular is a clusterfuck so reasoning about what machine code gets spit out in that case would be pretty tricky, I agree.
>>
>>56032146
thanks babe
>>
What's a good looking aliased font for terminal?
>>
>>56031137
Because C++ is a bloated piece of shit
>>
>>56031322
>>56031532
What do syscalls look like in assembly?

Anon's code looks a lot smaller than what I assumed you'd need.
>>
File: Screenshot_2016-08-11_21-44-43.png (16KB, 493x444px) Image search: [Google]
Screenshot_2016-08-11_21-44-43.png
16KB, 493x444px
>>56032370
>>
>>56031629
>and I shitpost rust
mah nigga, good choice.
>>
>>56032414
I feel sorry for your eyes.
>>
>>56032414
How small is your resolution?
I can hardly read that and my resolution is shit (1280x800)
>>
>>56032139
Where?
>>
>people claiming C++ is "BLOAT" "CLUSTERFUCK"
>its a fucking multiparadigm language you pick what you want
>you can make everything an object like C# or Java or do functional C coding and any mix of the two
>meta-coding templates and lots of other features of the syntax

>BLOAT!!!! ITS SO HARD TO READ!!!
>its clearly not code using the paradigm suited for you and you are able to program in your own way so reading heavily-templated code is gonna look ugly when you yourself don't code that way
>one snippet of C++ code does not represent the entire language

>one snippet showing the C++ standard library is not a proper judgement of the syntax

>people will still claim "BLOAT"
>C programmers getting prostate-pestered at C++ when C++ includes the entire C-syntax and coding paradigm
>>
>>56032370
Proggy or Gohu

http://font.gohu.org/

http://www.proggyfonts.net/
>>
>>56032445
ok

>>56032450
1366x768

i can read that perfectly fine
>>
>>56032402
Sometimes the OS sets up interrupts to do simple stuff. If you set up the registers right and call that interrupt the OS will take over and read those registers and do the right thing. In this case int 0x80 is calling a function that looks at certain registers and generates stdout.
>>
>>56031969
>>Unity (C#)

I will never understand the appeal of using a 3D engine to make 2D games.

>>56031783
I'd probably suggest C#, whether you use an engine or not. SFML has bindings for it I think, if you want to go with the libraries rather than engines route.

With regards to engine or no engine, I'd say it doesn't really matter. 2D game stuff is usually really simple to do on your own (!!unless you want full Newtonian rigid body physics, don't roll that yourself even if it is 2D!!), but since performance also usually doesn't matter, an engine won't hurt anything.

If you want to gitgud at programming I'd say C# and SFML, whereas if you want to just like make game, use some kind of engine. Which engine? No fucking clue. I know a lot of people swear by Gamemaker.

(for the unaware, SFML is a multimedia library, not an engine. It wraps all of the horrible shit about writing, say, crossplatform 2D raster drawing, or crossplatform audio output.)
>>
>>56031135
Me
>>
>>56032458
>>ITS SO HARD TO READ!!!
People are saying that?
It's pretty easy to read.

The real problem in C++ is that the multiple paradigms aren't unified in any way and play with eachother very poorly. This results in things like calling "delete" on pointers to memory allocated with "malloc()" causing shenanigans.
>>
>>56032534
Ahh, thanks, cool.

>>56031135
Reporting in.

Am I still invited to the Rustacean orgy if I'm learning to write it with a [spoiler]Minecraft clone[/spoiler]?
>>
>>56032539
Using a 3D engine for 2D games is logically simpler than using 2D engines that are dedicated for specific genres to do something that doesn't fit perfectly within that genre.
>>
>>56032616
>This results in things like calling "delete" on pointers to memory allocated with "malloc()" causing shenanigans.

That has nothing to do with "multiple paradigms". People who call delete on malloc'd memory just don't understand the language.
>>
best book you'd recommend on the spot ?
>>
>>56032661
>People who call delete on malloc'd memory just don't understand the language.
psssst

~sometimes you get a pointer from a library and you don't know what the library used to allocate it~
>>
>>56032644
>Using a 3D engine for 2D games is logically simpler than using 2D engines that are dedicated for specific genres to do something that doesn't fit perfectly within that genre.

That's fair. I'd like to think that there are 2D engines more flexible than that, but that wasn't the case when I was looking for one in 2008.
>>
File: 079567490005.jpg (107KB, 900x900px) Image search: [Google]
079567490005.jpg
107KB, 900x900px
>>56031135
>>56032592
>>56032641
squirt squirt
>>
>>56032706
only if you use shitty libraries you stole from shithub
>>
>>56032644
that's just because 2d engines tend to be even more shitty and amateurishly underdeveloped than 3d engines
>>
>>56031930
...I'm not that fat and I've since lost weight
>>
>>56032414

What font is that? It's awful. I love it.
>>
>>56032685
>>56032685
fuck off stupid fuckign idiot
>>
unsigned SetBit(unsigned BitMap, unsigned position)
{
return BitMap | (1 << position);
}


Can anyone explain how this function deals with the rightmost bit? I can't work it out.

For example, given bitmap 0000 and trying to set the rightmost bit, if we assume position 0 is the rightmost bit then the result is 0000. If we assume that position 1 is the rightmost bit, it returns 0010 which obviously the rightmost bit.
>>
>>56032878
why so mad??
>>
>>56032887
1 bit shifted left by zero is just 1.

0000 | 1 is 0001
>>
>>56032887
When position is 0 "1 << position" yields 0001
>>
>>56032685
>>
>>56029070
Can you explain the code please?
I don't quite get what's written there.
>>
How should I avoid an include loop? I have two header files which include each other but I need declarations from them in both files. I'm using include guards.
// context.h

//--------------------------------------------------------*
// Include statements
#include <vector>
#include <SDL2/SDL.h>

#include "entity.h"
#include "inputhandler.h"
#include "texture.h"

//--------------------------------------------------------*
/**
* Context class containing pointers to relevant game entities
* Pass a pointer to an instance of this class to game objects
*/
struct Context {
InputHandler* inputHandler;
SDL_Renderer* renderer;
std::vector<Entity*>* entities;
std::map<std::string, Texture*>* textureBank;
};

// entity.h

//--------------------------------------------------------*
// Include statements
#include "context.h"
#include "texture.h"
#include "geometry.h"

//--------------------------------------------------------*
/**
* Abstract class for all game entities such as the player, enemies and projectiles.
*/
class Entity {
public:
virtual void update(Context* ctx);
virtual void render(SDL_Renderer* renderer);

Geometry::PlaneVector getPosition() {return position;};
Geometry::PlaneVector getLastPosition() {return lastPosition;};

protected:
Geometry::PlaneVector position;
Geometry::PlaneVector lastPosition;
Texture* texture;

};
>>
>compiler written in C++
>has to be compiled in a C++ compiler

which came first?

how far back can you go before you find someone writing a compiler in asm?
>>
>>56033034
Since you're only using a pointer in this case you don't need the definition of Context. Remove the #include "context.h" and add a class Context; line instead.
>>
>>56029212
can you send reading materials please?
>>
>>56033034
https://en.wikipedia.org/wiki/Include_guard
>>
>>56033034
forward delcarations
>>
>>56033058
Oh and that goes the other way too for entity.
>>
>>56033050
https://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29
>>
>>56032916
>>56032925
Is this a special case?

Also, I can't understand how this function deals with inputs where the decimal position converts to a binary string with multiple 1s.

For example, if I want to set the third bit of an 0000 bitmap, that would mean 0000 | 0110 which doesn't get the job done. Am I misinterpreting the position variable? Should that be another mask that corresponds to the bit I want to set e.g. 1000?
>>
>>56033058
>>56033078
>>56033068
Thank you, I didn't realise just a declaration would suffice.
>>56033062
Thanks, but I'm already using guards.
>>
NEW THREAD!

>>56033133
>>
File: I have no idea.jpg (37KB, 500x282px) Image search: [Google]
I have no idea.jpg
37KB, 500x282px
>>56028612
Please help me with Java quickly

for(Walls walls: wall) {
scoreArray[i] = true;
}

I want to find the current number of the Walls array, and place that number into i.
So, if I'm on the 4th value of the Walls array, I want to set the 4th value of scoreArray to true.

I don't know how to change my foreach loop into a for loop, can someone write it for me?

I'm so stuck
>>
>>56033106
>Is this a special case?

Not at all.

1 is 0001 in binary.
1 << 1 is 0010
1 << 2 is 0100
1 << 3 is 1000
and so on.
>>
>>56033140
If you want to set the 4th value in the array to true, why do you need a loop?
scoreArray[3] = true;
>>
>>56033177
How come when 0000 | 1 then the answer is 0001 as suggested by posts above?
Is it because the place from 0 shifts to 1? I guess that could make sense, though seems rather tricky if someone assumes that shifting only shifts numbers.

Also, how do you get 1 << 3 is 1000?
If we assume decimal 3 = 0011 as in >>56032887 , then that would surely become 0110? If not, how does the position get translated to binary in this case?
>>
>>56033254
At the same time as I set scoreArray[3] = true, I need to access the 3rd(or is it 4th), value of the walls array.

for(Walls walls : wall) {
if(cam.position.y - (cam.viewportHeight/2) > walls.getPosTopBlock().y + walls.getTopBlock().getHeight()) {
walls.reposition(walls.getPosLeftWall().y + (WALL_COUNT * WALL_SPACING));

scoreArray[i] = true;
}
if(bubble.getPosition().y > walls.getPosLeftWall().y && scoreArray[i] == true) {
// Increases the score
score++;
scoreString = Integer.toString(score);
scoreArray[i] = false;


}
if(walls.collides(bubble.getBounds())) {
gsm.set(new PlayState(gsm));
break;
}
}

I don't know how to do that fancy code, first time on this board

I'm hoping you can see why I need the loop
>>
>>56033292

1 << n is really 1 * 2^n
So 1 << 3 is 8 and that's 1000 in binary.
>>
>>56033292
0 | 1 is bitwise OR
1 << 0 is 1 shifted by 0 so it's 1
>>
>>56033292
1 << 3 is 1 shifted by 3, not 3 shifted by 1
>>
>>56033367
>>56033436
>>56033461

Thanks lads, I'm a total dumbshit for misunderstanding the shift operation.
>>
>>56031845

Who is the Cyberia you think I am?

I got the name from the cafe in lain.
>>
>>56031900
For some damn reason this executes silently.
>>
>>56033140

for(int i = 0; i < walls.length; i++)
scoreArray[i] = true;
>>
File: computerscience.png (245KB, 2088x2080px) Image search: [Google]
computerscience.png
245KB, 2088x2080px
https://github.com/KittyKatt/screenFetch/commit/8d9769612a2b732282a06d1474b98ac4db18d24e

elif [[ ${DE} == "GNOME" || ${DE} == "GNOME" ]]; then


How did this shit even get in there? Someone actually wrote this line of code.
Thread posts: 326
Thread images: 44


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.