[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: 47
File: sicp.gif (9 KB, 511x494) Image search: [Google]
sicp.gif
9 KB, 511x494
Previous: >>53847372

What are you working on /g/?
>>
>>53855925
why does it output incorrectly?
#include <stdio.h>

int main () {
float hourly_rate, hours_worked, gross_pay;
char input = 'n';

printf("press y to continue, n to end: ");

while((input = getchar()) != 'n') {
printf("whats your hourly rate?: "); scanf("%f", &hourly_rate);
printf("how many hours did you work?: "); scanf("%f", &hours_worked);

switch(hours_worked > 40) {
case 1:
gross_pay = (40.0 * hourly_rate) + ((hours_worked - 40.0) * 1.5 * hourly_rate);
break;
default:
gross_pay = 40.0 * hourly_rate;
}

printf("\nyour hourly rate: $%.2f/hr\n", hourly_rate);
printf("amount of hours you worked: %.2f hrs\n", hours_worked);
printf("your gross pay: $%.2f\n\n", gross_pay);
printf("do again?(y/n): "); scanf("%c", &input);
}
return 0;
}
>>
>>53855976
what do you mean? It seems to output exactly what you tell it to
https://ideone.com/Mc0QkG
Also there is a nice operator called "if" - it's syntactic sugar for switch(bool)
>>
>>53855976
>>53856086
be a real pro and use

gross_pay = hours_worked > 40 ? (40.0 * hourly_rate + hours_worked - 40.0 * 1.5 * hourly_rate) : 40.0 * hourly_rate;


Also C knows an order of operations so you dont need to apply all those parenthesis in the future.
>>
>>53856086
>>53856134
you tell me how 10 * 10 = 400
>>
>>53856163
>gross_pay = 40.0 * hourly_rate
So you wanted
gross_pay = hours_worked * hourly_rate;
I suppose. I did think it was weird that you were getting full week pay for part time.
>>
File: 1442974560975.png (14 KB, 166x166) Image search: [Google]
1442974560975.png
14 KB, 166x166
amount of hours you worked: 0.00 hrs
your gross pay: $40000.00


Looks right to me.
>>
>>53856193
>>53856163
So the lesson to learn from this is "don't copy paste code"
It's easy to overlook a small required change and then it's difficult to find the bug because code always looks fine to you.
>>
>>53856193
>>53856214
thanks.
IAlthough, I don't understand why I need scanf("%c", &input); when I have input = getchar() as the condition for while
whats the deal here?
>>
I'm working on doing some decryption exercises. I have no clue where to start on this Morse code one though.

http://pastebin.com/74SBCRWp
Apparently it's supposed to be some Morse code thing but I have no clue.

Anyone have any ideas?
>>
>>53856237
desu you stumped me there for a bit, not a c guy. It seems like scanf was leaving the newline character in the buffer and the last scanf was supposed to read '\n' so that getchar() gets the actual character
>https://ideone.com/Mc0QkG
I updated the code there - adding "\n" to the second scanf allows to remove it at the end of the loop
>>
>>53856363
>desu
oh ffs this retarded thing is still on
>>
>>53856363
thanks, I didn't know scanf could do that
>>
>>53856360
doesn't looke like morse code to me
>>
>>53856427
Yeah. But the exercise says it is in same way able to be changed to a Morse code input.
>>
>>53855925
No I haven't Mr. Snek.

I've fallen for the Rust meme.
>>
>>53856453
of course, every text can be changed to morse code
>>
File: 1434862848917.png (7 KB, 500x500) Image search: [Google]
1434862848917.png
7 KB, 500x500
I am learning Arrays and Functions in C++. I am having trouble understanding assignments and calls of functions. The concept of inputs and outputs, inputs with no output and things like VOID are leaving me confused.

With arrays i am getting a lot of syntax errors I don't understand, they might be related to my functions.

My current HW is to build a function that displays the highest number of an array.

float maxArray(int aArray[], int length){
int t, a, i;
for(int i=0;i<4;i++){
if(a[i]>a[i+1]){
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
>>
>>53856196
one day, anon.
>>
>>53856655
What the fuck is this
>>
>>53856655
what the fuck are people thinking when they write this... like they just guess and say it's the language fault it isn't working
>>
>>53856655
This has to be a joke, everything is wrong.
>>
>>53856655
o man
>>
>>53856655
Jesus Anon, here's your homework.
#include <iostream>

int getTopArrayValue(int arrayIn[], int arrayLength) {
int maxValue = INT_MIN;
for (int i = 0; i < arrayLength; i++)
if (arrayIn[i] > maxValue)
maxValue = arrayIn[i];

return maxValue;
}

int main() {
int arrayThing[4] = {5, 2, 8, 3};
std::cout << getTopArrayValue(arrayThing, 4) << '\n';
return EXIT_SUCCESS;
}
>>
>>53856765
>>53856803
>>53856823
>>53856819

Jesus in juice form are you guys samefagging me? It cant be THAT bad. 90% of that code was given to me in a powerpoint that i barely adjusted.

Will it calm your rage if i tell you its my first year programming seriously? And that college classes are lazy as fuck.
>>
>>53856929
The entire thing is just wrong, nothing about it works. It's so wrong that it looks like you purposefully wrote it wrong.
>>
>>53856929
you're the lazy fuck. read your fucking textbook. you're probably paying a lot of money just to write this bullshit.

>some of us didn't pay anybody
>and asked less questions than you
>>
No Mr snake
>>
>>53856929
>Will it calm your rage
I was not raging, I honestly thought it was hilarious. A really fun read, like "a stands for array! So I'm gonna use that! What aArray argument? Sounds retarded - i don't give a fuck about it." "4 items in array should be enough for everybody!" "float is such a nice looking keyword - imma just put it there for aesthetic purposes"
>>
>>53857013
Float is used when you want to carry a few decimal places of a value. So im using whole numbers anyways makes it redundant, or, does it actually hurt something.

I think the float part is what i put in...
>>
>>53855976
>switch(x > y)
>case 1 and default
I know I'm extremely late but what the fuck. Even if you wanted to expand that in the future you would just make more if branches for each new 'rule'
>>
>>53857324
what about
switch (x < y | (w < z) << 1)
{
case 0b01: ...
case 0b11:
case 0b10:
default:
}

:^)
>>
>>53857385
are you that guy?
>>5382814
>
#include <stdio.h>

int main() {
int n;
for(n = 1; n <= 100; n++)
switch((n % 3 == 0) | (n % 5 == 0) << 1) {
case 0: printf("%d\n", n); break;
case 1: puts("Fizz"); break;
case 2: puts("Buzz"); break;
case 3: puts("FizzBuzz"); break;
}
return 0;
}

>
> >>53827973
>if else if Fizzbuzzes aren't readable. There are two duplicate expressions; this is inelegant and inefficient. The pattern-matching version, or this one above I posted some days ago are much better. It's also common for people to write this:
>
       for(int n = 1; n <= 100; n++)
if (n % 3 == 0)
System.out.println("Fizz");
else if (n % 5 == 0)
System.out.println("Buzz");
else if (n % 3 == 0 && n % 5 == 0)
System.out.println("FizzBuzz");
else
System.out.println(n);

>And to wonder why this isn't working. In contrast, pattern-matching has the "most specific pattern first" rule, so it becomes both obvious and programmatically detectable that the error is due to it.
>>
>>53857763
no I only use languages that support binary literals in the standard
>>
>>53857781
Why?
>>
>>53857796
I'm just taking the piss man

although binary literals are a lot more readable in that case
>>
>>53856929
i'm the second one. Dude you can't program without knowing what tools you are using. Always you have to do some examples to know at least the basic usages of stuff... It's like you'd want to build a house with hammer using as a nail and a 2×4 using as cement.
>>
>ursala
#import std

mergesort "p" = @iNCS :-0 ~&B^?a\~&YaO "p"?abh/~&alh2faltPrXPRC ~&arh2falrtPXPRC

#show+

example = mergesort(lleq) <'zoh','zpb','hhh','egi','bff','cii','yid'>

w-what?
>>
>>53856655
return array.reduce!((a, b) => a > b ? a : b);

:^)
>>
>>53857838
continuing

it's like one dude i know, he keeps creating an int variable with the name stop, thinking that if he assign 1 to the stop the loop will stop and other nonsense
>>
http://input.fontbureau.com/preview/
>>
>>53857249
float is the return type, but your gay ass function doesnt even return anything.
it shouldnt return a float nayway, because your array arg is of ints. unless you cast it to a float (which is pointless and stupid and doesnt makea ny sense) the compiler will complain about mismatched types
>>
>>53857812
I prefer decimal integers there. They are still obvious, shorter, and I tend to think of the operations as (maybe 1) + (maybe 2) anyway. To me it's simpler if they are "possibility #1, possibility #2 etc."
>>
I'm working on an audio decoding/encoding library in C. Each packet of audio has some number of frames, and each frame has a sample for each channel. I could represent this as an int **, an array of frames where each frame was an array of samples, or as an int *, an array of interlaced samples, where the ith frame's packet for the jth panel could be accessed at the index (i * j) + j.

Which way would be preferable?
>>
>>53857999
That should say, "the ith frame's sample for the jth channel".
>>
Working on a terrain system that can render a large terrain with proper curvature of the Earth (or any sphere-shaped planet) given a height map. I have a pretty good feeling this has been done before, albeit not for gaymin engines afaik.

I might also add in something to replace the skybox with simulated atmosphere/stars.

I feel like I should feel bad since "gaymin", but at the same time I'm not actually attempting to make a game so it makes me think that it's a little less worse.

Anyone else here generally interested in graphics programming?
>>
>>53858048
Finally a nontrivial project on /dpt/

Do your best, anon!
>>
>>53858048
>given a height map. I have a pretty good feeling this has been done before, albeit not for gaymin engines afaik.
See space engineers source?

>I feel like I should feel bad since "gaymin", but at the same time I'm not actually attempting to make a game so it makes me think that it's a little less worse.
Don't listen to /g/yards on this matter, they are mostly noons and/or idiots. Creating games and game engines is like an arcane wizardry them (quaternion sounds like a spell lol), they just feel inferior to someone that can do these things.
>>
>>53858048
>Anyone else here generally interested in graphics programming?

I am, but I'm more into physics simulation.
>>
Please help me /g/, what is the name of the error here? It's two words, same number of letters
 
for (var i = 0; true; i++) {
eval("var magic_var_" + i + " = " + Math.random());
}
>>
Haskell
>>
>>53858273
We naming shitlangs? Javascript.
>>
>>53858307
C
>>
>>53858317
PHP
>>
>>53858323
Java
>>
>>53858215
You prolly mean overflow
>>
>>53858200
Nice dubs. And yeah I'll definitely be doing some physics simulation when it comes time to simulate sky color based on atmosphere composition/details.

>>53858181
Thanks man! My main thought is that it's probably been done (or something similar) for flight simulators.

>>53858130
Thanks babe.
>>
Hey folks, which one should I choose QT/GTK/wxWidgets, using them for general purposes I guess
>>
>>53858336
Ruby
>>
>>53858307
Basil
>>
>>53858353
Forth
>>
Do directories in Linux have inodes? if not, how are directories represented in the Linux kernel, and what is their relation to the representation of files within the kernel?
>>
>>53858369
This is a concept language, it doesn't count.
>>53858377
Emacs-Lisp
>>
>>53858341
Can you tell me what must this code do?
>>
Custom engine for Stranded 2 in C++ (original is written in BlitzBasic and is slow as fuck)
>>
File: carmack.jpg (2 MB, 1819x1866) Image search: [Google]
carmack.jpg
2 MB, 1819x1866
Can someone please tell me how I can accept UDP packets outside my main application while the main application is running?

Say my main application is ~60 simulations per second, UDP packets get sent 20 per sec from the server, I call a socket recvfrom every simulation step, but if recvfrom freezes until it gets a packet, this means that 60 simulations per second drops to maybe 20 simulations per second or less, works but it's slow and unreliable.

So how do I constantly have an infinite recvfrom loop that is separate from my main simulation loop but have the infinite recvfrom loop modify variables so my main simulation can use them?
Multithreading? Running a client program and simulation program separately and somehow share values?

I guess to make it short how do I make two C loop programs share values?
>>
>>53858429
Listen for packets asynchronously
>>
>>53858429
Threads.
>>
>>53858403
What the fuck is this question? Can't you acknowledge my answer to the last? It starts defining an infinite number of local variables, and runs into OOM before finishing. Even if it were not the case, it would be an infinite loop, or at least a very long one: I din't know how JS handles number representation boundaries, since they are double normally. Still: this OOMs way before 2^32.

Also: never use eval, learn to not use half of the language.
>>
Named the order/age that you learned or first wrote in each language.

Scratch - 9
Python - 10
JavaScript - 11
PHP - 13
MySQL - 13
Java - 16
C++ - 17
>>
>>53858454
Reading into threads currently, seems like exactly what I'm looking for. Thanks.
>>
>you will never be happy again like you were when you were young
>>
>>53858528
>>>/r9k/
Kill yourself
>>
Can I learn something by just messing around with snippets from Reddit's daily programmer threads?
>>
>>53858543
You can learn something from messing around with code snippets, but I'd recommend doing it with code snippets from books rather than code snippets from DPTs or whatever. It's easy to pick up bad programming habits that way.
>>
File: Capture.png (26 KB, 780x380) Image search: [Google]
Capture.png
26 KB, 780x380
>>53858501
I'm sorry, I don't know anything about Javascript this is just a puzzle I am trying to solve for hours and I can't find the solution.
>>
File: 1352036032324.jpg (336 KB, 1829x925) Image search: [Google]
1352036032324.jpg
336 KB, 1829x925
>>53858503
12 PHP, C++98
13 JS
14 C99, Perl
15 Ruby
16 Python
17 Haskell
18 Coq, Scheme, C11
19 Idris, F*, C++11
20 OCaml, SML, C++14
>>
>>53857763
Can someone explain that switch to me?
Why does the switch go to case 1 when n=3?
>>
>>53858503
BASIC - 8
6502 ASM - 11
C - 14
x86 ASM - 16
C++ - 18
Javascript - 20
Java - 23
SQL - 24
PHP - 25
Haskell - 26
Python - 30
>>
>>53858589
n % 3 == 0 evaluates to 1.
>>
>>53858503
25 scheme, ada, c, c++, java, x86
26 racket, smalltalk, d, and many many more
>>
>>53858589
(n % 3 == 0) and (n % 5 == 0) are boolean values, i.e. 0 if false, 1 if tue
shifting (n % 5 == 0) left one place gets 10 (binary) if true, 00 if false
ORing it with the other one gets 00 if both are false, 01 if (n % 3 == 0) and (n % 5 != 0), 10 if (n % 3 != 0) and (n % 5 == 0), and 11 if both are true
>>
>>53858503

PBASIC - 16
Python - 16
Java - 18
BASH - 18
LC3 ASM - 19
SQL - 20
C - 21
PHP - 22

Currently 23, though C is still my preferred language for anything that isn't practical as shell script.
>>
File: when the d on point.jpg (14 KB, 250x377) Image search: [Google]
when the d on point.jpg
14 KB, 250x377
>>53858604
>d
>>
>>53858503
Lua 12
C++ 13
Python, Java, Basic, JS, Forth 14
C, GAS, NASM, Scheme 15
>>
>>53858589
This version without bitwise operators works jzst as well in this context:
(n % 3 == 0) + (n % 5 == 0) * 2

What this does is assign a distinct integer value to each possible couple of values (n % 3 == 0, n % 5 == 0). (note that false casts as 0 and true casts as 1) then it's just a binary trick.
>>
Now that I'm 18 I feel like I was never good enough to be full child prodigy but still better than everyone else in my AP Comp Sci class. Granted there's like one Indian who claims he wrote patches for Android but seems like he tries hard to be cool all the time and there's another entrepreneur type who only codes in Go and generally has no idea what I'm talking about if I ask him about certain things (e.g. Backus-Naur Forms) but knows certain stuff which is not unimpressive, but even says he doesn't want to learn about stuff that's unnecessary.

Please tell me that I'll feel dumber in Uni, I honestly don't like not having anyone smarter than me around who I can learn from. Even my fucking APCS teacher doesn't teach, we do the entire class through a MOOC (Edhesive).
>>
>>53858048
Could you just ray trace onto an appropriately sized sphere and color the light by shining it through a plane that is your terrain?
>>
>>53858618
Thanks!
>>
>>53855925

How can I send 2d array thru MPI?
>>
>>53858691
Not sure what you mean exactly, because this would create a sphere with nothing but a flat 2d texture imitating terrain.

I'm trying to create terrain that is meant to be walked around on. Right now there already exists terrain mesh generators that can read heightmaps and create meshes, but there's no curvatures at all to the terrain (essentially flat maps). Ideally when I'm done, I could give it any heightmap, the radius of the planet, and the coordinates of each corner of the heightmap on the planet, and it will recreate a mesh for the heightmap accordingly.

Hopefully this will lend itself to a game being able to use coordinates like we do IRL (longitude/latitude/elevation) instead of using x/y/z coordinates.
>>
>>53858799
they talked about some game that had spherical planets as maps in agdg yesterday, turns out it's hard as shit to orient yourself in such a map
>>
>>53858181
/dpt/ only shits on enginebabbies
>>
>>53858429
>So how do I constantly have an infinite recvfrom loop that is separate from my main simulation loop but have the infinite recvfrom loop modify variables so my main simulation can use them?

dude select.select so your recvfrom function doesn't get blocked.
>>
>>53858825
>enginebabbies
What is this?
>>
>>53858799
>this would create a sphere with nothing but a flat 2d texture imitating terrain.

Oh I thought you just wanted to capture the curve effect (draw this image on / over an appropriate curve).
>>
>>53858815
Well I honestly can't see any good reason why this should be the case unless you make the planet dwarf sized. If it's a normal planet it should be just as easy to do so as in IRL or on a flat map.
>>
>>53858852
people who use pre-made engines like unity or ue4. they usually make very poor quality games with very little effort put into them and with very little programming. unity is apparently made to be bad on purpose (like it still uses strings as keys) so people will buy assets to fix it.
>>
>>53858916
i haven't played the game myself so i wouldn't know but they also said that since the terrain was randomly/procedurally generated and it was an RTS game it was lacking in strategy because the maps weren't purposefully designed by humans and it didn't have e.g. plateaus that you could launch artillery attacks from or things you could hide behind. just something to keep in mind. i think you should go ahead and make your plan come to life
>>
>>53858503
QBASIC - 14
HTML, CSS, JS - 16
Ruby -17
C - 18
C++, C#, JAVA, SQL, PHP - 19
ASP - 24
My life is fucked.
>>
>>53858943
I mean like I said I'm not really making a game yet as far as I know (truly don't have the time or enough original ideas) but just thought it'd be cool to make a game engine closer to real life in certain aspects.
>>
>>53858503
Pascal - 16
Java - 17
Python - 17
C - 19
Haskell - 20
Prolog - 20
>>
>>53858528
Fuck you, I found alcohol
>>
Trying to get VGA working on the obscure piece of shit that is qemu ARM64 virtual board
>>
>>53858679
>I honestly don't like not having anyone smarter than me around who I can learn from
It's good that you feel this way.

It is likely that you will be humbled by a few people once you get to a university.

Remember, high school is just the people that live there.

Once you get to any college, even the shittiest of them, you've immediately removed a good bottom 40% of the population.

Seek clubs or interest groups, as those are full of people who actually care enough to learn more.

"If you're the smartest person in the room, you're in the wrong room."
>>
File: carmackscreen.jpg (110 KB, 938x707) Image search: [Google]
carmackscreen.jpg
110 KB, 938x707
>>53858429
Back.
>tfw all I needed to do was define an infinite loop function that calls recvfrom and call a pthread_create in my simulation init function

Why is C so fucking based?
>>
>>53859591
lel or you could just have a programming language that has semantics and syntax for coroutines.
>>
File: haskell-hnreddit-shills.png (260 KB, 600x800) Image search: [Google]
haskell-hnreddit-shills.png
260 KB, 600x800
>>53859639

Come join the alphas on /fpg/
>>
>>53859654
Stop making that shitty thread
>>
>>53859650
>programming sockets in any programming language other than lisp or C
Just doesn't feel right. Besides, It's obvious I'm programming a low latency server here, I'm willing to bet any language that has "syntax for coroutines" is too slow.
>>
>>53859810
this

webshit is slow but it doesn't mean you have to make it even slower
>>
Anyone here tried using Firebird instead of Mysql or Postgres?
Experiences?
>>
>>53859810
>I'm willing to bet any language that has "syntax for coroutines" is too slow.
What is Go. Segmented stacks and a modified setjmp/longjmp are sufficient to implement coroutines. Very fast. Not as fast as a function call, but still pretty fast. Go's speed deficit is mostly because it has to schedule the coroutines.
>>
>>53860096
Microsoft's stackless coroutines they want in C++ are allegedly as fast as function calls
>>
>>53859810
>I'm willing to bet any language that has "syntax for coroutines" is too slow.
lel, confirmed for not knowing shit (you literally just did you first concurrent code). PLs specifically made for distributed programming like erlang, go, or clojure have been used in critical performance environments. Go has native support of co routines and is faster than any lisp implementations. For example, Erlang is being used at whatsapp where one of their servers is able to handle +2,5 millions of simultaneous connections and able to process an average of 600k packets per second.
>>
>>53860165
I'll finish that statement for you.
>stackless coroutines
are worthless.
But it's nice to seem them finally adopt something.
>>
>>53860185
stackless and non stackless coroutines can achieve all the same things
>>
>>53860185
https://paoloseverini.wordpress.com/2015/03/06/stackless-coroutines-with-vs2015/
>>
shame C++17 will be a huge disappointment

no concepts, probably no modules, no coroutines, might not get ranges, no UCS let alone good UCS
etc
>>
>>53860209
No they can't. Stackful coroutines allow yielding from recursive functions. Yes many recursive problems can be made iterative, but not all. For instance take these functions in Lua, they generate combinations.

Stackful, yield from recursive call.
function Combinations(l, r)
local p = {}
r = r or #l
local function f(pos, k)
if k > r then
coroutine.yield(p)
else
for i = pos, #l - r + k do
p[k] = l[i]
f(i+1, k+1)
end
end
end
local c = coroutine.create(f)
return function()
local ok, r = coroutine.resume(c, 1, 1)
if ok then
return r
end
end
end


Stackless, algo must be made iterative.
function Combinations(l, r)
local p = {}
local sel = {}
r = r or #l
for i = 1, r-1 do
sel[i] = i
p[i] = i
end
sel[r] = r-1
return function()
local i
for j = 0, r do
if j == r then return end
if (sel[r - j]+1) <= (#l - j) then
i = r - j
break
end
end
sel[i] = sel[i] + 1 -- increment first place that doesn't cause carry
p[i] = l[sel[i]]
for j = i + 1, r do
sel[j] = sel[j - 1] + 1
p[j] = l[sel[j]]
end
return p
end
end


Which is more readable? Now imagine if you had to do this for a recursive algorithm that can't be made easily iterative?

Lua author talking about how asymmetric stackful coroutines are sufficient to implement all other types of coroutine-like control structures, like one-shot continuations.
http://www.inf.puc-rio.br/~roberto/docs/MCC15-04.pdf
>>
Man, this depresses me, are switch cases the only good way to code a main and submenu?
Does anyone have any idea on how I can refactor this stuff later on?
>>
>make a simple change to shader, looks fine
>doesn't compile
>the exact same shader compiles just fine on shdr.bkcore.com
just fuck my shit up
>>
>>53860280
Pretty sure there was a proof that ALL recursive functions can be made iterative.
>>
>>53860302
i use switch/case and if/else but you could try object polymorphism or arrays of function pointers
>>
>>53860302
bunch of if statements? gcc's computed gotos?

>>53860319
Ackermann function.
>>
>>53860345
http://try.haxe.org/#1b818
not sure this is reliable
>>
>>53860319
lel, k tard.
>>
>>53860383
Oh, yeah. Using a stack and an iterative method to replace recursion. I guess you can do that, but you are really just implementing recursion, iteratively instead of replacing it.

Either way I'll take what I can get. It's about time low-level languages got coroutines. We can abandon my shitty x86-only libraries.
>>
>what is turing completeness
>>
>>53860440
Don't remember off hand. Maybe you should google it.
>>
>>53860383
you basically re implemented the call stack...
>>
>>53860460
a turing machine could be written using only iteration or only recursion

>you can write a higher order recursion function to implement iteration
>recursion is emulated using an iterative call stack
>>
>>53860479
a call stack is basically what recursion is
call stacks are iterative
>>
>>53860314
used glGetShaderInfoLog, turns out i had a semicolon after \n
>>
>>53860166
Of course you gave reasons to use Go over lisp, but didn't give any reason to use Go over C. Good job.
>>
>>53860502
>a call stack is basically what recursion is
there no such a thing as "call stack" in mathematics
>>
>>53860166
>go is faster than any lisp implementations
Is it faster than Python too?
>>
>>53860485
>>53860502
There is a divide between math and programming. Using a call stack whether implicitly or explicitly is not removing recursion. There are two types of computable recursive functions: primitive and non-primitive. The ackermann function is one of a few non-primitive computable functions. Primitive recursion (iteratation) doesn't require storing partial answers in a stack.
>>
>>53860553
you can have a call stack in mathematics, it's just a stack. there are plenty of stacks in maths
>>
>>53860568
Yeah. Go is about the speed of Java generally.
>>
>>53860568
it's definitively faster than cpython. not sure when compared to pypy.
>>
File: watermelon confirmed best girl.jpg (474 KB, 1619x1725) Image search: [Google]
watermelon confirmed best girl.jpg
474 KB, 1619x1725
>>53860602
>garbage collected languages
>>
>>53860440
turing completeness is about a specific kind of computation and has nothing to do with abstraction. X being turing completeness never meant X can do everything. see http://www.engr.uconn.edu/~dqg/papers/myth.pdf
>>
>>53858503
VB6 - 10
javascript, php - 12
c# - 13
c/c++ - 18
python - 22
scheme - 26
>>
>>53860624
but, anon, garbage collection is vital for concurrent programming.
>>
>>53860695
X being turing complete means X can calculate any computable function
>>
>>53860727
stop writing garbage and you won't need garbage collection
>>
>>53855925
>What are you working on /g/?
Some shitty stuff on xcode.
I swear to god if I see more tutorials and shit on objectiveC I will go and kill cook.
>>
Hey lads,

best way to learn about systems? reading an os / systems book? writing kernel modules? etc?

I feel like im at a point where i could start writing shit myself but there is still so much i dont know.
>>
>>53858503
>Python
16 or so
>Java, PHP
17
>Swift ObjectiveC Ruby
>>
>>53858503
MSWLogo - somewhere between 8 and 12
>>
>>53860778
>best way to learn about systems?
>reading an os / systems book? writing kernel modules? etc?
All of the above.
>>
>Tfw making a real good application is way too hard
>>
>>53860727
no it isn't
>>
>>53860890
for you
>>
>>53860933
Okay lets see your applications
>>
Is it worth to do CS50 course on Edx?
>>
File: SizeOfAnonsPenis.png (270 KB, 422x339) Image search: [Google]
SizeOfAnonsPenis.png
270 KB, 422x339
>When Bob Tabor sees your penis.
>>
>>53861295
Rule 34 on Bob Tabor
>>
>>53861318
I may or may not be downloading tutorial videos so I can record sections of the screen featuring Bob Tabor gesturing instructionally to make webm's for dank memeposting/C# shilling.

I'm a horrible person.
>>
>>53860727
Not really. ARC is good enough. Best is probably a hybrid. ARC with a coloring algorithm to detect cycles. Memory gets free'd upon final delete so you can know when and measure how long frees will take.

>>53858503
C++ - 12
C - 19
Lua - 19
Go - 20
Javascript - 20
Java - 21
Python - 21
Haskell - 21
No I didn't use C++ exclusively during my teens. I wasn't interested in programming in my teens.
>>
>>53861414
>ARC
arc is an implementation of garbage collection.
>>
>>53861495
Fuck your semantics up your ass.
>>
Need some help.
Im looking into making Android apps that install content in specific folders. I want to make money selling expansion packs for games and shit.

I tried to look into coping source codes of other people's apps that do it but it looked encrypted.

Help.
>>
>>53861572
>Help.
Learn Java and write it yourself.
>>
File: GesturingInstructionally.webm (2 MB, 308x244) Image search: [Google]
GesturingInstructionally.webm
2 MB, 308x244
>>53861495
Did someone say garbage collection!

When working with the .Net framework I can run you through, step by step, on how C sharps built in garbage collection can help improve your productivity, AND help keep your application debug free. Using the .Net framework and garbage collection YOU THE DEVELOPER can take control of your application can spend your time writing code to make your application do what YOU THE DEVELOPER want it to do, instead of worrying about the mess that memory management leaves behind.
>>
File: aXbVN9g_700b.jpg (77 KB, 587x551) Image search: [Google]
aXbVN9g_700b.jpg
77 KB, 587x551
>>53858503
12: Python, Bash
13: Emacs Lisp, C, C++
14: Java, Perl, Lua
15: Perl6, Haskell, OCaml, Scala
16: Go, Ruby
17: CL, Racket
I'm quite the language enthusiast. Now I'm 18, which lang should I look into? Who won? Who's next? You decide!

>inb4 Basil
>>
>>53861608
Memory management doesn't leave behind a mess
>>
File: longlong.jpg (85 KB, 587x551) Image search: [Google]
longlong.jpg
85 KB, 587x551
>>53861631
>>
>>53861608
shut up idiot

GC doesn't help "productivity" if you need high performance and consistent performance
>>
Some of you familiar with modern C++ implementation of well known algorithms? The web is full of poo in loo C implementations of depth first, Dijkstra, etc. algorithms, but I cant find a simple, elegant, short STL based one.
>>
File: 200_s.gif (59 KB, 386x200) Image search: [Google]
200_s.gif
59 KB, 386x200
>>53861691
This is the one I was looking for originally, thank you honey boo boo
>>
>>53861743
>simple, elegant, short
>STL based
pick one

>tfw no ranges
>>
File: 1459325368771.png (1 MB, 1280x720) Image search: [Google]
1459325368771.png
1 MB, 1280x720
>>53861743
I have never tried writing them, at least in C++, but I'm good at algorithms and I know the STL. What are you looking for?
>>
File: 1459616228715.jpg (250 KB, 462x554) Image search: [Google]
1459616228715.jpg
250 KB, 462x554
>>53861743
>>53861779
Wait, you mean pathfinding algorithms, right? I remember trying to do this in my early C++ days... I should start again from scratch, tho
>>
>>53861587
Currently downloaded Android studio.
>>
>>53861779
I'm sucks with graph based competetive programming exercises. Many of the based on find the shortest path in a weighted graph. I'm looking for an STL based implementation of that (regardless of graph representation like matrix or adj. list). Thaks for the interest.
>>
>>53861779
>>53861829
kill yourself idiot
>>
>>53861842
>2016, the year of the .NET stack developer
>not using the MIT licensed Mono project with the free(beer) Xamarin with glorious C#
>>
>>53861908
>>>/b/
>>
>>53861918
kill yourself fag
>>
>>53861908
normie get out
>>
>>53861908
>>53861936
>>>reddit
>>
>>53861743
Look into BOOST
>>
>>53861938
>>53861958
FAG fuck off to >>>/lgbt/ and whatever board is dedicated to anime trap fag shit
>>
File: 1459535824992.jpg (94 KB, 500x701) Image search: [Google]
1459535824992.jpg
94 KB, 500x701
>>53861863
http://rosettacode.org/wiki/Dijkstra%27s_algorithm#C.2B.2B is this a good starting point?
>>
>>53861980
I know about Boost graph but its not includd in competitive checking systems like UVA.
>>
>>53861842
Goodluck you do realize it is hard to make good Android Apps
>>
>>53861986
This board is 18+
>>
>>53861916
kill yourself idiot
>>
>>53861936
>>53862017
>>53861986
I swear we get this guy in here like once a week.

Only seems to be capable of lashing out at everyone.

Add a trip so we can filter you.
>>
>>53862013
shut the fuck up fucking delusional projecting cancer
>>
File: 1447949448140.gif (844 KB, 200x150) Image search: [Google]
1447949448140.gif
844 KB, 200x150
>>53856929
>he fell for the CS cuz muh money
>>
>>53862029
and i swear we get the delusional himespamming SHIT FAG every single day
>>
>>53862046
And yet this person is actually posting relevant discussion about programming and no one else seems to care.

Thread was fine until you started shitting it up with your childlike tantrum.

I don't even know why I'm responding to your complaints.
>>
>>53862062
kill yourself fag
>>
>>53862030

>fuck cuck cancer delusional projecting kill yourself idiot retard faggot enough

Yeah, we get it
>>
File: 03-apollo-arrow-geneva-1.jpg (608 KB, 1920x1280) Image search: [Google]
03-apollo-arrow-geneva-1.jpg
608 KB, 1920x1280
>>53861992
no it isn't you fucking retarded FAG

>>53862077
kill yourself FAG
>>
File: firefox_2016-03-30_12-42-40.png (910 KB, 1138x1030) Image search: [Google]
firefox_2016-03-30_12-42-40.png
910 KB, 1138x1030
Do you like nullable types, /dpt/?

Does the null coalescing operator make you feel giddy every time you use it?
>>
File: 1404500492838.png (152 KB, 311x311) Image search: [Google]
1404500492838.png
152 KB, 311x311
>>53862098
pic related
>>
https://www.reddit.com/r/gamedev/comments/1clmlm/what_lighting_models_are_most_popular_in_games/

are they fucking delusional or is it true that even AAA games don't bother with physically based shading and just go with phong/blinn-phong mostly. come on people it's fucking 2016
>>
>>53862098
how come that in an argument with a trap anime-loving pedophile YOU come up as a mental one?
>>
>>53862155
>le forced trap meme
fuck off fag
>>
Which does /dpt/ prefer?

int* ptr;
int *ptr;
int * ptr;
>>
File: 1458019263810.png (1 MB, 1000x1400) Image search: [Google]
1458019263810.png
1 MB, 1000x1400
>>53862098
At least Hime is alive+prog-related you pervert
>>
>>53861863
Jebus dude. You are almost as bad as me. Proof-read your posts.

I've recently done something like this, but I found the total number of paths through a state graph. The solution could be similar. Basically I transformed the graph into a ruleset and collapsed all the rules from the start set into each other and the final count of terminals was the number of paths through the graph.

your solution might work similarly, follow all paths simultaneously, keeping track of the sum of the weights and at the end find the minimum value in the set of terminals. That seems like it might explode instead of reduce though. Think it over.
>>
>>53862098
>duckface the car
top kek
>>
>>53862183
no it isn't fucking delusional retard

carshit is just as programming-related as fucking gay forced trapshit
>>
>>53862178
in a sane language the first one would be the only one that makes sense because it would be modifying the type of the declaration - not modifying the variable to be a pointer to the type of the declaration and
int* a,b;
would declare two pointers. But c is too retarded, so the second one fits best.
>>
File: Derr.png (5 KB, 219x244) Image search: [Google]
Derr.png
5 KB, 219x244
>developing indie game
>not sure what license to use
>using github for source control

Sorry if this is a retarded question or it doesn't matter(I know the chances of someone stealing some random faggots terrible code is basically non-existent) but still might as well select something. What type of license is most reasonable to use if I just don't want people to completely steal my shit?

eg. copy and release a commercial product without my permission.
or
copy and release a non commercial product without my permission.

Including copying and expanding upon it.
>>
File: 2gIImej.jpg (38 KB, 580x346) Image search: [Google]
2gIImej.jpg
38 KB, 580x346
>>53862173
What on earth for the love of The License? I'm a Libre Software fan, I'm in no way affiliated with xeir and xies degeneracy thank you very much!
>>
>>53862192
To add. There will be similar subgraphs from different decisions that lead to those subgraphs. Cache the results so you don't have to recompute. Keep track of the minimum valued path to each subgraph.

It's starting to sound a little like a dynamic programming approach. Fuck that.
>>
File: ss (2016-04-05 at 01.51.07).png (43 KB, 750x500) Image search: [Google]
ss (2016-04-05 at 01.51.07).png
43 KB, 750x500
>>53855925
Today I finally had enough of YouTube's website and since I'm also unemployed, decided to build a minimalist YouTube browser of my own in C# that plays videos in MPV to add to my currently quite bare portfolio, as well as limit my need to visit YouTube's website.

It's nothing fancy at the moment but I'm hoping to add the ability to sign in and browse my subscriptions as well as channels tomorrow. Maybe I'll work on adding playlist support too.
>>
File: 12yo simulator.png (15 KB, 801x270) Image search: [Google]
12yo simulator.png
15 KB, 801x270
>>
>>53862192
>>53862234
Thanks for the information
>>
>>53862222
Why don't you host it privately until you're done?

http://choosealicense.com/licenses/
>>
>>53855925
Reading the Dragon book
>>
>>53862213
this, unfortunately. I used to love C. Now I can't stand all the idiosyncrasies.
>>
>>53862222
just do closed source.
>>
>>53862259
same desu
>>
File: Ankg4eZ.png (46 KB, 700x700) Image search: [Google]
Ankg4eZ.png
46 KB, 700x700
>>53862245
:^)
>>
>>53862239
I'm interested in this. Even an app if you can.

For example, YouTube won't let me select lower quality videos when I'm using the network. It also forces a crazy amount of 2 minute ads when I just want to play a music playlist
>>
>>53862310
Purchase Youtube Red / Play Music All Access, goyim.

(Seriously, totally worth the $10 a month)
>>
>>53862310
I hadn't really planned on applying this to mobile. I'm pretty sure there's already a ton of third party YouTube apps out there anyway that probably do exactly what you want.

Unless you're using an iPhone, in which case I'm not so sure. Maybe if you Jailbreak
>>
>>53862256
I don't have a premium github account. I "think" I could do a local github(I'm completely new to hosting a github pretty much, but I've heard people talking about using a local one) however I'm also using it as a back-up in case my internal drive, and my external drive fail.
>>53862269
Would that just be selecting "None", or do you mean just not hosting it publicly on Github?
>>
>>53862333
Use BitBucket.
>>
>>53862333
>a local github
Nigga, you need to research 'git'.

GitHub is just a service for hosting git repositories.

Read this:
http://tom.preston-werner.com/2009/05/19/the-git-parable.html

It's interesting and will learn ya some stuff.
>>
>>53862330
There is no point in making that there have been hundreds kinds of it already made and same with any other mobile application it has already been made
>>
>>53862333
>Would that just be selecting "None"
No, it would be not sharing code publicly on github, and look into proprietary licenses if you don't want to allow people to distribute/sell your code (not that anybody would do this if it were under any of the regular open source licenses).
>>
>>53862222
If you don't care about open sores
Just use bitbucket which has private repos
Otherwise you can just copyright with all rights reserved and say othershit like no copying, selling, etc
>>
File: privilage.png (36 KB, 1091x360) Image search: [Google]
privilage.png
36 KB, 1091x360
>>53862222
Quints
>>53862333
trips

I'm so sorry stealing these for stupid questions /g/.
>>
>>53862553
>quints
>4
>>
>>53862582
QUADS fuck
>>
File: himegoto.gif (13 KB, 300x100) Image search: [Google]
himegoto.gif
13 KB, 300x100
>>53861779
>>53861829
>>53861938
>>53861992
>>53862013
>>53862029
>>53862155
>>53862163
>>53862183
>>53862062
listen you weebtrapfags

GET A LIFE!
>>
File: smug_anime.jpg (54 KB, 500x500) Image search: [Google]
smug_anime.jpg
54 KB, 500x500
I decided to determine once and for all whether C is indeed faster than C++.

I wrote two scripts to calculate the number of primes up to 3 billion. Here's num_primes.c
 #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
const unsigned int UPPER_BOUND = 3000000000;

bool *p = (bool*) malloc(sizeof(bool) * (UPPER_BOUND + 1));
p[0] = false;
p[1] = false;
for (unsigned int i = 2; i < UPPER_BOUND + 1; ++i) {
p[i] = true;
}

unsigned int i = 0;
while (i*i <= UPPER_BOUND) {
if (p[i]) {
for (unsigned int j = i*i; j <= UPPER_BOUND; j += i) {
p[j] = false;
}
}

++i;
}

unsigned int count = 0;
for (unsigned int i = 0; i < UPPER_BOUND + 1; ++i) {
if (p[i]) {
++count;
}
}

printf("%d\n", count);

return 0;
}


