[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: 342
Thread images: 32

File: red-pill.jpg (99KB, 1200x600px) Image search: [Google]
red-pill.jpg
99KB, 1200x600px
Old thread: >>59060949
What are you working on, /g/?
>>
>>59064420
TRAPPOSTER WHERE WERE YOU
>>
http://arstechnica.com/security/2016/08/code-dumped-online-came-from-omnipotent-nsa-tied-hacking-group
http://xorcatt.wordpress.com/2016/08/16/equationgroup-tool-leak-extrabacon-demo
Once again, a buffer overflow has lead to new vulnerabilities in C land. This time all pre-2013 Cisco routers are affected.

It does indeed feel there is a gaping hole in our software stack as these buffer overflows are only increasing in rapidity. It is time we take a serious look at the epidemic of exploits in C land, and begin to implement real solutions; they are out there.

It’s hard to deny that easy access to stack, especially unprivileged access, plays a serious role in creating computer crime. How many buffer overflows happen in languages with access checks on stacks? How many buffer overflows are discovered in the Ada each year? None. How many in Haskell? None. How many in Java?
None. The list could go on. And yet, mass exploitation in the C-land continue to increase. There is certainly a correlation. But there are other important causes at play as well: the language is an ill-designed clusterfuck of hacks upon hacks.

Of course, mass buffer overflows are only one indication of the security nightmare that plagues the language — the whole language is built on unsafe and insecure code. In the C-land, memory rules are much more lax than that of other popular languages, on par with the assembly and lacking even basic safety features: unless explicitly requested by the programmer.

Nearly 70% pre-2013 routers are Cisco and are vulnerable to being hacked during the %CurrentYear%.
http://gigaom.com/2013/02/27/chart-cisco-owns-the-switching-and-routing-world

These are a only a few of the indicators of what may feed into the hopelessness and despair that causes so much distrust in C and its derivatives. The bugs cost real money and real work-hours to be wasted on correcting and debugging the garbage that was compiled by compilers which don't value anything but speed and memory use
>>
File: 1487613236418.png (19KB, 500x590px) Image search: [Google]
1487613236418.png
19KB, 500x590px
>tfw hardcore C fizzbuzzer
>tfw to intelligent to be employed
>>
>>59064471
Nice you copy-pasted an earlier /g/ thread's OP
>>
@59064471
>ada
>haskell
>java
>speed and memory use is not important anyway guise
bwahahahahaha
>>
>>59064563
Rust doesn't have that problem
>>
I have about $4000 and 6 months

Options:
a) CS degree somehow (unlikely in the near future)
b) Code bootcamp
c) learn on my own using resources from a + b

Which is the best?
>>
>>59064606
Spend it on drugs and hookers.
>>
>>59064606
d) Get a job and use that money for a)
>>
>>59064572
>wild rust shill appears
ding! ding! ding!
>>
how can you resolve a circular dependency without relying on function pointers?

like if you have a static library and you want the static library to call back to one of your functions
>>
>>59064694
>It's another episode of a C toddler can't accept the truth episode
>>
i have a datastream. i load data coming from this stream into a buffer and then i have a couple of threads run over this buffer byte per byte and do some math on each byte. after that, i erase the buffer and fill it with fresh data. i do this mainly because if i load in a lot of data all at once, around 300mb, my program crashes. i don't know why my program crashes and the only way i could fix it was by buffering the data instead.

is there some science to how big those buffers should be? should they be as big as possible? small as possible? can i calculate a sweetspot?
>>
>>59064572
doesn't have the power either :^)
>>
What are good resources to start with r?
>>
>>59064747
what power do you want?
>>
>>59064717
Weak symbols.
>>
>>59064606
Go get some unpopular STEM degree, CS is overhyped.
>>
>>59064764
all of them
>>
>>59064794
done
>>
What's a simple crypto method/library for C/C++ if I just want to hash some passwords?
>>
>>59064625
upvoted
>>
>>59064823
http://www.zedwood.com/article/cpp-sha512-function
>>
>>59064811
lies
>>
>>59064527
Post your best C fizzbuzz and explain why it's the best.
>>
>>59064420
Surely C ucks are just in denial when it comes to the fact that Rust is objectively better than C?
>>
>>59064893
>objectively
literally?
>>
>>59064889
Not mine but
Terry Davis wrote the perfect Fizzbuzz in AMD64 Assembler. It doesn't use division or modulo and stores the strings in registers instead of the stack or, God forbid, the heap. (8 characters per register).
>>
Hey gee, how can I coq muh hasklel in rust?
>>
>>59064606
get some plumber job or something and then learn programming in the meantime. trust me on that one.
>>
File: ^.^.jpg (112KB, 800x1200px) Image search: [Google]
^.^.jpg
112KB, 800x1200px
>>59064939
top memester
>>
>>59064931
>perfect Fizzbuzz in AMD64 Assembler
pff, back in the day I did it in amd32 asm in half the space requirements
>>
>>59064931
link me nig***
>>
File: anal beads.png (68KB, 895x269px) Image search: [Google]
anal beads.png
68KB, 895x269px
>>59064939
That's easy, but how do we Sqoop the Hadoop into Oraoop using OOP?
>>
>>59064966
http://www.templeos.org/Wb/Demo/Asm/BuzzFizz.html

#define RANGE_START     1
#define RANGE_END 100

#define FIZZ_SPAN 6
#define BUZZ_SPAN 7

asm {
_BUZZ_FIZZ::
PUSH RBP
MOV RBP,RSP //Always set-up stk frame. (Stack Gets Traced)
PUSH RSI //See REGG_LOCAL_VARS & REGG_LOCAL_NON_PTR_VARS
PUSH RDI
MOV RSI,FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1
MOV RDI,BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1
MOV RAX,RANGE_START

@@05: CALL PUT_HEX_U64
PUSH RAX
MOV RAX,CH_SPACE
CALL PUT_CHARS

DEC RSI
JNZ @@10
MOV RAX,'FIZZ '
CALL PUT_CHARS
MOV RSI,FIZZ_SPAN

@@10: DEC RDI
JNZ @@15
MOV RAX,'BUZZ '
CALL PUT_CHARS
MOV RDI,BUZZ_SPAN

@@15: MOV RAX,'\n'
CALL PUT_CHARS
POP RAX
INC RAX
CMP RAX,RANGE_END //Actually only a 32-bit inst.
JBE @@05

POP RDI
POP RSI
POP RBP
RET
}


Note how he uses general-purpose registers for string processing, not pointers to memory.
>>
>>59064984
MUH DICK!
>>
>>59064931
>doesn't use division or modulo
>>59064995
>RANGE_START%FIZZ_SPAN
lad...
>>
>>59064995
fuck
>>
>>59065032
not in the main loop, just in the initialization
>>
File: CthyVVWWcAAIqa.jpg (222KB, 914x1200px) Image search: [Google]
CthyVVWWcAAIqa.jpg
222KB, 914x1200px
>>59064563
>Ada is isn't fast
>>
>>59065050
faster than python, slower than C
>>
File: 1457928173436.jpg (17KB, 270x320px) Image search: [Google]
1457928173436.jpg
17KB, 270x320px
i'm 4 years into a software engineering uni and i still fucking hate programming

