[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: 39
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>52107255

What are you working on, /g/?
>>
Posted in last thread.

How do I motivate myself to learn a programming language? I did some C in college last year but haven't touched anything since. What do I do?
>>
Threadly reminder that coding is not the proper term to use when referring to the act of programming

You are a programmer not a coder
While programming you produce code
>>
>>52111886
Before the bump limit.

REEEEEEEEEEEEEE
>>
Based trap threads
>>
>>52111903
Motivation is not programming related
>>>/adv/

Try working on projects you actually care about though
>>
File: 1451001555606.png (272 KB, 470x624) Image search: [Google]
1451001555606.png
272 KB, 470x624
Daily reminder that there is nothing wrong with multi-threaded linked list stack implementations.
>>
>>52111908
Daily reminder that if you are this autistic, you are not cut out for life
>>
>>52111936
Then fucking post yours already
>>
>>52111908
While programming you should produce programs. If you can only produce code you might as well kill yourself now and end your suffering.
>>
>>52111903
I'll rephrase this actually.

I absolutely loved the module, came out top of my class in terms of grades too. But how do I continue? Should I continue learning C or try and learn some scripting language like Python?
>>
>>52111946
sure thing redditor
>>
File: uui9.png (481 KB, 626x988) Image search: [Google]
uui9.png
481 KB, 626x988
What CSS does /dpt/ recommend for 4chan?

This what I got so far:

#azk91603, .ad-plea, .middlead, .bottomad, .aboveMidAd, .belowLeaderboard, #delform > hr:nth-child(7),
.absBotDisclaimer, #footer-links, .boardList, #blotter,
[style="width: 728px; height: 90px; display: table; border: 1px solid rgb(52, 52, 92);"],
[style="width: 448px; height: 60px; padding: 0px 10px; display: table; border: 1px solid rgb(52, 52, 92);"] {
display: none !important;
}


I would like to move replies to the bottom of posts next.
>>
>>52111886
kill yourself

>>52111909
you better get used to posting them around 290-300. the de facto standard is to keep the thread posted near the bump limit and delete subsequent threads as they are to be considered duplicates. the only way to reduce the occurence of trap threads is to post early threads of your own. i would have posted a thread myself if it weren't for the fact that i'm going to bed now. have fun :^)

>>52111908
web devs and python users are coders
>>
>>52111946
XD DUDE WANNA GO WRITE SOME CODE?
>>
>>52111981
>reduce the occurence of trap threads
but we want more trap /dpt/s

>post early threads of your own
inciting shitposting and spamming the board

get out
>>
>>52111966
this

>>52111946
and this
>>
File: Coders.jpg (70 KB, 612x612) Image search: [Google]
Coders.jpg
70 KB, 612x612
>>52111988
>>
>>52111981
>web devs and python users are coders
>>
>>52111988
>>52112004
no seriously, your autism knows no bounds, and you care too much about other people, and about what people on the board you share think
>>
>>52112019
Fuck off, brodowner.
>>
>>52112011
they produce code. they don't make programs. they make markup shit and simple scripts. they are neither professional nor hobbyist programmers.
>>
>>52111968
This is a dumb question. If you have an interested in C, continue with C. If you have an interest in Python, do Python. If you want to learn a programming language to get a job, read some job offerings to see what they want.
>>
>>52111936
>linked list
>implemented as stack
What the fuck?
>>
File: a-day-in-the-life.jpg (133 KB, 980x400) Image search: [Google]
a-day-in-the-life.jpg
133 KB, 980x400
>>52112019
>>52112004
>>
>>52112036
>>52112054
>choosing to restrict yourself from an identity because of how others perceive this
I'm so sorry you're so insecure
>>
File: this triggers the assburger.png (66 KB, 998x1132) Image search: [Google]
this triggers the assburger.png
66 KB, 998x1132
>>52112019
>>52111946
he's an assburger, not an autist. assburgers are as stupid as normies and will incessantly and stubbornly nitpick on trivial little shit that doesn't fucking matter.
>>
>>52112077
C O D E
R
U
N
C
H
>>
>>52112049
Making your stack a linked list means no stack overflows unless you run out of memory.

typedef struct _frame {
int data;
struct _frame *next;
} frame_t;

typedef struct _stack {
struct _frame *head;
unsigned size;
} stack_t;

void stack_push(stack_t *stk, int data)
{
frame_t *frame = (frame_t *) malloc(sizeof(frame_t));
frame->data = data;
frame->next = stk->head;
stk->head = frame;
stk->size += 1;
}

int stack_pop(stack_t *stk)
{
if (stk->head == NULL)
printf("Stack empty.\n");
frame_t *frame = stk->head;
int data = frame->data;
stk->head = frame->next;
stk->size -= 1;
free(frame);
return data;
}
>>
>>52112080
Oh right, I did feel the difference
>>
File: 1046.jpg (52 KB, 471x694) Image search: [Google]
1046.jpg
52 KB, 471x694
c++
what is the difference between
struct
{
string text1 = "foo";
string text2 = "fooo";
}foo;

