[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: 35
old thread: >>53902106

What are you working on, /g/?
>>
Shout out to the only anon so far to enter the contest >>53906619
>>
>>53907281
>Creating threads before the bump limit
>Fagposting
Delete this shit and kill yourself.
>>
Implementing logging into a concurrent C++ program: what's a good way to do it?

I have an inline function that just pushes logging text from worker threads into a vector then the main thread empties the vector and prints to IO file when it gets around to it. Its race condition galore. I don't want to lock the vector because then my worker threads handling critical tasks will get slowed down by a dumb log line.
>>
>>53907361
No idea anon, not a fucking clue....
>>
File: roguelikes.jpg (78 KB, 359x498) Image search: [Google]
roguelikes.jpg
78 KB, 359x498
>What are you working on, /g/?
I've started work on a rogueliek for /tg/. Still in very basic prototype.

I fucking love anime gayshit.
>>
>>53907390
are you trolling because I'm really stuck on this and need the infinite wisdom of /dpt/ to show me the light.
>>
>>53907441
Nope, my logging knowledge stops at anything past getting system time and then subtracting the current time from it at the end of my function. See, genuinely an idiot.
>>
>>53907281
I'm reading a paper about Solomonoff's Alpha incremental machine learning system.
>>
Need an idea for a program to make in c++. What do you guys suggest?
>>
File: 93209432.gif (193 KB, 320x350) Image search: [Google]
93209432.gif
193 KB, 320x350
>>53907281
A python script that automates a variety of shit I do in Gimp
>>
>>53907281
what does this gril have to do with programming?
>>
>>53907508
No idea anon, not a fucking clue....
>>
>>53907508
She programs her body with hormones.
>>
>>53907502
Write a space invaders game.
>>
>>53907361
i had to implement this too. My logging only occurs on errors or in exceptional cases so I chose to use locks.

what you might want to do is give each worker thread its own log vector. at set intervals the logs are locked in an order (i.e. not all workers at once) and merged together over time.

W = Worker, L = base log vector

So, W1's log is locked and merged with L. Then W2 is locked and merged with L. So on and so forth until WN-1 is done. Then you can sort L on its timestamp.
>>
>>53907508
She's a trap, anon, and /g/ is full of trannies.
>>
>>53907631
hime isn't a tranny
>>
If you aren't able to continue writing code on a line after a comment the language which you are working with is incomplete.
>>
>>53907645
I never said she was; I said she was a trap. Trannies like traps for obvious reasons.
>>
File: stoolworth.jpg (144 KB, 1395x1395) Image search: [Google]
stoolworth.jpg
144 KB, 1395x1395
>daily reminder that the Son will not restore us to heaven until we program away all the evils of this world.
>>
>>53907647
so this excludes python then?
>>
Can you guys rate my program?
This is about as complicated as it gets so I would like your opinions
#include <iostream>
#include <stdio.h>
#include <vector>
int main()
{
std::vector<int> test = { 1, 2, 3, 4 ,5, 6, 7, 8, 9, 10, 11, 12, 13 };

for (int i = 0; i < test.size(); i++) {
std::cout << test[i] << std::endl;
}

getchar();
return 0;
}
>>
>>53907723
Meant to say unintuitive as fuck.
>>
>>53907593
that's a really good idea anon and will work very well for my setup I believe. thank you.

>>53907480
typically about all you need to know i guess.
>>
>>53907794
I dunno, I'll stand by my statement that it's pretty cool. Maybe unintuitive coming from other languages, yes.
>>
File: chim.jpg (286 KB, 900x675) Image search: [Google]
chim.jpg
286 KB, 900x675
>>53907812
no problem buddy.
>>
>>53907834
no, unintuitive from any point of view.

a string by definition is a collection of chars. If you iterate over a string, you expect to see chars. What the fuck made them split it by return characters? That's retarded.
>>
>>53907784
>iostream
>stdio.h
Pls
>>
Can someone explain threads and multithreading because everything I find on the internet is overcomplicating it.
>>
A daily reminder that machine learning >>> programming
>>
>>53907784
now do it in c
>>
>>53907858
If you want to run 2 pieces of code at the exact same time, then you need to use threads. That's basically it.
>>
>>53907857
Whats wrong with iostream and stdio.h
>>
>>53907859
>implying a machine can learn without being programmed how to do just that
>>
>>53907856
open does not return a string get that through your thick skull
>>
>>53907784

Are you running this in a console that disappears after the program finishes? Is that why you have a getchar() at the end?
>>
>>53907889
yea
>>
File: RichardStallmanCutout.png (2 MB, 1000x1000) Image search: [Google]
RichardStallmanCutout.png
2 MB, 1000x1000
Daily reminder to stop daily reminders
>>
>>53907884
A single universal learning program is enough to learn anything you throw at it
>>
>>53907856
I guess I didn't explain it very good - it's not iterating over strings. open('filename.txt') returns an io stream, saying
with open('fname.ext') as 
 is somewhat like saying f = open('fname.ext') which can be iterated upon to return a line by line runthrough of the file
>>
>>53907911
You are old
>>
>>53907920
that program is called the Universe and we are living in it, now get back to work.
>>
>>53907925
>>53907856
Fucked up my formatting. Meant:

I guess I didn't explain it very well - it's not iterating over strings. open('filename.txt') returns an io stream, saying with open('fname.ext') as f is somewhat like saying f = open('fname.ext') which can be iterated upon to return a line by line runthrough of the file
>>
>>53907925
That's still odd as fuck.
>>
>>53907920
If I throw my affections at it, will it learn to love me?
>>
>>53907946
Nah, it is called Universal Induction
>>
>>53907857
No response, prolly cuz your a fucking retard who has no clue what the fuck he is typing
>>
>>53907970
If you reward it for this behavior then yes. https://en.wikipedia.org/wiki/AIXI
>>
>>53907955
Not really. Maybe with performs differently in other languages, but in python it just lets the object clean up some stuff based on what happens inside the block. And why shouldn't files be iterable? If you want, you could use .readlines() anyway, this is just shorter.
>>
ha
hahahaha
>>
>>53908001
>And why shouldn't files be iterable?
I don;t mind file streams being iterable.

But what I would expect *if* an IOStream is iterable, is collection of bytes. That's what makes sense. Not fuckign string for each line, which won't work if it's a binary file. Better it not be iterable at all instead of broken like that.

Python has some nice bits, but it has a lot of pants on head retarded shit like this that makes shit very hard to read unless you specifically know that iostream is a fucking string iterable in advance.
>>
File: 91489028904.jpg (77 KB, 600x819) Image search: [Google]
91489028904.jpg
77 KB, 600x819
>>53907859
>not programming in binary
It's almost like you want to have something beyond human error limiting you in hacking the planet
>>
>>53908089
nine times out of ten you're opening a file as a collection of strings

for those other times there's a flag you set to read it as bytes

>unless you specifically know that iostream is a fucking string iterable in advance.
how can you not tell that from context clues dude
>>
>>53908089
Yeah, it's quirky alright. Whilst what you said would make sense too, and it actually will happen - but you need to open the file in read bytes mode (which is open('fname.ext', 'rb')), and open defaults to read mode 'r'
>>
>>53908115
>Not synchronizing your heartbeat with the sound of bleeps and bloops on your thinkpad
Its like you don't want to live the life of a programmer
>>
File: pbm.png (4 KB, 305x397) Image search: [Google]
pbm.png
4 KB, 305x397
PBM is simpler than PGM, but I cannot get this nigger to actually work. For some images, it works fine, but for others.. not so much.
>>
>>53907281
Stio this programming fag meme.
>>
>>53908166
>nine times out of ten you're opening a file as a collection of strings
???
I almost never treat ext files as new line lists when i work with them. Ever use fucking JSON or XML? Sorta fucking popular you know. New lines are just whitespace in those formats.

>for those other times there's a flag you set to read it as bytes
That's even worse. IOSteam is a iterable, but it's not always the same type. Fucking hell.

>how can you not tell that from context clues dude
I can by looking at it long enough. But intuitively, if a iosteam is iterable, it's a list of bytes unless you did something to specify otherwise line .readlines(). To be able to figure that out, you need to know what the code is doing in the first place, which you don't always know in advance.
>>
>>53908215
>Ever use fucking JSON or XML? Sorta fucking popular you know.

CSV is still kicking around, you know.
>>
>>53908229
Just use java pajeet
>>
File: Linus-Torvalds-Says.jpg (70 KB, 971x647) Image search: [Google]
Linus-Torvalds-Says.jpg
70 KB, 971x647
>>53908177
>Not hacking your brain to be one with computer so you can write code in your dreams.
>>
>>53908229
>CSV
Not nearly as popular. So why have iosteam be a readlines() iterable by default? These are some of the reasons python is hated. It's heavily peppered with retarded design decisions.
>>
>>53908215
python has dedicated json parsing libraries, you'd never use open for that

>muh intuition
just stop already
>>
>>53908254

I'm not defending the choices made, I'm just suggesting that there are existing alternatives to JSON and XML that are more widely used than you might expect.
>>
>>53908198
Man I implemented PPM in an afternoon or two. You look close to getting it right. Are you sure you're reading the header right? There's both ASCII and binary formats, you know. It looks like you've just got the dimensions too narrow on this one, so it shifts to the right.

By the way, absolutely check if you reached EOF reading all those pixels.
>>
>>53908254
>So why have iosteam be a readlines() iterable by default? These are some of the reasons python is hated.
lmao that is some serious grasping at straws right there
>>
>>53908292
I know. I actually worked on a large python project that was parsing huge CSV files.

I know CVS exists. It's not as popular as xml/json
>>
>>53908318
who's grasping at straws? You admit i have a straw then at least. I only mentioned this because some anon brought it up in an example and said it was neat. I'm triggered as fuck
>>
File: torvalds.jpg (204 KB, 575x467) Image search: [Google]
torvalds.jpg
204 KB, 575x467
>>53908247
>>
>>53908296

For some reason, I found PPM & PGM simpler.
>>
>>53908354
You've already implemented those two? Can't you reuse a lot of your code?
>>
So I am trying to learn Python, because there is a promotion in it for me. I am pretty new to coding (Though I am having a blast and am planning on learning something else once I master Python) How come when I run it I get the None in the return?

Return:
Welcome to the dungeon
Here is the map of the dungeon, you are at (0, 0)
(0, 0) (0, 1) (0, 2)
(1, 0) (1, 1) (1, 2)
(2, 0) (2, 1) (2, 2)
None
What is your move hero?


Here is my program.
import random

CELLS = [(0, 0), (0, 1), (0, 2),
(1, 0), (1, 1), (1, 2),
(2, 0), (2, 1), (2, 2)]

def map_builder(player):
print("Here is the map of the dungeon, you are at {}".format(player))
print(CELLS[0],CELLS[1],CELLS[2])
print(CELLS[3],CELLS[4],CELLS[5])
print(CELLS[6],CELLS[7],CELLS[8])

def get_locations():
monster = random.choice(CELLS)
door = random.choice(CELLS)
player = random.choice(CELLS)
if not monster == door or monster == player or door == player:
return monster,door,player
else:
return get_locations()

def get_moves(player):
moves = ['LEFT','RIGHT','UP','DOWN']
if player[0] == 0:
moves.remove('UP')
if player[0] == 2:
moves.remove('DOWN')
if player[1] == 0:
moves.remove('LEFT')
if player[1] == 2:
moves.remove('RIGHT')
return moves

def move_player(player, move):
x, y = player
if move == "LEFT":
y -=1
elif move == "RIGHT":
y+=1
elif move == "UP":
x-=1
elif move == "DOWN":
x+=1
return x,y

monster,door,player = get_locations()
print("Welcome to the dungeon")
while True:
moves = get_moves(player)
print(map_builder(player))

move = input("""What is your move hero?
""").upper()

if move == "QUIT":
break
elif move in moves:
player = move_player(player,move)
elif move not in moves:
print("Ouch, you bonked your head!")
continue

if player == monster:
print("""You have been slain by the monster!
---GAME OVER---""")
break
elif player == door:
print("""You escape into the light of day!
---YOU WIN---""")
break
>>
>>53907281
i wanna smell and suck her toes
>>
>>53908374
>You've already implemented those two?

I kind of did it on a lark last week when I was talking to the one guy about his convolution filter not working right.
>>
>>53908378
You are trying to print map_builder, but map_builder doesn't have a return statement so it returns a None object. Just replace that line with map_builder instead of print(map_builder).
>>
I have a challenge that we can all participate in.
We all get to write one line of code in c++
lets see if we can build a program, I will start:

#include <iostream>
>>
File: pbm2.png (17 KB, 518x326) Image search: [Google]
pbm2.png
17 KB, 518x326
>>
>>53908401
int main() {}
>>
>>53908399
Fuck man, I knew it was something retardedly stupid.

Your the best
>>
File: relate.jpg (107 KB, 1600x557) Image search: [Google]
relate.jpg
107 KB, 1600x557
>>53908383
>>
>>53908383
>her
>>
>>53908399
Speaking of which, surely it would be better design to throw an error instead of none when a non returning function has it's return value used?

>Errors should never pass silently. Unless explicitly silenced.
-Zen of Python

Guido, pls
>>
>>53908425
We aren't including anything else...
>>
>>53908463
It's sometimes useful. None is interpreted as False when used in a boolean expression. You can have
if my_function():
, and the branch will only execute if my_function returns something.
>>
>>53908463
>Errors should pass silently. Unless explicitly "use strict"ed.
-Zen of JavaScript
>>
>>53908401
int i, j; double ***arr = (double ***) malloc(sizeof(double **) * INT_MAX); for (i = 0; i < INT_MAX; i++) arr[i] = (double **) malloc(sizeof(double *) * INT_MAX); for (i = 0; i < INT_MAX; i++) for (j = 0; j < INT_MAX; j++) arr[i][j] = (double *) malloc(sizeof(double) * INT_MAX); /* leak all the memeory */


:3
>>
>>53908490
Surely, this doesn't matter because you can just return False or return None instead of returning nothing.
>>
>>53908425
int mainForRealThisTime() {
>>
>>53908425
kek. yet another challenge solved by the great minds at /dpt/.
>>
File: MUD.png (4 KB, 360x160) Image search: [Google]
MUD.png
4 KB, 360x160
>>53908490
>>53908463
Alright so do you guys reckon there is any way to pretty the return up with only characters?

Or should i stop wasting my time on something so trivial (in comparison to actually learning something)
>>
Does anybody here know CUDA? I've been trying to write a very fucking simple Floyd-Warshall and it just won't work.

I'll post code if anyone is interested (in a few hours, going to get some sleep first)
>>
>>53908401
while(1) malloc(1); /* LEAK ALL THE MEMORY :DDDD */
>>
>>53907878
why both?
>>
>>53908534
>or return None instead of returning nothing.
Returning nothing means you return None.

But anyway, it would be pretty unnatural to return False instead of None in some circumstances, especially if the author of my_function doesn't expect the function to be used in boolean expression.

For example, let's say you wrote a function that takes in a list of strings and returns the first element that has a length of 7 or more. If no such strings exist, is it more natural to return None or return False?
>>
>>53908569
You can replace that with a for loop, but it hardly matters. Your time is better spent.
>>
File: pbmmarbles.png (43 KB, 1076x629) Image search: [Google]
pbmmarbles.png
43 KB, 1076x629
>pbm reader fine
>test files broken

fuck me running.
>>
>>53908585
You can't ask a half-assed question then leave for bed.
>>
>>53908671
>returning nothing means you return None
But returning None is explicit. Otherwise it can lead to wierd stupid bugs like the guy originally thought

As for your example, you can still return None (which imo is more natural). You just need to add a return None to the end, which will run if nothing else returns. Again:
>Errors should never pass silently. Unless explicitly silenced.
And from the same zen:
>Explicit is better than implicit
And
>In the face of ambiguity, refuse the temptation to guess.
>>
>>53908747
Forcing people to write return or
return None
to the end of their programs would make the language uglier. I agree that it violates the "explicit is better than implicit" rule, but every rule of thumb has exceptions.
>>
>>53908690
Probably going to do that actually, because the next step states to make the map show where the player currently is visually, and where the player has been
>>
I want to write an artificially intelligent agent for a card game I play. (I've posted about this before I think)

I have next to no experience with AI, and basic programming (I made a game in C once and some other <5k sloc projects). I think a good idea to prepare myself before jumping into this big project is to write AI agents for simpler card games, maybe 4 or 5, in ascending complexity.

What else should I do to git gud so my attempt isn't futile?
>>
A script to scrape a 4chin thread's media
it's working only that i keep getting both the thumbnails and full size image files downloaded. By now i've "solved" it by removing the thumbnails identified as *s.jpg but it feels retarded doing it like that.

anyway

#!/bin/bash
echo enter url with http://
read url
echo enter extension e.g. jpg,jpeg,png,gif
read extension
echo enter destination /home/user/
read destination
cd
mkdir -p $destination
for i in 1; do
# removes http:// and formalizes Destination Folder
short_url=`echo $url| cut -c8-`
echo ""
echo ""
echo "Scraping $short_url"
echo "ooooooooooooooooooooooooooooo"
cd $destination
echo "> scraping $short_url"
wget -e robots=off \
-H -nd -nc -np -nv \
--recursive -p \
--level=1 \
--accept $extension\
--convert-links -N \
--limit-rate=200k \
--wait 1.0 \
$short_url

echo ""
echo "> Finished scraping $short_url"

done
>>
>>53908776
I think it makes it more readable, in a way. You know it's going to return None, because it says so. I can see where you're coming from though.
If we consider the function you talked about:
def find_over_6(arr):
for item in arr:
if len(item) >= 7
return item
return None # implicit 'else'

So OK, I suppose it looks cleaner, even if it does violate the rules. But I don't think it's worth it when
>Special cases aren't special enough to break the rules.
Really though, it isn't going to get changed, because it would break backwards compatibility.
>>
>>53908910
To be fair they already did that in the jump to Python 3 by changing print "me" to print("me")
>>
>>53908909
>echo "ooooooooooooooooooooooooooooo"
love it
>>
Isn't this basically avatarfagging and against the global rules?
>>
>>53908899
Is the card game deterministic?
>>
>>53908931
They broke a lot in 2 to 3, that was the point I guess. Still, I don't think there's going to be another large update like that for a long time considering the shitstorm that ensued

>>53908938
What are you referring to?
>>
>>53908378
why not represent the map with nodes, and populate each node's adjacency list at the time of generation?
>>
>>53908935
hey i gotta make use of my
sick potato gpu with dem sick GUIs
>>
What's the general /dpt/ concensus on C#?
>>
>>53908957
I think it isn't...

You play a sequence of up to 4 cards, and you know the effects of each, but you and your opponent alternate, and what your opponent does can alter your cards or you
So that's a no, I think.
>>
>>53909078
It's dogshit.
>>
>>53909078
The general /dpt/ consensus on any language is the following:

it's shit
>>
>>53908742
"can't" is a rather strong word

I'm using Alea-GPU which is a CUDA interface for .NET, and in particular F#.

The first member declaration is the kernel.

    [<Kernel;ReflectedDefinition>]
member this.FloydWKernel (width:int) (k:int) (data:deviceptr<float>) =
let col = blockIdx.x * blockDim.x + threadIdx.x //col is index i, row is index j
let row = blockIdx.y

if col >= width then ()

let index = width * row + col
let best = __shared__.Variable<float>()

if threadIdx.x = 0 then best := data.[width*row+k]

__syncthreads()

let tmp = data.[k*width+col]
let cur = !best + tmp
data.[index] <- min data.[index] cur

member this.LaunchParams width =
let threads = dim3(tileDim, 1)
let grid = dim3(divup width tileDim, width)
LaunchParam(grid, threads)

member this.FloydW (width:int) (k:int) (odata:deviceptr<float>) =
let lp = this.LaunchParams width
this.GPULaunch <@ this.FloydWKernel @> lp width k odata


I suspect it has to do with the grid and block sizes in LaunchParams, but the configurations I've tried keep fucking up, and I've seen this code written by others before - and it worked for them. In C++, the kernel doesn't have to be fed two dim3 values, since integers are acceptable as well, but in F# that won't do. So, where they simply write 256 for the block size I don't know if it is dim3(16,16) or dim3(256,1).

FloydW will simply get called N times, where N is the width/height of the (square) input matrix.
>>
>>53908909
>for i in 1
what?
>>
>>53909136
Infinite loop? Knowing bash for what it is I wouldn't be surprised.
>>
>>53909090
>>53909093
Alright, what's the best alternative then?
>>
>>53909150
No, it iterates once with i set to 1. He didn't even use i.
>>
>>53909152
Best alternative? Suicide
Best alternative programming language? Java
>>
>>53909152
another language that's non proprietary
>>
>>53909109
>>53908742

Ah, nearly forgot mentioning that the `k` argument for FloydW is the current iteration of the outer (third) for of Floyd-Warshall's algorithm, and that tileDim is the number of threads per block (the variable was a bit down below).

What I want to know is - what launch parameters should I set?
>>
How do I use function pointers in a C function?

i'm just guessing, but it would be something like...
int function(void *data, void (*funcptr))
{
(*funcptr)(data);
...


???
>>
>>53908569
If you wanted to graphically display the location of the player, you could do something like
pos = player[0] * 3 +  player[1]

to get the index of the player's current location, then you could do something like
for loc in range(0, 9): #doesn't include 9!
if loc == pos:
print "(*C*)",
else:
print CELLS[loc],
if (loc % 3 == 2):
print ""
>>
>>53909242
That should work.
>>
>>53909274
better yet, replace
print "(*C*)",

with
print "(HERO)",

or something else thats 4 chars wide.
>>
>>53909242
You need the parameter types too, you also don't need that (*).

int function(void *data, void (*funcptr)(void *))
{
funcptr(data);
>>
>>53909274
That's disgustingly unreadable
>>
whats the deal with haskell's read?
it always has problems reading a number in this thread
>pic realted
>>
>>53909344
is it that bad?
How would you recommend fixing it?
>>
File: wew.png (18 KB, 527x339) Image search: [Google]
wew.png
18 KB, 527x339
There we fucking go. Turns out I'm retarded and can't read a spec.

"with don't care bits to fill out the last byte in the row" means those bits need to get discarded, not added to the image as if the whole thing were packed.
>>
>>53909180
Thanks i forgot to change that.
Yeah i figured i didn't need it,
that's when i was testing and debugging it because i was trying to figure out wget and it kept giving me errors with the levels of recursion, i thought it was related.
>>
>>53909358
Are you the faggot whos JSON parser I broke by posting an absolutely shitty code example?

Stop using haskell you ultra nerd, it's been a week and you still haven't fixed your json parser lol
>>
>>53909358
wow anon, even i had no trouble at all writing a json scraper in C, and C is supposedly supposed to be really bad for string manipulation
>>
>>53909455
its not my problem, its a haskell's read function problem
my program works with the type of threads I download anyways

>>53909477
>implying JSON scrapping is the same as JSON interpreting
>>
File: did it.png (9 KB, 416x449) Image search: [Google]
did it.png
9 KB, 416x449
>>53909344
Better than mine.
First is for during the game, and the last shows all the locations once the game ends.

Sloppy as fuck, but at least I figured it out how to solve it. Here how it looks in code/practice
def map_builder(player):
visited = []
for room in CELLS:
if player == room:
visited.append("OO")
elif room in hold:
visited.append("XX")
else:
visited.append(" ")

print("Here is the map of the dungeon, you are at {}".format(player))
print("____________________________")
print("|",CELLS[0],"|",CELLS[1],"|",CELLS[2],"|")
print("| {} | {} | {} |".format(visited[0],visited[1],visited[2]))
print("----------------------------")
print("|",CELLS[3],"|",CELLS[4],"|",CELLS[5],"|")
print("| {} | {} | {} |".format(visited[3],visited[4],visited[5]))
print("----------------------------")
print("|",CELLS[6],"|",CELLS[7],"|",CELLS[8],"|")
print("| {} | {} | {} |".format(visited[6],visited[7],visited[8]))
print("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯")
del visited

def end_map(player):
visited = []
for room in CELLS:
if player == room:
visited.append("OO")
elif room in hold:
visited.append("XX")
elif monster == room:
visited.append("MM")
elif door == room:
visited.append("DD")
else:
visited.append(" ")
print("Here is the map of the dungeon, you are at {}".format(player))
print("____________________________")
print("|",CELLS[0],"|",CELLS[1],"|",CELLS[2],"|")
print("| {} | {} | {} |".format(visited[0],visited[1],visited[2]))
print("----------------------------")
print("|",CELLS[3],"|",CELLS[4],"|",CELLS[5],"|")
print("| {} | {} | {} |".format(visited[3],visited[4],visited[5]))
print("----------------------------")
print("|",CELLS[6],"|",CELLS[7],"|",CELLS[8],"|")
print("| {} | {} | {} |".format(visited[6],visited[7],visited[8]))
print("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯")
>>
>>53909455
i don't understand why you guys are so nasty around here?
I don't think my code is spaghetti
pic related, it might be unreadeable to a degree, but I don't see how thats important since I'm not gonna release it (plus, I know how it all works)
>>
>>53909651
Why don't you just use a real programming language?
>>
File: 1457666437515.jpg (50 KB, 499x488) Image search: [Google]
1457666437515.jpg
50 KB, 499x488
I'm working on a school assignment in C.

Currently I'm presented with two options:

->use a static (but global to the file) struct, such as "static struct example globalData;" that all the functions will operate on

->add in a "struct example this" to all the functions signatures

It's a small file not necessarily intended for reuse. What do /g/?
>>
>>53907281
Windows batch script for creating large sets of files while maintaining a naming convention
>>
>>53909666
define a "real programming language"
>>
>>53909683
Not that or Python
>>
>>53909670
There's nothing wrong with a global.h if it has some important forward decs and structs that that all your .c files will rely on.
>>
>>53909705
Brainfuck is a real programming lang?
Seems like you guys just wanna pile up on other language users for no reason
Tell me one legitimate reason you hate Python or Haskell?
>>
>>53909651
that's a nice tablet anon. is that cuneiform? perhaps you can log the debts owed to me at my urn shop.
>>
>>53909802
????
>>
>>53909802
>implying Haskell is ancient
It's arcane, not ancient
>>
>>53909892
It's gay if you ask me...
>>
>>53907281
Finally getting around to learimg DX 12

Ive made a box so far!
>>
>>53909925
don't jeb yourself
learn opengl instead
>>
>>53909358
use readEither instead of read
>>
>>53909968
>>
>>53910018
Its really not in the stdlib? I thought it was. Well, if you're ok with adding a dependency:
https://hackage.haskell.org/package/base-4.8.2.0/docs/Text-Read.html
>>
>>53909925
opengl is so much better tho
>>
>>53910103
thanks bud
>>
how do I into parsers theory?
>>
>>53909892
>what is ancient is now arcane

>>53909877
the point is if no one can read your code it better do something fucking amazing.
>>
>>53910183
im just a newfag
I can into syntax, but I can't into design, which is beyond langs anyways
where do I learn that?
>>
>>53910206
http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612

gold standard.

>I stole mine from my college library
let's see those faggots come find me.
>>
>>53910230
>object oriented
ill do it when I learn Java
>>
>>53910253
are you just trying to meme you faggot?

you aren't funny. lurk more and don't pollute /dpt/.
>>
>>53910276
no, I have to learn Java in the future for uni
therefore, I though it'd be better if I read the book after I learned Java's principles and syntax
>>
>>53910314
Oh fuck are you the Haskell kid?

My apologies, I didn't realize you were retarded.
>>
i'm sitting here in my dress with nothing to do, like a ferrari revving in neutral
>>
>>53910358
pics of you posing with your code?
>>
>>53910347
why r you so nasty?
anyways, obviously, it'd be me given the conversation
>>
>>53910358

Write a recursive descent parser.
>>
File: 954634532.jpg (23 KB, 200x200) Image search: [Google]
954634532.jpg
23 KB, 200x200
>>53910380
oh i'm nasty alright.
>>
>>53910418
im going ot be nasty, it seems its the only way to succeed in /g/
anyways, you're such a fucking faggot, holy shit
>posting anime
go back to /a/, loser, how many pillows did you buy with your good boy points
>reccommending object oriented programming
hahhaah, this just gets better
>using OOP seriously
have fun making twenty instances and cobble it up together you fucking nigger faggot
we all know C, Haskell, and any non-object oriennted programming language are the only ones that matter
again, go back to /a/, or as I like to call it, /reddit/
also
>he has 2000 pictures of one anime girl
pathetic
>>
Well, I just got done writing a Win32 routine to load a dialog box with the system font and size.

As it turns out that involved a song and dance involving patching resource files in memory to a spec from some MS employee's blog. But hey, now my program blends in with your system better than 99% of programs AND it does so on Windows 95. Because that's totally needed in the year 1995+21.
>>
>>53910347
Why's he retarded?

>>53910373
yes pls

>>53910418
stobbit u baga ://DDDD
>>
how many traps are in this thread right now?
>>
>>53910490
>>>/h/
>>
>>53910490
Do I count if I've only started transitioning?
>>
>>53909514
I'm willing to bet a function that's used by thousands other than you isn't flawed, rather your reasoning around it is flawed in some way. Don't worry though, Haskell is a tough langauge!
>>
>>53910522
no, once you start taking hormones you're no longer cute, you're an abomination

also >>>/soc/
>>
File: hacker.png (255 KB, 600x561) Image search: [Google]
hacker.png
255 KB, 600x561
>>53910522
shit are you serious lol

>>53910146
I never even used a textbook, there's a ton of great resources just on Wikipedia and Google

>>53910544
Nah man, it's the Haskell standard library I'm sure, us /g/ kids are pretty smart. I routinely uncover tens of GCC bugs a week in programming C++ but I never report them
>>
File: 25232352.jpg (55 KB, 520x700) Image search: [Google]
25232352.jpg
55 KB, 520x700
>>53910474
You know what anon, you're right, I was being nasty. I'm sorry.

Stay on the righteous path to success that is functional programming and don't ever look to the future for answers. You should also be easily employable given the wide usage of your language.
>>
>>53909651
Your code is so fucking spaghetti it's falling out of your pockets. Even your editor's background color is spaghetti. Learn a useful language and stop messing around, you need to get a job at some point.
>>
>>53910562
>>53910566
rused you guys somethin good
>>
File: hurrr.jpg (55 KB, 600x1104) Image search: [Google]
hurrr.jpg
55 KB, 600x1104
>>53910581
>>
>>53910474
Can you leave my /g/ and come back when you're 18?
>>
>>53910587
No, I'm actually retarded. Just not a trap.
>>
>>53910544
it must be my hand-written parser then
I'd have to look at it
>>53910567
but im learning haskell for fun, not for a job
>>53910578
mine isn't spaghetti, its just unreadeable
learn the difference, kike
>>53910598
>>>/reddit/
>>
>>53910613
>mine isn't spaghetti, its just unreadeable

A typical consequence of spaghetti code.
>>
>>53910642
>implying his code wasn't fettuccine
>>
File: xdress.png (1 MB, 1702x2471) Image search: [Google]
xdress.png
1 MB, 1702x2471
>>53910600
Oh. Well it would have been interesting if you were

How do you guys feel about Oracle? Specifically, why are they the worst company on Earth?
>>
>>53910648

Fettuccine is actually one of my favorite foods :3
>>
>>53910642
>I can't understand it therefore its spaghetti
kys
spagghetti is chunks of innefficient code scattered around and somehow made to work together
my source code it modularized into tasks it does, as evidence by the comments
try agan pal
>>
File: 743534523.jpg (333 KB, 1467x1100) Image search: [Google]
743534523.jpg
333 KB, 1467x1100
>>53910656
mostly because the company is owned and operated by Mammon.
>>
>>53910648
>>53910676
I literally just had 3 lbs of fettuccine alfredo and feel bloated AS FUCK. Holy shit.
>>
>>53910696

Yeah it tends to do that. But hey, it's a good food coma.
>>
>>53910696
Throw it all up anon, you fat fucking pig
>>
File: frog.gif (199 KB, 336x468) Image search: [Google]
frog.gif
199 KB, 336x468
So we're coming up on the summer, right boys and girls? Most of you should have an internship by now if you're in college.

What's your internship plans for the summer?

>>53910696
fucking christ, 3lbs, try not to die
>>
>>53910696
please escort yourself to a hospital!
you are dangerously close to becoming italian.
>>
>>53910684
Doesn't need to be inefficient, it needs to look like shit (it does) and barely work (your code doesn't even work as evidenced by your posts). Your code is probably inefficient too.

Just accept your code's spaghetti and move on mate, to a real language.
>>
>>53910710
ruby impostor pls go
>>
>>53910724
>implying I'm not a NEET living in perpetual summer
>>
>>53910696
how are you going to fit into your dress if you keep eating so much, anon?
>>
>>53910748
>Most of you should have an internship by now if you're in college.
>if you're in college.
>you're in college.
>college
>NEET
>>
>>53910724

No internship plans. Gonna be working on personal projects.

>>53910744

Give me a few minutes. I'll post with my offrails tripcode on my laptop. I'm on my phone right now, so I can only use my secure tripcode.
>>
>>53910759
>Implying I haven't dropped out but am still living in my dorm because it's payed for
>>
>>53910759
you fucking retard. you're the Haskell kid aren't you? god dammit I wish hiro moot would give us a vote ban in threads.
>>
>>53910735
its not innefficient
anywyas, stop hating on my choices
I just really like FP, ok
are real langs Java and C#?
>>
>>53910782
If you want to do FP do OCaml or a Lisp. Those are actual languages that are used for actual shit outside of academia.
>>
File: nagisa.jpg (40 KB, 480x749) Image search: [Google]
nagisa.jpg
40 KB, 480x749
>>53910770
I'm not that Haskell kid you're referring to, but I do know Haskell (more or less... I solve Euler problems with it). I actually don't come to /dpt/ that often anymore.
>>
>>53910782
C is the one true language
>>
>>53910792
ok sorry. NEETs aren't in college though...
>>
>>53910811
That was my point
>>
File: 22.jpg (32 KB, 314x289) Image search: [Google]
22.jpg
32 KB, 314x289
>Django is an MVC framework. However, throughout the code, the controller is called view, and the view is called template. The view in Django is the component which retrieves and manipulates the data, whereas the template is the component that presents data to the user. For this reason, Django is sometimes called a Model Template View (MTV) framework.

Why change the terminology if both achieve the same purpose, and MVC was already stabilished?
>>
>>53910807
but we must evolve anon!
>>
File: gradpy.jpg (45 KB, 695x431) Image search: [Google]
gradpy.jpg
45 KB, 695x431
Can I parse HTML with regex?
>>
>>53910839
https://www.google.com.br/search?q=parse+HTML+with+regex&ie=utf-8&oe=utf-8&gws_rd=cr&ei=kesFV-eoPIKkwATBrKKoBQ
>>
>>53910839
nononono absolutely not
search stackoverflow for rationale
>>
>>53910724

>tfw no internship with a company
>finishing up website for grad student
>paid $10 an hour
>tfw probably graduating in August

I feel like I am probably fucked for interviews when all I have had is 1 job designing a website for some dude.
>>
No.

<insert DPT edit of [X]HTML regex parsing zalgo copypasta that has yet to be made>
>>
>>53910770
>we should have upboats and dowboats gaise
>im totally not from reddit
>>
>>53910850
I looked at those results, but they don't seem to answer my ques̛tión̡.
>>
what does the future of programming look like?

templates everywhere? types 95% abstracted thread-safety an accepted standard? main functions that look like
int main()  {
start
spawn
go
}


with the pajeets writing all your data structures for you what will you do with your free time?
>>
>>53910885
http://blog.codinghorror.com/parsing-html-the-cthulhu-way/
Literally the first page.
>>
Writing a catgirl bot that I can talk to in group chats and play games. Wish me luck friends
>>
>>53910889
the future is Java
the future is now
for(String arg : args) {
try(BufferedReader f = new BufferedReader(new FileReader(new File(arg)))) {
>>
Where do you get your technology and programming news from, /dpt/? So far i've only used code project's mailing list.
>>
>>53910790
I though Ocaml wasn't even used
I heard some people here say Lisps are shit
>>
>>53910854
>>53910867
>>53910889
ẁow, ͢this҉ i͏s͝ ͜no fu͠n

everyone here is way too serious
>>
>>53910889

Writing optimized code. We're hitting the physical limits of silicon. The future of performant computation MUST come from software, and not from hardware.
>>
>>53910949
Software is only getting more bloated as newcomers are being brainwashed into thinking library languages are the only way to do things and pointers are the devil.
>>
>>53910949
more cores ::DDDDD
>>
>>53910896

How well do you understand probability theory?
>>
>>53910873
here's how the thread vote ban would work:
>if a post sucks you can down vote it
>no one can see down votes
>each unique IP can only downvote another unique IP once per thread
>if an IP gets X downvotes he is banned from that thread for Y time
>each unique IP can only down vote Z posts
>X and Z are determined based on the speed of the board
>still no upvotes, as it should be

I guess for fast generals it wouldn't make a huge difference. It would be funny though. And after the lel's wore off it would be a fairly useful feature. God forbid they actually add more features to this site, we just get shitty April fools jokes.
>>
File: partay.gif (276 KB, 240x287) Image search: [Google]
partay.gif
276 KB, 240x287
>>53910943
Oops, third one meant for >>53910895

>>53910949
We're not hitting the limits of silicon, we're hitting the limits of single-core silicon. Parallel computing still has quite a ways to go, but the changes necessary to use it must come from software. In other words, no free lunch anymore.
>>
>>53910917
https://news.ycombinator.com/
https://slashdot.org/
http://hackaday.com/blog/
first two should be kinda standard, I guess
>>
>>53910982
Fuck off, reddit.
There's nothing stopping a dedicated autist from buying a network of cheap VPSes and coordinating them to ban people they don't like.
>>
>>53910967

Anon, we're hitting a limit on how small we can make transistors. We can only add so many cores.

Unless you're suggesting we start giving everyone motherboards with multiple sockets for CPUs

(even then, Node.js and Python, and all of these other noob-friendly languages don't play well with multi-core)
>>
>>53910982
no, i wanna have the freedom of being retarded while also making serious posts from time to time
>>
>>53910949
if we really can't figure out a way to advance hardware we are going to enter a technological dark age. code that truly needs to be optimized already is.
>>
what the fuck is Ruby on Rails? I heard that buzz worded around a lot a few years ago but not much anymore.
>>
>>53910997
I only ever browsed reddit on high school computers because it wasn't blocked. also it was kind of fun back then because it was digg vs reddit and digg was for fags.

to solve that problem though you only allow a certain number of downvotes per thread, board, and site per ID. they should at least fucking test it.

>>53911013
worst case you get booted from a thread and go to another one. if you got booted from something like /dpt/ for trolling you'd just wait for a new one.
>>
>>53911015
Dude we're working on quantum computers. Chill out
>>
>>53911027
it's a MVC website framework based on Ruby
>>
>>53910985
Thanks, didn't know about them.
>>
>>53911044
If you want that shit then go to a different site.
>>
>>53911045
>what is alchemy
>>
>>53911002
beyond the fact that there's a limit to the usability of
>moar cores
in software.
>>
>>53911045
>what is VR?
We don't even need computers anymore sometime soon, because everyone is using VR then
>>
>>53911015

The majority of code that people use on a regular basis runs like ass. This will need to be improved.
>>
>>53911095
You realize how retarded that statement is, right?
>>
>>53911069
thats the attitude that keeps us stagnant though. I'll admit it, I'm attached to this site. I've blown months worth of hours here. I've seen some pretty epic shit and really felt like I was at the beginning of some movements. Of course I have no proof and of course I can never really tell anyone, but I know.

4chan has had real power from time to time. It would be a shame to watch it stagnate and die.
>>
>>53911115
Please leave.
>>
>>53911095
quality post, pajeet
>>
>>53911111
nice repeating digits thing

anyways, are there ANY good piece of software out there? There has to be a masterpiece out there (in this day and age).
>>
>>53911115
I wanna watch you stagnate and die.
>>
>>53911111
>real ruby is back
yeah, of couse. but if we only start realizing like 5% yearly improvements in hardware performance software development will stagnate eventually as well. we're just writing to what they give us after all and coming from a world of 50% per year improvements.
>>
>>53911119
>>53911129
see you faggots could've vote kicked me already.

doesn't anyone remember the lel's of counter strike source vote kicking? it was a fucking good feature. i'll stop now.
>>
>>53911150
I can think you're fucking brain dead and still think you should be allowed to be here.
Thread replies: 255
Thread images: 35

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.