[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: 33
File: shig pee.jpg (133 KB, 960x624) Image search: [Google]
shig pee.jpg
133 KB, 960x624
Old thread at >>51990371

What are you working on, /g/?
>>
First for iteration
>>
Second for c++ = lua
>>
Third for faggotry (Haskell)
>>
>>51997021
c++ + lua
>>
Thank you for not using an anime picture.
I've had a traumatic experience with anime when I was a child, and anime pictures evoke those unpleasant memories.
I wasn't able to participate in half of the threads during the last year.
>>
int avg(int a, int b)
{
return (a/2) + (b/2) + (a%b%2);
}
>>
>>51997039
What happened, anon?
>>
http://a.pomf.cat/srkghc.webm
>>
File: Unbenannt.png (838 KB, 602x917) Image search: [Google]
Unbenannt.png
838 KB, 602x917
>>51997048
the best method I've seen yet. prove me wrong, pro tip: You cant

Also pic related. I thought it was a meme, but it's true
>>
>>51997048
Correct solution:
>>51994579
>>
>>51997086
Correct solution:
int avg(int a, int b){
return 0.5*a + 0.5*b;
}
>>
>>51997066
My brother was a huge anime fan, and we used to watch anime together in his room when I was a kid.
One day when were were watching an anime, my mom came into the room and started yelling at him for not having a job and being a disappointment. They fought and yelled for a long time, while I was sitting there watching anime, trying to be as quiet as possible and ignore the whole thing.
After a while my brother got really pissed off, said something very nast to my mom and stormed back into the room, almost breaking the door when he shut it. As he was walking to the computer, he slipped on his lube covered Tenga onahole, fell and broke his neck against the figurine shelf.
He fell right in front of me, and was staring me right into the eyes as he slipped into darkness while default joshikousei nyan was playing in the background.
I will never forget his face.
>>
13th for python is comfy
>>
>>51997149
Kek
>>
>>51997149
What happened to his onahole afterwards? Was it just thrown away or did you continue the legacy?
>>
>>51997217
Mom threw out all of his figurines, manga collection and other stuff, sold his PC. Having those as a reminder was too much for her to bear.
And she told me to never, ever watch "those japanese cartoons". It was her dying wish, in fact.
>>
>>51997239
What happened to her?
>>
>>51997239
>never, ever watch "those japanese cartoons"
Well, you're lucky they are actually mongolian. Although I can see that ignoring you mother's deathbed wish on a single technicality may feel cheap to you.
>>
>>51997262
After brother died, father blamed her for his death and left.
She started drinking heavily, and eventually died from liver failure.
>>
>>51997285
How did your dad die?
>>
>>51997305
I don't even know whether he's alive or not, I've lost all contact with him. And honestly I don't care.
>>
>>51997285
How did your father die and then leave?
>>
>>51997319
It it because you can't forgive him for molesting your sister?
>>
>tfw ocaml will never do multicore
;_;
>>
File: quite a ruff victory.jpg (46 KB, 653x510) Image search: [Google]
quite a ruff victory.jpg
46 KB, 653x510
Hello and good day, /dog petting thread/.
I would like to create an emulator. Which platform should I emulate, that is just a tad more advanced than Chip8?
Thank you, and may you have many more ruff victories over the shitpaw shitlords.
>>
>>51997239
Have you ever thought about getting into furry shit, bad dragon fleshlights and such?
>>
>>51997336
ps4 pls
>>
>>51997336
>animals which step all over their shit and lick piss off the floor are not shitpaws
>unlike the cleanest animals in the animal kingdom
LMAO dogfags!
>>
>>51997336
dos
>>
File: a ruff victory.jpg (65 KB, 500x368) Image search: [Google]
a ruff victory.jpg
65 KB, 500x368
>>51997353
Back to shitting in a box in the kitchen you go! My dog which doesn't exist smells wonderful, while your entire house smells like shit.
>>
File: Untitled.png (392 KB, 701x612) Image search: [Google]
Untitled.png
392 KB, 701x612
>>51997353
Also, are you just too lazy to pull yourself away from your chinktoons to train your dog a little bit? It isn't hard to teach them not to shit and piss inside. Hell, I taught my retarded corgi how to shake a paw in literally 1 hour.

Also holy fucking shit what is this captcha? what is going on?
>>
when a function has a reference parameter, what is passed to a functions data area when the function is called in c++?
>>
>>51997331
It will anon, just be patient.
>>
>>51997424
a pointer
>>
What are these kind of labels called? i know that some assembler uses them and i want to implement them in my own, i'd imagine they'd be useful in if-else blocks, but i don't know what they're called, local and relative labels are already taken.
blah blah
@:
blah blah
jmp +@ // Jump to the first @ label forwards.
@:
blah blah
jmp -2@ // Jump to the second @ label behind us.
>>
>>51997469
[citation needed]
>>
File: 1.jpg (65 KB, 1177x680) Image search: [Google]
1.jpg
65 KB, 1177x680
Exercise for my parallel programing course.

main: http://pastebin.com/1KqXzKjW
vektor.h: http://pastebin.com/3653SBKj
data.h: http://pastebin.com/iqNz4Kk6

Caluclates the orbit of the solar system planets with the GPU and OpenMP for the CPU operations, also takes care of the symmetry from the forces matrix. You can see the mars halfway through after one year.
>>
>>51997523
Multicore is the future. OCaml will adapt.
>>
>>51997563
Multicore is the present. Multicore has been the present for the past 20 years. Ocaml has yet to adapt.
>>
>>51997563
nice meme

running multiple threads only makes sense for certain tasks or for running entirely different tasks concurrently
>>
>>51997563
You misspelled out of order execution.
>>
>>51997424
References are implemented with pointers. They're just pointers that can't be null and can't be redirected, but of course they can still be invalidated.
>>
>>51997628
Pytard detected. How you like dem apples?
>>
>>51997649
https://en.wikipedia.org/wiki/Amdahl%27s_law

there is an inherent limit to how much you can speed up a given task using parallelism and there is overhead in using multithreading in and of itself. even if you get better overall throughput with a multithreaded solution, it's very possible that you get a much worse worst-case latency.
>>
File: Gustafson.png (93 KB, 976x685) Image search: [Google]
Gustafson.png
93 KB, 976x685
>>51997702
>Amdahl's law only applies to cases where the problem size is fixed. In practice, as more computing resources become available, they tend to get used on larger problems (larger datasets), and the time spent in the parallelizable part often grows much faster than the inherently serial work. In this case, Gustafson's law gives a less pessimistic and more realistic assessment of parallel performance.

https://en.wikipedia.org/wiki/Gustafson's_law
>>
File: 1450732367480.jpg (530 KB, 2880x1800) Image search: [Google]
1450732367480.jpg
530 KB, 2880x1800
Does anyone know what theme this is? Or a similar theme for pycharm?
>>
>>51997083
>prove me wrong
why? you are obviously baiting.
>>
https://doc.rust-lang.org/book/dining-philosophers.html

This shit is ridiculously complex. I guess that's the price paid for the concurrency guarantees in Rust.
>>
>>51997594
>>51997628
>>51997634
No it's the future. Today developers who can handle multithreading correctly are very rare.
>>
>>51998035
The need for it is right now, no matter if most people are too stupid to grasp it.
>>
>>51998052
So OCaml have time to adapt.
>>
>>51997534
>course
what year?
>>
>>51998035
99% of all use cases do not benefit from multithreading. Only stateless software like webservers benefit from it.
>>
>>51998035
Probably, but none of them are ocaml developers. lel.
>>
>>51997959
Doesn't seem complex at all, maybe a bit too verbose/clusterfuck syntax but that's Rust for you.
>>
>>51997048
Floating point exception (core dumped)

nice solution
>>
>>51998085
but in those 1% of cases it's extremely useful. They day you work on a project that could really benefit from it is the day you'll be sorry for using ocaml, and not something like F#.
>>
>>51997702
>who cares about a free 6x+ speedup?
>here's an unrelated wikipedia page that doesn't have any relevance
>I WIIIIIIIIIIIIN!
>>
>>51997944
The Cancer theme. Keep posting and it'll come to you automatically.
>>
>actually arguing against multithreading
Fuck off Intel.
>>
>>51998142
I use neither. Sure, multithreading is really useful on some occasions like webservers. Too bad multithreading goes the route of OOP. It's overused and increases complexity.
>>
>>51998035
Multicore and parallelism don't need to care about multithreading, we have tons of nice higher-level abstractions instead. Moreover, 99% of people in fields where computational performance matters already employ multithreading without issue. Multicore is not going to help a game much since the great majority of the work is handled on the GPU (obviously, you were referring to game devs since they're the only ones not employing parallelism primitives right).
>>
>>51998085
>99% of all use cases do not benefit from multithreading.
>>
>>51998163
>Too bad multithreading goes the route of OOP. It's overused and increases complexity.
Who cares? So long as a good programmer can use it well, what does it matter? Shit programmers are gonna be shit no matter what the paradigm.
>>
>>51998179
>Multicore is not going to help a game much since the great majority of the work is handled on the GPU
Oh god. please stop talking about stuff you know nothing about.
>>
>>51998179
>Multicore is not going to help a game much
Buddy, you have no idea. The biggest bottleneck nowadays besides the cache is actually issuing commands to the GPU, and the new APIs like D3D12 and Vulkan make it possible to basically smash that bottleneck out of the park by allowing it across multiple threads.
>>
>>51998204
The irony in this post is so thick, a knife couldn't cut through it.
>>
>>51998221
>by allowing it across multiple threads.
Hence why multithreading is not going to help a game yet, since current frameworks won't allow it, and the bottleneck is rendering and not AI.
>>
>>51997944
How long do you want to keep shitposting? By that time you could've already recreated it. lazy fuck
>>
>>51998179
>Multicore is not going to help a game much since the great majority of the work is handled on the GPU