and
struct foo
{
string text1 = "foo";
string text2 = "fooo";
};
>>
>>52112080
>just overwriting the previous results with the new results
ew
>>
Why is /dpt/ still called /dpt/ if it isn't actually daily?
The old thread is less than 5 hours old.
>>
File: coder_projects.jpg (51 KB, 640x250) Image search: [Google]
coder_projects.jpg
51 KB, 640x250
>>52112077
wow dude u r right i have been lookin at this world wrongly this whole time!!! guess i need 2 do more codin...
>>
>>52112102
I like that stack_pop checks for NULL and then just proceeds to use it anyways.
>>
>>52112102
Have you ever heard of vectors?
>>
>>52112134
not sure if pretending or seriously assburger
>>
>>52112047
I don't care about any language in particular, that's why I'm asking. I have no idea where to start so I can just start learning about programming instead of start learning language x or y.
>>
>>52112140
This is literally a vector if you keep traversing stk->head->next->next.... and so forth
>>
>>52112117
>>52112117
first one just declares a "foo" variable that has a text1 and text 2 variable as its structure

second one declares a reusable type. Not a variable. which allows you to later go on and declare instance of the "foo" type like
foo fooins;
foo fooins2
>>
>>52112130
/dpt/ stands for /dog petting thread/
>>
>>52112102
Oh.
You meant a stack implemented as a linked list.
I thought you were referring to the other way around.
>>52112140
Vectors aren't thread safe.
>>
File: de.jpg (8 KB, 480x360) Image search: [Google]
de.jpg
8 KB, 480x360
>>52111925
>As a Libertarian
>I believe private weapon companies should be free to sell weapons to enemies of the state
>I believe there should be no public roads or property
>I believe the mentally ill should have easy access to recreational drugs
>>
>>52112130
Daily implies like a regular, ongoing thing, like your life.
Your daily chores are called "daily" even if you don't do them daily.
>>
>>52112172
Do a project you actually care about and preferably with others.
>>
>>52112119
unless you have the right text so that it will align perfectly at the intersections, it's inevitable for one text to go "on top" of the other(s)

>>52112130
A S S B U R G E R

>tfw you couldn't do the full LONDON because Error: Our system thinks your post is spam. Please reformat and try again.
>>
>>52112180
I mean a dynamic array, usually called a 'vector'.

>>52112187
Linked lists are no more thread safe than dynamic arrays.
>>
>>52112182
thanks man
>>
>>52112218
Should I consider trying to contribute to projects on github and the likes?
>>
>>52112222
those are my second quads today. i really am done for today. g'nite folks :^)
>>
>>52112080
There's something off with your circles senpai.
>>
>>52112195

Everybody should be armed. Everybody.
>>
>>52112225
His implementation of the stack isn't thread safe, but the initial post was about multithreaded stacks implemented as linked lists.

Incidentally, multithreaded queues ARE implemented as linked lists.
>>
>>52112244
It's because he calls it coding not programming desu family
>>
>>52112248
What about the clinically insane?
>>
>>52112222
put it in a code block
L  O  N  D  O  N
O
N
D
O
N

the sticky no longer mentions abusing code tags
>>
>>52112263
how did you post senpaitachi, senpai?
>>
>>52112234
Sure, why not
>>
>>52112248
Shut up cuck, you have your flaws too.

>>52112266
He's being sarcastic.
>>
>>52112244
if you use for example bresenham's circle drawing algorithm, the circles will not align correctly at the intersections because of the geometry of the flower of life.
>>
>>52112266
Depends, where do you draw the line?
>>
>>52112288
People who are or were wards of the state because of their illness sound like a pretty good generic line to me, though I'm not him.
>>
>>52112281
Weird, perfect circles line up properly on paper.
>>
>>52112253
>Incidentally, multithreaded queues ARE implemented as linked lists.
Yeah, that makes sense.

If anon wanted to make thread-safe code all he would have to do is add a mutex. Or if he really wanted to travel down the rabbit hole a lock-less list is the simplest lock-less ADT to make.
>>
>>52112314
yes but now you have "pixels" in the form of a grid of chars. you can't draw perfect circles like this.
>>
Do you professional programmers do a lot of stuff on the side?

Some days I have that itch to solve shit, others I want to kill myself if I look at a screen some more.
>>
>>52112326
Well maybe your circles aren't big enough.
>>
>>52112277
>Shut up cuck, you have your flaws too.

What are you talking about?

>He's being sarcastic.

