[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: 315
Thread images: 44

File: 1480661992200.jpg (194KB, 1024x1101px) Image search: [Google]
1480661992200.jpg
194KB, 1024x1101px
Old thread: >>58888613

What are you working on, /g/?
>>
anime
>>
Midna a cute.
Will I run into problems if I never use private? I almost always use public for my variables and functions. The books tell me to set things to private so people don't have access to things they shouldn't but if they're already doodling with the code don't they have full access already?
>>
>>58894674
learning web dev.. any one know a good site/board I can go on and beg for answers for my JS questions?
>>
>>58894794
yes you should when you finally make a full real application making them all public will cause lots of problems for your program
>>
>>58894809
No.
>>
>>58894794
no one will hire you, its a security nightmare.

lets say you have a function that allows for transfer or reception of money. Then the variable for the cash is public. See what could go wrong
>>
why is qt so fucking expensive
>>
>>58894794
you're fucking retarded
>>
>>58894794
>set things to private so people don't have access to things
>people don't have access
>people
this is obviously bait.
>>
>>58894822
wow, except private does literally nothing to protect that field. It's like you don't understand what the keywords actually do. Private is just a suggestion, if someone's able to interact with your code in that way they can just get the field by peeking at the object in memory and guessing offsets.
>>
for the following


double bmi (double;

int main

cin height
cin weight
cout bmi
}

double bmi(n);
double n
n = weight / height^2



what am i doing wrong to not be able to call bmis value

obv this is pseudo code of c++
>>
>>58894825
It's for gaylords. Gaylords have a lot of money or are willing to pay a lot of money for things because they are also hipsters.
>>
>>58894794
when you're dealing with a bunch of contributors this is a thing you need to consider.

For now don't worry
>>
>>58894856

>obv this is pseudo code of c++
How about you post the actual code, along with the error you're getting?
>>
I am overloading with 3 constructors, how does that make you feel buddy? eat shit

>muh clean code
>>
>>58894884
Smells like Java
>>
>>58894856
post actual code
>>
Pajeet here ask me anything
>>
dumb question time

if i close my program, is windows smart enough to free up the memory the program used?
>>
>>5889489>>58894881
#include <iostream>

using namespace std;

double BMI (double);
int main()
{
double height;
double weight;

cout << "Height" << endl;
cin >> height;
cout <<"Weight" << endl;
cin >> weight;
double n;
n = weight / (height * height);
cout << "bmi is " << n << endl;

return 0;
}

double BMI (height, weight)
{ double n;
n = weight / (height * height);

}
>>
>>58894926
Yes
>>
>>58894794
Public methods, private data.
aka: Make getters and setters and make all variables private and live happy
>>
>>58894939
you only declared 1 argument in the prototype and 2 in the definition, also you didn't include the types for the definition.
>>
>>58894809
Most things can be googled. Try to break down problems until you get stuck at a single thing and then ask for help
>>
>>58894958
this is what Java is all about
>>
>>58894809
pirate udemy nodejs and angularjs courses
i did those and i'd consider myself to be an expert webdev
>>
>>58894926
Most/all operating systems do that automatically.
>>
>>58894939
>>58894962
http://www.cplusplus.com/doc/tutorial/functions/
>>
>>58894926
Windows is a lot smarter than you think. At least a lot smarter than you, for asking such a stupid question.
>>
>>58895010
>>58894962
cheers, super easy fix

#include <iostream>

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;

cout << "Height" << endl;
cin >> height;
cout <<"Weight" << endl;
cin >> weight;
double n;
n = weight / (height * height);
cout << "bmi is " << n << endl;

return 0;
}

double BMI (double height, double weight)
{ double n;
n = weight / (height * height);

}
>>
>>58895054
now do it in Java
>>
>>58895054
you're not even calling the function anywhere
>>
>>58895054
double BMI (double height, double weight)
{ double n;
n = weight / (height * height);
}

Why isn't the compiler yelling at you for this
>>
>>58895086
I think it's technically valid on most compilers if the statements are within the block and end with a semicolon
>>
>>58895075
holy shit your right, i tried to fix it without having thefunction outside of main and forgot to remove it

#include <iostream>

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;

cout << "Height" << endl;
cin >> height;
cout <<"Weight" << endl;
cin >> weight;
cout << "bmi is " << bmi << endl;

return 0;
}

double BMI (double height, double weight)
{ double n;
n = weight / (height * height);

return 0;
}

now i get bmi is nan as the output
>>
>>58895111
You never gave input to your function and your function doesn't output anything either
>>
>>58895111
lol
you have to return n from bmi not 0
>>
pls rate

#include <stdio.h>

void fizzbuzz(int a, int b, int n) {
int i;

for (i = 1; i <= n; i++) {
if (!(i % (a * b))) {
printf("%d: fizzbuzz\n", i);
}

else if (!(i % a)) {
printf("%d: fizz\n", i);
}

else if (!(i % b)) {
printf("%d: buzz\n", i);
}

else {
printf("%d: %d\n", i, i);
}
}
}

int main(int argc, char *argv[]) {
fizzbuzz(3, 5, 100);
return 0;
}

/*
I like giant throbbing cocks in my boipussy.
*/

>>
>>58894894
smells like shit you mean?
>>
>>58895125
Not using argc and argv
4/10
>>
>>58895125
>Not doing Fizzbuzz in a proper OOP Enterprise edition

It's like you aren't even a real Software Engineer
>>
>>58895118
>>58895118
>>58895122
right

/**<  */#include <iostream>

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;
cout << "Height" << endl;
cin >> height;
cout <<"Weight" << endl;
cin >> weight;
cout << "bmi is " << BMI(height, weight) << endl;

return 0;
}

double BMI (double height, double weight)
{ double n;
n = weight / (height * height);

return n;
}