Are you fucking stupid? Sure the rendering work is done on the GPU but how about physics, resources management, networking or anything like that? That's not gonna be running on the GPU dipshit.
>>
>>51998154

Wow, I actually thought someone answered it and got excited; thanks asshole for contributing nothing society like a true neet faggot.
>>
>>51998276
You are fucking furious kid
>>
>>51998179
even game programming gems 1 released in 2000 containing articles from you know, industry professionals and not random anonymous internet people talks about how multithreading is becoming increasingly necessary
>>
>>51998183
True, but most programmers are absolute shit and only use paradigms because they're hip. That's why OOP is now the norm.
>>
>>51998253
Go on...

The unreal engine for one is highly multithreaded on the CPU side. Rendering is multithreaded. Physics is multithreaded. Many other game engines do the same thing. There's a reason the last two generations of game consoles have multicore CPUs.
>>
>>51998268
Mantle has existed for a while now. D3D12 is a current API. Vulkan will be in a matter of months. All of them report massive speed ups building command buffers across multiple threads.

And even besides bottlenecks, you can make huge gains in simulating physics or doing pathfinding especially using multiple threads.
>>
>>51998288
And if you're a good programmer, the paradigms shit programmers sue should not affect your decision making whatsoever.
>>
>>51998179
>Multicore is not going to help a game much since the great majority of the work is handled on the GPU