No, I'm not.
>>
>>52112330
sounds pretty normal
>>
>>52112330
After spending like 8-10 hours staring at emacs at work I usually don't want to come home and work on anything unless I really get the itch. I tinker on weekends mostly.
>>
>>52112348
>No, I'm not.
Oh, I'm sorry. I was giving you the benefit of the doubt, I didn't know you were actually retarded.
>>
Dumb question, which I don't know how to search for on google:

Is there a file extension that defaults to opening a file in the web browser, as an URL?
>>
>>52112288
I'm not sure, but I would assume there are people out there who definitely aren't fit to own guns (i.e. most republicans). Arming everyone seems careless.
>>
File: bjarne2.jpg (25 KB, 293x324) Image search: [Google]
bjarne2.jpg
25 KB, 293x324
>>52112373
>I didn't know you were actually retarded.

Praise the lord and pass the ammunition.
>>
File: 37.png (92 KB, 969x1145) Image search: [Google]
37.png
92 KB, 969x1145
>>52112345
making them larger would indeed improve their appearance, or in the case of bresenham circles improve the approximation of the flower of life. but i would have to piece together several screenshots or concoct the image in some other way and i can't be bothered doing that right now. good night, for real this time
>>
Haven't been to this thread in years. What do you guys who program games use (discounting raw sepples+opengl and SDL). Love still can't target web afaik, but snowkit's too immature. Maybe I should stop being lazy and do shit in javascript
>>
>>52112345

That's part of the problem. If he drew them in terms of actual pixels (SDL/SFML, Graphics/C#, Graphics2D/Java, etc) he'd have circles which were a lot more accurate.
>>
>>52112402
raw sepples+opengl
>>
File: iu.png (320 KB, 940x720) Image search: [Google]
iu.png
320 KB, 940x720
>>52112271
>the sticky no longer mentions abusing code tags
Does that mean we should put all our posts in code tags from now on senpai?
>>
>>52112402
unity lad
>>
>>52112373
Gun grabbers pls go
>>52112387
>but I would assume there are people out there who definitely aren't fit to own guns (i.e. most republicans)
Opinion discarded.
>>
>>52112382
.htm
.html
possibly .url
maybe more, don't know
>>
>>52112413
yes but you fuck up the flower of life pattern because the circles are supposed to be a certain distance and angle away from each other
>>
>>52112387
This is the greatest irony to me. Republicans are the front runners for gun ownership yet most of them are unstable old codgers who should never be allowed near a gun.
>>
>>52112422
now you're getting it
>>
>>52112435

More accurate circles would result in a more accurate flower of life.
>>
>>52112435
wait nvm i see you're talking about actual pixels. indeed with a higher resolution y'all niggas wouldn't be so upset about the circles
>>
>>52112428
>Gun grabbers pls go
Sorry, but gun ownership should only be allowed for people who can trace their ancestry back 5 generations or more.
>>
File: 1450500917998.jpg (21 KB, 480x319) Image search: [Google]
1450500917998.jpg
21 KB, 480x319
>>52112428
>Gun grabbers pls go

Amen. I just got some 30-30 reloading supplies. It feels good.
>>
>>52112427
Last ludum dare I followed was the one where chrome deprecated extensions and everyone panicked. At that time, prevailing opinion seemed to be that unity's HTML5 export was shit. Has it gotten substantially better in the past year or so?
>>
>>52112486
>At that time, prevailing opinion seemed to be that unity's HTML5 export was shit.
everything about unity is shit
>>
>>52112102

Implementing a stack as a vector also means no overflows unless you run out of memory.

>>52112195

>I believe private weapon companies should be free to sell weapons to enemies of the state
No. As a general rule of thumb, aiding someone whom you know to be committing a criminal act is, in and of itself, a criminal act. Aiding someone who has declared war against your people is treason. The proper role of government is to protect the people's rights to life, liberty, and property. Part of this role requires maintaining an active military, and may even require an offensive role against groups that have attacked us in the past.

>I believe there should be no public roads or property
The constitution actually has clauses for public roads and property. If we consider that the government must protect the people's rights, sometimes via a military, this logically requires an infrastructure to support said military. How do you move tanks and troops around a country without roads?

>I believe the mentally ill should have easy access to recreational drugs
Yes.
>>
>>52112508
Kewl. Enjoy programming in Lua where typos create a new variable that's initialised as nil then.
>>
>>52112523
lua and love2d are also shit

use raw opengl seriously or at least use something a bit better than unity like ue4 or cryengine 3
>>
Shut the fuck up about guns.

If I gave a crap about weapons I'd be on /k/.

You're all offtopic af.
>>
Is that guy who says you need to implement every library before you use them here now?

I wonder what he's doing.

Browsing 4chan on his home built OS no doubt.
>>
>>52112568
There are programming threads, but also threads for programmers to discuss other topics in the company of like minded people.
>>
>>52112570
>not writing your own os
Wow I thought that was kind of a thing everyone did
>>
>>52112570
using shit like unity is for literal children