what the fuck do i do
>>
>>59065101
That folder name is stupid and could have been said in less words.
>>
>>59065101
>4 years into
bite the bullet.
lube and take it up the ass.
>>
File: Sans titre.png (73KB, 1710x935px) Image search: [Google]
Sans titre.png
73KB, 1710x935px
So i dropped highschool and having nothing to do at home, I decided to learn C++ because my brother wanted someone who can help him for a project.

I'm stuck there, pic related, it cannot recognize the class Guerrier (warrior in french) despite recognizing the mother class Personnage (character in french)
What did I fuck up ?
>>
>>59065149
Always program in English, regardless of your native tongue.
>>
>>59065045
>backpedaling
please
>>
why is <complex.h> so /comfy/ in C, /g/?
>>
@59065208
why do you jerk it to cartoon kids, mentally ill fag?
>>
>>59065149
Did you try refreshing intellisense
>>
>>59065101
Either shoot yourself in the head because you should have swiched 3,5 years ago or suck it up.
>>
>>59065258
wat
>>
>>59065204
Did it work?
>>
File: 1477315328127.jpg (45KB, 1080x663px) Image search: [Google]
1477315328127.jpg
45KB, 1080x663px
http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/ifconfig/ifconfig.c?rev=1.169&content-type=text/x-cvsweb-markup

How long do I have to work to write C at this level? It's just the ifconfig source

I also looked at the wpa_supplicant source. In both, they seem to use C structs like classes, which is strange to read as a C++ programmer
>>
>>59064889
#include "stdio.h"

int main(){

f=fopen("E:/program.c", "w+");

int limit = 100;

char iff[] = "\tif(i ";
char eliff[] = "\telse if(i ";
char mod15[] = "% 15 == 0)\n";
char mod5[] = "% 5 == 0)\n";
char mod3[] = "% 3 == 0)\n";
char fizz[] = "\t\tprintf(\"fizz\");\n";
char buzz[] = "\t\tprintf(\"buzz\");\n";
char fizzbuzz[] = "\t\tprintf(\"fizzbuzz\");\n";
char i[] = "\tint i = 0;\n";
char incl[] = "#include \"stdio.h\"\n";
char beg[] = "int main(){\n";
char end[] = "}";


fprintf(f, "%s\n", incl);
fprintf(f, "%s\n", beg);
fprintf(f, "%s\n", i);

for(int i = 0; i < (limit - 1); ++i){
fprintf(f, "%s", iff);
fprintf(f, "%s", mod15);
fprintf(f, "%s", fizzbuzz);
fprintf(f, "%s", eliff);
fprintf(f, "%s", mod5);
fprintf(f, "%s", fizz);
fprintf(f, "%s", eliff);
fprintf(f, "%s", mod3);
fprintf(f, "%s", buzz);
fprintf(f, "\n", 0);
fprintf(f, "\ti = %d;\n", (i + 1));

}
fprintf(f, "%s", end);
fclose(f);

}
>>
>>59064563
Those are all pretty fast languages, bro. You should have gone for Python or something.
>>
>>59065375
>didn't explain why it's the best
>>
>>59065375
not portable
>>
>>59065385
>pretty fast
not fast enough
>>
>>59065375
Can I get a TL;DR on this disgusting fizzbuzz?
>>
>>59065375
>metaprogramming
needs to compile twice
>>
>>59065426
GOTTA GO FAST
>>
>>59065375
>Not calling GCC in the program and running it
Fucked it, tbqh
>>
>>59065489
GOTTA!
>>
>>59065440
It outputs the source code for a fizzbuzz program.
>>
File: 1385136139955.png (19KB, 870x870px) Image search: [Google]
1385136139955.png
19KB, 870x870px
>>59065503
>>
>>59065375
Not portable, doesn't meet the requirements of FizzBuzz.

It's shit.
>>
File: ab_sonic_by_pink_diapers-d3ita3a.jpg (320KB, 900x1220px) Image search: [Google]
ab_sonic_by_pink_diapers-d3ita3a.jpg
320KB, 900x1220px
>>59065426
GOTTA
O
T
T
A
>>
#ifndef HFILE_H
#define HFILE_H

#endif

or
#pragma once
?
>>
>>59065385
> pretty fast
pleb
>>
Why is Python SO SLOW?
>>
>>59065631
Because everything in Python is object.
>>
>>59065631
Because you're not using Cython
>>
>>59065631
This. Why can't Python be as fast as Assembly?
Most languages are shit in that way.
>>
>>59065596
First one is more portable
>>
>they think neural networks won't be able to translate spoken human language into optimized machine code

fools

we will have human friendly language running maximally efficient soon and there's nothing you can do about it
>>
>>59065596
the first if you ship your code to others

the first if you only use it for yourself and don't mind changing it when compilers drop support for it
>>
>>59065685
>reddit spacing
>>
>>59065101
I'm 5 years into pharmacy school and want to switch to CS.
Thankfully I have no student debt but this fucking opportunity cost is killing me.
Stick it out for another year for a job I hate, will be gone in 10 years.
Or rush through a degree in three years and get into the workforce at 25/26.
Just fucking end me.
I have no idea what I want to do but fuck pharmacy.
I want to die.
>>
>>59065718
Get the degree, it's just a year.
>>
>>59065685
>he thinks human language is precise enough to specify a program
baka, the specs will be as complicated as the program itself
>>
>>59065739
That's what I think I'm going to ultimately do.
The future of this profession is terrifying though.
>>
>>59065745
> The future of this profession is terrifying though.

CS or pharmacy?
>>
>>59065766
Yes
>>
>>59065745
In the UK, the vast majority of secondary care pharmacists spend their time on medicine reconciliation.

As soon as the NHS gets its shit together enough to centralise patient records two thirds of them will be out of a job.
>>
>>59065642

Why is cython not popular yet? How much is it missing?

If I could get compiled speeds from python, I don't think I'd use anything else.
>>
>>59065718
Earn easy $$$ as a pharmacist
Then study CS for fun
>>
File: 1407872496888.png (42KB, 500x354px) Image search: [Google]
1407872496888.png
42KB, 500x354px
I need some help in C

I'm doing this excersize from a book and I'm having trouble with the if part

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

main(){
int answernum, inputnum;

inputnum = 0;
answernum =(rand() %10)+1;

printf("\nGuess the number");
printf("\nWrite your answer: ");
scanf ("%d inputnum");

if (isdigit(inputnum)){
if (inputnum == answernum);
printf("\nYou guessed right");

else \* my compiler says it expects an expression before this, I add a } but then it gives me the same error on the 'else' below*\
printf("\nYou guessed wrong \n the answer was %d" answernum);
}
else \* and if I add a } before this it gives me more errors in other lines*\
printf("\nThat is not a number");
}
>>
>>59065766
Pharmacy.
I'm likely going to get a job in retail since I'm not competitive for a residency.
Retail is seeing a huge downward shift due to reimbursement, huge number of grads coming out, and automation.
I just fucking wish I was 18 and never even heard of this shit.
>>
>>59065718

>Will be gone in 10 years

If anything, there will be more people needing drugs. Just finish the Pharma.
>>
become a pharmacist and sell drugs illegally, possibly in collaboration with a crooked doctor
>>
>>59065791
>if (inputnum == answernum);
why do you have a ; after an if statement
>>
>>59065742
>"onee-chan ai, write a fizzbuzz program"
>"yes master"
>nanosecond later