lel, k tard.
>>
>>51997149
>default joshikousei nyan
I looked up the song to read the story to :)
>>
; in nasm u can set org
org 0xfaggot


; how you set code segment in c?
#define org 0xfaggot

do I do it in the source code?
or do I have to make some bullshit linker script?
>>
>>51998035
>>51998052
super meme

>>51998085
this
>>
>>51998129
nigga >>51997048 doesn't have anything to do with floats. something else is wrong with your program
>>
>lower case Java OOP shill has included multi threading FUD in his repertoire
>>
>>51998155
>hurr if your programmers weren't so stupid you could make anything run fucking amazing on muh poorfag 8 core (4 FPU) CPU
>>
>>51998204
most current games are GPU limited you dip
>>
>>51998288
No, OOP is the norm because it makes complex software manageable.

But you won't really discover that until you move beyond working as a one-man team in your mom's basement.
>>
>>51998508
SIGFPE isn't necessarily limited to floating point arithmetic. Try the following:
int main(void) { return 1/0; }

It will also throw a SIGFPE.
>>
>>51998549
And this implies multicore is not used in games much how?
>>
>>51998531
That's what tends to happen, yes. It's typical to have an 8-module FX beating or closely matching a 4-core i7 with HT that costs twice as much simply due to scalable multi threading.
>>
>>51998513
gayms are often poorly programmed but you can't necessarily get say a 64x speedup or even a 4x speedup with a 64 core processor over a fast single core processor. any gaymer knows that it's mainly the GPU that determines the performance you get in most current gayms.
>>
>>51998579
Said the Java developer.
Give me a good example on how OOP saved your day.
>>
>>51998596
multicore gets used but you can't take an arbitrary task and split it up into infinitely small pieces to be executed in parallel. that would require time travel.

>>51998600
not all applications are highly scalable for multithreading.
>>
>>51998624
>but you can't take an arbitrary task and split it up into infinitely small pieces to be executed in parallel.
No one is claiming that you fucking retard.
>>
>>51998583
oh

it should probably make sure b != 0 or something

>tfw we still don't have a good solution for averaging two ints in C
>>
>>51998610
Of course not, but a speed up is a speed up. And you can guarantee that the ratio of gains to extra cores is going to skyrocket with the switch to the new APIs and as GPUs get faster. Take the "infinitely fast GPU" simulation in D3D12, where cores are completely saturated.

>>51998624
If they aren't scalable for multi threading, they're not going to scale with better IPC, either. Because that means they're truly limited by I/O, GPU, etc.
>>
>>51998653
>If they aren't scalable for multi threading, they're not going to scale with better IPC, either. Because that means they're truly limited by I/O, GPU, etc.
you shove a dildo up your ass. you remove it from your ass. you lick the shit off the dildo.

you can't do those in parallel. you can't lick the shit off the dildo before you've had it up your ass. you can't remove it from your ass before you've inserted it up your ass.

but you can do that sequence of events faster, with better IPC.
>>
>>51998680
Can you show to me that boring, absolutely serial applications are that wide spread?

Because saying "not all" something is pointless if the vast majority still is.
>>
>>51998644
>>tfw we still don't have a good solution for averaging two ints in C
Well at first, this isn't only a problem in C - any language has the same problem unless arithmetic is lifted to an entirely different abstraction level.
Secondly we have lots of solutions, but nobody actually cares.