there's a handful of examples of games that are considered decent. but for example the city building game has all custom game logic and only uses unity for the graphics and input. and the graphics are shit like everything is made out of blurry clay. seriously unity is so fucking overrated
>>
>>52112551
>raw opengl
>not lambdacube

I remember when haskell was the in-thing around these parts. Where's that fox comic at? Can't find that shit on google.
>>
>>52112430
>possibly .url
I tried that, but it requires a bunch of html/css

All I want is something like test.url, where the url is the content of the file. Does nothing like this exist?
>>
>>52112568
>Shut the fuck up about guns.

If you don't like guns, then you're a piece of shit.
>>
>>52112514
Daily reminder that tripfags constantly espouse shit. And dont even know the constitution.
>>
>>52112612
Windows shortcut to URL, or this http://superuser.com/questions/538089/how-to-create-cross-platform-internet-shortcut-files
>>
>>52112656
do guns run Lisp?

I didnt think so.

fuck guns
>>
>>52112605
>>52112605
>>52112570
>custom game logic and only uses unity for the graphics and input

You mean to say the engine will stick to being an engine instead of programming my game for me? What a swizz.
>>
>>52112760
>do guns run Lisp?

You could make a fancy one that did.
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52112958
Can we add nim to this list?
>>
>>52112659

The only claim I have made about the constitution is that it has clauses for public roads and property. To this, I direct you to Article 1, Section 8.

>>52112760

With all due respect, most intelligent gun owners don't want a "smart" gun. They shouldn't run any software at all.

>>52112523

There are more options to game development than just Lua and Unity.
>>
>>52112958
>python
>bash
>>
File: 1451204435267.jpg (38 KB, 349x352) Image search: [Google]
1451204435267.jpg
38 KB, 349x352
>>52113006
>They shouldn't run any software at all.
>>
Daily reminder that self driving cars have to decide who to kill in an accident
>>
>>52112907
Writing in lisp is essentially shooting yourself in the foot, so you could call it a gun
>>
>>52112958
>No idris, agda, coq, elm, or benis.
>>
>>52113077
Someone hasn't read their SICP today.
>>
>>52113079
Great additions to the list of meme languages
>>
>>52112958
Where is javascript?
>>
How do I make a kernel?
>>
>>52112958
>D is included
>Rust is not
>>
>>52113069
ok
>>
File: 1446426477711.jpg (29 KB, 176x242) Image search: [Google]
1446426477711.jpg
29 KB, 176x242
>>52113069
>>
>>52112958
>no go
>>
>>52113154
become the biggest asshole you can
>>
>>52113154
Follow the instructions on the OSDev wiki
>>
>>52113154
Avoid good languages and only use C
>>
>>52113185
That post treated Go like Go treated the last 30 years of language design research.
>>
>>52113154
https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf

>>52112688
Thanks man
>>
>>52113058

Yes. A proper firearm is purely mechanical, and always reliable.
>>
>>52113069
>Tfw you modify the firmware to target minoritys
>>
>>52113254
>A proper firearm is purely mechanical, and always reliable.

One of the only places I don't like computers. In cars, they're a mixed blessing.
>>
>>52113259
What if you're the minority?
also relative to what?
>>
>>52113287
Minority always means coloreds
>>
Has anyone every reverse engineered a USB device protocol to get data off of it? It's basically an RFID reader but doesn't simulate keypresses - it keeps the data on the device until it gets some command and then sends it over. Manufacturer has an expensive ass SDK so I just want to try writing shit to it (knowing full well I could stumble across something that starts rewriting the firmware, bricking the thing).
>>
hey /dpt/

how much of your time spent "programming" is on average spent thinking/working through the problem you're trying to solve rather than actually physically entering code?
>>
Somebody rate my style, I want to know if I'm doing anything wrong.
http://pastebin.com/FLpd1M1C
>>
File: dfg.png (27 KB, 568x465) Image search: [Google]
dfg.png
27 KB, 568x465
Wahey, I've moved the replies to the bottom of posts.

$( document ).ready(function() {
$(".backlink").each(function() {
var id = "p" + $(this).attr("id").substring(3);

$(this).prepend("<hr>");

$("#" + id).append(this);


});

$(".backlink").addClass("show");
});


Don't think it works with update though. :(
>>
>>52111886
im learning about lists and shit in python.
I've never programmed before.
>>
Is Haxe a meme?
>>
>>52113369
What

Just use wireshark bro
>>
>>52113504
What does that even mean

Haxeflixel is mature but uses OpenFL
Snowkit could be the cat's tits but is poorly documented right now
>>
Is it possible to write games without oop? How the fuck
>>
>>52113550
Why would you want to?
>>
>>52113550
Programmers have been using OOP constructs and design patterns long before OOP was a thing.
>>
>>52113550
>what is functional programming

