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

/dpt/ - Daily Programming Thread

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

Thread replies: 317
Thread images: 16

File: sicppatt.jpg (66KB, 800x534px) Image search: [Google]
sicppatt.jpg
66KB, 800x534px
This is /dpt/, the best subreddit of /g/

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

http://mattgemmell.com/what-have-you-tried/
http://www.catb.org/~esr/faqs/smart-questions.html

** D I S C O R D **
https://discord.gg/NzCVN

What are you working on ?
>>
How did Japan manage to preserve their gene pool while Brits all look like 10 generations of inbreeding?
>>
>>57145603
>Pajeet overflow
>>
>>57145603
Does it even matter in the end? They would have been better off not preserving it since they all look like genetic failures.
>>
>>57145620

hey, I just found a good pejorative term for stackoverflow.com
>>
>>57145579
Incorrect. Japab looks at university on a national scale, theres no reason for competing against schoolmates except for healthy empty rivalry. Japan has WAY more social activities at school, and clubs are glorified.
I don't think japan is better though, companies are way too invasive and the culture doesn't support individualistic behavior. Comparatively you'd be right on with china, that place is truly cold, the huge focus on family and deifying parents means that each person is his own tribe and that screwing over others is a virtue
>>
>>57145590
Making a website, just wanted to know what everyone else is using. I have a fair ammount of skill in jurry rigging, but most of what I know about web dev software is a decade out of date. What software do people use these days to make it go faster? main feature I'm looking for is possible auto complete and debugging features. real time preview would be a bonus but far from needed. What do you fags use?


This isn't technically a programming question but new threads asking for help get replies punishingly infrequently.
>>
>>57145603
>>57145620
>>57145659
>>57145672
>>57145673

We're in a new thread, let's keep the topic strictly to programming. The old thread will be fine to keep the political discussion going, since it is no longer bumping.
>>
>>57145672
https://www.youtube.com/watch?v=-1yzoiUIGGs
>>
>>57145697
If you keep this up hiroshima is sure to make you a janitor!
>>
>>57145697

>mods in charge of interrupting the discussion anytime it gets interesting
>mods implying you can have actual, intellectual discussions about culture and politics on /pol/
>>
>>57145677
vi
>>
>>57145697
y--yes Sempai.

Anyone can help me on a multithreaded epoll server?
>>
>>57145697
No.

hitler did nothing wrong
>>
>>57145579
in a way that's the point.
4chanX filters images based on MD5 hashes, so does that mean that if I filter a specific pepe and someone takes it, changes obe pixel and posts it again, does that mean that the manipulated pepe will bypass the filter?
That's kinda the point of the neural network which would determinen if it's a frog or not, and feed the large database.
It's basically the only way if you want 4chanX filtering.
I imagine anything else would be too performance demanding
>>
are there any sites of similar quality as Codeacademy for learning stuff?

ten hours of interactive tutorials are equivalent to literal months of learning by scrapping information together
>>
>>57145721
>Anyone can help me on a multithreaded epoll server?
For what? Downloading pictures of 4chan?
>>
>>57145673

i know little about life in japan, but absolutely every happiness poll places north america at the top.
>>
>>57145677

Well, it's at least related to development of some sort. That said, we have a webdev general for these specific sorts of questions.

>>57145709

Not interested.

>>57145711

Mods delete large swaths of posts on /dpt/ whenever it gets too political, because it's "off topic", and sometimes will even delete the entire thread for it. I'd like to prevent that situation from happening. Since the old thread is dead, I think we should not bring existing political discussions into the new threads to avoid them being deleted.

>>57145721

epoll? Like a strawpoll-like site?
>>
>>57145771
>server
Also, P2P game experiment
>>
>>57145758
>neural network
Way too complicated.
What you want is a simple, fast similarity check.
Just convert that image to gray scale and scale it down to like 32x32 or something.
Then you compare that byte for byte (maybe allow for a tiny window here).
>>
>>57145813
epoll(7), the linux kernel event-based IO facility
>>
>>57145794
No, scandinavia generally wins. I'm danish and I remember a few times when we've placed at the top. I could imagibe canada taking it though
>>
>>57145833
b--but neural networks is fun

>muh AI
>>
File: ZHappiness.jpg (231KB, 890x1126px) Image search: [Google]
ZHappiness.jpg
231KB, 890x1126px
>>57145859

the US is not at the very top, but at the top nonetheless.
the crown indeed belongs to either denmark, switzerland or norway.
>>
http://www.inc.com/salvador-rodriguez/devschool-coding-bootcamps.html

i think if he can do it you can do it too
>>
>>57145859

north america is still at the very top nonetheless, because all three constituents - USA, mexico, canada - score high in happiness polls. whilst europe includes not only blessed places as switzerland or denmark, but also ukraine, greece and other poorfags.
>>
>>57145833
it could also be taught to learn how to recognize pepe in general, so any kind of pepe variant will be picked up as well
>>
>>57145921
Good luck getting a database of thousands of pepes.
>>
>>57145846