#define RANGE_START     1
#define RANGE_END 100

#define FIZZ_SPAN 6
#define BUZZ_SPAN 7

asm {
_BUZZ_FIZZ::
PUSH RBP
MOV RBP,RSP //Always set-up stk frame. (Stack Gets Traced)
PUSH RSI //See REGG_LOCAL_VARS & REGG_LOCAL_NON_PTR_VARS
PUSH RDI
MOV RSI,FIZZ_SPAN-RANGE_START%FIZZ_SPAN+1
MOV RDI,BUZZ_SPAN-RANGE_START%BUZZ_SPAN+1
MOV RAX,RANGE_START

@@05: CALL PUT_HEX_U64
PUSH RAX
MOV RAX,CH_SPACE
CALL PUT_CHARS

DEC RSI
JNZ @@10
MOV RAX,'FIZZ '
CALL PUT_CHARS
MOV RSI,FIZZ_SPAN

@@10: DEC RDI
JNZ @@15
MOV RAX,'BUZZ '
CALL PUT_CHARS
MOV RDI,BUZZ_SPAN

@@15: MOV RAX,'\n'
CALL PUT_CHARS
POP RAX
INC RAX
CMP RAX,RANGE_END //Actually only a 32-bit inst.
JBE @@05

POP RDI
POP RSI
POP RBP
RET
}


this is how it's gonna go in the future, programmers will be obsolete
>>
>>59065791
>
if (inputnum == answernum);
>>
>>59065846

can you make it more enterprise?

that'd be great
>>
>>59065791
>
if (inputnum == answernum);

>not a syntax error

Cfags WILL defend this
>>
File: 1470935250985.jpg (26KB, 328x466px) Image search: [Google]
1470935250985.jpg
26KB, 328x466px
>>59065101
I know that feeling, I study twice as hard for my cs classes simply because I want to get it over with.
>>
>>59065787
It's got a niche in scientific computing, but other than that I'm not sure why. Might just be a marketing thing if anything.
>>
>>59065791
>
  if (inputnum == answernum);

remove that semicolon. This is what your code means
if (inputnum == answernum)
{ //do nothing }
printf("right");
else //the printf above means the if clause ended so this else is not owned by an if
printf("wrong");
>>
>>59065789
That's what I'm thinking.
I'm just so fucking worried about the future.
Right now there are pharmacists with 10-20+ years of experience out of a job because of saturation.
All I can think about is what happens if I ever get fired or laid off.
Or about 10 years in the future if I'll have to start from the bottom at a whole other profession due to automation.
>>
>>59065791

Also, going to pull you up on style.

Why are you creating variables, and then assigning them on a later line?
>>
>>59065907

Do we need to design it a fucking logo?
>>
>>59065791

don't you need to call srand?
>>
>>59065846
>"master what is a fizzbuzz can you be more clear"
>"for every number from 1 to 100, if the number is divisible by 3 print fizz else if it is divisible by 5 print buzz else if it is divisible by both print fizzbuzz otherwise print the number"
>>
What are some books that help in the topic of artificial intelligence? I would prefer pseudocode
>>
>>59065149
#include "guerrier.h"
>>
>>59065326
yes!
>>
>>59066015
Artificial Intelligence: A Modern Approach
>>
>>59066033
Then it tells me
"error : redefinition of class Personnage"
"error : previous definition of class Personnage"
>>
>>59065672
Yes. But not significantly.
>>
>>59065896
; is a valid statement
>>
>>59065706
wat?
>>
>>59065896
Might be a warning if you use more restrictive flags. It's an error in languages that respect your time, however.
>>
>>59066073
Leading to nothing but errors and bad style.

Golang did everything right by forcing one code style. They should have pulled through and made the compiler force-autoformating all source code upon compilation.
>>
>>59066067
then remove "personnage.h" from your client code (but not from guerrier.h, or make sure everything is encapsulated in ifndef/def/endif
>>
>>59065779
See this is the kind of shit I'm terrified of.
>>
>>59066172
I know :)

t. doctor
>>
Best qt tutorial you got senpaitachi?
>>
>>59066194
Then help me Dr. Dick.
I need you advice oh so quick.
>>
>>59065596
#pragma once

always.

#ifndef HFILE_H
#define HFILE_H

#endif

only if you have symlinks in your repo so the same file gets included twice and the compiler thinks it's a second file so it includes it anyway and then linker error happens because of multiple definitions
>>
>>59066165
Ok it works.
Now I want to create a wizard.
Do I have to include "Guerrier.h" and "Wizard.h" in main?
>>
>>59066221
programming knowledge.

But warch it at lime 1.5x or 2x speed, he speaks extremely slowly
>>
>>59066235
Suck it up and be a community pharmacist. Maybe put yourself through medschool when you've piled up enough cash.
>>
>>59066254
i watched that1
>>
>>59066244
Yeah. Just add include guards or pragma once to each of your header files, and you won't run into redeclaration problems
>>
>>59066057
>FlipMoran is online
feels good man
>>
>>59066242
Seems reasonable.
>>
I'm using Python to check if a year is a leap year or not. Here is what I have so far

year=int(input("Enter a year:"))

if ((year%400 == 0)or ((year%4 == 0 ) and (year%100 != 0))):
print("{} is a leap year".format(year))
else: print("{} is not a leap year".format(year))


If I enter a leap year, it works just fine, but if I don't, it just print's out the name of the year instead of "(year) is not a leap year" like I want it to.

Also if I don't enter an integer, it crashes. I think to solve that, I should make a while loop that won't break until an integer is entered for the year, right?
>>
>>59066349
In C# this is just
string IsLeapYear(int year)                                     {
goto step1 ;
step1: if (year % 4 == 0) goto step2; else goto step5;
step2: if (year % 100 == 0) goto step3; else goto step4;
step3: if (year % 400 == 0) goto step4; else goto step5;
step4: return $"{year} is a leap year. It has 366 days.";
step5: return $"{year} is not a leap year. It has 365 days.";
}
>>
>>59066349
Make sure your formatting and indentation is correct:
while 1:
try:
year = int(input("Enter a year: "))
break
except ValueError as e:
pass

if (year%400 == 0 or year%4 == 0) and year%100 != 0:
print("{} is a leap year".format(year))
else:
print("{} is not a leap year".format(year))
>>
https://github.com/ableiten/Doggo
>>
>>59066401
>turning a trivial problem into an unstructured goto graph
fired.
>>
>>59066303
Cheers it works fine
>>
>>59066472
>checking validity of phrases/pallettes in
doggo()
and not setters for those properties

Sad!
>>
>>59066401
  bool Thing(int year)
{
int[] mods = { 4, 100, 400 };
bool isLeapYear = true;

for(int i = 0; i < mods.Length; ++i)
{
if( year % mods[i] != 0)
{
isLeapYear = false;
break;
}
}

return isLeapYear;
}
>>
>>59066542
>replaced a simple condition with a loop
What is this, loop enrolling?
>>
File: enterprise.png (169KB, 640x360px) Image search: [Google]
enterprise.png
169KB, 640x360px
>>59066401
>>
>>59066401
>>59066542
It is cool seeing different languages/solutions to the same problem.
>>59066455
Hmm, now it works for the first time but every input after that it just repeats the number back without determining whether it's a leap year or not.

Also i'm a total beginner, is their any difference between "While True:" and "While 1:"? also what does "as e" mean?
>>
>>59066589
it also doesn't work
>>
File: code.png (113KB, 1920x1080px) Image search: [Google]
code.png
113KB, 1920x1080px
Can Someone please help me
Im stumped on how to get the Min,Max,and Average Values from my Array list
>>
>>59066349
year=int(input("Enter a year:"))

if ((year%400 == 0)or ((year%4 == 0 ) and (year%100 != 0))):
print("{} is a leap year".format(year))
else:
print("{} is not a leap year".format(year))
>>
>>59066602
The C# example was a joke, I hope.

No sane person would write it like that.
>>
>>59066401
does C# really support goto?
>>
>>59066401
>goto
THE ABSOLUTE MADMAN
>>
>>59066724
yes. C# is absolutely disgusting. java is far superior. if you feel you have the need for all sorts of different features, just use C++ instead. C# is just the worst of C++ and the worst of java combined.
>>
>>59066750
But GUI programming isn't half as cancerous in c# as in Java.
>>
>>59065718
>opportunity cost is killing me

Do you mean sunk cost?
>>
>>59066840
>windows-only GUI programming
spotted the code monkey
>>
>>59066869
>Not-Windows GUI programming
Why would anyone do that?
>>
>>59064946
Ok guise, before I start my programming career, let me go to trade school to start a career while i start my career.
>>
>>59066540
there are setters for them, see the other functions. They just aren't named the way you expect because 2017 lol
>>
>>59066840
JavaFX is okay, even though tool support is still lacking, naturally
>>
File: setters.jpg (330KB, 680x481px) Image search: [Google]
setters.jpg
330KB, 680x481px
>>59066540
>>59066937
>doggo setters
>>
>>59066840
>not wiring the gui in html and compiling your c# to javascript
jesus christ
>>
>>59066650
Still waiting on some help
>>
>>59066750
>C# is just the worst of C++ and the worst of java combined.
That's funny, because personally it feels like the opposite.

I like being able to manually manage memory if I want, and I like Java overall, but find C# to have some sweet syntax sugar that makes it more fun to write in.
>>
>>59066472
cute but why did you use the builder pattern in DoggoGenerator if you dont bother using it?
>>
>>59067071
Can't you just call Min(), Max(), and
Average()
?
>>
>>59067071
you should be able to figure that out yourself, review your notes

if you can't, just drop out right now, you'll not make it.
>>
>>59067071
Did you try fixing your indentation?
>>
How do i into version numbering?

I can't increase version number everytime i hit 'build', can i? I compile every three lines of code, or about that frequency, like a noob.
>>
>>59067211
>I compile every three lines of code, or about that frequency, like a noob.
No. It's normal to always build.
>>
>>59067211
potentiallybreakingchanges.minorbackwardscompatiblechanges.patches

just add 1 to patches, it's okay if it's 2.17.476223623
>>
>>59067131
it's java not Cshart
>>
>>59067211
versions matter when other people start caring
>>
File: dad_of_the_year.webm (2MB, 1335x720px) Image search: [Google]
dad_of_the_year.webm
2MB, 1335x720px
>>59067211
http://semver.org/
>>
>>59067244
>java can't call max() directly on an array
Sad!
>>
>>59067131
I cant its Java
>>
>>59067253
is essentially >>59067243
>>
>>59067211
make a file called version.h with:
const unsigned build_num = 1234;

write a program to increment this number and rewrite the file, then call it in your makefile before compiling.
>>
if functional programming languages don't have for loops , does that mean every time you would want to use a for loop, you have to use a recursive definition instead?
>>
>>59067317
lambdas, son

They're interative loops under the covers anyway.
>>
>>59067277
>wanting even more bloat than java and more cluttered shit than python
>>
>>59067317
typically map is used
for (i in list):
print i

map print list
>>
>>59067317
Yes, but compiler will unroll tail recursion into a loop for you. Also most of the time you just use high-level functions like `map` and `filter`.
>>
>>59067127
It isn't a builder pattern.
>>
>>59067335
>being able to easily get the max value in an array of primitives is bloat

topkek

those grapes are sour anyway, right?
>>
>>59067317
>functional programming languages don't have for loops
most of them have
>>
>>59067348
>seters end with return this;
>when you're done messing with setters you call build() or doggo()
what do you call this technique?
>>
>>59067354
because looping through an array to get the max is so hard

because using an external library is so hard

because you need to have all kinds of inefficient shit built into the standard library
>>
>>59066909
Not that anon, but I'm trying to develop a media organizer, and GUI toolkits are pissing me off mightily. It doesn't make sense for a photo/video organizer to be a CLI application, since CLIs tend to do a piss-poor job at, you know, displaying graphics.

One option is writing it for the web: which means using JavaScript if you want the application to be anything resembling usable. Also I have no control over what codecs the browser was compiled with, so it's a crapshoot whether or not it can even display all my media. (You're also round-tripping through the networking stack, browser cache, etc. for files that were probably on your local machine in the first place.)