Go check out the haskell engine the team who worked on starbound are making
>>
>>52113518
Wireshark won't see anything until I write to it
>>
>>52113550
Easy, don't use inheritance, just records.
>>
>>52113575
Starbound is shit and not even a finished product
>>
>>52113550
Yes but that's a long and painful process.
>>
>>52112610
Traps BTFO'd. And you should too, pseudo-scientist.
>>
>>52112610
Haskell killed itself by being a pure functional language
>>
Ate breakfast for the first time in a long time and it's lunch time now and I feel sick as fuck

Is this normal
>>
Daily reminder that GCaml deprecates OCaml
>>
>>52113721
>what is the IO Monad
>what is unsafePerformIO
>>
>>52113422

Depends on the problem, but as a general rule of thumb, more than 50 percent of development time is not spent programming.
>>
>>52113797
>but as a general rule of thumb, more than 50 percent of development time is not spent programming.

Did you pull that thumb straight out of your ass?
>>
>>52113779
not good enough
>>
>>52113779
>implying IO is the only set of operations that need to be impure
k lad your Haskell wins. Go home and re-write the windows kernel with it. Don't come back until you're done.
>>
>>52113847
Anon pls, he's a tripfag, we must value his opinion.
>>
from time import sleep
import requests
import json
wait = 60
limit_dpt_threads = []
while True:
r = requests.get('https://a.4cdn.org/g/catalog.json')
j = json.loads(r.text)
dpt_threads = []
for page in j:
for thread in page['threads']:
if ('/dpt/' or 'daily programming thread') in (thread.get('sub', '').lower() or thread.get('com', '').lower()):
dpt_threads.append(thread)
for thread in dpt_threads:
if thread['replies'] >= 290 and thread['replies'] <= 320 and thread['no'] not in limit_dpt_threads:
print('Thread No.{} is nearing the bump limit. It has {} replies. Get ready to post a new one, faggot.'.format(thread['no'], thread['replies']))
limit_dpt_threads.append(thread['no'])
print('Waiting {} seconds'.format(wait))
sleep(wait)

Now I'll always be ready to post trap /dpt/s
>>
>>52113880
between 290 and 32

Kill yourself
>>
>>52113880
Change 290 to 250 or so imo
>>
>>52113880
>not in Haskell
Look, a traitor of its kind.
>>
>>52113880
Open the browser window and display a notification too. Or even better get 4chan pass and have it automatically create a thread.
>>
>>52113934
from time import sleep
import requests
import json
warn_at = 250
bump_limit = 320
wait = 60
limit_dpt_threads = []
while True:
r = requests.get('https://a.4cdn.org/g/catalog.json')
j = json.loads(r.text)
dpt_threads = []
for page in j:
for thread in page['threads']:
if ('/dpt/' or 'daily programming thread') in (thread.get('sub', '').lower() or thread.get('com', '').lower()):
dpt_threads.append(thread)
for thread in dpt_threads:
if thread['replies'] >= warn_at and thread['replies'] <= bump_limit and thread['no'] not in limit_dpt_threads:
print('Thread No.{} is nearing the bump limit. It has {} replies. Get ready to post a new one, faggot.'.format(thread['no'], thread['replies']))
limit_dpt_threads.append(thread['no'])
print('Waiting {} seconds'.format(wait))
sleep(wait)
>>
>>52113864
There are already kernels written in Haskell. House comes to mind but I think there are plenty more. Haskell isn't an ideal systems programming language due to the arcane ghc knowledge you need to be able to predict how memory will be used. Rust is the language you should be using.

Also, kill yourself.
>>
>>52114000
Notice how only the trips fag likes Haskell
Coincidence?
>>
>>52114037
>kernels
>side effects out the ass
what
>>
>>52114037
>Rust
>sjw shit should be used, he says
We all know who has to kill himself here.
Protip: you
>>
Daily reminder that nothing stops you from programming in rust and ignoring their code of conduct


yet
>>
>>52114015
now use paplay/mpv to playback a notification sound, like https://www.youtube.com/watch?v=AKJh7IpV-4c
>>
File: 8u.jpg (50 KB, 640x360) Image search: [Google]
8u.jpg
50 KB, 640x360
>>52113880
>>52114015
That's nice, anon.

I look forward to the drama.
>>
>>52114076
>the politics of the people who make software effect whether I should use them.
>herp derp Steve Klabnik no platformed Moldbug from taking about Urbit at Strangeloop I'll never use anything he's touched
>why didn't Steve understand politics and software aren't relevant to each other

Your posts are low effort and I hope you feel ashamed.
Go suck a dick whist watching Lessig talk about how "Code is Law", it'll do you good.
>>
File: 1424552405676.jpg (59 KB, 607x520) Image search: [Google]
1424552405676.jpg
59 KB, 607x520
Java makes me want to put a bullet in my skull.