which I compiled with
clang -std=c11 -O3 -o c_test num_primes.c
>>
File: smug_anime.jpg (96 KB, 724x720) Image search: [Google]
smug_anime.jpg
96 KB, 724x720
>>53862807
...and here's num_primes.cpp
#include <iostream>
#include <vector>

int main() {
const unsigned int UPPER_BOUND = 3000000000;

std::vector<bool> sieve(UPPER_BOUND + 1, true);
sieve[0] = false;
sieve[1] = false;

unsigned int i = 0;
while (i*i <= UPPER_BOUND) {
if (sieve[i]) {
for (unsigned int j = i*i; j <= UPPER_BOUND; j += i) {
sieve[j] = false;
}
}

++i;
}


unsigned int count = 0;
for (bool b : sieve) {
if (b) {
++count;
}
}

std::cout << count << std::endl;

return 0;
}


which I compiled with
clang++ -std=c++14 -O3 -o cpp_test num_primes.cpp


Guess which is faster?
>>
>>53856655
So, by your logic, if I ask you to write a bubble sort, you'll actually write the function calculating the maximum value of an array, right?
>>
>>53862245
you forget "autistic"
>>
>>53862840

import java.util.Arrays;

int[] arr = {5,3,2,7,4,2,N,1}

Arrays.sort(arr);