Assuming one is sane and can't stand javascript: that leaves writing a desktop application. Now I'm faced with the problem of building said app on Windows, Mac OS X, Linux, and maybe even a mobile client (Android), all of which I use on a daily basis to add to my library. Writing desktop applications sucks though, and I don't feel like doing it once, let alone three or four times.

Writing an FFI core is all well and good, but the core is not the hard part. It's a query parser and some SQL. The graphical frontend for a graphical media organizer is where all the development effort is.

Honestly I wouldn't mind one of these "immediate mode" GUIs (named for the API, most of them are actually retained scene graphs) ... but they're all developed for inclusion in games (e.g: a single GL context, most of them puke as soon as you try to display a second window in the same process.)

tl;dr: sometimes you want graphics, and use more than one OS. life is suffering.
>>
Why is R a blue pill?


Anyhow, I'm working on developing both a program and shell script that will record the amount of time I do something and will append a Libreoffice Calc chart, or even a normal text file to begin with.

I thought it'd be cool to compare the amount of time I spend in leisure on my computer and compare it the amount of time I spend truly studying or practicing.
>>
in a non-trivial program you usually don't want just the max of an array, and even if you do just want the max, you can get it easily, doesn't need to be built-in method in the array class
>>
>>59066854
Opportunity cost in the way of graduate at 24 for 100k/yr at a job where I blow my brains out in 6 years or I am unemployable in 10.
Or risk three more years of my life to work in CS when I have no prior experience and hopefully still have a job by the time I'm 35.
I'm planning on studying some C++ through online coursework and a friends classes over the coming weeks but I'm just dead fucking tired and scared of the future.
>>
>>59067385
Just use Qt.
>>
>>59067382
>>59067429
I appreciate a library function that can find the max of a list but it shouldnt exist in the List class itself, thats basic oop
>>
>>59067374
The setters are just normal setters. They return the current context to allow for chaining, just for convenience.

doggo() just generates a doggofied image with the specified input image. You can generate as many doggofied images as you want and they will come out different each time because of the randomization.

It isn't a traditional builder pattern, the layout just makes it look similar. If you want to know more about these techniques I suggest you read "Effective Java" by Joshua Bloch.
>>
>>59067382
>because looping through an array to get the max is so hard
Not the point.