Oh, shit. Thought it was like an e-poll or something. Was not aware this was a thing.
>>
>>57145931

>search for "pepe meme" in Google
>take first 1000 results
>>
File: peon.gif (16KB, 166x161px) Image search: [Google]
peon.gif
16KB, 166x161px
>>57145921

Here, you can test it against this not-pepe to see how good your classifier is.
>>
Anyone wants a moderately easy algorithmic challenge?
>>
>>57145953
i'd love to do your homework yes
>>
>>57145940
I'll train a neural network if you make a torrent of at least 1k pepe images.
Then you will able to back propagate any image and "transform" it into a pepe image through the network automatically.
>>
>>57145697
Is this guy a tripfag?
>>
>>57145974

he is, albeit a tolerated one, since his contributions to threads are valuable and mildly entertaining.
>>
>>57145990
More importantly: Is she cute?
>>
>>57145970
This would be the most fruitful application of the project by far. The machine-created pepes might be the rarest yet.
>>
>>57146001

she tries to convince everyone she is male, so no clue.
>>
File: 1476888687751.png (1MB, 1200x1800px) Image search: [Google]
1476888687751.png
1MB, 1200x1800px
>>57146001
Yes.
>>
>rare pepe
reddit
>>
>>57146012
I'll even make a web service where you can upload any image and it will be transformed on the server and returned back to you.
Just get me a big database of pepes.
>>
Recurrent perceptron rare pepe generator when?
>>
>>57145721
Why would it be a muiltthreaded? I thought tht whole point of epoll was to avoid threads and use a single threaded event based model. Just like NodeJS in a sense.
>>
>>57145953
We are going to the hills. A is a vector of n heights (integers) on our way. We want to place as many flags on the hilltops on our way as possible. A hilltop is a place A[i] in which A[i-1] and A[i+1] are smaller than A[i]. The only restriction is the distance between the flags has to be greater or equal than the number of the flags placed.
Assume the first and the last heights in vector A aren't hilltops.
>can be done in O(n)

>>57145967
I already have the solution.
>>
>>57146031
>54 kg
why is java so fat?
>>
>>57146072
Yes but it's still possible to achieve greater performances by spawning one thread per core. The fact NodeJS doesn't do this is due to laziness and, Javascript.
>>
>>57146102
Same reason as for PHP.
>>
>>57145939
It's select, but faster.
>>
>>57145794
How is this relevant tho? I'm simply correcting an assumption that didn't address happiness at all, unless you think empathy and happiness has strict correlation
>>
>>57145764
There is something called books, they have and will always be your best source for learning how to program.
>>
>>57146215
wtf is book
>>
>>57146215
>books

wat
>>
>>57146225
The only media that is actually useful.
>>
>>57146215
>2016
>books
>>
>>57145697
Hello. I made a scrapper that logged all your post since you started using 4chan. After deep analysis and datamining I've been able to reveal your true identity. What do?
>>
>>57146232
kek. you overshot a bit there fampai
>>
>>57145721

I made a simple proxy for fastcgi traffic that used Epoll, so maybe I could help..

https://github.com/DuSTman31/FastCGI-Proxy/blob/master/prox.cpp
>>
>>57146314
>https://github.com/DuSTman31/FastCGI-Proxy/blob/master/prox.cpp#L182
>GNU style
>7 levels of indentation

kill yourself. do it now.
>>
>>57146332
>not liking freedom braces
>>
>>57146314
I'm having a hard time to understand edge-triggered mode which is necessary when multithreading. Thanks for the link though.
>>
>>57146332

Ok. I'm killed.
>>
File: Angewidert.png (114KB, 320x320px) Image search: [Google]
Angewidert.png
114KB, 320x320px
>>57146314

>Sepples
>>
>>57146365
edge-triggered is inherently racy and therefore useless.
>>
>>57146387
>2016
>not using sepples
>>
>>57146393
Can you explain more about it? I don't understand it very well actually. Tried to check the kernel source but it didn't help
>>
>>57146365
Why do you need edge-triggered for multi threading?
Do the docs say level-triggered doesn't work with threads?
Or does the level-triggered behavior not work for you?
>>
>>57146387
I started off writing it in plain C, but couldn't be arsed making my own map to store the connections rather than using the STL one..
>>
>>57146409
>2016
>using sepples
>>
>>57146416
For performance reason. It works fine level-triggered but then I have to check for each events if they're already being processed by another thread, unless I'm doing something stupid.
>>
>>57146473
I might be tempted just to have the separate threads handle different sets of connections, and just add new connections to whichever thread:epoll set had the least at that time.
>>
File: traurig.jpg (23KB, 400x343px) Image search: [Google]
traurig.jpg
23KB, 400x343px
why do people require EXTENSIVE experience for STUDENT jobs????
>>
>>57146511
>for students
what gave you that idea
>>
>>57146518