I miss Python.
>>
>>52114146
Why?
>>
>>52114146
>going from Python to Java
Do you have any fucking dignity at all?
>>
Why doesn't this work?
It gets stuck in an infinite loop.
#include <stdio.h>
#include <omp.h>

int main(void)
{
static long num_steps = 1000000;
enum { NUM_THREADS = 2 };
double pi = 0.0;
double step = 1.0 / (double) num_steps;
omp_set_num_threads(NUM_THREADS);
#pragma omp parallel
{
int i, id, nthrds;
double x, sum;
id = omp_get_thread_num();
nthrds = omp_get_num_threads();
int nthreads = id;
if (id = 0)
nthreads = nthrds;
id = omp_get_thread_num();
nthrds = omp_get_num_threads(); /* ??? */
for (i = id, sum = 0.0; i < num_steps; i += nthreads)
{
x = (i + 0.5) * step;
sum += 4.0/(1.0 + x * x);
}
#pragma omp atomic
pi += sum * step;
}
printf("%lf\n", pi);
}
>>
>>52114146
Casual.

More seriously, read Effective Java, it's like Good Practice The Book, 8/8. You can find that shit on library genesis or with a cursory google
>>
>>52114140
Fine, get cucked then.
>>
>>52113880
your organization is shit
>not separating the logic, output, and data collection

enjoy your tight coupling
>inb4 furfags
>>
btw from what I've seen rust has quite a lot of features

syntax and naming don't look great
>>
File: play.webm (433 KB, 1366x768) Image search: [Google]
play.webm
433 KB, 1366x768
Tiny little 2048 clone in Go and GTK3
Runs on Linux and Windows, now adding in some CSS to make the playgrid thing look nice
>>
>>52114200
>go
>>
>>52114158
>if (id = 0)
>=
>>
File: 1447453632658.jpg (30 KB, 403x497) Image search: [Google]
1447453632658.jpg
30 KB, 403x497
>>52114210
>>
>>52114113
>>52114008
from time import sleep
import webbrowser
import requests
import json
import wave
warn_at = 250
bump_limit = 310
wait = 60
limit_dpt_threads = []
while True:
r = requests.get('https://a.4cdn.org/g/catalog.json')
j = json.loads(r.text)
dpt_threads = []
for page in j:
for thread in page['threads']:
if ('/dpt/' or 'daily programming thread') in (thread.get('sub', '').lower() or thread.get('com', '').lower()):
dpt_threads.append(thread)
for thread in dpt_threads:
if thread['replies'] >= warn_at and thread['replies'] <= bump_limit and thread['no'] not in limit_dpt_threads:
print('Thread No.{} is nearing the bump limit. It has {} replies. Get ready to post a new one, faggot.'.format(thread['no'], thread['replies']))
limit_dpt_threads.append(thread['no'])
webbrowser.open('https://boards.4chan.org/g/')
print('\a') #play ASCII bell character - https://en.wikipedia.org/wiki/Bell_character
print('Waiting {} seconds'.format(wait))
sleep(wait)
>>
>>52114223
I like your smug anime collection
>>
why do people like python so much?
i dont think its really any easier to read, and afaik its a pretty average language
>>
>>52114200
Pretty cool, could you share the code
>>
>>52114254
you dumb nigger you can figure the url to the source from the webm
>>
>>52114215
thanks...

is multithreading a meme?
>>
>>52114254
https://github.com/Soreil/2048
It is a bit ugly
>>
>>52114271
>is multithreading a meme?
No, but it can often cause more problems than it solves.
>>
>>52114271
>is multithreading a meme?
anon pls, it's almost 2016
>>
>>52114267
Take a break dude, deep breaths, maybe a shower.
>>
>>52114271
>is ____ a meme?
stop asking this shit. you're not a fucking retard. clarify your question so it means something.
>>
>>52114247
Because it runs code even if it doesn't fully work. Most people are too lazy to read compiler errors, even though it speeds up workflow.
>>
>>52114271
Yes, there can only be one /dpt/. Multiple threads ruin everything.
>>
>>52114271
>is multithreading a meme?
anon pls, it's actually 2016
>>
>>52114237
>his shit program just keeps getting bigger
>still coupling tighter than one of his trap's anuses
>>
>>52114247
Low barrier to entry, very rich ecosystem, and the other general advantages of network effects.
It's a descent scripting language although perhaps no better than JavaScript.
>>
>>52114326
Decouple it
>>
>>52114353
MVC nigga
>>
>>52114237
>ASCII bell
i tried this but it doesn't do anything
>>
File: 4cha.png (16 KB, 725x335) Image search: [Google]
4cha.png
16 KB, 725x335
>:D
>>
I really feel like this is a shitty way to check if a thread has been updated and it doesn't work with auto update tbqh.