It's more convenient to call .Max() rather than cluttering up a method with another loop.
>>
>>59067108
I don't know how anyone can stand Java. Frankly types before identifiers was a fucking grammar mistake that we'll be paying for until the fall of modern computing. Once you've had a taste of type deduction (C#'s var, C++'s auto) or used a language w/ real inference like F#/Swift/Rust/et al, Java is damn near painful to write.

The diamond operator is perhaps the most hilarious thing to me. It's an admission that the language had a huge verbosity problem, yet it's a completely backwards solution. Having to specify a concrete type on the RHS of an expression was *never* the fucking problem.
>>
>>59067418
It's not R, it's Rust.
>>
Is there a way to convert an integer to a string *statically* in C++?

Something like this:
template <unsigned N, unsigned Base = 10>
struct itoa {
static constexpr const char* value = concat<itoa<N/Base, Base>::value, ('0' + N%Base)>::value;
};


How is concat implemented? Is it possible?
>>
>>59067466
i'd personally call it a builder - how is it not one?
>>
>>59067471

Nobody knows or cares about Rust dude.
>>
>>59067467
as soon as you do something more complex than webfaggotry or GUI dev the convenience will be marginal at best
>>
does "refactoring" have a more specfic , technical definition other than "rewriting code so that it is structured better" ?

whenever I read people talk about "refactoring" it sounds as though they're talking about a technical process like compiling or something with a clear-cut definition or procedure.

Do they really just mean re--writing or re-structuring to improve the strcuture?
>>
>>59067534
>Do they really just mean re--writing or re-structuring to improve the strcuture?
yes, rewriting it to make it less retarded
>>
>>59067534
>Do they really just mean re--writing or re-structuring to improve the strcuture?
Yes.
>>
>>59067534
any change in code that does not require a change in tests
>>
>>59067534
>whenever I read people talk about "refactoring" it sounds as though they're talking about a technical process like compiling or something with a clear-cut definition or procedure.

There's refactoring and refucktoring. Refactoring is improving the internal structure of code *without* modifying the public interface. If you make major internal changes, and break the public API/ABI in the process, that's just refucktoring.
>>
>>59067496
int a = 7;
std::string number_string = std::to_string(a);
>>
>>59067592
>*statically*

I need to do it at compile-time.
>>
>>59067471
Oh ok lol, I see now.


>>59067501
that's some spicy retardation my man
>>
>>59067496
i've been interested in this as well but there doesn't seem to be any known solution (except for stringifying literals of course). you can get pretty far with constexpr functions but then you get fucked on some technicality like i don't remember exactly but it was like some buffer thing and the method to get a pointer to the backing char array is non-constexpr
>>
What is the best way for me to learn Python? Every website i've tried to learn from so far is either retarded easy and just gives you all the answers, or they just tell you to accomplish a task and expect you to know how to do it already. I managed to work my way through a few of them, but there's some stuff that I just don't know how to do at all, like making a clock.
>>
>>59067496
>>59067723
maybe you can hack around with your build system to generate a file with string literals which gets included into your program at compile time
>>
>>59067731
Do you want to code something or do you just want to learn?
>>
>>59067753
I just want to learn really, there's nothing specific I want to code yet, I just wanna code anything, really.. Maybe make my own roguelike one day, but I'm not even sure Python is the right language for that.
>>
>>59067613
I'm not so hot on this myself, but look up the
constexpr
keyword.
Get back to us and let me know if that lead to a solution.
>>
>>59067783
Python is ideal for that.
>>
>>59067499
You could call it a builder since it is creating images but it doesn't really fit the modus operandi of a builder pattern.

Builder patterns are usually used to build an instance of a specific type, not augment one that already exists.
>>
>>59067783
Learn OCaml instead of the shitty untyped python scripting language.
>>
>>59067783
Learn haskell like a real man.
>>
Finding (more) good resources to learn Django. Most of the free and "pirated" stuff I find is for old versions of Python or just not the kind of book I'm looking for. Tango with Django, for example, has this whole Rango project that I felt would have been great to learn what I can develop with django. Any suggestions?
>>
>>59067923
old versions of Django*, although Python applies too
>>
Are there any big differences between mysql and MSsql? There'll just be a few different functions between the two but they still do the basic things the same?
>>
def collatz(number):
while number != 1:
if number % 2 == 0:
number //= 2
print(number)
elif number % 2 == 1:
number = number * 3 + 1
print(number)

print('enter a number.')
number = (int(input())
collatz(number)


Is there any tips you could give me? I'm trying to learn Python, and I would appreciate if you could point out any flaws in this.
>>
File: 1479473604982.png (205KB, 322x276px) Image search: [Google]
1479473604982.png
205KB, 322x276px
>>59064420
Working on legacy Visual Basic stuff because emergency
>mfw VB syntax and overall behavior of the language

>>59067995
Do you mean in terms of SQL queries? I don't think so, and even then, most websites that have SQL information have it translated across the DB types
>>
how should I organize my code when I have project specific code and code that is also used by other projects? right now I have it organised like
projects
utils
util1
util1.c
util1.h
project1
main.c
project2
main.c

where the functionality in the utils are used by different projects
now that leads to things like #include "../utils/util1/util1.h" which I'm not a fan of, also I'm using recursive make but apparently that's not recommended
I thought about softlinking the required utils in the project folders but I'm not sure if that's gonna work too well
it's code for AVR if that matters
>>
>>59068075
Use two spaces for indentation instead of four. Best coderz always use 2 spaces.
>>
>>59068089
I suppose in queries. A lot of jobs I'm going through are asking for MS SQL experience but I know MySQL. I'm not seeing much different between the two in terms of query writing
>>
>>59067784
>>59067752
>>59067723
Well, I couldn't figure out a way to do it, but anyway, here is my TEMPLATE FIZZBUZZ:
#include <array>
#include <iostream>
#include <limits>
#include <string>

template <unsigned N, bool Fizz, bool Buzz>
struct fizzbuzz_helper {
static constexpr const char* value = "<N>";
};

template <unsigned N>
struct fizzbuzz_helper<N, true, false> {
static constexpr const char* value = "fizz";
};


template <unsigned N>
struct fizzbuzz_helper<N, false, true> {
static constexpr const char* value = "buzz";
};

template <unsigned N>
struct fizzbuzz_helper<N, true, true> {
static constexpr const char* value = "fizzbuzz";
};

template <unsigned N>
struct fizzbuzz : public fizzbuzz_helper<N, N%3 == 0, N%5 == 0> {
};

template <unsigned Max>
std::string recursive_fizzbuzz()
{
return recursive_fizzbuzz<Max - 1>() + "\n" + fizzbuzz<Max>::value;
}

template <>
std::string recursive_fizzbuzz<0>()
{
return "0";
}

template <>
std::string recursive_fizzbuzz<1>()
{
return "0\n1";
}

template <>
std::string recursive_fizzbuzz<2>()
{
return "0\n1\n2";
}

int main()
{
std::cout << recursive_fizzbuzz<10>() << std::endl;
}
>>
>>59068089
>Working on legacy Visual Basic stuff because emergency
>>mfw VB syntax and overall behavior of the language
Ouch. I feel your pain.
>>
>>59067923
Have you looked at the sentdex series on YouTube? I went through it but it seems to just cover getting a basic site going, I'm wondering if there are any better resources out there myself
>>
>>59068173
Nicely done.
>>
>>59068173
reminds me of this
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
>>59068075
>>59068075
What does //= do? I've never seen that

Also you're probably aware of this but you don't need paranthesis before int
>>
>>59068214
Thanks. Here it is on Ideone for easier running: https://ideone.com/xHgFdE

>>59068230
Jesus, he must have spent fucking ages on this. Imagine spending that much of your life on a single meme. And writing it in Java, no less.
>>
>>59064471
I think C++ will live on forever in gamedev, for the simple reason that faster code=higher effects budget=prettier games=more money.
>>
>>59068174
I'm definitely glad I was taught VB in my college intro course, this would have been 10x worse if I wasn't at least somewhat used to it from that class.

>>59068256
Looked it up, looks like it's floor()
https://docs.python.org/2/library/operator.html#operator.floordiv
>>
>>59068173
>>59068267
Something's wrong, for n>=3 it prints <N> instead of the number
>>
>>59068267
Pray tell what is the purpose in life if not the memes themselves?
>>
>>59068174

I work on "legacy" Visual Basic (VB6) stuff every day. It's not even in "maintenance mode" or anything, people are routinely ring me up with support questions.

We only have one laptop left with a *working* VB6 development environment for this app. It's an old HP Probook that requires percussive maintenance to restart. (The display won't turn on unless you smack a specific corner.)