dunno about the US, but in germany, there are jobs aimed specifically at students.
>>
>>57146508
I didn't think of that, I'll try
>>
How do I average two ints again?
>>
>>57146554
(x+y)/2
>>
>>57146554
Add them and divide by 2
>>
>>57145603
They learned their math and their chemistry the right way.
>>
>>57146554
Use GMP.
>>
>>57146554

( int + int ) / 2 //, pajeet
>>
>>57145697
Oh shit somebody bought Ruben! Must be all those make files a

Also, hi Ruby!
>>
>>57146559
No
int average(int a, int b){
return a/2 + b/2;
}
>>
>>57146577
Full retart.
>>
>>57146584
define retart
>>
>>57146577
>not shifting
It's like you hate performance.
>>
>>57146584
define Full
>>
>>57146617
define define
>>
>>57146599
>what is compiler optimization
When you need performance just use ASM. C code should be easy to read.
>>
>>57146592
>>57146617
>>57146628
バカなの?
>>
>>57146592
#define retart
>>
>>57146628
#define define define //retart
>>
>>57146659
define #
>>
>>57146559
>>57146560
>>57146568
wrong

>>57146565
>ints
>>
>>57146685
I use GMP for all of my high precision averaging needs.
>>
>>57146671
define the concept of definition without using a pre-existing concept of definition while doing so
>>
>>57146710
yes
>>
>>57146710
define the language you used to write that post
>>
File: IMG_2265.jpg (2MB, 3500x2333px) Image search: [Google]
IMG_2265.jpg
2MB, 3500x2333px
it does temperature

"long" sensor is the upper one. it has less degrees because sprayed it with some alcohol
>>
Does /dpt/ has a programming challenge sheet?
>>
>>57146732
>it has less degrees

Have you reinvented refridgerators?
>>
File: umarusfs.jpg (115KB, 1280x720px) Image search: [Google]
umarusfs.jpg
115KB, 1280x720px
>>57146685
>wrong
how so ?
>>
>>57146728
define the concept of communication without communicating it
>>
>>57146732
>spraying alcohol
alcohol is for drinking
>>
>>57145590
What are some good resources to get a semi-thorough understanding of OOP and algorithm analysis?
>>
>>57146740
Evaporation makes stuff colder.
That's how sweating works.
>>
>>57146756
>Implying you're an human who need to postpone death with liquids
>>
>>57146771
>understanding of OOP
There is nothing to understand.
>>
>>57146756
not isopropyl
>being on a tech board
>not having isopropyl at home
are you like one of those meme guys?
>>
>>57146745
Assuming unsigned 64 bit numbers, use your program to average 2**50 and 2**50+2

>>57146703
>he can't even average ints together
t.pajeet
>>
void avg(int a, int b) {
printf("(%d + %d)/2", a, b);
}
>>
Learning C and thinking about learning C++ too.
Should I practise both at the same time little by little or learn C thoroughly and then C++?
>>
>>57146805
you never said anything about unsigned, bit size, or even if your question was about pure maths or related to a specific programming language.
>>
>>57146828
>Learning C
What do you mean by this?
>>
>>57146832
What? Do you mean there are other languages than C?
>>
>>57146805
>use your program to average 2**50 and 2**50+2
Do you want to imply that it overflows?
Because it doesn't (assuming it does (x+y)/2 with 64 bit numbers).
2**50 + 2**50 + 2 ~ 2**51

Do you even know how powers work?
>>
>>57146771
what programming languages do you know ?
>>
>>57146838
reading books to learn about the language
maybe do some projects later on
>>
>>57146851
Brainfuck, Molboge and whitespace
>>
>>57146864
Sounds 出来ない to me. The only way to learn a language is to write it.
>>
File: out.webm (1MB, 1920x1080px) Image search: [Google]
out.webm
1MB, 1920x1080px
>>57145590

I'm learning OpenGL making a simple vehicle simulation.

GUI bits aren't finished yet, nor is most of the program.
>>
>>57146899
yes
>>
>>57146848
kek, dat guy can't even meme right.
>>
>>57146881
Well yes the books contain sample code and exercises so there's code writing as well.
>>
>>57146912
>epic troll guiz
>i just pretended to be retarded
>>
>>57146832
>dpt thread
>daily programming thread
>thinking a question on the daily programming thread is not about implementation and about pure math on the daily programming thread

>>57146848
I... I am not a bright man.
2**64-1 and 2**63
>>
>>57146921
That's not how it works.
>>
>>57146925
even that, he never specified the programming language
>>
>>57146851
Java and some python
>>
>>57146899
very ncie
>>
>>57146947

let me guess
you are indian
>>
File: umarusummer.jpg (56KB, 848x480px) Image search: [Google]
umarusummer.jpg
56KB, 848x480px
>>57146805
In this case
uint64_t average (uint64_t x, uint64_t y) 
{
return (x/ 2) + (x / 2) + (x & y & 1);
}
>>
>>57146938
Just guess between ARM andx86_64.
>>
>>57146932
How does it work o I need to know.
>>
>Did a minor amount of travelling after graduation, now starting to look for graduate jobs
>Asking my friends and contacts what they did
>Every single fucking person I know is retarded and incapable of negotiating properly
>They complain about shitty conditions when its entirely their fault