These two are essentially the same:
int avg2(int x, int y) {
int sum = (x / 2) + (y / 2);
int mod = (x % 2) + (y % 2);
sum -= (sum > 0) * (mod == -1);
sum += (sum < 0) * (mod == 1);
return sum + mod/2;
}

int avg1(int x, int y) {
int sum = (x / 2) + (y / 2);
int mod = (x % 2) + (y % 2);
int nsig = (sum < 0) - (sum > 0);
return sum + nsig * (nsig == mod) + mod / 2;
}


This one depends on the platform
int32_t avg3(int32_t x, int32_t y) {
return ((int64_t)x+y)/2;
}


This one is garbage to read
int avg5(int a, int b)
{
int t = (unsigned)(a^b)>>(INT_BITS-1);
return ((a/2+b/2+(a%2+b%2)/2)*!t) | (t*(((t*a)+b)/2));
}


They all perform about the same, except the platform dependent one - it's faster by about 200 to 230%.
>>
>>51998710
Sorry, meant 100 to 130%.
>>
File: output (1).webm (391 KB, 1920x1080) Image search: [Google]
output (1).webm
391 KB, 1920x1080
I made a Langton's ant based wallpaper.
>>
>>51998700
>the vast majority
outside of things like movie rendering, program compilation, running a server, controlling particles/swarms individually, i don't know of many applications that scale well with more than a few cores.
>>
>>51998724
not everything has to scale well. If 4 extra cores makes something in your game 20% faster, then why not use it? To the end user, the game is just faster.
>>
>>51998723
spasm/10
>>
>>51998710
Out of the platform independent ones avg1 is the fastest by about 16%
>>
File: 20151222_175647.jpg (1014 KB, 2048x1152) Image search: [Google]
20151222_175647.jpg
1014 KB, 2048x1152
I just coded a networked Hello World in Go
>>
>>51998724
>i don't know of many applications that scale well with more than a few cores.
You can't prove a claim through ignorance.
>>
>>51998743
sure you can find uses for 4 threads or so. one for input, one for physics, one for rendering, one for audio. but 8, 16, 32 threads? sure you could use them for adding more entities like in those DX12 and vulkan demos i guess
>>
>>51996984
>be me
>have a big college project with a real customer
>9 persons during 10+ month at ~30 hours per week
>customer ask for non-exotic languages
>it's probably going to be java
>if not, it's going to be PHP
>user interface is probably going to be web
>we are probably going to use some j2ee craps
>the j2ee framework we've seen in class is struts
>we didn't see any php framework in class

Is there any j2ee framework that doesn't suck? Or am i doomed to work with some shitty frameworks?
>>
>>51998761
it's obvious that many happenings, algorithms etc occur in a sequential order.
>>
Took a class, all was in Matlab. Now the final project supervisor insist on C++ which I don't really know much about because 'we need the performance'.

Now is there any straightforward approach to maintaining performance in C++ apart from learning all the language constructs?

So far all I can come up with is 'make everything that does not change const' and 'dont use recursion'
>>
>>51998778
>one for input, one for physics, one for rendering, one for audio
This is widely considered to be the worst way to multi thread a game, and basically isn't used. You must, and pretty much always can, break it down far more using a job model. Each job is something that is inherently serial and self-contained, but you generally have hundreds of jobs to chew through at the same time.

>>51998796
Sure, but I'd say most applications can benefit from running many instances of these serial algorithms at once.
>>
>>51998723
why would you want that as a wallpaper? its so fucking shit it gave me a headache instantly.
>>
Ruby I miss you, brose
>>
>>51996984
What are the best 3 books to learn C as a first language?
>>
>>51998846
Read K&R 3 times
>>
>>51998835
He died of autism. That's what you get for using Ruby.
>>
>>51998830
Dunno, I find the spasms amusing.
>>
>>51998778
>but 8, 16, 32 threads?
Yeah, some things won't scale as well then. I never claimed they would. I was just responding to people saying multithreading wasn't useful in games, which is laughably untrue.

Still, physics stuff can be parallelized over many threads to some degree. I can foresee developers finding ways to use up those extra cores for something.
>>
File: 295991-the_ilp_wall_fig4.jpg (19 KB, 576x268) Image search: [Google]
295991-the_ilp_wall_fig4.jpg
19 KB, 576x268
>>51998796
pipelining is pretty useful when you need sequential order.
>>
>>51998319
No, you can't, because physics typically uses the GPU and both pathfinding and physics are trivial to calculate in practice (pathfinding for obvious reasons and physics because very few frames get calculated and the rest is interpolated) and never bottleneck any game. Shows how much you know big guy.
>>
>>51998274
Not sure if retarded or just pretending.
>>
>>51998881
pipelining can only do so much. adding more stages will fuck your branch performance
>>
>>51998286
Too bad gpugems are not about games then, you might have had a point!
>>
Man, defining codata by their eliminator(s) using copatterns is so cool. Probably going to be tricky to compile down to LLVM, though.