This product's "replacement" is a web application that was written in Java/J2EE, complete with all the Java Enterprise Beans and JSF and Spring dependency injection goodness. (Called into from "native" mobile apps written in Titanium's Appcelerator, e.g Javascript.) It's not so much a replacement as a companion, though.

I want to kill myself. In fact I probably would kill myself, but thankfully functioning alcoholics aren't really frowned upon in the midwestern US.
>>
>>59068289
You are retarded.
C++ is not used for gamedev, entire STD is hated by gamedevs, look up EA STL/STD.

Please stop thinking, thanks =)
>>
>>59068267
IDEs make it easy to bloat things. You can carve out tiny parts into different classes with a few clicks. Autocompletion makes stupidly long variable names trivial. It's still a lot of work but nobody is writing every byte of a .java file by hand.
>>
>>59068322
Where did I say anything about using the STL? Gamedev usually takes a "C with classes" approach.
>>
File: 1451995301143.jpg (141KB, 600x2158px) Image search: [Google]
1451995301143.jpg
141KB, 600x2158px
>>59068317
I feel you, I had to support a Visual FoxPro project for some time.
>>
>>59066750
>C# is absolutely disgusting. java is far superior.
as a lang c# is far superior to java in many ways.

>if you feel you have the need for all sorts of different features, just use C++
this statement is so vague as to have no meaning whatsoever

>C# is just the worst of C++ and the worst of java combined.
the opposite is true

java does have merits over c#, but since you've failed to touch upon a single one I assume you either have no experience in the languages or are trolling.
>>
>>59068352
>Gamedev usually takes a "C with classes" approach.
unless you're interested in
A) performance
B) development time
C) maintainability
>>
>>59068292
Thanks
>>
>>59068372
Using a bloated template laden mess like the STL gives you none of those things.
>>
>>59068398
There's nothing wrong with parametric polymorphism, the problem is C++
>>
Im working on writing an exploit for CVE-2017-6074, which is the new Linux kernel double free in dccp methods.
>>
>>59068075
Wouldn't it be better to return the number to the function and then call print on the function. I'm also a beginner in Python so I'm not sure but it seems like that would be better so you could implement the function in different ways. Otherwise do you even need a function at all ?
>>
>>59068398
As long as you stick to using std::vector then performance is not a problem - and maintainability is easy with vectors too.

Problem seems to be that too many people take a theoretical approach and choose to use std::list when they want to do insertions in the middle of the structure often. It actually turns out that using std::vector will beat std::list pretty much every time (simply due to contiguous memory).
>>
out of all the programming languages Java has actually pretty good GUI programming and how it is structured
>>
you've been memed into believing that c++ is bad when in actuality, it's the best language there is. by a mile.

i feel sorry for you.
>>
File: 1460612544671.jpg (33KB, 590x394px) Image search: [Google]
1460612544671.jpg
33KB, 590x394px
>>59068317
>mfw looking up options for VB6 dev environments in 2017
http://stackoverflow.com/a/8029361/2332318
You are actually in the worst hell.
>>
I remember a C++ template program for something like the Fibonacci series which computed and even printed the series at compile time. It forced the compiler to print each number as an error message. In fact I think the entire series was one long error message for every level of

Does anybody know/can figure out how to do this? It can't be done with #error or static_assert, because both of those are only evaluated once.

>>59068305
That's because I couldn't figure out how to get the numbers as strings. To do so requires concatenating non-literal string constants at compile-time, which is seemingly impossible.
>>
>>59068398
Yet all the popular container/algorithm libraries in pure C are slower and harder to use than STL.
>>
>>59068322
>C++ is used for gamedev
>entire STD is hated by gamedevs, look up EA STL/STD
One does not contradict the other.
>>
>>59068461
std::vector is one of the most hated classes by real gamedevs.
>>
>>59068567
>real manchildren hate this
ok
>>
File: 3qrjJJPm.png (233KB, 465x465px) Image search: [Google]
3qrjJJPm.png
233KB, 465x465px
>>59068567
t. real gamedev
>>
>>59068567
Well they must be retarded then, std::vector is one of the best designed containers of any language.
>>
>>59068567
who is this /real/gamedev/?
and if vector is so bad, what else do they use?
do they roll their own malloc clusterfuck and only use straight pointers like embedditards?
>>
>>59068567
[citation needed]
>>
>>59068567
>hating a wrapped
malloc(oldsize * 1.5)


nigga, what?
>>
>>59068728
>tfw no malloc(float)
>>
File: 1474350828919.jpg (107KB, 1156x705px) Image search: [Google]
1474350828919.jpg
107KB, 1156x705px
So I'm trying to make a greasemonkey script for comfy keyboard-only browsing but.. Highlighting a thread isn't really working right for threads with very few replies.

Any suggestions on how to resolve?
>>
>>59068832
already exists
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en
>>
>>59068882
Irrelevant
>>
File: sheldonbubinga_zpse0057a96.jpg (48KB, 1024x610px) Image search: [Google]
sheldonbubinga_zpse0057a96.jpg
48KB, 1024x610px
>>59068921
Much like your script.
>>
>>59068937
Kill yourself :')
>>
>>59068567
cryengine uses std::vector
>>
File: Screenshot_2017-02-22_23-29-25.png (106KB, 975x742px) Image search: [Google]
Screenshot_2017-02-22_23-29-25.png
106KB, 975x742px
>>59064420
>What are you working on, /g/?
Go+C image/video/audio/PDF/w/e thumbnailing library.
>>
>>59068650
Exactly. custom container, custom allocator with custom memory pooling.
>>
File: 1484097211609.jpg (202KB, 1280x720px) Image search: [Google]
1484097211609.jpg
202KB, 1280x720px
currently working on my own chan.