$("a[data-cmd='update']").click(function(){
setTimeout(function() {
var interval = setInterval(function(){
console.log($("#delform > div.board > div.navLinks.navLinksBot.desktop > span").text());
if( $("#delform > div.board > div.navLinks.navLinksBot.desktop > span").text() !== "Updating...") {
clearInterval(interval);
moveReplies();
}
}, 250);

}, 1);
});


Is it shit, /dpt/?
>>
>>52114381
>parsing HTML
>>>/OUT/
>>
>>52114237
whitespace is hard
>>
>>52114381
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
>>
>>52114423
>API Terms of Service
>>
>>52114391
>>52114422
>>52114423

You just hate to love D
>>
Best way to make this code better?

#include <iostream> 
using namespace std;

int getNumAccidents(int, int, int, int, int);
void findLowest(int, int, int, int, int);
int main()
{
int north=0, south=0, east=0, west=0, central=0;
getNumAccidents(north, south, east, west, central);
return 0;
}
int getNumAccidents(int north=0, int south=0, int east=0, int west=0, int central=0){
//ask the user the input for number of accidents for each region
do {
cout << "How many accidents for north? \n";
cin >> north;
} while (north < 0);
do {
cout << "How many accidents for south? \n";
cin >> south;
} while (south < 0);
do {
cout << "How many accidents for east? \n";
cin >> east;
} while (east < 0);
do {
cout << "How many accidents for west \n";
cin >> west;
} while (west < 0);
do {
cout << "How many accidents for central \n";
cin >> central;
} while (central < 0);
findLowest(north, south, east, west, central);
return north, south, east, west, central;
}
void findLowest(int north=0,int south=0, int east=0, int west=0, int central=0){
//Finds the least region and displays figures
if (north < south && north < east && north < west && north && central)
{
cout << "North is the least at " << north << " figures" << endl;
}
else if (south < north && south < east && south < west && south < central)
{
cout << "South is the least at " << south << " figures" << endl;
}
else if (east < south && east < north && east < west && east < central)
{
cout << "East is the least at " << east << " figures" << endl;
}
else if (west < south && west < east && west < north && west < central)
{
cout << "West is the least at " << west << " figures" << endl;
}
else if (central < south && central < east && central < west && central < north)
{
cout << "Central is the least at " << central << " figures" << endl;
}
}
>>
>>52114156

What's wrong with that progression?
>>
>>52114391
>>52114423
but he is using the API
read before shitposting
>>
>>52114499
Nice triple dubs

>>52114497
jesus christ the repetition
>>
>>52114499
Python to C#

>>52114497
your find lowest method is extremely ugly and can be done by any sorting method. I would recommend putting the north-west variables into a map and sorting it to find the lower
>>
>>52114497
the point of programming is to reduce repetition
>>
>>52114499
Nothing. Are you planning on going to Javascript next?
>>
File: 1423606138172.jpg (24 KB, 421x407) Image search: [Google]
1423606138172.jpg
24 KB, 421x407
>>52114530

Thanks I didn't even notice.
>>
File: 1449729851402.png (42 KB, 614x340) Image search: [Google]
1449729851402.png
42 KB, 614x340
>Start learning Python
>Get errors because my whitespace wasn't correct (lol?)
>Quit Python
>>
>>52114497
use a map fgt.
Use two if you have to.
>>
>>52114665

Considering the sheer amount of python code that has been written and works, If you cant correctly indent python maybe you shouldn't program.
>>
>>52114699
>"Correctly" indent

Indenting is a matter of preference
>>
>>52114715
No it is syntax in python
>>
>>52114715
There are no preferences under god emperor Guido.

Begone, heretic.
>>
>>52114683