codata Stream : Set -> Set
head : Stream a -> a
tail : Stream a -> Stream a




>>51998887
Mate, I just said that those weren't bottlenecks. They still speed up the game, or rather, allow you to do MORE of that stuff without slowing the game down.

>physics typically uses the GPU
Some parts of a physics pipeline do, like broad phase collision detection and integration. The nitty gritty parts of collision detection typically don't work on the GPU. Also, you have to be careful about going back and forth between the CPU and GPU too much, because there is a lot of latency.
>>
>>51998310
I like the fact that you show your intense ignorance so cucksurely. You are allowed to go back to reddit anytime where you'll be praised for being retarded.
>>
>>51998914
>game programming exists in this bubble completely removed from any other field
>>
>>51998924
Wow, I totally forgot to finish the first part.

codata Stream : Set -> Set
head : Stream a -> a
tail : Stream a -> Stream a

repeat : a -> Stream a
head (repeat x) = x
tail (repeat x) = repeat x

map : (a -> b) -> Stream a -> Stream b
head (map f xs) = f (head xs)
tail (map f xs) = map f (tail xs)
>>
>>51998319
Mantle lived for a few months and nobody used it. D3D12 is too new for anyone to use it seriously and not as an experiment to see if it is viable to use in real titles in the future. Vulkan isn't even out and will be in the same situation when it is.

If multicore was so useful, how come 90% of games are single-threaded, 8% of games use 2 threads, and 1% use 4?
>>
>>51998931
you bitter insults make me laugh anon. But I'm glad I was able to educate someone today.
>>
>>51998632
>No one is claiming that you fucking retard.
Backpedaling at the speed of light!
>>
>>51998855
Don't do this anon. K&R is good once you know some C or another programming language but before then get A Modern Approach by KNKing
>>
>>51998963
>Mantle lived for a few months and nobody used it. D3D12 is too new for anyone to use it seriously and not as an experiment to see if it is viable to use in real titles in the future. Vulkan isn't even out and will be in the same situation when it is.
Maybe stick to AMD vs. Nvidia threads where you're more comfortable and can spout memes without being called out.

>If multicore was so useful, how come 90% of games are single-threaded, 8% of games use 2 threads, and 1% use 4?
You've got me there. I can only attribute that to the original point, which is that most programmers simply aren't good enough to do that, and for the fact that you're probably including old games in that metric.
>>
>>51997512
Didn't you have your answer previous /dpt/?
>>
>>51998907
It really comes down to the problem, but in some cases pipelining can solve many problems. You can even have multiply pipelines which are interleaving depending on the branching.

>>51998982
I found "Introduction into Computer systems; from bits & gates to C & beyond", a introduction into computer science and C.

Anyways for people starting with parallel programming you should have a look at CSP, and read the Tony Hoare paper on it.
>>
>>51998952
>raytracing renderers are used in games gais pls believe me
>>
best resource for learning PHP? not something aimed at beginners pls
>>
>>51999087
Cyanide pills.
>>
What's a good no-nonsense linux distro for programming that doesn't require much maintenance?
>inb4 Arch or Gentoo
I used Gentoo for a few months but got sick of resolving emerge conflicts. I need a distro that can go on my laptop that I use a couple of days a week and no more.
>>
>>51999120
What's wrong with Arch?
>>
>>51999015
No, that guy was just being retarded.
>>
File: 1325134958287.jpg (49 KB, 400x566) Image search: [Google]
1325134958287.jpg
49 KB, 400x566
>>51999120
Debian
>>
>>51999135
I heard Pacman has some issues if you go too long without syncing. Is that true? If I can turn my laptop on after a week and sync everything without spending 10-15 minutes fixing shit, then Arch is probably OK.
>>
>>51999120
Gentoo.
>>
>>51999148
I never had that issue. The only thing to look out for is updating packages that might break the closed source graphics card driver.
>>
>>51999120
Gentoo with a Windows 10 VM
>>
>>51999148
>fixing shit
HAH! If only that was an option when not synching every 2 days at worst.
>>
>>51999120

Something Ubuntu based.

>inb4 that's for casuals
>>
>>51999148
I haven't upgraded in weeks

I used to upgrade every day a couple of times but now I have less time and everything keeps working just fine. You just need to be more careful about what gets upgraded
>>
>>51999176
>windows 10
>ever
>even in a VM
>even just with a compatibility layer
>>>/tumblr/
>>
>>51999180
Don't listen to war mongering amerifats.
>>
>>51999180
But Ubuntu is for casuals, GTP.
>>
>>51999197

I know it is, but that doesn't mean it's bad. It's low maintenance.

>>51999191
>war mongering