I've got friends staying in expensive ass hotels because they were too retarded to tell their employer that they needed a week to find somewhere to live, friends who somehow negotiated themselves into a shitty salary because they thought it was "rude" to negotiate it or bring it up and then felt obligated to accept when a contract was presented (wtf), etc.
>>
>>57146925
>thinking dpt is more than shitposting of pseudo-programmers
>>
>>57146947
http://composingprograms.com/pages/25-object-oriented-programming.html
>>
>>57146958
I'm not...
>>
>>57146974
>pseudo-programmers
What's a real programmer then?

>inb4 pajeet
>>
>>57146978
Thanks!
>>
>>57146997
One that has a Job and doesn't shitpost from mommies basement.
>>
>>57146511
filtered
>>
>>57146539
No one calls those jobs in the US.
>>
>>57147011
>One that has a Job
Haha no. I don't want to burst your bubble but the small useless world you live in doesn't care if you're a compliant code monkey or not.

>doesn't shitpost
Keep pissing Java instead of actually trying to enjoy the universe gift.
>>
>>57147106

what are they called then? internships?
>>
>>57146960
>x & y & 1

Captcha: Burger
>>
>>57145967
How's the "homework" going?
>>
>>57147089
on the caps or on the frog pic?
>>
>>57147128
it's a trick for
(x % 2 && y % 2)
(check if both x and y are odd numbers).
>>
Help me understand threads.

void shit()
{
for(int i=0; i<30000; ++i)
{
std::cout<<"Shit\n";
}
}
void fuck()
{
for(int i=0; i<30000; ++i)
{
std::cout<<"Fuck\n";
}
}
int main()
{

std::thread T2(fuck);
shit();
T2.join();
return 0;
}


Why does this take almost as much time as using a single thread?
>>
>>57147190
I know what it is. Check it again.
>>
>>57147237
>std::thread
There is nothing to understand.
>>
>>57147248
Whoops, I'm retarded. Sorry >>57147190
.
>>
>>57147237

Because you are using join, rather than detach. Look at what each one does, you'll understand the problem.
>>
>>57147237
Cause you're writing to stdout
>>
>>57147237
I guess they are both wait on stdout.
Try sleeps.
>>
>>57147282
>>57147289
Wrong answers, see:
>>57147278
>>
>>57147298

Even considering the wait on stdout, using join won't give Anon the performance increase they are looking for. You won't have both threads running simultaneously if you use join.
>>
>>57146710
A statement is a definition if and only if it is in the form "A x is a y if and only if z."
>>
>>57147332

Wait, I reversed the order of replies and thought you were saying I was wrong.
>>
>>57146710
A definition is an equivalence relation.
>>
>>57147403
define relation
>>
>>57147332
But even when joining, they still should run in parallel, until they hit the join.
>>
>>57147237
Because std::cout doesn't scale.
>>
>>57147407
It's a mathematical relation. A relation on a set A is a subset of AxA.
>>
>>57147454
hmmm
>>
what is the point of critizing OOP?

OOP is a feature in imperative languages. dont like it -> dont use it. albeit is makes solving most problems just so much easier.
>>
>>57147462
An equivalence relation is a relation that is reflexive, symmetric and transitive.
>>
>>57147480
t. pajeet
>>
>>57147480
>dont like it -> dont use it
tfw I'm the only autistic programmer who just wish simplicity..
>>
>>57147491
hmm
>>
>>57147495
t. shitposter
>>
>>57147282
>>57147289
>>57147440
Yes, this was the problem. Doubles my speed when I just have the functions do some arbitrary calculation instead of using cout.
>>
>>57147491
define is
>>
>>57147237
std::atomic<bool> done[2] = {false, false};

void a()
{
for (int i = 0; i < 30000; ++i) {
std::this_thread::sleep_for(10ms);
}
done[0] = true;
}

void b()
{
for (int i = 0; i < 30000; ++i) {
std::this_thread::sleep_for(10ms);
}
done[1] = true;
}