It could just as easily be a vector of simple structs. It could be a lot of things, really.
>>
>>52114497
something like
map getNumAccidents() {
for direction in {N, E, S, W}:
accidents[direction] = read "how many accidents for $direction?"
return accidents

direction findLowest(map accidents) {
lowest = accidents[N]
for direction in {E, S, W}:
if (lowest < accidents_map[direction]):
lowest = accidents_map[direction]
return direction
>>
https://en.wikipedia.org/wiki/Lisp_machine
These look cool as fuck
>>
>>52115376
they're shit though
>>
File: Untitled.png (10 KB, 498x330) Image search: [Google]
Untitled.png
10 KB, 498x330
Created a guessing game. Does this count as a small project? Should I add it to my github account?
>>
>>52115473
>cmd
Nigga, at least use Powershell
>>
>>52115473
i just created one too. should I add it to my github too?
getNumAccidents() {
for direction in {N, E, S, W}:
accidents_map[direction] = read "how many accidents for $direction?"

findLowest() {
lowest = accidents_map[N]
for direction in {E, S, W}:
if (lowest < accidents_map[direction]):
lowest = accidents_map[direction]
>>
>>52115473
>small project
I'd say it's more of a toy program.
>add it to my github account
why not?
>>
>>52115619
*
#!/bin/sh

i=$(($RANDOM % 100))

g=-1
while [ $g -ne $i ]; do
read g
if [ $g -lt $i ]; then
echo "higher"
elif [ $g -gt $i ]; then
echo "lower"
fi
done
>>
>>52115619
>what are higher order functions
>>
File: fizz.jpg (31 KB, 638x359) Image search: [Google]
fizz.jpg
31 KB, 638x359
>>52115473
Created a fizzbuzz. Should I add it to my github account /g/ ????
>>
>>52115840
personally, if I was HR and I saw a github full of babbies first toy programs copied out of a programming book, i'd trash their resume
>>
File: 1444519185838.jpg (122 KB, 425x516) Image search: [Google]
1444519185838.jpg
122 KB, 425x516
>>52114282
>Christ-chan 128
My dude.
>>
>>52115473
Sure but post the code here first so I can grill you.
>>
this openmp thing is pretty cool, I don't even have to worry about race conditions.
#include <stdio.h>
#include <omp.h>

int main(void)
{
static long num_steps = 1000000000;
double pi = 0;
double step;
int i;
double x, sum = 0.0;
step = 1.0/(double) num_steps;
omp_set_num_threads(2);
#pragma omp parallel for reduction(+:sum)
for (i = 0; i < num_steps; i++)
{
x = (i + 0.5) * step;
sum = sum + 4.0/(1.0 + x * x);
}
pi = step * sum;
printf("%lf\n", pi);
}


>single threaded
3.141593
real 0m8.329s
user 0m8.320s
sys 0m0.000s


>multithreaded
3.141593
real 0m4.267s
user 0m8.388s
sys 0m0.000s
>>
>>52115840

let (|None|) x = x

let (|Fizz|Buzz|FizzBuzz|None|) = function
| x when (x % 15 = 0) -> FizzBuzz
| x when (x % 3 = 0) -> Fizz
| x when (x % 5 = 0) -> Buzz
| x -> None x

[|1..100|] |> Array.iter
(function
| FizzBuzz -> "FizzBuzz"
| Fizz -> "Fizz"
| Buzz -> "Buzz"
| None x -> x.ToString()
>> System.Console.WriteLine)
>>
>>52116106
ffs keep forgetting reply box isn't monospaced
how do i into monospace
>>
>python meme
I genuinely do not respect anyone who thinks python is a good language.
>>
>>52116063
Switch to Rust
>>
>>52116126
no
>>
>>52116166
Then enjoy your sub par multithreading :')
>>
>>52116184
Don't you have a code of conduct to enforce?
>>
>>52115946

Good thing no one actually scrutinizes github accounts
>>
>>52116200
It would really be a shame if you were to avoid the future of systems/multithreaded programming because you're transphobic
>>
>>52116106
Sensible edition:

let (|Factor|_|) y = 
function
| x when (x%y = 0) -> Some (x%y)
| _ -> None

[|1..100|] |> Array.iter
(function
| Factor 15 _ -> "FizzBuzz"
| Factor 3 _ -> "Fizz"
| Factor 5 _ -> "Buzz"
| x -> x.ToString()
>> System.Console.WriteLine)
>>
File: 1438549251542.png (483 KB, 497x732) Image search: [Google]
1438549251542.png
483 KB, 497x732
>>52115946
>describes my github
I'm trying
>>
File: 1432323884812-0.png (26 KB, 431x499) Image search: [Google]
1432323884812-0.png
26 KB, 431x499
>>52115840
>>52116106

#include <stdio.h>
#include <inttypes.h>

int main()
{
for (uint_fast8_t i = 0; ++i < 101;)
printf(i % 3 ? i % 5 ? "%" PRIuFAST8 "\n" : "Buzz\n" : i % 5 ? "Fizz\n" : "FizzBuzz\n", i);
}
>>
>>52116206
Trannies and SJW types have literally contributed nothing but shitposting to any project ever. It's an extreme form of bikeshedding - they can't contribute shit to real discussions so they make themselves into victims in order to get the attention they can't legitimately earn.

I honestly don't think I've ever seen these people write a single line of code. They just chase away real developers then claim the remnants of projects as their own work since they're the only ones still around.
>>
>>52116352
Ew
>>
File: 1441904861342.jpg (481 KB, 1920x1080) Image search: [Google]
1441904861342.jpg
481 KB, 1920x1080
At what point should I make a GitHub? I haven't made anything original, just uni assignments and stuff out of textbooks.
>>
>>52116352
for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i
Thread replies: 255
Thread images: 39

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.