It's like you don't even know me.
>>
>>51999210
So you're not a burger?
>>
>>51999210
you may as well just use windows if you want something low maintenance
>>
>not computing the Fibonacci numbers in O(n) using corecursion
head fibs = 0
head (tail fibs) = 1
tail (tail fibs) = zipWith (+) fibs (tail fibs)
>>
>>51999241

I do, personally. On my linux machines I use debian. I also like [spoiler]FreeBSD[/spoiler], but that's sacrilege around here.

>>51999237

I am a burger, just not a war monger.
>>
>>51999241
depends what you're doing. If you need/want to use linux for any given reason, ubuntu is probably going to give you less headaches.
>>
>>51999271
That's not what Rodong Sinmun tells me boy.
>>
>>51999271
>I am a burger, just not a war monger.
that's bullshit. burger DO take pride of being warmongers...
anyway, what else can we expect from this anarcho-capitalist-nationalist-christian-statist.

>>51999120
if you use IDEs, install them separately. eclipse, for example, is a PIECE OF SHIT that will break every other week if you are using the version in the repos.
>>
>>51999364
Only on Arch.
>>
File: 1438816761548.png (80 KB, 500x421) Image search: [Google]
1438816761548.png
80 KB, 500x421
>tfw no gf
>>
>>51999364
>burger DO take pride of being warmongers...

Not at all. I think we should end our involvement in all these worldwide conflicts.

>what else can we expect from this anarcho-capitalist-nationalist-christian-statist.

You can expect me to be at least partially reasonable, that's for sure.

I may like my guns, but I'm not looking for war.
>>
>>51999455
>I like my guns
thank you for supporting the thriving arms industry that spills into everywhere else in the civilized world

when are you amerilards gonna learn that your toxic attitude to guns affects negatively everyone?
>>
>>51999452
>2015
>not realizing GF is open-source and a functional programming language
>>
>>51999568
>GF is functional
Imperative virgins BTFO
>>
how expensive is it to iterate backwards through a large buffer instead of forward? will the CPU line load a cache line at a time in the opposite direction or will it inefficiently offset the "bucket" in smaller increments than the cache line size?
>>
>>51999568
The "G" doesn't stand for gay, son.
>>
>>51999647
Profile it.
>>
>>51999648
ayy trap fags BTFO
>>
>>51999540
>thank you for supporting the thriving arms industry

You're welcome.
>>
>>51999647
>how expensive is it to iterate backwards through a large buffer instead of forward? will the CPU line load a cache line at a time in the opposite direction or will it inefficiently offset the "bucket" in smaller increments than the cache line size?
I might be mistaken, but the CPU doesn't offset memory before caching it, it caches a piece of memory and then move the offset in the cache line, no?
If that's the case, it should be the same.
>>
>>51999683
I'm not talking about that bullshit
I don't give a flying fuck about africa
>>
File: DjHMG313.webm (3 MB, 720x405) Image search: [Google]
DjHMG313.webm
3 MB, 720x405
Ask your beloved programming literate anything.

>>51998644
>>51998710
could you test this one ?