I didn't want to just copy and paste vichan, so I'm making TinyIB much more efficient, and adding more features. It's already up but don't want to shill it here though because it's pretty degen
>>
>>59068759
void* real_malloc_for_real_programmers(float x)
{
return malloc((unsigned)(x + 0.5f));
}
>>
>>59069091
I didn't say anything about rounding
>>
>>59068981
Woah, that editor looks cool as fuck. What editor are you using, anon?
>>
>>59069199
VS Code
>>
>>59068981
Fuckin nice, anon! Does it do filetype detection on its own, or do you need to specify the type of the file you're thumbnailing? (Also if it does filetype detection: is it naive by extension, or is it actually looking at magic bytes etc?)
>>
>>59065343
>that source
Hahaha. This is babby level. Watch this:
http://code.metager.de/source/xref/gnu/coreutils/src/yes.c
>>
File: 1487521078536.jpg (242KB, 495x600px) Image search: [Google]
1487521078536.jpg
242KB, 495x600px
What resources are there to learn cross platform GUI programming? As in, learning to make your program portable and utilize a platforms native toolkit instead of using a general one like Qt, tk, etc.

I basically just want to be able to write a library then make a GUI frontend for each platform that uses it, but I don't know anything about GUI programming for a single platform let alone multiple. I figure it will entail just generalizing the functionality I need like createWindow() and implementing it per platform but I'm unfamiliar with how to actually implement these things. Is it common for people to use some kind of visual constructor that then gets exported to relevant C code? I want to try and not have a hard dependency on any particular tools like Qt creator, Visual studio, etc.

Am I crazy? How do I become sane?
>>
>>59069415
other people have already, why bother

void CreateWindow(){
#ifdef __linux__
//create window on linux
#elif _WIN32
//create window on windows
#elif OS_X
//create window on mac
#endif
}
>>
>>59069415
>cross platform GUI programming
>sane
Pick one.
>>
Why does this not fucking work. god damn it.

 
int x = 42;
int array [x];


This should work ffs. why doesn't it /g.
>>
>>59069510
Stop using C++, idiot.
>>
>>59069415
WIth java javafx for gui, you have to implement platform api for yourself for example for camera.
With python you got kivy and plyer which define some platform specific stuff.
With scheme you got scheme which is like kivy for scheme.
With qt you got qt...

Otherwise your option is webapp.
>>
>>59069278
>Does it do filetype detection on its own
It will. Currently working on that.
>is it naive by extension, or is it actually looking at magic bytes etc
Magic detection and other stuff in special snowflake hurr durr cases like MP3 (and maybe later SVG too).

Thumbnails are be JPEG with configurable quality, but all images with transparent pixels are PNG. Will also provide some basic meta information like stream length, dimensions, etc.
>>
>>59069510
But it does: http://ideone.com/3gGeyh .
>>
>>59069415
I don't think there are resources for what you ask. You have to look at each platforms native API separately, and then bring them together under a unified front end. So you'll be writing your own crossplatform toolkit with separate implementations for each platform you want to support.
>>
>>59068981
Is it easy to interop in Go?
>>
>>59069566
VLAs are not in C++.
You're relying on non-standard shit there.
>>
>>59069510
Because VLAs are not standards-compliant, they work in GCC but won't work in some other compilers (Clang for example, I think).
>>
>>59069510
so how do you create arrays of unknown length?
>>
>>59069510
I don't know what you're talking about, anon... Works for me

int main()
{
int x = 42;
int array[x];
int count = 0;
for( int a : array)
{
std::cout << "COUNT = " << count++ << "\t\t";
std::cout << a << std::endl;
//shitty formatting because I'm suffering from crippling depression and something something something about optimizations
}
return 0;
}
>>
>>59069577
Pretty nice. Go understands C headers, most Go types are C-compatible and casting them has no runtime cost. Go can allocate C data structures natively on the Go stack or heap. The only downsides are that you must make sure that there are no pointers to Go memory left on the C side, when the C function returns, and there is a slight runtime cost for context switching between Go and C (~30 nanoseconds IIRC).
>>
File: Screenshot_2.png (5KB, 368x111px) Image search: [Google]
Screenshot_2.png
5KB, 368x111px
>>59069652
but then why doesn't this work?
>>
>What are you working on, /g/?
Still working on my twisty puzzle collection game.
>>
>>59069483
Sorry I meant what it entails to actually create those windows, not how to preprocess it. I'm very unfamiliar with it and don' know where to begin. It seems like people don't actually write GUI code themselves but instead use tools to generate code. I'm just trying to find out if that's actually the case and the things I should be looking into. Like I know for Windows I'd have to look into MFC or the Windows API itself but I'm unsure of how people generally work with it. For most things there's only really one way to approach it, read the documentation and write the code, but with GUI's it seems like it might be different and you might be bound to visual tools or a full IDE, not just your editor.

Ideally I just want to have platform native visual consistency, while also keeping the project easy to build (few deps), even if this means it will be harder to write initially.

The bittorrent client Transmission may do what I'm talking about, they have their core library and a bunch of different front ends for it. I want to do something like that.

>>59069542
Do you have any experience with Qt, if so are there any caveats you could tell me about? I've considered using Qt, wxWidgets, or Tk but I'm concerned with how native it will look on various platforms. There seems to be things you can do to help with that but if I have to do additional work with the native api anyway I may as well just use my own thing instead of pulling in big dependencies that do much more than I need.

>>59069570
Is this a common thing to do or am I being naive in my approach? If it's worth doing I would like to do it that way even if it's more difficult and requires more learning.
>>
>>59069641
If you're using C++ then use a std::vector, or if you're using C then `int* arr = malloc(sizeof(int)*42)`.
>>
>>59069729
Because the expression 'length_of_n' must have a constant value.
>>
>>59065101

I don't understand how you can "hate" programming.

Like can you explain why you hate it? What about it makes you hate it?
>>
>>59069632
I use clang and VLAs work fine for me in C, they're part of the C99 standard, they're optional past that. I don't know about C++.

Only some syntax stuff is exclusive to gcc but I don't even know the benefit in using them over the standard, like the gcc reversed arguments, I don't know why you'd do that.

http://stackoverflow.com/a/14549030
>>
SO I just started learning java and programming I guess all together and i'm not sure how to stop animations that are in a draw function, can you guys help me out? pls don't bully.
example:

var x = 10

draw = function () {
x = x + 1;
arc ( 187, 332, 100, x, 0, 180);

}

so basically the x value keeps growing without stopping. How would I go about stopping it?
>>
>>59069852
>VLAs work fine for me in C, they're part of the C99 standard, they're optional past that.
I know.
>I don't know about C++.
It is a feature deliberately left out of C++ for whatever reason.
>>
>>59069129
static const size_t POOL_SIZE = 32768;
#define CLOSED NULL
static void* pool = CLOSED; // FIXME: AIDS
#undef CLOSED
static float pool_addr = 0.f;

void(* internal_alloc)(size_t) = malloc;

void real_malloc_init()
{
pool = internal_alloc(POOL_SIZE);
}

void* real_malloc_for_real_programmers(float size)
{
void* p = pool + (size_t)(pool_addr + 0.5f);
pool_addr += size;
return p;
}


Coming soon: version with no rounding at all
>>
>>59069858
>var
>Java
Why would you lie on the Internet?
>>
>>59065896

ITS JUST UB bRO YOU WOULDN'T UNDERStaND
>>
Should I learn COBOL? It's the favorite meme of my 55 year old father.
>>
>>59069729
What IDE are you using? I think it's got to do with the fact that some compilers won't allow you to use variable length arrays (VLA), as stated here:
>>59069632


If you want a VLA, I would recommend the following snippet:
int * array= new int[length]