int main(int, const char **)
{
std::thread t1{[&]() { a(); }},
t2{[&]() { b(); }};
while (!(done[0] && done[1])) {
std::this_thread::sleep_for(10ms);
}

t1.join();
t2.join();

return 0;
}
>>
>>57147440
Correct.
Standard out is not webscale.
You need Mongo DB and a Hadoop cluster to print 60000 strings in a scale able way.
Trust me, I work at a successful startup (it's like amazon for gold fish).
>>
>>57147526
I know you're memeing but he's right - I/O is expensive and usually the cause of most bottlenecks.
>>
>>57147520
third-person singular simple present indicative form of be
>>
>>57147526
>it's like amazon for gold fish

lel
>>
>>57147526
When will the MongoDB meme die?

>Hadoop
>Java
Also, no.
>>
>>57147545
define be
>>
Can /dpt/ prove that 30 + 30 = 60?
>>
>>57147576

the compiler says so

the compiler is always right
>>
>>57147561
exist
>>
>>57147524
>Using atomic bools instead of condition variables
>>
>>57147576
when will the circlejerk end
>>
>>57147588
define existence
>>
>>57147524
Full retart.
>>
>>57147592
never, it's /dpt/ after all

>>57147576
Only if you give me your definition of +, 30, 60 and =.
>>
>>57147576
theory Dpt
imports Main
begin

theorem aaaa: "30 + 30 = 60"
apply(auto)
done

end
>>
>>57147633
>apply(auto)
That's cheating.
>>
>>57145590
I just read a couple short chapters on C (coming from C++).
I also found out something I never knew:
for(;;){
//do shit
}

is valid

I always thought you had to do like while(true) or while(1).
I didn't know you could do that with a for() loop at all...
Now, here's my question: is there any particular reason TO use a for() loop like that instead of while(true) or while(1)?

Additionally, since my interest in C is mostly Operating Systems, how easy or difficult would it be to start a kernel from scratch that I can dump into a VM?
Just like a side project atm.

How difficult would it be to write a bootable kernel (that maybe says, i don't know, fucking "Hello World")?
Furthermore, how difficult would it be to make it turn off?
>>
>>57147626
>Only if you give me your definition of +, 30, 60 and =.
One might define 30 as S^30(Z).
>>
>>57147651
Then it's trivial and an exercise for the reader.
>>
>>57147606
https://www.youtube.com/watch?v=D_d3KN1d7Y0
>>
>>57147647
Quoting another anon:
for(;;)

looks sad.

while (1<3u)

Much better.
>>
>>57147673
saving that

That's wonderful, Anon
>>
>>57147673
#define FUCKYOU true

while(FUCKYOU)
>>
>>57147646
theory Dpt
imports Main
begin

theorem aaaa: "30 + 30 = 60"
apply(simp)
done

end

>>
"true" undefined. First use in >>57147704
>>
do ruby and ruby on rails have any relevance for the job market?

i barely see anything where they are used.
>>
Is there a reason to use C in your personal projects over C++ in 2016?
>>
>>57147704
#define you ;;
for (you) {
printf("Pajeet\n");
}
>>
>>57147723
Just use 1 instead. The poster before that used true already so I assumed it was defined.
>>
>>57147743
autism
>>
>>57147743
Yes, being retarded and not understanding the beauty of C is a valid reason.
>>
>>57147480
>OOP is a feature in imperative languages.
no
>>
>>57147743
Did you get that the wrong way around?
>>
>>57147745
I like this one.
>>57147765
Yeah, it's more of a regression.
>>
>>57147743

There's a formally verified compiler available for c. Not for c++. There's a verification annotation language (acsl) for C. Again, I'm not aware of one for C++.

So that's an argument if you're targeting high reliability for your projects.

Also, penis.
>>
>>57147783
>Also, penis
4chan please
>>
>>57147783
Sometimes you are required to use shit like MISRA C.
>>
File: threads.png (127KB, 936x595px) Image search: [Google]
threads.png
127KB, 936x595px
I've got a bit of a problem /g/, and I was wondering if you could help.

I'm writing a textboard using Flask (which uses the Jinja templating engine).

If I wanted to display all the threads, I could just query the db and pass the result dictionary from the controller to the view and do something like:

    {% for thread in threads %}
display thread here
{% endfor %}


The problem I'm having is: how the fuck would I display the last couple of posts to a thread (like pic related).

Any ideas how I'd do something like this?
>>
>>57147847
use sorting and LIMIT in SQL?
>>
>>57147847
Since you're probably using SQLAlchemy you can setup a relationship then limit the queried children to only last few (or first, not sure what you want) then extend the thread rendering method to include those if the children member is set and contains any results.
>>
>>57147847
>Webdeveloper in 2016
>framework doesn't do everything
>shit himself
t. whatever

(where does the t. meme come from anyway?)
>>
>>57147868
It's not a question of how I get the data, I know exactly the queries I'd need to do.

It's how I somehow get the two query result dictionaries (threads and thread replies) and render them together.
>>
>>57147892
>(where does the t. meme come from anyway?)
Krautchan /int/
It's a finish thing I think.

t. meme expert
>>
>>57147907
You know how to get the data and you know how to display it.
I don't understand your problem.
>>
Is there any good/simple/open-source game like teeworld? I'm bored.
>>
>>57147892
It comes from Finnish chans, where "t." is short for their equivalent of "sincerely" or "best regards" from what I remember.

This isn't so much a dependency on frameworks (Flask is a micro-framework, it's a large reason why I'm using it), it's just how unfamiliar I am with creating views with Jinja.
>>
cout << "Would you like flight 3, 4, or 5? ";
int flightChoice;
cin >> flightChoice;
switch (flightChoice) {
case 1:
cout << "You didn't choose a valid flight. Choose again: "
cin >>flightChoice;
case 3:
cout << "You chose flight Three" << endl;
FlightThree++;
break;
case 4:
cout << "You chose flight Four." << endl;
FlightFour++
break;
case 5:
cout << "You chose flight Five." << endl;
FlightFive++
break;
default:
cout << "flight not available. Choose another: ";
cin >>flightchoice;

}


I'm trying to make a program where a user picks which flight to go to and if they choose flight one I want it to say that the flight is not valid and have them pick another flight. It seems to let me pick another, but it won't register it when there is a summary at the end when it's suppose to state which flight the user picked.
>>
what is the most and the least "elegant" general purpose programming language?

imo,
most: ruby
least: c++
>>
>>57148059

For case 1: it's suppose to say
"Flight One is not available" 
>>
>>57148060
>c++
>not elegant
hmm
>>
>>57148060
What a stupid question. "elegant" is about as subjective as it gets.
That being said, it's Haskell of course.
>>
>>57147892
>>57147912
>>57147944
It came from Yililuta (probably the only Finnish chan, recently deceased) and was later exported to Krautchan. The simplest translation is "regards" and a common usage was usually

"t. knower"

as in, "regards, one who knows all about [subject]", generally for menial subjects. Once it made its way here, it developed other usage like "t. pajeet" or >>57147912 's "t. meme expert" - it's not meant to be overused and it's not meant for complex titles
>>
>>57148060
Most is Lisp.
Least is Perl.
>>
>>57148060
Most: Haskell
Least: PHP
>>
>>57148060
Scheme wins in elegance. Only has a single structural primitive: The cons cell.

C++ varies a lot. The template code syntax is a pain, but RAII is quite a neat pattern for what it does..
>>
>>57148060
most elegant: C, ASM, Haskell
least: Everything else

>tfw they think you're a meme but can't accept such a simple truth
>>
File: 1476846711237.jpg (30KB, 467x435px) Image search: [Google]
1476846711237.jpg
30KB, 467x435px
>>57148103
>most elegant: C
>>
>>57148131
It's elegant because it's actually useful.
>>
>>57147237
Not that guy, but I was actually thinking it'd be faster

#include <iostream>
#include <thread>

void foo(uint64_t length)
{
uint64_t a = 0;
uint64_t b = 1;
uint64_t temp;
for(uint64_t index=0; index<length; index++)
{
temp = a;
a+=b;
b =a;
}
}

void bar(uint64_t length)
{
long i;
float x2, y, number;
const float threehalfs = 1.5F;
for(uint64_t index=0;index<length;index++)
{
number = (float) index;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
}
}

int main()
{
const uint64_t test=100000000;

// std::thread T2(foo,test);
foo(test);
bar(test);
// T2.join();
return 0;
}

With threading: 3.06
Without threading: 3.05


Eh. I don't have a powerful PC anyway. Only 2 cores, 2 GB of ram. It's under 60% workload right now. I shouldn't expect too much difference. I was hoping it would be less, though
>>
>>57148059
Because you modify the variable you are switching on.
It would have to execute the switch again.
The switch is a one-of decision, it decides which case to run and does so *once*.
It's not like a cascade of ifs.
>>
File: Psycho2.jpg (8KB, 170x170px) Image search: [Google]
Psycho2.jpg
8KB, 170x170px
>>57148148
>C
>useful
>in 2016
>>
>>57148148
yeah useful for all those operating systems everyone writes
>>
>>57148183
>>57148195
>>>/g/wdg/
>>
>>57148212
>C
>>>/his/
>>
>>57148149
You could use a finite state machine for that.
>>
Where does g++ store exception objects?
>>
>>57148332
in ur butt
>>
>>57148353
>>>/b/
>>
>>57148370
>>>/b/utt
>>
>>57148332
Guess it'd have to be on the stack. Thread local storage wasn't implemented until the itanium abi, and exceptions are thread-local.
>>
>>57148171

So would I have to create another switch statement within that case?

 
case 1:
cout << "flight 1 not available. Choose another: ";
cin >> flightChoice;
switch (flightChoice){
case 3:
break;

}
break;
>>
Guys I have a question
I use Transimssion-qt on Windows 7 for torrenting.
There is an option in prefferences to execute a script when torrent finishes.
I made a simple script:
@echo off
taskkill transmission-qt.exe
I chose to execute it.
The script works on its own when I double click it, a command prompt pops up for 0.1 sec and Transmission shuts down.
BUT
When a torrent ends, the cmd pops up but Transmission doesn't shut down and just keeps on going.
What gives?
>>
>>57147651
>>57147665

Whoa, whoa, somebody remembers my shitty "proof"..
>>
>>57148438
And what do you do when the user picks 1 again? Another switch?

What you need is a loop around your switch. While the user hasn't picked a valid option, keep asking them.
>>
>>57148438
You could use nested switches.
But something more disciplined like finite state automata (look it up) is better.
>>
>>57148490
Trust me, it's not as scary as it sounds.
>>
I want a simple codemonkey job.
Would it be a mistake to go to college for computer science?
>>
>>57148332
https://mentorembedded.github.io/cxx-abi/abi-eh.html#imp-emergency
>>
>>57148515
Just go to a 6 week coding academy. If it's too hard for you, getting a degree might be your only chance to learn.
>>
>>57148515

Only if you pay for it. If you can get a degree without any debt, go for it.

>computer science
>not getting an easy degree like computer information system and supplementing with experience (internships, your own work, etc)
>>
>>57148471
the application may not have permission to execute scripts? this is a faglt question
>>
>>57148567
But computer science already is an easy degree.
>>
Learn Ruby y/n?

I consider applying for Ruby jobs after graduation, since less competition.
>>
>>57148600
>less competition
I doubt that.
>>
Can /g/ help me decide which to major in? Programming and Analysis or Software engineer?
>>
>>57148634
if there's no computer science degree i'd go with software engineering. i've only taken 1 SE class and it made me want to blast my brains out, fwiw
>>
>>57148650

CS is out of the question, are you saying SE instead of programming because it pays more?
>>
>>57148600
Get started with Elixir instead. It's going to be the next big thing/
>>
>>57148700

listen to him.
study greek literature or gender studies.
>>
>>57145590
discord invite please
>>
>>57148634
>Can /g/ help me decide which to major in?
No.
>>
Tried out F# today. Pretty cool stuff.
Here's something, I guess.
open System
open Microsoft.FSharp.Core
open System.Collections.Generic

let print = printfn "%A"

let wraps str padding =
padding + str + padding

let rec intToBase (b:int) (i:int)=
match i with
| i when i < b -> string i
| _ -> String.concat "" [intToBase b (i / b) ; string (i % b)]

let rec baseToInt (b:int) (s:string)=
match s with
| s when s.Length < 2 -> (int s)
| s -> (baseToInt b s.[0..(s.Length - 2)]) * b + (int s.[s.Length - 1]) - (int '0')


let fromEnd(str:String)(i:int) =
let max = str.Length - 1
let negativeIndex = max - i
str.[negativeIndex]

let neighborhoods (str:String) =
"0"
|> wraps str
|> Seq.windowed 3
|> Seq.map(String.Concat)

let ruleString n b =
n
|> intToBase b
|> fun s -> s.PadLeft(pown b 3, '0')

let next rule b gen =
gen
|> neighborhoods
|> Seq.map(fun neigh ->
neigh
|> baseToInt b
|> fromEnd (ruleString rule b )
)
|> String.Concat

let render =
Seq.map(function
| '0' -> ' '
| c when c <> '0' -> c)
>> String.Concat

let rec propogate i b rule gen =
gen
|> render
|> print
match i with
| 0 -> ()
| _ ->
next rule b gen
|> propogate (i - 1) b rule


[<EntryPoint>]
let main argv =
String.replicate (int argv.[0]) "0"
|> wraps "1"
|> propogate (int argv.[0]) (int argv.[1]) (int argv.[2])
0


Try running with the args
63 3  387459870
>>
>>57148682
i've just never heard of a programming and analysis degree, and idk if most employers will have heard of it either. if they have a lot of the same requirements you could try to double major. programming and analysis sounds like more of the stuff i enjoy about computer science. ie more theory and less discussion of UML diagrams and boring shit like design processes
>>
>>57148775
you might like haskell
>>
>>57148790
I've tried it before. I like F# a bit better. But I suppose I could give haskell a second chance
>>
>>57148775

that syntax looks whack. especially the |
>>
>>57148806
>I like F# a bit better
I don't understand how
>>
>>57148814
Yeah it takes a bit getting used to.
>>57148824
I was still new to programming when I looked at haskell. Didn't know what type systems were or any of that jazz. Higher order functionality was lost on me
>>
>>57148775
Wait till you see type providers.
>>
>>57148782

It's just the problem right now - is i don't think i'll be able to finish the 2 HS preqreqs for either programs by January.

Programming can start in May but the software program only starts in sept or jan.
>>
>>57148849
are these just associate degrees or something similar? if so, definitely go with the software engineering program. also you're going to have to have to have a good github to get an internship, and then 1 or 2 internships to get a good job but after that i'd imagine you'd be as hire-able as someone with a bs in computer science
>>
>>57148846
Just looked them up.
computed on-demand type factories. Cool Shit
>>
>>57148842
Well I can't think of much that can be done in F# that can't be done in Haskell
>>
>>57148881

Their an advanced diploma
>>
File: seeing-red.jpg (284KB, 2507x1673px) Image search: [Google]
seeing-red.jpg
284KB, 2507x1673px
>rewrite something from scratch
>it's now larger and even worse

FUck this shit programming as a hobby this isn't what I wanted I can't live like this
>>
>>57148849
What are the prereqs?
>>
>>57148898
Isn't that the point of universal completeness?
It's about the expression of what you're trying to do.

I want to do research into the formal enumeration of Cellular Automata families.

It seems to me F# handles data sciences a bit better, I could be wrong.
>>
>>57148922
>cellular automata
comonads
>>
>>57148898
Running on .NET and interfacing with C# is a big one Haskell can't do.
>>
>>57148928
That's sweet! Thanks!
>>
>>57148907

Ontario Secondary School Diploma (OSSD) or equivalent with:

Grade 12 English: ENG4(C) or ENG4(U)
Grade 12 Mathematics: (C) or (U) or Grade 11 Mathematics: (U) or (M)

Both programs have the same requirements
>>
File: vitality.png (159KB, 307x311px) Image search: [Google]
vitality.png
159KB, 307x311px
>when the super male vitality supplements finally kick-in and turn you into a super programmer.
>>
>>57148943
Well I can't think of much good that can be done in F# that can't be done in Haskell
>>
>>57148956
Oh okay. Try calling them. Explain your situation and it might help you out. It might be a program that you get into while you're already in the school.
>>
why was this redundant syntax necessary?

Object cube = new Object


We repeat the name of the class twice?
>>
>>57149028
look into polymorphism
>>
File: 1467852551435.png (1MB, 1357x1281px) Image search: [Google]
1467852551435.png
1MB, 1357x1281px
>>57148983
>when the estrogen and testosterone blockers kick in and you turn into a super duper programmar
>>
>>57148746
sent
>>
>>57148985
PatternSynonyms combined with ViewPatterns changed that, but F# has active patterns which
GHC Haskell couldn't do nicely up until recently.
And you don't have Haskells age old record name problem in F#.
Are overloaded record fields in the recent GHC or did they postpone that?
>>
>>57149046
you can use DuplicateRecordFields assuming the type perfectly identifies it
>>
I'm trying to get into OpenGL, but there's a part I don't understand.

Element array buffers are used to store as few vertex data as possible. So if I have a cube, I only need 8 vertices for each corner, and the element array tells how to connect those to create all the triangles.

But how can I apply this to textures?

The tutorials I have found so far abandon using element arrays at this point, and just describe the cube with as much vertices as needed, and they apply the corresponding texture point to each point. Why is that? How could I handle texture data while setting up the least amount of vertices?
>>
>>57149088
Awesome.
>>
When doing 0-padding for converting hex to base64, Wikipedia translates an index of 000000 to =, why do that instead of translating it to A?

Should the implementation care whether or not an index of 0 was generated through padding or occurred naturally in the input?
>>
>>57148775
Are there jobs for F# devs?
>>
>have a CS bachelors
>no portfolio
>weak fizzbuzz skills
>barely remember a prog language
>no internship since company i went to didn't give me a cert
>only experience is a manual labor job wiring telephony equipment to outside facilities for 18 months
>quit that job because pay is shit
>neet for 17 months now

I'm relearning Python, but I know just that won't get me anywhere.

Any advice is welcome.
>>
>>57149459
Be smarter.
>>
>>57149459
>Any advice is welcome.
Stop being exactly like me. I'm a fuckup. Just be like anyone else and you'll be fine.
>>
>>57149459
>>weak fizzbuzz skills
Maybe you should learn Haskell
>>
>>57149102
>Why is that?
Because the texture coordinates aren't equal at all the vertices.
>>
>>57149459

Learn java or C#

depending on the fashions in your area.
>>
new thread when ? :3
>>
What's the game development thread in v or vg called? Can't find it.
>>
>>57149611
App development is strong here, but I don't want Java. I get nightmares.

>>57149526
Is there a market for that?

>>57149515
I'm so sorry.

>>57149488
Trying.
>>
>>57149716
>I don't want java

do you want a job?
>>
>>57148591

Computer Information System is even easier.

Protip: If you just want to be a code monkey, you don't even need a degree other than to have the robot resume filter not throw your resume in the trash.

Furthermore, you don't even have to touch Calculus 2+ or Physics. Stuff a code monkey doesn't even need. Unless you actually want to touch CS jobs like designing algorithms then the most basic degree is good enough.
>>
>>57148484
>>57148438
>>57148171
>>57148059

Thanks, I had to do a do-loop to get the program to work the way I wanted the program to work.
>>
>>57149713
>>>/vg/agdg
>>
>>57149733
Sure, but Java is a mess to deal with.

Ah fuck it. Guess I'll bite the bullet.
>>
New thread:
>>57149874
>>57149874
>>57149874

No stupid reddit shit in the OP edition.
>>
>>57146102
You realise 54kg is like 100lbs?
>>
>>57149037
Is Karlie Kloss a man... or a woman... or?
Thread posts: 317
Thread images: 16


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

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


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