int average (const int x, const int y) 
{
if ((x > 0) == (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}


>>51997331
it already does through multi processing.
>>
>>51999764
Thanks for the suggestion. Shimoneta is a good anime.
>>
>only code snippets on thread are to average numbers
Holy shit what a garbage thread
>>
>>51999777
It's a meme that's spiraled out of control
>>
>>51999724

Now who's the inconsiderate one?
>>
>>51999764
>could you test this one ?
Neat, it's faster by about 33% than the other platform independent ones and passes all tests.
>>
>>51999804
touche
I did mention "civilized world" though, didn't I?
>>
>>51999777
I had some snippets about codata.
>>
>>51999777
it's harder than it looks
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
How do I learn JavaScript senpai?
>>
>>51999889
by offing yourself you shittaste weebshit.
>>
>>51999838
Well post them

These autists concerned with averaging numbers are driving me crazy, if you really need high precision arithmetic for the program you're writing then use one of the many existing libraries that exist for that. What's with this obsession over re-engineering the wheel? You'll never finish any of your projects if you have that attitude.
>>
>>51999901

>>51998955
>>51999259
>>
>>51999889
become a grill
>>
>>51999777
if you.lower() == "faggot":
print("there, now it's not just averaging ints in C.\n Happy?")
>>
>>51999889
Assuming you already know how to program.
Read this: http://www.w3schools.com/js/default.asp. Next up, create your own project.
>>
>>51999911
doesn't print anything wat do
>>
>>51999923
Have you tried turning it off and back on again?
>>
>>51999923
just be yourself
>>
>>51998508
he's obviously talking about that programs obvious divide by zero flaw.
>>
6x9 get
>>
No get
>>
>>51999923
just do it
>>
Go get.
>>
>>52000000
>>51999999
FUCK YOU
>>
>>51999901
>muh syntactically beautiful perfectly performant and precise solution
It's just code masturbation. These retards don't actually plan on writing applications that will be consumed by anyone other than their own sexually frustrated penis.
>>
Daily reminder that C is garbage.

https://sourceware.org/bugzilla/show_bug.cgi?id=19390
>>
File: g-senpai-notice-me.jpg (269 KB, 1366x768) Image search: [Google]
g-senpai-notice-me.jpg
269 KB, 1366x768
a-am I doing good senpai?

just started last night, read through intro, etc etc :333

how long until I become worthy of your love /g/?
>>
>>52000149
Off yourself, manchild.
>>
>>52000094
please explain how a bug in assembly code means C is garbage
>>
>>52000149
Not until you install intellij idea and switch to scala
>>
File: 1450611265064.jpg (537 KB, 1200x1264) Image search: [Google]
1450611265064.jpg
537 KB, 1200x1264
>>52000160
not until /g/ loves me
>>
>>52000163
>please explain how a flaw in the core part of C means C is garbage
>>
>>52000178
I'll love you when you're dead and your corpse is burned.
>>
>>52000149
Looks good apart from your indentation.

>>52000178
fuck off weeb
>>
>>52000094
Actually, that's an issue with glibc, not C itself.
>>
>>51999950
reminder that we're part of a toxic culture that will blow the fuck up in a few years
>>
File: 1450800062445-1.jpg (63 KB, 531x400) Image search: [Google]
1450800062445-1.jpg
63 KB, 531x400
>>52000218
What about the indentation? too much? too autistic? pic related, one day I hope /g/ will be as proud of me as pic related.
>>
>>51999889
code.org
>>
>>51999831
>I did mention "civilized world" though, didn't I?

Europe is full of muzzies now, so you can't be referring to it.
>>
>>52000285
you haven't indented after your main method, it looks like dog dicks
>>
>>52000285
//Class name always start with uppercase and rest of the word is lowercase (see CamelCase)
//Full uppercase names are for final variables
public class JPract {
//Consider putting all of this in a different method van main and calling that method from main
//That would just looks nicer
public static void main(String[] args) {
//Start with an indent at the start of a new method
double gallons, liters;

for (gallons = 1; gallons <= 100; gallons++) {
liters = gallons * 3.7854;
System.out.println(gallons + " gallons is " + liters + " liters.");

//No need to use a counter if it counts up as much as gallons (by 1)
//Instead you can just use modulo to see if another 10 gallons have passed
if (gallons%10 == 0) {
System.out.println();
}
}
}
}
>>
>>52000307
we let them in because we are a rich and tolerant society which feels able to share their wealth with the less fortunate

if you refer to the crime fueled by these elements in our society, well, if there's a gun, before reaching their hands, they were meant for a profitable market that you and your fellow amerilards encourage
>>
File: scala-logo.gif (16 KB, 635x282) Image search: [Google]
scala-logo.gif
16 KB, 635x282
Daily reminder that Scala is the best programming language ever created.
>>
>>52000516
s/best/worst
>>
>>52000543
Stay classy Javafags
>>
>>52000554
https://www.youtube.com/watch?v=uiJycy6dFSQ
>>
>>52000582
I will definitely keep this in mind for when I contribute to Scala's collections.

It it doesn't mean jack shit to the end user if something under the hood isn't designed in the most clean way possible ((for performance tradeoffs, btw)
>>
File: 1385792865025.png (304 KB, 722x768) Image search: [Google]
1385792865025.png
304 KB, 722x768
Where can I find some JS challenges to practice, /dpt/?
>>
>>52000625
Make your own. For instance: make a web scraper.
>>
>>52000505

You certainly have an unusual outlook on things.
>>
>>52000674
my views are shared by more than half the people I know irl
>>
>>52000674
The anon you replied to is batshit insane.
We don't 'share' our wealth, but we get robbed of our wealth.
>>
>>52000692

That's because you don't even have any conception of what it means to be armed. I know that Europeans on the internet go on and on about how barbaric things are in the United States, but that's because you haven't ever had the opportunity to BE armed. Go and ask someone who is 60, 70, or 80 years old in your country about what it was like. They were likely alive before the major gun bans occurred.

The bottom line is this: no guns, no freedom. know guns, know freedom.

Thanks for reading.
>>
>>52000702

I know. The socialist brainwashing runs deep.
>>
>>52000611
>It it doesn't mean jack shit to the end user
My sides just exploded!
>>
>>52000761
>It it
You didn't even manage to copy paste my post properly. Good job retard.
>>
What's a good programming animu, /dpt/?
>>
>>52000880
umaru
>>
Small program for 8-bit AVR microcontroller. It shows numbers 1..9 on a 7-segment LED display.

My next challenge is to connect an external A/D converter chip via a serial bus (i2c). No idea yet how to even begin working on that one. Ultimately I'd like to show the A/D converted value on the 7-segment display.

#include <avr/io.h>
#include "delay.h"

int main(void) {
/* Port B output */
DDRB = 0xFF;
PORTB = 0x00;

unsigned char num = 0x00;

while(1) {

switch (num) {
case 0:
PORTB = 0x7B;
break;
case 1:
PORTB = 0x18;
break;
case 2:
PORTB = 0x6E;
break;
case 3:
PORTB = 0x3E;
break;
case 4:
PORTB = 0x1D;
break;
case 5:
PORTB = 0x37;
break;
case 6:
PORTB = 0x75;
break;
case 7:
PORTB = 0x1A;
break;
case 8:
PORTB = 0x7F;
break;
case 9:
PORTB = 0x1F;
break;

default:
PORTB = 0x04;
break;
}

delay_msec(250);

if (num < 9) {
num = num + 1;

} else {
num = 0;

}
}
}
>>
>>52000786
THE IRONY
IT'S KILLING ME
>>
File: 346356365234.jpg (45 KB, 620x413) Image search: [Google]
346356365234.jpg
45 KB, 620x413
>>52000724
the problem is culture not "freedom"
like I never felt the need to see a gun, hold a gun, interact in any way with a gun -- the only time I've seen a gun in real life was part of a demonstration by the gendarmerie when I was in grade school
it's just not part of my system, not part of what I consider "freedom"
the only way a civilian can own a firearm here is by going through psychological evaluations and training programs with experts, getting a permit from the police and registering the firearm; and then he is limited to hunting rifles
I haven't heard of a crime committed with a hunting rifle that wasn't an accident acknowledged by both parties. If it's a crime where guns are involved, the guns got inside these borders because somewhere else, there was a demand for them that warranted their manufacture.
>>
File: imgur-2015_12_22-17:37:16.png (12 KB, 643x322) Image search: [Google]
imgur-2015_12_22-17:37:16.png
12 KB, 643x322
Code golf:
Make a program that counts the vowels in a word.

Example:
input: hello
output: 2

Shortest or most interesting solution wins.
Good luck!
>>
>>52000948
>>52000724
go away
>>
can't find anything related to this, so I'll ask you guys:

How do I know, when I have to realloc() my pointer?
The pointer has been calloc'd() before, but I seriously don't know what happens when it is running out of space.

Can anyone help me with a link or a simple answer?
>>
>>52000582
lmao why the fuck does he walk like that
>>
Give me something to program that I can do in under an hour in python?
>>
>>52001053

>>52000981
>>
>>52001053
>>52000981
If by under an hour you mean way less than an hour.
>>
>>52000981
F#
Console.ReadLine()
.toLower()
.toCharArray()
|> Seq.filter(fun c -> List.contains c ['a'; 'e'; 'i'; 'o'; 'u'])
|> Seq.length
|> printfn "%i"
>>
>>52000981
print(len([x for x in input() if x in "aeiou"]))
>>
>>52000981
(match-count "[aeiou]" (read-string))
>>
>>52000981
Fixed your scala there buddy

val input = StdIn.readLine()
println(input.toList.count("aeiou".contains(_)))
>>
>>51997944

Standard solarized it seems like.

The one everyone apparently uses.
>>
>>52000981
#!/usr/bin/env ruby
p ARGV[0].split(//).count{|c| c=~/[aeiou]/}
>>
File: Capture.png (12 KB, 405x283) Image search: [Google]
Capture.png
12 KB, 405x283
>>52000981
Does this count?
>>
>>52001282
lol retarded
p ARGV[0].count "aeiou"
>>
>>52000991
You calloc/malloc it for a certain block size, when you need more or less memory you realloc it for the new size. Realloc copies the contents over. If you do
 char* ptr = malloc(10); 
, the 10 bytes starting at that pointer are yours. If you access
 ptr[10] 
the 11th byte starting at that pointer, you get a segmentation fault because it reads memory that was not allocated: it's outside the block you allocated. If you decide that you need to increase the size of the block so that you can store 20 bytes in it, you do
 ptr = realloc(ptr,20);
. If you no longer need the memory, you use
free(ptr)
, which is the same as doing
 realloc(ptr,0); 
.

This is often used in data structures to make sure you can always add elements to it. Take for example a stack and its push operation:
typedef struct stack {
unsigned int size;
unsigned int capacity;
int* array;
} stack;

void push(int elem,stack* s){
if(s->size >= s->capacity){
s->array = realloc(s->array,s->capacity * 2 * sizeof(int));
s->capacity *= 2;
}
s->array[s->size++] = elem;
}


Where capacity indicates the size of the array and size the number of elements in it. When you push onto it, the function checks if there is space left to put the element. If not, the capacity is increased (in this case doubled) and the array reallocated.
>>
>mfw murrifats don't consider y to be a vowel
>>
>>52001320
I'm EU and it isn't a fucking vowel idiot
>>
>>52001053
make a function that averages two ints with a parameter that determines the rounding mode
>>
>>52001320
why?
>>
>>52001320
in english it's mostly not a vowel
Thread replies: 255
Thread images: 33

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.