This may just be clang being weird, but when I do the following code snippet (which definitely compiles with XCode), I get the error in pic related:
#include <iostream>
int main()
{
int x = 17;
int * int_arr = new int [x];
//Why won't this compile with clang?
delete [] int_arr;
}
>>
>>59069756
>Is this a common thing to do or am I being naive in my approach? If it's worth doing I would like to do it that way even if it's more difficult and requires more learning.

As i said, you'd basically be making a new Qt, GTK, whatever, toolkit, and most people don't feel it's worth their time to reinvent the wheel.
It's only worth doing for educational purpose if you're like me and find it really annoying to rely on third party libraries.
It don't think it's terribly difficult, as much as it is time consuming.
>>
>>59069958
Yeah you know what I'm officially a dumbass... I forgot to do
clang++ [MYFILE].cpp


God dang it
>>
>>59069756
i'm 90% sure that qt automatically uses a theme appropriate to whatever os it's running on. i.e, if you compile for windows, buttons will look like generic windows buttons. if you compile for mac, buttons will look like generic mac buttons. etc pp

i wouldn't use qt tho because it costs a ton of money unless you're only looking to create open source stuff.
>>
>>59069990
>hey guys why doesn't my program compile
>oh I forgot to compile it
>>
>>59069957
Only if you're willing to do it for teh lulz.
>>
>>59069927
i'm new and could have sworn that's what this was. my bad
>>
>>59070036
I believe I should properly learn C++ first
>>
New thread: >>59070063
>>
>>59069961
I appreciate the input, Anon. I think I will give it a go and see how things turn out, if it ends up poorly for me I will just take to learning an existing toolkit instead, most likely Qt. Hopefully I'll learn something either way in the process.

>>59070005
Good to know. I'll have to read the licensing terms. I don't intend to keep anything closed but I wonder what they have to say about linking anyway. If it's possible to keep the core closed while opening up the frontend only.
>>
>>59069958
That's not a VLA, it's just a dynamically-allocated array. Also if you're using C++ then there is absolutely no reason to not use std::vector over `new`.
>>
>>59070061
That would probably be a better use of your time.
>>
>>59070017
The issue was that I used clang instead of clang++

In my defense, I never said I was a good programmer
>>
>>59069958
I'm using Visual Studio. Should I try in a different compiler?
>>
>>59070099
>Should I try in a different compiler?

Maybe? Once again, this is a relatively simiple fix (dynamically allocated arrays), so if most of your project is already in VS, I wouldn't change it... It's up to you, but you might want to keep in mind that by default, arrays need to have a fixed (const) size
>>
>>59069510
int x = 42;
kek:
int array [x];
if (x == 42) { x = 420; goto kek; }

what would happen?
>>
>>59070074
Break a leg.
>>
I would like to learn java where should i go
>>
>>59070166
India.
>>
>>59069958
this worked, thanks anon. :)
>>
>>59067783

Look up Zed Shaw's book if you're still around.

Its retarded easy to begin with because its intended for general use, which implies general public, who are literal retards. You sort of have to be to have any audience with a beginner's book though. He makes up for it with a really positive attitude, the way he writes can be pretty funny too.

Zed uses instruction, which is the idea of "Write this code out exactly and think about what it does whilst you write it, and you should be able to guess if you're not a complete fuckhead. Afterwards, I'll tell you what it does." This way you form your own thought patterns, in the way your brain works, for the techniques he's teaching you, and then he reinforces whatever pattern you generated yourself. I feel this is one of the best ways to teach programming, especially in books, because you don't have to make too many assumptions about how your audience is going to learn - your audience has more freedom to learn in their own way.

Its definitely not an instruction manual, it doesn't focus on shitty reference-explaination-example like 99% of shit books/resources too -- it feels far more like a genuine teacher than any other programming book I've read.

It'll take until about 2/3rds of the way through the book to get to anything anyone would actually care about, but its done in a way that, if you have patience, isn't going to make you want to kill yourself and is going to allow you to be a better programmer no matter what language you choose to use in the future.

The only problems with it are that it makes you use atom. Nobody in their right mind would ever use atom because atom is for female social justice warriors from github and their cucked orbiters. If you install atom on your computer, the chances of a woman remaining faithful to you in any future relationship drops by almost three quarters.

Also his editors/proofreaders fucking suck balls, but that can be overlooked.

Also atom isn't a bad editor. (it is)
>>
>>59070166
https://docs.oracle.com/javase/tutorial/
>>
>>59070166
I tried to learn java once. Too difficult. So I learned x86 assembly and got a job instead.

I don't people actually know java. It's just a myth that people have learned it as a language.
>>
File: 1483073157801.jpg (110KB, 1280x720px) Image search: [Google]
1483073157801.jpg
110KB, 1280x720px
Employed Haskell programmer reporting in
>>
>>59070582
What kind of stuff do you usually write?
>>
>>59070582
Employed as what?
>>
>>59070631
Garbage collector probably.
>>
>>59068322

I work in gamedev. All I've ever known is C and whatever I have to use from C++.

None of that has ever been std. C++ is not standard library, even though its taught like that in 99% of cases, especially by non-C-first subscribers who will write books that use input/output operators in every single exercise and go away pretending they've just taught somebody how to develop literally anything at all.

Just because C++ has been taught to you in a not-fit-for-purpose way, doesn't mean it doesn't have a use in another way.
>>
>>59070693
Java is used for gamedev
>>
>>59068446
>>59068075

A good way to implement this would be as a generator:

def collatz(n):
while n != 1:
if n % 2:
n = 3*n + 1
yield n
else:
n //= 2
yield n


Then when you do
collatz(10)
you initialise a generator which will give you the list of steps taken to reach the end, allowing you to do more than just print out the answer.

It's usually a bad Idea to create a function just for something like this if you're just going to print the result, by having the function return the answer you're now able to re-use it in more places.

fyi to use the above function you would either iterate over it, or just use a list constructor and print that, f.e:
print(list(collatz(55)))

or
for i in collatz(55):
print(i)
>>
>>59068289
I'm excited to see Jon Blows JAI, it's designed specifically around game development.
>>
>>59068289
It's not about C++. Any language which offers offers the same performance benefits (aka control) is OK. Nobody serious likes C++. It's what you put up with. If you make a language that compiles to C that could easily replace C++.

And really with llvm you just need a few of the C/C++ qualities to be competing with them.

Obviously getting people to move to your language is the hardest part of it.
>>
there is literally nothing wrong with using libraries for your projects instead of wasting time reinventing the wheel
>>
>>59071084
depends entirely on what you're doing and what your requirements are and if the libraries fit your requirements. personally i don't find libraries very useful outside of very basic utility things like decoding files and things like that
>>
pythonfag here

guys, how the hell can I convert ascii to utf-8 in python and fix the weird characters like ± with sys.argv

I'm trying to get filenames but those with weird characters come out looking like that when I print them
>>
>>59071606
Use Python 3.
>>
>>59071606
>convert ascii to utf-8
You literally have to do nothing.
>>
>>59071837
what? no you can't, I dare you. add an argument from cmd into a script and then try converting it to utf-8 with the right characters
>>
>>59072073
This thread in on page 10, so I replied in the new thread: >>59072134
>>
>>59071606
https://docs.python.org/2/howto/unicode.html
Thread posts: 342
Thread images: 32


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