works now, but i fell i can optimise it better?
>>
>>58895149
what the fuck is this retarded language you're trying to speak? and no, i'm not talking about sepples
>>
>>58895159
what?
>>
>>58894982
nice ty, Nodejs is the backend for JS isnt it?
>>
>>58895054
1. You only run it once, so cin for the two arguments is tedious to use.
In your declaration of main, it should be like this:
int main(int argc, char *argc[]){
...

Then you call call your function with two arguments instead (like you do with other applications).
2. You didn't call the function, you wrote it twice.
3. The function was not properly declared. You need to return the n value.
4. I know this is 4chan, but fix your indentation. It is a fucking mess to look at.
>>
>>58895149
lol at "optimizing" this.
I guess what you really need is to write some multithreaded simd code in assembly language so that you can compute 16 BMIs simultaneously.
>>
Im currently working through an android development course online, however Im starting to loose interest in app development. But I still like programming...

Should I just switch to a pure Java or different programming language course or is it worth it to stick it on the android course?
>>
>>58895180
Nodejs is essentially a compiler for JS. It allows you to write an application backend in JS.
>>
>>58895197
apply to fixed pls
>>58895149
>>
>>58895205
developing a weather app is a meme
>>
memeing is totally mispelled
>>
>>58895225
What are non meme Android application projects to learn and do?
>>
>>58895242
fizzbuzz with a GUI
>>
>>58895180
no.

in past times, you'd need javascript for the frontend, some c type language for a backend, and then sql or something comparable else for a databse

nodejs allows you to use javascript for all of those. nodejs is a godsend, you should definitely learn it if you want to webdev. it's really powerful in ways you can't even comprehend. i wasn't joking when i said that i'm an expert webdev, and it's all thanks to nodejs.
>>
>>58895242
well since you need to ask the weather app isnt a meme to you since its necessary for learning shit.

android developement is a meme though. you can make money sure, but you cant make anything useful
>>
>>58895309
what useful applications could you make that would earn you lots of money on Android?
>>
>>58895258
what would that gui do?
>>
>>58895286
interesting, thanks for the info.
>>
Where is the real money in programming these days?
>>
>>58895380
being a CEO in charge of programmers and not a programmer
>>
whats a good win32 book other than the petzold meme
>>
>>58895334
none, especially sinec the mobile market favours ios. a clash of kingdoms or whatever its called clone will make you money.

>>58895380
like i said,
>>
i want to get into electrical engineering and programming robots n shit. oop would be uselesss in this case right? if i know c++ though, would that make it easier
>>
>>58894045
>>
myAny :: (a -> Bool) -> [a] -> Bool
myAny f xs =
foldr (\x b -> f x || b) False xs

> myAny even [1..]


what are the values of x and b in the anon func
>>
>>58895423
x is an element in the list and b is the state
>>
File: 1470588821776.jpg (186KB, 705x1000px) Image search: [Google]
1470588821776.jpg
186KB, 705x1000px
>tfw every project is a lonely endeavor
>tfw not a single person to share code ideas with
>all people I know are code monkeys who wouldn't understand
>>
>>58895466
i cant believe overwatch wasted money to use starcraft 2 in their game
>>
>>58895385
i'm interested in this too since qt is too expensive

i looked up the book you mentioned but that's from 1998, is there anything more recent? also, what's wrong with just using SDL to write a program even if i only use it to render a gui? at least i somewhat know my way around video game engines.
>>
File: 004[1].png (454KB, 905x1300px) Image search: [Google]
004[1].png
454KB, 905x1300px
>>58895503
>tfw no programming sempai
>>
>>58895546
she would probably work shit like kobayashi
>>
File: why.png (16KB, 588x546px) Image search: [Google]
why.png
16KB, 588x546px
I dont get it.

Why?
>>
>>58895546
>sempai
there isn't such a thing
>>
>>58895571
cant you only use case once?
>>
>>58895571
a ~ b isn't a thing you can do
~X is binary NOT
so flips all bits
>>
>>58895571
~ is a unary operator
>>
>>58895589

Oh wait, you are right, I forgot about that.

Thanks.
>>
>>58895571
don't need break statements when you have a return statement btw
>>
File: 1462325170797.jpg (13KB, 240x180px) Image search: [Google]
1462325170797.jpg
13KB, 240x180px
>>58895532
Nothings wrong with SDL
I have a specific fetish for doing it with the Win32 API but eventually I'll probably make my own
>>
pls rate again

/* >tfw no pure functions */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

#define PROGRAM_NAME "fizzbuzz"
#define REQ_PROG_ARG_CNT 4

/* returns true if str contains only a positive int and returns false otherwise*/
int isstrposint(char *str) {
char *stritr = NULL;

for (stritr = str; *stritr != '\0'; stritr++) {
if (!isdigit(*stritr) || atoi(str) <= 0) {
return 0;
}
}

return 1;
}

int parseargs(int argcnt, char *args[], int parsedargs[]) {
int i;

if (!parsedargs)
{
puts("Something happened: something happened");
return 0;
}

else if (argcnt < REQ_PROG_ARG_CNT) {
puts("Not enough arguments were passed");
puts("Usage: <first multiple> <second multiple> <number of iterations>");
return 0;
}

else {
/* ensure that the args are only positive ints*/
for (i = 1; i < argcnt; i++) {
if (!isstrposint(args[i])) {
puts("Error: positive integers only");
return 0;
}

parsedargs[i - 1] = atoi(args[i]);
}
}

return 1;
}

void fizzbuzz(int a, int b, int n) {
int i;

for (i = 1; i <= n; i++)
{
if (!(i % (a * b)))
{
printf("%d: fizzbuzz\n", i);
}

else if (!(i % a))
{
printf("%d: fizz\n", i);
}

else if (!(i % b))
{
printf("%d: buzz\n", i);
}

else
{
printf("%d: %d\n", i, i);
}
}
}

int main(int argc, char *argv[]) {
int parsedargs[REQ_PROG_ARG_CNT - 1];

if (parseargs(argc, argv, parsedargs)) {
fizzbuzz(parsedargs[0], parsedargs[1], parsedargs[2]);
}

return 0;
}

/* I really love feminine pensies! */

>>
>>58895617
I too enjoy win32 api. when I first worked with it I got a stiffy for weeks
>>
File: just-one-man.png (252KB, 579x329px) Image search: [Google]
just-one-man.png
252KB, 579x329px
>>58895617
>I have a specific fetish for doing it with the Win32 API
>>
>>58895466
you sound like me but now I'm wondering what you mean by ideas. I just want someone to share the task of coding with and maybe someone to share the project ideas with.

If you drew that, and this isn't just bait, then I would totally delegate art to you and code off of your ideas as you may have more on the ready than I am willing to look over while coming up with new ways to hold it all together.

No teetering either. Want my twitter? I am not a code monkey. But I'm probably not as good as I think I am.
>>
>>58895680
>>tfw no pure functions
Chuck an __attribute__((pure)) (behind an appropriate compiler test macro) on it.
Also your code is needlessly complicated and your error handling is shitty.
>>
>>58895748
not look over, I mean overlook
>>
>>58895749
>__attribute__((pure))
neat
>Also your code is needlessly complicated
be more specific pls
>your error handling is shitty
that I know
>>
>A function returning a function
Is this practice really necessary? Or is it just pretending to be 1337

Hard to follow in a big file
>>
>>58895792
I'd recommend it. There's a few more advanced ways to put them to use but explaining them might make them sound insignificant. But learning how to use them now might make it easier for you to create little patches here and there without having to make a full blown class file out of nothing.
>>
>>58895792
function is just data, not hard at all to follow

it's useful since you can partially apply shit together
>>
Just remembered that you can do GUI in html now.
Is there any reason not to? I've mostly used xaml and winforms(for quick projects)
>>
>>58895782
isstrposint is completely pointless and implemented very poorly (O(n^2) solution).
You can just covert the argument to an integer, and check if it's negative after that.
Don't use atoi, as there is basically no way to check for bad input. Use strtol instead.
>>
>>58895825
when you don't wanna include v8 in your app
>>
>>58895837
>v8
what's that?
>>
>>58895863
"html" desktop apps include Chromium in the app, that is how they do the gui stuff
http://electron.atom.io/
>>
>>58895863
How many cylinders are in a car engine.
>>
File: tumblr_nzrv2fVKen1sebz5yo1_500.gif (2MB, 500x270px) Image search: [Google]
tumblr_nzrv2fVKen1sebz5yo1_500.gif
2MB, 500x270px
>>58895792
This is used in Closures. Closure provides data isolation.
package main

import "fmt"

func main() {
counter := newCounter()
fmt.Println(counter())
fmt.Println(counter())
}

func newCounter() func() int {
n := 0
return func() int {
n += 1
return n
}
}

In this example our closure references the variable n even after the newCounter() function has finished running. This means that our closure has access to a variable that keeps track of how many times it has been called, but no other code outside of the newCounter() function has access to this variable. This is one of the many benefits of a closure - we can persist data between function calls while also isolating the data from other code.
>>
>>58895906
Please stop posting those disgusting tumblr GIFs, you faggot.
Those look fucking terrible.
>>
File: reLr4K3.png (978KB, 1366x768px) Image search: [Google]
reLr4K3.png
978KB, 1366x768px
>>58895917
Where else do I get my rare yurus?
>>
>>58895906
go really needs type inference, and then syntactic sugar

like it shouldn't be hard at all for HM type inference
>>
>>58895906
>:=
why don't more languages do this?
>>
>>58895825
because your included audience is:

> Linuxfags on desktop

0.001% of the population and not a usergroup you ever want to waste your time focusing on, endless whining about the thousands of bugs daily will wear you down

> Macfags

do you really want to support homosexuality
>>
>>58895830
>isstrposint is completely pointless
after re-reading the docs for atoi() I missed the part where it does catch the case where no conversion can take place. the original intent for isstrposint was to catch such a case. so I'm retarded.
>O(n^2)
is that because atoi iterates through the str?

btw thanks for letting me know of strtol's existence, anon. I'm pretty pissed at myself for not knowing though. anyway, I appreciate your help
>>
>>58895944
It's fucking pig disgusting
>>
>>58895873
ahh, yeah don't wanna do that, think i'll just stick with xaml.

>>58895876
google it
>>
>>58895951
>>58895958
This is a 18+ website, junior
>>
>>58895968
actually it's good, even Microsoft stopped shipping xaml apps.

Visual Studio Code is made with electron
>>
File: potato.png (275KB, 556x720px) Image search: [Google]
potato.png
275KB, 556x720px
>>58895906
>>58895928
Keep posting those hun!
>>
>>58895792
>Is this practice really necessary?
Absolutely, the lambda calculus is the only real fundamental programming language (ignore alan he's a literal fag)
>>
>>58895906
so this is cool and all for little toy examples, but for anything even slightly more complex why wouldnt you just turn this into a class with explicit defined behavior
>>
>>58895944
because let is better
>>
>>58895984
>why wouldnt you just turn this into a class
because i don't like the taste of literal shit in my mouth
>>
>>58895984
have you ever used foreach?
>>
>>58895951

>Linux on desktop
>Macfags
Both supported by Winforms if you use Mono.
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
>>58895984
I'd like to refer you to >>58895811 (not me)
>>
File: 1486376698008.gif (415KB, 500x500px) Image search: [Google]
1486376698008.gif
415KB, 500x500px
Is this the yuru thread?
>>
>>58896001
disgusting
>>
>>58895928
They're not rare at all.
Your shitty tumblr gifs are washed out, and stupidly short for their file size.
>>
File: fucko.jpg (36KB, 689x693px) Image search: [Google]
fucko.jpg
36KB, 689x693px
>>58895969
>lmao I'm so grown up!

found the teenager
>>
File: Alldayfire.jpg (88KB, 1032x720px) Image search: [Google]
Alldayfire.jpg
88KB, 1032x720px
>>58896008
It's mostly me.

You are welcome to my thread too https://boards.4chan.org/g/thread/58894045#bottom
>>
>>58895954
>is that because atoi iterates through the str?
Right. You iterate over a string of length n, n times.
n * n, n^2.
>>
File: 1453856271896.png (309KB, 692x720px) Image search: [Google]
1453856271896.png
309KB, 692x720px
>>58896012
>being this asspained about images
wew
>>
>>58896026
Please anon. I want to have my animus of the highest quality.
Not this washed-out filter-heavy tumblrshit.
>>
File: 1458181522343.gif (2MB, 350x197px) Image search: [Google]
1458181522343.gif
2MB, 350x197px
>>58896008
Yes it is
>>
>>58895976

Just because Microsoft does something doesn't mean it's good. VS Code, like Atom, has a problem opening extraordinarily large files (about 50 MB+ from what I'm reading, although it might even be less). Isn't it a little strange that the two editors that struggle to work on large files in spite of available memory... are both the ones written with Electron?
>>
File: 1455950055870.jpg (32KB, 300x470px) Image search: [Google]
1455950055870.jpg
32KB, 300x470px
>>58896018
XDXDXDDDDDDDXDdd
I keked more than I should have :DDD
lul rekt >DDD
kek420 lul I showd 4chen today :DDDXSXDDD
>>
>>58896001
yeah but then you've kind of played yourself at that point, you are writing in a jumbled tangled deprecated piece of shit and also doing that for the purpose of supporting the aforementioned parties
>>
>>58896039
>opening 50mb binary blob in a fancy code editor
>>
>>58896026
>being this much of a feminine faggot
>>58894674
websocket chat like discord but much lighter
>>
File: hell-yeah.jpg (59KB, 449x451px) Image search: [Google]
hell-yeah.jpg
59KB, 449x451px
>>58896041
>>
>>58896039
atom already made it faster
http://blog.atom.io/2017/02/08/atom-1-14.html

try on a ~40mb / 1mil line JSON file and it works great
>>
>>58896053
It's not uncommon to open log files that are several megabytes in size.
>>
>>58896071
>Open a log file
>Not using cat
>>
>>58896023
gotcha my man.
though
>n * n, n^2
tha'ts a little condescending though, but I can understand if you think I'm a retard

>>58896034
okay, now this gif is shit.
>short length
>really shit quality
>1.87 MB

>>58896039
electron is shit, but VS Code is actually one of their better products
>>
>>58896011

Indeed. The preferred toolkit for cross-platform GUI development with Mono is actually GTK#. Personally, I'd like to see it ported to .NET Core proper so one could make a .NET Core GUI application instead of just ASP.NET and Console applications.
>>
>>58895125
why do you check for fizz buzz instead of only fizz or buzz?
class fizzbuzz {
public static void main (String[] args) {
for (int i = 0; i < 100; i++) {
if (i % 3 == 0) System.out.print("fizz");
if (i % 5 == 0) System.out.print("buzz");
System.out.println();
}
}
}
>>
>>58896081
>electron is shit, but VS Code is actually one of their better products
How to spot a microshaft fanboy 101
>>
>>58896075
>not using less
>>
>>58896081
>tha'ts a little condescending though, but I can understand if you think I'm a retard
Normally people who are newish to programming know absolutely nothing about algorithmic complexity.
>>
File: 1458179700268.jpg (62KB, 567x600px) Image search: [Google]
1458179700268.jpg
62KB, 567x600px
>>58896081
webp isn't well spread yet
>>
>>58896088
It's true though
https://github.com/Microsoft/vscode
>>
>>58896096
>algorithmic complexity.
cringed

why do we need to use such shiny words to identify simple concepts

at least this isn't the case for most of programming, things are called meaningful concrete things - trees, stack etc. naming is generally ok
>>
>>58896087
ah nvm, forgot about the whole 'instead of counter print this and that'
>>
>>58896053

>binary blob
Try a 3.2 GB CSV. Yeah, that's plaintext. Sublime handles it like a champ.
>>
>>58896119
>Empty lines
>No capitalisation
>Very little punctuation
Why do you format your post like that, redditor?
>>
>>58896130
>>58896119
Also I forgot to mention
>cringed
>>
Just finished up writing some thread posix stuff for some simple threads.

Plan on using volatile int for a value associated with the thread that will signal that the thread is done so the main thread can call a completion function on whatever data it was working on. Heard volatile doesn't work for mutex stuff but that is the only value being observed
>>
>>58896104
That's cute as fuck
>>
>>58896130
>capitalization
fixed that for you
>>
>>58896142
>Volatile
Use atomic types instead.
>>
>>58896130
>>Empty lines
conveying more then one point you see
>>No capitalisation
>>Very little punctuation
are you tribbered

i diont browse reddit, but redditors are an improvement to the user base here now
>>
+1 for Midna.

She is my waifu in my dark times.
>>
>>58896149
Go home, dumb American.

>>58896154
>conveying more then one point you see
No, it shows that you're illiterate and just stupid in general.
There are actually standards for posting on here, and proper writing style is one of them.

Come back once you've finished high school.
>>
>>58896096
I only really pay attention to muh asymptotes when I'm writing non-trivial things. I know it's a bad habit but my brain just doesn't pay attention otherwise
>>58896104
I don't think I've seen anybody mention webp outside of 4chan and other imageboards
>>58896130
>No capitalisation
>Very little punctuation
if any thing, redditors would be writing posts grammatically correct
>>
>>58896167
>proper writing style is one of them.
its not

what you post matters, how you do it doesn't
>>
>>58896167
>implying you need to be American to know proper English
mate...
>>
>>58896181
>how you do it doesn't
How you format your post _is_ part of what you post. They don't exist in a vacuum.
There is a lot you can infer from someone's writing style alone.
>>
>>58896156
who's your waifu in the brighter times?
>>
And by "Sublime handles it like a champ" I mean "when Firefox doesn't eat up 4 GB of RAM on its own."

I need to upgrade to 16 GB of RAM at some point. I hit the 8 GB limits too easily with Firefox + Steam games or Firefox + VirtualBox, and I'd really like to have two VirtualBox instances open simultaneously on my laptop.
>>
File: 53925469_p0.png (675KB, 1000x1400px) Image search: [Google]
53925469_p0.png
675KB, 1000x1400px
>>58896170
>I don't think I've seen anybody mention webp outside of 4chan and other imageboards
If google pushed it a bit more, it would be everywhere in a month or two, it must not be fully ready yet since they aren't talking about it enough.
I would convert all my images to webp, if it wasn't for 4chunk not accepting them...
>>
>>58896193
k brainlet
>>
>>58896214
delete all your images
>>
>>58896150
straight c. I would otherwise.
>>
>>58896233
C does support atomic types.
It's an optional feature in C11, but both GCC and Clang support them.
>>
File: IMG_6299.jpg (133KB, 1280x720px) Image search: [Google]
IMG_6299.jpg
133KB, 1280x720px
>>58896231
i don't want to
>>
File: 1481243278470.jpg (470KB, 1200x1754px) Image search: [Google]
1481243278470.jpg
470KB, 1200x1754px
>>58896214
>>
>>58896231
>all your
Please, anon: it's "all of your".
>>
#include <iostream>
using namespace std;

int furlongtoyards (int);
int main()
{
int furlong;
cout << "number of furlongs" << endl;
cin >> furlong;
int yards = furlongtoyards(yards);
cout << furlong << "furlongs is " << yards << "yards" << endl;
return 0;
}

int furlongtoyards (int yrs)
{return 120 * yrs;}

output is off, one furlong is 120 yards so what am i doing wrong`
>>
>>58896245
sauce
>>
>>58896245
go on
>>
>>58896238
Nice. I will look into it.
>>
>>58896129
>>58896204
bruh it's taking my just downloaded sublime text 3 a long ass time to open this 5gb txt file i generated

using freaking +7gb of ram, had to close it (i7 6700k with ssd and 16gb ram)

my emacs gui (emacs w64) opened it WAY faster

any use case for this is retarded anyway
>>
>>58896273
>>58896280
newfags
>>
>>58896295
faggotnew post source
>>
>>58896202
I'm waifu less in those times.
>>
>>58896273
>>58896280
>>58896280
pls noone post sauce
>>
>>58896295
yeah we know that you spend your life on imageboards on forums anon
now post sauce
>>
>>58896273
>>58896280
https://exhentai.org/g/1028827/0ddf77f0c1/
>>
>>58896292

Yeah, Sublime takes a while to open large files, but the point is that it CAN do it, where VSCode can't. I can imagine Vim, like Emacs, is also pretty decent at opening large files.
>>
File: 1428523466411.jpg (434KB, 5000x5000px) Image search: [Google]
1428523466411.jpg
434KB, 5000x5000px
>>58896348
>>
>>58896348
>spoonfeeding when the source is easily found by reverse-image searching
anon you're only going to encourage them
>>
>>58896348
doesnt load
>>
>>58896383
>implying reverse search showed any results
>>
idk which is the bigger troll
>>58896348
or
>>58896387
>>
>>58896399
im just a dude watching people try hard to troll to feel better about being losers
>>
File: grtztrzhtrz.jpg (89KB, 716x378px) Image search: [Google]
grtztrzhtrz.jpg
89KB, 716x378px
FUCK IT BRO I'M JUST GONNA SPEND AN AFTERNOON LEARNING SDL INSTEAD
>>
>>58896383
>implying that is the actual source
did you even follow that link to see where it leads?
>>
>>58896394
Use SauceNAO. Should find it.
>>
>>58896441
timeout
restarted router already so good luck xd
>>
File: 1454117922745.jpg (124KB, 726x1040px) Image search: [Google]
1454117922745.jpg
124KB, 726x1040px
>>58896458
>>
>>58896441
too lazy. though I'm sure he probably posted something with a million tags, furry, and/or guro
>>
>>58895762
you mean overwatch
>>
>>58894794
Do whatever your superiors say. Don't learn actual programming. It's not your job. You're supposed to be a conduit for management so they can input code through you.

That's what object oriented programming is all about. And frankly if you just submit to this hierarchy and place focus on other things you're most likely gonna live happier than most people.
>>
>>58896269
You aren't passing the user input input to the function. I'm a novice to C++ but I'm surprised to learn something like this compiles.

int yards = furlongtoyards(yards);
>>
>>58896435
>Unicode uses a full 16 bits for character encoding
That's wrong though. The entirely of Unicode requires more than 16 bits.
That's also why Microsoft is fucking retarded for having wchar_t be 16 bits. UTF16 is a multibyte encoding.
>>
>>58896668
it's a book from 1998. some anon suggested it to learn win32 dev.
>>
>>58896668
utf-16 ruins windows i hate it
>>
>>58896684
What is it you really want to learn? What do you envision win32 development being?
Because most just wrap it for one reason or another. Either for convenience (because it's not their flavor of API) or its because they want portability.
>>
>>58896699
Yes, we can all agree that UTF16 is fucking retarded, and should not be used for any purpose.
You get the worst of both UTF8 and UTF32, and no real advantages.
>>
File: 1486472040738.jpg (73KB, 604x604px) Image search: [Google]
1486472040738.jpg
73KB, 604x604px
Say I have a text file with a list of terms in it separated by newlines. Can I write a program to concatenate those terms with a web address like "https://www.google.com/#q=" + "$yourterm" and open them all in a web browser? I have 2000 terms I need to search.
>>
File: 1461891294146.jpg (47KB, 445x488px) Image search: [Google]
1461891294146.jpg
47KB, 445x488px
ANSI STRONK
>>
>>58896716
is the program possible? of course and it's damn easy
but is it possible for you? probably not
>>
>>58896716

Seems like a trivial program that could be hacked together in a scripting language in 5 minutes or less.
>>
>>58896742
Could you imagine if he tried to have it open all of his links at once?
>>
>>58896716
Yes. But I'm not sure how to call your favorite browser.

Personally I'd consider it an issue to have it all opened in a browser so I'd probably just use some web crawler library instead. That way I can programmatically extract what I wanted from the searches.
>>
>>58896716
A bash script could do that pretty easily.
#!/bin/bash

if [ $# -ne 1 ]; then
echo "usage: $0 input-file"
exit
fi

while read -r term; do
firefox --new-tab "https://www.google.com/#q=$term"
done < "$1"

Or replace the firefox bit with whatever browser you're using.
>>
File: 1452222492913.jpg (56KB, 550x537px) Image search: [Google]
1452222492913.jpg
56KB, 550x537px
>>58896760
>bash
>>
File: 1486394472638.jpg (44KB, 640x532px) Image search: [Google]
1486394472638.jpg
44KB, 640x532px
>>58896760
Thanks pham, guess I will split up the text file into manageable chunks for processing.
>>
>>58896785
I actually like bash. I've written lots of handly scripts with it.
This is one of those problems suited to using bash.
>>
File: 1470743205649.jpg (136KB, 960x1280px) Image search: [Google]
1470743205649.jpg
136KB, 960x1280px
Brainlet chink here, how do I define lists by using only lambdas?
>>
>>58896837
linked lists you can, just define numbers in terms of lambda, use functions, make singly linked for example using cons

lists where you assign things aka arrays im not sure
>>
>>58896798

Can also be done quite handily in Ruby:
url = "https://www.google.com/\#q="
File.open(ARGV[0]).each_line { |l| `firefox --new-tab #{url}#{l.chop}` }.close
>>
>>58896888
Yes, if I decided to omit the "proper usage" stuff, my script would be that short. It would be a one-liner in fact.
Also, mine isn't limited to being used by homosexual hipsters only.
>>
>>58896904

Ruby can be used by more than just homosexuals. It's quite a useful scripting language for any task that gets too complex to be done sanely in Bash.
>>
>>58894794
private/protected is 100% useless, no one randomly and arbitrarily starts writing to class/struct fields just because they are public, you need to know what they are for to write any code at all, and then you would also find out whether it should be modified directly or not.
It's a complete cargo cult phenomenon that it somehow prevents bugs or 'lesser programmers' on your team from accidentally misusing the fields - I bet it has never happened in the history of programming, prove me wrong if you doubt me, show me a single real world case.
>>
>>58896716
you should be ashamed of your reddit image/post
>>
File: 1376221108800.jpg (50KB, 510x532px) Image search: [Google]
1376221108800.jpg
50KB, 510x532px
Jesus fucking Christ i've never seen a thread filled with so many incompetent retards.
This thread is proof that /g/ couldn't program a fucking ping pong game into life if their life depended on it.

These threads should seriously be banned from /g/.
They are filled with too many retards who call random wall scribbles "programming". It's an insult to the field and the board.
>>
>>58897071
no good programmers even bother with forums, its just for noobs
>>
>>58897071
I think most of the skilled programmers are either answering beginner questions, or partaking in the shitposting.
People aren't just posting what they're working on most of the time and trying to flaunt their skill, because it's usually not very interesting.
>>
>>58897099
>noobs
woah there grandad
>>
>>58897099
speak for yourself. I can write hello world in less than a line
>>
>>58897109
whats the new terminology
>>
>>58897113
If I do
:set binary noeol
, does that count?
>>
>>58897125
pajeets
>>
File: 1486490226860.png (151KB, 341x314px) Image search: [Google]
1486490226860.png
151KB, 341x314px
>>58897071
>This thread is proof that /g/ couldn't program a fucking ping pong game into life if their life depended on it.
Maybe this would mean something back on the Commodore 64 but now you have to initialize huge graphics libraries just to make pong.
>>
>>58897143
a line does not end is still a line
>>
>>58897158
Your sentence makes no sense.
Also, wc seems to disagree.
>>
how do i get anime gf
>>
>>58897179
a line that does not end is still a line, an infinite line. thus wc is wrong

>>58897200
by promising never to have desire for 3DPD ever again
>>
Learning (((Structs)))
>>
>>58897241
I don't think structs are the sort of thing that requires the weird emphasis round brackets meme that's been on here lately.
>>
File: Midna_9.jpg (390KB, 600x1146px) Image search: [Google]
Midna_9.jpg
390KB, 600x1146px
Thanks for posting best waifu
>>
>>58897222
>a line that does not end is still a line, an infinite line. thus wc is wrong
A line is defined by being terminated by a newline character.
>>
File: 1455504970125.jpg (50KB, 384x384px) Image search: [Google]
1455504970125.jpg
50KB, 384x384px
>>58897259
>he doesn't know
>>
>>58897259

>terminated by a newline character
Or an end of file. The last line of a file is always still considered a line.
>>
File: 1486463131585.png (369KB, 900x900px) Image search: [Google]
1486463131585.png
369KB, 900x900px
>>58897270
wc just counts /n characters nerd, it doesn't care about whatever semantics you attach to the notion of a line.
>>
>>58897291
So what happens when the last line of a file is a newline? Does /nEOF count as 2 lines? Dumby.
>>
>>58897360

\nEOF is one line. There are no bytes after the \n to start a line ending in EOF.
>>
File: akarin ambiguous.jpg (450KB, 1000x900px) Image search: [Google]
akarin ambiguous.jpg
450KB, 1000x900px
Can GCC compile x86_64 instructions? If so whats the flag
>>
>>58897417
Of course it can. If you're on an x86_64 system, that is the default.
If you're not, you'll have to set up a cross compiler.
>>
File: akarin dab.png (185KB, 417x600px) Image search: [Google]
akarin dab.png
185KB, 417x600px
>>58897432
Whats the flag to compile my asm instructions to an executable image sir?
>>
Prelude> "" == []
True

is there any strongly typed language where this isn't true?
>>
>>58897417

If you are using a version of GCC that can target x86_64 and IA-32, the default is typically to produce 64-bit instructions. The -m32 flag switches to IA-32 (regular old 32-bit x86), while the -m64 flag tells it to use x86_64 instructions (this is typically considered superfluous). There is also the -mx32 flag, usable on Linux, which targets a platform known as x32, which uses the x86_64 instruction set with 32-bit pointers.
>>
>>58897449

as if you're using GNU syntax
nasm if you're using Intel syntax.
>>
I want to code a program where you can fiddle with a stretched elastic rope (some sort of very basic novelty program with physics), mostly for learning purposes. I have adequate knowledge on C++ and I'm thinking of doing it using it, any tips or frameworks I should know about before I get started?
>>
>>58897449
What exactly are you trying to do?
Are you writing some assembly by hand? GCC is a C compiler. What you're looking for is an assembler.
>>
File: illya dance.gif (483KB, 243x270px) Image search: [Google]
illya dance.gif
483KB, 243x270px
>>58897487
Thanks luuby, always here to save the day
>>
>>58897487

Err... actually should amend this. Both of these commands will turn .s or .asm files into .o files. You then have to use ld to link them into an executable. If you want to link against libc and libgcc, it may be simpler to just use gcc as your linking command, since it links them by default.
>>
>>58897496
stop feeding his attention whoring
>>
>>58897519
>actually helping people
>what an attention whore!
Or maybe you're just a huge asshole.
>>
File: babyrage.png (55KB, 320x240px) Image search: [Google]
babyrage.png
55KB, 320x240px
>>58897519
Why? Hes a nice guy(female) that always answers my questions and spreads the good word of the pursuit of knowledge

You sir, have spent way too much time on 4chan rather than actually doing something productive, tata~
>>
>>58897490
Fuck I meant libraries, not frameworks
>>
>>58895981
What about combinatory logic?
>>
>>58897598
Go onto git hub and type youngs modulus as a keyword, something will pop up probably?
>>
>>58897519
he deserves it, stay salty
>>
i want to be ruby's loli
>>
File: csb.jpg (122KB, 558x743px) Image search: [Google]
csb.jpg
122KB, 558x743px
>>58897628
>>
>>58897628
you want to be a loli for everyone who'll give you cock*
>>
>>58897611
It's a meme

>ISK is the currency in EVE online
>>
>>58897618
Didn't find anything useful unfortunately :/
>>
>>58897659
That doesn't make any sense, Ruby is a girl
>>
>>58897550

>guy(female)
Will there ever be an end to this silly meme?

>>58897628

Wut?
>>
>>58897695
girls have cocks too silly
you should know better than me
>>
File: durrr2.jpg (24KB, 640x480px) Image search: [Google]
durrr2.jpg
24KB, 640x480px
>>58897689
Now that I think of it of course it didn't pop up, why would it after all, you can't create a database with thousands of god-knows-what materials related to their properties, I don't think theres some type of generally accepted format for specifying what a material is let alone identifying their youngs modulus (infinite proportion of compositions for a given material theoretically).

I don't think a programming language is your best choice, surely there is some physics program that has all this stuff? Im sure your uni offers this proprietary program for free if youre enrolled in a physics major.

>>58897704
Nope

Also, why is your unsecure trip called "Sempai" and not "Senpai" ?? Isnt Senpai correct romaji
>>
>>58896837
Only 'cell' is essential.

(define (cell x y)
(lambda (key)
(if (equal? key 'head) x
(if (equal? key 'tail) y (error "derp")))))

(define (head seq)
(seq 'head))

(define (tail se
q)
(seq 'tail))
(define nil 'nil)
>>
>>58897757

When spoken, it's pronounced like sempai... also, I'm not the one who genned the trip. I consider it a gift, so I'll keep it despite it not technically being the right romanization.
>>
>>58896924
But Ruby is not just for the homosexuals, Ruby.
>>
>>58897461
This is only True because String is defined as [Char], which is widely regarded to be a mistake due to efficiency concerns.
>>
>>58897687
What is a 'meme' in this context?

Combinatory logic is certainly a valid model of computation.
>>
How do i do conditional defines in c++? i mean if i set one variable, next compilation will run difrent code
>>
File: rindou cute.jpg (89KB, 1280x720px) Image search: [Google]
rindou cute.jpg
89KB, 1280x720px
>>58897800
greentext story pls

include me in screenshot
>>
>>58894825
Its creators are aware that nothing else comes even remotely close and therefore are able to put a price on it that big industry players happily pay.
>>
>>58897842
>Combinatory logic is certainly a valid model of computation.
So is stack-only based calculation and turing machines, but that doesn't make it very useful.
>>
>>58898032
>Absolutely, the lambda calculus is the only real fundamental programming language (ignore alan he's a literal fag)
I wasn't looking for useful; that's too subjective.
You'll also find that concatenative languages (which I guess you mean by stack-based) and combinatory logic are very closely related.
>>
>>58897179
why is that white dot in the middle of the picture
>>
File: 16508094.jpg (14KB, 262x260px) Image search: [Google]
16508094.jpg
14KB, 262x260px
What's a good and (((short))) programming book that teaches me the vary basic topics of programming (like channels, interfaces, routines, (((structs))) etc) so that upon finishing it I can dive straight into a book that assumes I have prior knowledge of any language?
>>
>>58898097
His monitor has a broken pixel
>>
>>58898105
There's no such thing, you lazy fuck. Lrn2code.
>>
>>58898105
>channels, interfaces, routines
Sounds like you want a book on Go.
>>
>>58898105
the Haskell book
>>
>>58898105
dive into python. and as said there are no shortcuts, if u want to be good
>>
>>58898132
Ironically the shitty book I have been reading was for go but after finishing pointers and (((structs))) it went out of hands
>>
Is it possible to use the youtube-dl's download method in multiple threads?
Want to download multiple videos using threading.
With something simple like this doesnt seem to work. Am i doing something wrong with threading or does youtube-dl simply dont support it?

def download(url):
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])

videos = [...]

for vid in videos:
t = Thread(target=download, args=[vid])
t.start()
t.join()
>>
>>58898148
I figured you had been submerged in Go.

Those concepts are not the 'very basic topics of programming', but some features that happen to be present in Go.
>>
>>58898105
Learn Lisp. Everything else is Blub.
>>
>>58898156
t.join() means you're waiting for the thread to end before doing anything else, so it's not multithreaded at all
>>
>>58898172
Lisp is blub.

All you need is untyped lambda calculus
>>
>>58898156
Some old code (think it works), 2 threads with a queue.

import threading, time, Queue

def worker():
while True:
item = q.get()
print 'New item get! (%s)' % item
time.sleep(5)
print 'Item done! (%s)' % item
q.task_done()

q = Queue.Queue()

for i in range(2):
t = threading.Thread(target=worker)
t.daemon = True
t.start()

for item in range(5):
q.put(item)

q.join()
>>
>>58898156
You're actually running them sequentially. You start a thread, then you join to it, only then start the next.

You'll want to create a list of threads, start them all, and only then join them all.

threads = [Thread(target=download, args=[vid]) for vid in videos]

for thread in threads
thread.start()

for thread in threads
thread.join()
>>
>>58898180
oh shit im retarded, thanks
>>
>>58898212
>>58898204
thanks yeah as >>58898180
suggested, works now

>>58898212
so you have to start them all first, before joining them if i understand it right?
>>
>>58898157
If you are right, which I hope you are, I will have to get a thicker book that tries to explain instead of making me search through millions of websites. thanks.

Picture related. It lets you know the name of the topic and secretly tells you to fuck off back to google search to know more :^)
>(((structs)))
>>
>>58897879
#if VARIABLE == 1
foo();
#elif VARIABLE == 2
bar();
#else
baz();
#endif


For more info: https://gcc.gnu.org/onlinedocs/gcc-3.0.1/cpp_4.html .
>>
>>58898264
>gcc-3.0.1
Why are you linking such an old version of their docs?
I suppose what's in there isn't wrong in any way, but 3.0.1 literally came out 16 years ago.
>>
Do you need to have much algorithmic/data structure knowledge within web dev?

I've learned javascript on the front and back end. I expect that algorithmic/data-structure stuff really only comes into use on the back-end.

An unfortunate side-effect of my choice of language is that most resources for learning algo/ds stuff are taught through a different, more traditionally-established language like Java.

> tl;dr Is algorithmic/data-structure knowledge necessary to have when pursuing a career in web dev, and if so, are there any decent javascript-based resources for learning it?
>>
>>58898324
>>>/g/wdg
>>
>>58898324
Anything computationally intensive on the desktop will be even worse with a browser. It's good to know this shit in case.
>>
>>58898324
as long as you know

Rules for naming C++ variables
n
C++’s built-in integer types:
unsigned long
,
long
,
unsigned int
,
int
,
unsigned
short
,
short
,
char
,
unsigned char
,
signed char
,
bool
n
C++11’s additions:
unsigned long long
and
long long
n
The
climits
file,
which represents system limits for various integer types
n
Numeric literals (constants) of various integer types
n
Using the
const
qualifier to create symbolic constants
n
C++’s built-in floating-point types:
float
,
double
, and
long double
n
The
cfloat
file,
which represents system limits for various floating-point types
n
Numeric literals of various floating-point types
n
C++’s arithmetic operators
n
Automatic type conversions
n
Forced type conversions (type casts)

math to a 2nd year lvl your g

not really, web dev needs half a brain and javascript
>>
>>58898370
Disgusting!!
>>
How to do this fancy code colorung in post?
>>
>>58898421
 tags.
>>
>>58898421
[kode]
:^)
[/kode]
>>
>>58898324
>I expect that algorithmic/data-structure stuff really only comes into use on the back-end.

Yeah, that's probably true. And for basic webdev you probably don't even need to know how to come up with clever algorithms in the back end either. You need to know that it is possible to sort an array and what function to call to do so, not how to implement an efficient sorting algorithm.

>An unfortunate side-effect of my choice of language is that most resources for learning algo/ds stuff are taught through a different, more traditionally-established language like Java.

If you're learning algorithmics, you should be learning them in an abstract sense anyways, so choice of language shouldn't matter. You should understand why the algorithm works, read pseudo code and understand why its a correct implementation of the algorithm, and then be able to translate it to whatever language you're fluent in.
>>
>>58898483
That's a big help, thanks very much!
>>
Whats the smartest approach for a "did-you-mean?"-function? As in, if a search fails to return anything, suggest search phrases that are a close match and has results.

I'm currently calculating edit distance of the search phrase with all phrases in the database - and return a list of the ones with the lowest edit distance.

I feel this is a problem that must've been solved a thousand times!

private ArrayList<String> closeMatch(String s){
int lowestDistance = s.length();
ArrayList<String> closestMatches = new ArrayList<String>();
for(String word:allTerms){
int distance = Math.abs(s.length()-word.length());
for(int i = 0; i<s.length()&&i<word.length();i++){
if(word.charAt(i)!=s.charAt(i)){
distance++;
}
}
if (distance<lowestDistance){
lowestDistance = distance;
closestMatches = new ArrayList<String>();
closestMatches.add(word);
}else if(distance==lowestDistance && !closestMatches.contains(word)){
closestMatches.add(word);
}

}
return closestMatches;
}
>>
Why would I use Int over Integer in Haskell?
>>
>>58898776
faster
fixed size
>>
>>58898776
>>58898794
also there's Int# in GHC
>>
>>58898801
What does it do?
>>
>>58898819
it's an unboxed int
>>
New thread:

>>58898839
>>58898839
>>58898839
>>
>>58898819
The real question is why does language need 3 different keywords for some integer type where the names doesn't tell you anything about the actual type size.
>>
>>58898848
I think such keywords were an afterthought for Haskell.
>>
>>58898873
>>58898848
they aren't keywords
Thread posts: 315
Thread images: 44


[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.