>>
>>53862838
vector<bool> has this dead wrong (according to Stroustrup) specialisation where it packs all bools into bytes, right? Or maybe it's dead in C++14? Checked: nope. I would guess that C is faster in this particular case because C++ does BS, amirite?
>>
File: 1453648836231.png (681 KB, 840x720) Image search: [Google]
1453648836231.png
681 KB, 840x720
>>53862807
>>53862838
>vector<bool>
senpai pls
>>
Analyzing images and removing gradients where there shouldn't be any. Using Python of course so IMPORT IMPORT IMPORT DONE
>>
File: smug_anime.png (117 KB, 372x351) Image search: [Google]
smug_anime.png
117 KB, 372x351
>>53862919
% time ./c_test

real 0m38.872s
user 0m38.247s
sys 0m0.623s
% time ./cpp_test

real 0m29.411s
user 0m29.302s
sys 0m0.108s
>>
>>53862994
>where there shouldn't be any
Example?
>>
>>53863013
C++ allocates like 1/8th the memory
>>
>>53863013
https://benchmarksgame.alioth.debian.org/u64q/cpp.html
many times c++ is slower
>>
>>53863080
bullshit
those C programs are basically valid C++ programs
>>
File: thanksalot.png (2 KB, 379x407) Image search: [Google]
thanksalot.png
2 KB, 379x407
>>53863014
I have some images of thermal data of walls (in the thousands) and they are supposed to be grouped (10 groups) but apparently that means GROUPED MOSTLY BUT WE ALSO MADE SOME NICE GRADIENTS HERE AND THERE LOL so now I'm replacing all the gradient colors with the nearest proper color.
>>
>>53863111
the idea is to write c++ solution the way you would write actual c++ code. If you to habitually write c++ code as c code all the time then what's the fucking point of writing "in c++"?
>>
>>53863156
the point is you can use C++ only stuff when you want, and other stuff like templates and constexpr have no performance penalty
>>
>>53863115
wait if its thermal data then they must of just left those gradients, not made them right?
>>
>>53863156
for instance, if anybody actually dared to fucking use inheritance in any of those programs they should be shot
>>
>>53863231
>>53863202
idgaf, just go and submit better c++ solutions.
>>
>>53863243
submit the C solution as a C++ solution
>>
>>53863257
and better yet: write all of your code in c.
>>
>>53863295
Why would that be better?
C doesn't even have fucking overloading
Thread replies: 255
Thread images: 47

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.