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

File: 1498117439710.png (9KB, 637x130px) Image search: [Google]
1498117439710.png
9KB, 637x130px
What are you working on, /g/?
Previously >>61763350
>>
File: 1427364672215.jpg (118KB, 396x385px) Image search: [Google]
1427364672215.jpg
118KB, 396x385px
first for 'grammin' in the ood
>>
File: I_Want_You.png (264KB, 414x585px) Image search: [Google]
I_Want_You.png
264KB, 414x585px
>>61770973
>>
Haskell!
>>
re-writing Scala in Go
>>
I'd like to some text filter so I don't have to see the same dumb memes you losers say on here. Idk how though lol
>>
>>61771039
>say on here
say here*
>>
>>61771051
too late now. do you know how to do the shit I want?
>>
>>61771102
Yes, the best way is going to reddit
>>
>>61771122
what a fag
>>
File: lel.png (94KB, 508x882px) Image search: [Google]
lel.png
94KB, 508x882px
>>61771102
Create a basic ass script in TamperMonkey, I did it, that shit's easy as hell. You can even change what the posts say if you want.
>>
D is better than C++ --top to bottom.
C was created by Electronic Engineers
D was created by Compiler Engineers
C++ was created by a literal uneducated faggot because C was too hard for him
D is better than C++ --top to bottom.
C was created by Electronic Engineers
D was created by Compiler Engineers
C++ was created by a literal uneducated faggot because C was too hard for him
>>
>>61770973

Why do people dislike C++ so much?
>>
>>61771161
And D creators are the people who first implemented C++ because Bjarne is not a smart programmer himself. D creators knew, from the very beginning, what's wrong with C++
And D creators are the people who first implemented C++ because Bjarne is not a smart programmer himself. D creators knew, from the very beginning, what's wrong with C++
>>
>>61771166
Because it's a shitty language
>>
File: kancolle_4318.jpg (1MB, 2471x3500px) Image search: [Google]
kancolle_4318.jpg
1MB, 2471x3500px
>C++ has like twenty different ways to initialize a variable
How shit can you get
>>
>>61771137
thanks. will do this later but I found the filter in this site's settings menu
>>
>>61771192

Why though, I don't see any problems with C so how can a superset of the features be that bad?
>>
>>61771166
It's dogshit. It's like a government designed language. So it's worse than ADA because ADA was contracted out with abstract specifications.

C++ was fucking designed by the goddamn senate. So much fucking pork in the C++ standard. So many retarded decisions made by power tripping retards.
>>
>>61771251
C is C++ without the bullshit
>>
Sick of static typing.

Sick of broken promises of productivity. Sick of dealing with pointless incompatibilities. Sick of everybody and reinventing the wheel so that no two libraries can be used together. Sick of compiler bugs.
>>
https://durka.github.io/blog/2017/08/06/du-evolution.html
>>
>>61770993

Is that short for, "programming in the nude?"
>>
Sick of dynamic typing.

Sick of broken promises of productivity. Sick of dealing with pointless incompatibilities. Sick of everybody and reinventing the wheel so that no two libraries can be used together. Sick of interpreter bugs.
>>
>>61771251
The superset is bad because almost every single misfeature that C++ has over C is a terrible, terrible mistake. The pitfalls are so tightly bound that you can't escape just by using a subset because the pitfalls pollute any shred of good in C++ exclusive features. Even worse is that because it's a superset, it has all the flaws of C, most notably the preprocessor.

I don't have it but someone post the image. You know the one.
>>
>>61771325
Then pick one of 1000 static langs that compiler to JS. Unless you mean Python.
>>
Hello

I would like to apply for the position of Code Artisan.
>>
C macros and the preprocessor are cancer.
>>
>>61771411
C is cancer*
>>
>>61771411
how to concatenate two strings in C
#define concatenate (a,b) a ## b
>>
>>61771323
programming in the HOOD, hence the welfare frog
>>
>>61771504
>concat isnt an operator
>>
File: Ada.jpg (15KB, 192x240px) Image search: [Google]
Ada.jpg
15KB, 192x240px
>>61771260
>worse than ADA
>hfw
It's "Ada", you fucking computer illiterate.

4/10 if trolling
>>
What's a good beginner book for learning Java?
>>
>>61771405
>js is the new bytecode

want to fucking SLAP a nigga
>>
>>61771504
It's easier to just put the strings together
printf("Hello" " cruel " "world!\n");
>>
>>61771550
>he doesn't know about strcat

lmao
>>
>>61771565
https://www.amazon.com/Java-Beginners-Guide-Herbert-Schildt/dp/0071809252
>>
Can we all agree that C has the best community?
>>
>>61771569
Not really, its just people want to do webdev, but not have to spend an entire afternoon setting up 78k tools and frameworks and then get a bunch of undefined errors.
>>
>>61771581
Do you know what an operator is?
>>
>>61771622
no why?
>>
>>61771592
thanks
>>
>>61771606
No because it doesnt. Its more fragmented than hasklet and scala combined.
>>
>>61771346

What would be the choice then for OOP at a lower level than python? Everyone hates Java as well don't they?
>>
>>61771650
at least is not infected with SJW
>>
>>61771504
>two strings
>##
That's token concatenation, which is different.
Two string literals next to each other will automatically concatenate.
"a" "b" "c"
is equivalent to
"abc"
>>
hey /dpt/ I'm curious why you guys always shit on OOP? is it a meme or is it really that bad?
>>
>>61771650
not him but while c development is pretty fragmented, c programmers irl are some of the most humble yet most intelligent people i have ever seen in the tech sector
>>
>>61771696
>why you guys always shit on OOP?

because OOP reversed is POO
>>
>>61771710
>irl
Older ones are yeah, but then you also have your fair share of luddites.
>>
>>61771696
it's highly structured and formulaic. no room for creativity.

this makes oop perfect for business use since your codemonkeys don't need their brains to pump out code, but makes it INCREDIBLY boring and frustrating when you're working on a personal project to develop your own skills.
>>
>>61771696
OOP is fine but Java left a sour taste in everybodys mouth because ENCAPSULATE EVERYTHING
>>
Fucking around with the javascript framework react native for my capstone project.

>inb4 javascript cuck
I need the capstone m8
>>
>>61771743
ty, seems reasonable
>>
>>61771696
https://www.youtube.com/watch?v=QM1iUe6IofM
>>
>>61771223
can you list all 20?
>>
>>61771787
>react native
had to use that trash for a mandatory "software design" class.
i will keep you in my prayers, anon
>>
>>61771783
I see, it makes sense. Thank you.

I just finished a couple of semesters in uni and the introductory course was Java + OPP second semester was sql, php , design patterns and data structures. I

'm not in software Eng nor CS so I won't be seeing anymore of that, but I'm interested to keep learning on my own. What do you guys recommend I should look into now?
>>
File: fatty.jpg (73KB, 850x971px) Image search: [Google]
fatty.jpg
73KB, 850x971px
>>61771814
Yes, can you?
>>
>>61771958
ugh MOM!!
>>
Fact: Pascal is the most powerful programming language in the world.
>>
>>61771977
redpill me on Pascal pyramid vs Pascal wager
>>
>>61771893
You better disregard anything this thread (or board) says regarding programming if you want to move forward, unless backed by serious reference (and I don't mean some tweet or quote from an interview but data about actual usage in industry).
>>
>>61771998
Fuck off C++ baby.
>>
newfag here. engineering undergrad, kinda new to programming. but have done some python stuff, learned theoretical algo, some advanced linear algebra, done some hadoop, and bit of java but not much. little bit of c. trying to reboot.
i was gonna do cs50 for C real quick, and do C++ and Java after that. thoughts?
>>
is sicp a good book to learn programming (and scheme)? I saw a book recommendation list for programming/computing on /sci/ and I thought it was strange and notable that they left off sicp
>>
Riddle me this /g/
proc = subprocess.Popen(r'C:\asdf.exe', stdin=subprocess.PIPE, stdout=subprocess.PIPE)
proc.stdin.write('asdf')
output = proc.stdout.readline()
print(output)

Why can't I read and write input to this? It just hangs like a limp noodle.
>>
>>61772148
sicp is hard. It was written to make brainchads at mit feel dumb. It was probably left off because it made the image creator feel stupid.
>>
>>61772117
Go for it man
>>
>>61772221
ppl here are just shitting on c++. from what i heard, newfag should focus on c++,java,python. c++ for speed, java for legacy stuff, python for new stuff. also, any recommendation for good c,c++,python courses? i thought cs50.net was good enough. idk about c++, python tho. ive done some ai/ML stuff with python but i think i dont really know the language
>>
>>61772204
>limp noodle.
>python2fag
>>
>>61772117
C++ and Java are not only useless to an engineer, but suck dick. C++ especially.

What engineering are you majoring in? Computer? Mechanical? What's your goals for programming though? That changes things. If you wanna just work out your mind and learn to think differently then you should use SICP. If you have concrete goals then it really depends desu.

C + Assembly + Scheme is probably pretty good for an engineer.
>>
>>61772268
ive switched to cs for masters
>>
File: cryingwojak.jpg (43KB, 626x750px) Image search: [Google]
cryingwojak.jpg
43KB, 626x750px
>>61770973
C++ IS GOOD YOURE JUST AT IT

DELET THIS RN
>>
>>61772268
my goal is to get some AI/ML/quant job in bay-ish, and do for like 5y, and do mba and be manager or something.
>>
>>61772247
>java for legacy stuff
Legacy is COBOL or FORTRAN or Pascal, not Java. Java's 22 years old and only got big in the 2000's.
>>
File: algo.jpg (30KB, 361x499px) Image search: [Google]
algo.jpg
30KB, 361x499px
i've already studied programming superficially, few languages, now I want to actually seriously learn C. thing is I am a bit of a brainlet, is it a good idea to start at pic related and then move to a C book? if so, which? (heard that K&R might not be the best for beginners)
>>
>>61772282
>YOURE JUST AT IT

>Sepplets so mad they cant even form sentences
>>
>>61772268
These days, if you work on embedded systems or any kind of embedded software, you will need to know C++.
>>
File: wojakbrainlet.jpg (7KB, 204x306px) Image search: [Google]
wojakbrainlet.jpg
7KB, 204x306px
>>61772282
>tfw typing so fucking fast you forget to type a word
>tfw too smart to type
>>
>>61772299
also SICP, better before or after learning C?
>>
>>61772304
I was typing so fucking fast I forgot to type fucking "BAD"

j
>>
>>61772268
Why are you C-fags so cancerous? C has been useless for years now.
>>
>>61772306
>embedded systems
>C++
wat

In my experience embedded is either C, Assembly, Labview, or Java

>>61772292
Python is good to know desu and one of the biggest for AI since it's a language intended for scientists. A lot of backend code for python is in C though so that's good to know too.
>>
>>61772247
>ppl here are just shitting on c++.
They also never post any sort of significant project and the ones who do often do so in C++, so you shouldn't really pay attention to what "ppl here" are doing.
For C you can start with Modern C (Gustedt) or C Programming: a Modern Approach (King), I recommend starting both and seeing which one seems better to you. Modern C has the advantage of being free, even though you can get King's book through the usual means.
There's no easy way to get in C++. I did so by learning how to do C with classes and then forgetting it. Usually people recommend Stroustrup's book.
>>
>>61772299
It is a bad idea to start with Algorithms.
I'd recomend you to start with CS50, it is a course, not a book. It is from Harvard and free online. The structure of the course is divided by weeks, the first five or six weeks are C only. Complete them and you'll have a good understanding of C. I'm serious now, Four weeks of CS50 and you'll be pretty decent with C.
After four or five weeks, you'll be able to finish K&R (which is a slim book) in like two or three weeks, depending on how hard you study.
>>
>>61772360
>C has been useless for years now
That's as retarded as the C++ bashing
>>
who the FUCK is "Martin Herkt"???
>>
>>61772365
C++ is used very often, because it turns out OOP is very useful. And when performance and memory are at a premium, that throws Java out. It's generally always a subset of the language, I don't think I've seen anything more complex than classes and try catch blocks in embedded C++.
>>
>>61770973
Java works. Syntax isn't bad.

>>61771161
>>61771179
D feels like C and Java had a baby and only inherited the good parts of both language minus a decent debugger.
>>
>>61772148

Very good book but I wouldn't start with it, may be a little difficult unless you have a strong mathematics background; beside that you may not appropriate it's brilliance without some experience in another language first.

Just learn Python first if you want to get shit done, or C if you want to understand programming.
>>
>>61772375
i have tcpl. is it way over my league? i also read c primer plus (years ago, just read it) for c++, i have prata, if that helps. my background is matlab, if it counts at all. anyway, i think ill do cs50 briefly, and do stein algo book (which i had done previously) and do c++ simultaenous. thx.
also, sicp - is it still relevant? worth my time?
>>
>>61772432
>tcpl
Maybe, maybe no. Just start reading a book, don't think too hard about it. Worst case it won't suit you and you can fall back on one of those I recommended.
I haven't read SICP, I know it uses LISP to illustrate concepts which imo (isn't the (hottest (nor friendliest (language to) write))). It's quite simple though.
>>
File: IMG_0363.jpg (2MB, 3264x2448px) Image search: [Google]
IMG_0363.jpg
2MB, 3264x2448px
Just write some nuclear.
public static class Program
{
private static void Main()
{
Console.WriteLine("Hello /g/");
//Some nuclear things
}
}
>>
>>61772461
>(isn't the (hottest (nor friendliest (language to) write)))

excuse me SIR, i find these antisemetic punctuation VERY offensive, plese DELET this comment posthaste.

thank you for your cooperation,
rajpaat bhalapapurania
>>
>>61772461
thx m8
>>
>>61772381
I was planning on watching the cs50 lectures, yes. but do you mind explaining why is it bad to start with algorithms (do you mean this specific book?)? genuinely curious
>>
I read two textbooks on Bash but I have nothing to do with Bash.
>>
File: 1409286721653.jpg (12KB, 251x242px) Image search: [Google]
1409286721653.jpg
12KB, 251x242px
>>61772487
>rajpaat bhalapapurania
>>
>>61772265
>print()
>python2
pick one
>>
I chose 'Advanced Functional Programming' for one of my five master's degree electives and now I'm worried I might have memed too hard.
>>
>>61772375
>They also never post any sort of significant project and the ones who do often do so in C++,
But I post all about my shitty minecraft clone all the time and that's more than half C. While it is meaningless and thus not significant in that sense, it is a few thousand lines of code and at least beyond fizzbuzz tier and somewhat significant in size.
>>
Trying to play with Stellaris on Vista, got the K32GetProcessMemoryInfo nyanyanya KERNEL32.dll error.

Is there a way to force PSAPI_VERSION=1 without recompiling the exe or some shit ?
>>
File: dasit.jpg (181KB, 1200x1800px) Image search: [Google]
dasit.jpg
181KB, 1200x1800px
>>61772479
Nice, now tell me your thoughts on Sento
>>
>>61772556
The real question is are you shitposting about C++?
>>
>>61772599
useless good-for-nothing bimbo!
>>
If I have a file with a ton of floating point numbers (about 200 lines with 200 numbers each, tab separated), does the following code skip over newlines
and tabs?
std::ifstream file( ... /* initialize file */ ... );
double curr_point;
while(data_file >> curr_point)
{
/* Do stuff with current point */
}
>>
>>61772572
>on Vista
but why, just get 7 or 8.1.
>>
>>61771223
>Waaaah! I want my language to be restrictive!
>>
https://youtu.be/phi_vUKGbuE?t=10766
Are you an "engineer" or are you open about how you're just an software artist?
>>
File: seance 2.jpg (109KB, 1436x900px) Image search: [Google]
seance 2.jpg
109KB, 1436x900px
>>61771958
no, but I need to know
>>
>>61772932
literally dont get why the fuck hes wasting time on that.
>>
>>61772955
Maybe you don't use powerpoint a lot.
Anyway, even if he wasn't bothered by any particular tool he would have to write software to test his language. He could pick something arbitrarily.
>>
>>61771504
Fucking retard idiot. Also redundant.
>>
>>61772927
>I need my language to do the same thing a hundred different ways
>>
I forget, what's /dpt/'s favorite assembly language towards x86?
>>
>>61772982
>He's bitter because his language isn't the most powerful language in the world
>>
File: 1478455372790.gif (2MB, 300x300px) Image search: [Google]
1478455372790.gif
2MB, 300x300px
>>61773024
>hundreds of ways to initialize a variable
>wow, so powerful
>>
>>61773076
>4 ways is hundreds
>>
>>61772920
I irrationally hate reconfiguring the whole thing after each OS change. It's a huge mental block on pirating 7.
I hope my hard drive dies soon so that i'm forced to update, because i'd prefer to be sodomised by a rusty morningstar than update.
>>
>>61773085
>Needing more than one
>>
>>61772927
Really. The only people who should argue this are project leads who have shitty underlings. If you've ever worked in languages like that you know the only way you can feel good about them is if you convince yourself you're a bad programmer. You really see rust people argue for this stuff for instance.
Now you're just making a strawman. It's not about restrictions at all it's about unnecessary complexity.

If we had a language that let you construct 20+ ways of initializing variables that'd be fine. But with C++ you can't opt out.
>>
>>61772425
i took calc I and II, then "physics with calc" I and II in college but my programming experience is reading the first chapter of a perl book 6 years ago

I don't have a project I'm trying to do or anything, I just want to learn the esoteric mindblowingness that lisp apparently is

should I pick another common lisp/scheme book?
>>
>>61773177

Try SICP, if it's too hard then swap. From memory the only maths you may not have covered it mathematical induction and modular arithmetic.
>>
>>61773149
There is technically only 2 actually, parentheses and braces. The latter was introduced to get around the Most Vexing Parse problem, that's all.
Thing thing(6);

and
Thing thing = 6;

Are just different styles for the same thing, which makes complete sense, because if I can initialize an int using the latter style, then why can't I do the same with any other type?
It's also to make generic code better.
>>
>>61773177
For those purposes, SICP is perfect. It's all about learning how to conjure the spirit inside the computer with magic spells. It's got a fucking wizard on the cover and understanding the content of the book is a necessary step in joining the knights of the lambda calculus.
>>
>>61773166
>But with C++ you can't opt out.
Of course you can.
Also >>61773225
>>
>>61771223
>>61772982
>>61773076
>>61773085
int a = 0;
int b {};
int c = {};
int d (0);
int e {0};
int f = {0};
auto h = 0;
auto i (0);
auto j {0};
auto k = {0};

Really jogs the old nog
>>
File: cwords.jpg (230KB, 743x1026px) Image search: [Google]
cwords.jpg
230KB, 743x1026px
what's it asking for here? do they want me to write a sentence and have it print every word out on a new line on EOF? how are you supposed to do that without arrays?
>>
>>61772479

>lenovo
>windows
>utorrent
>bluetooth
>not black laptop
>Visual studio

2/10
>>
>>61773394
Hello world this is the input

Hello
world
this
is
the
input
>>
>>61773394
just print newlines instead of spaces
>>
>>61773394

printf( ) will only actually print when it reads the new line char (\n).

while(true){
char ch = fgetc(fp);
if(ch == ' '){
ch = '\n';
}
if(ch == EOF){
printf("\n");
return;
}
printf("%c",ch);
}
>>
>>61773475
That's not true. The screen must print when it encounters a newline, but it can print earlier if it pleases. It's not a functionality of printf, but ISO standards.

You can disable the buffer so that printf prints immediately if you so desire.
>>
File: dong.png (762KB, 1036x1160px) Image search: [Google]
dong.png
762KB, 1036x1160px
>>61772479

Hello my chinese friend
>>
>>61773247
But anon, they all have different meanings and the differences are important!
>default-construct an int and copy-assign it 0
>construct an int from an empty initializer list
>default-construct an int, construct another int from an empty initializer list, and copy-assign the int the other int
>copy-construct an int from 0
>construct an int from an initializer list containing 0
>default-construct an int, construct another int from an initializer list containing 0, and copy-assign the int the other int
>default-construct an object whose type is the same as that of 0 and copy-assign it 0
>copy-construct an object whose type is the same as that of 0 from 0
>construct an object whose type is the same as that of 0 from an initializer list containing 0
>default-construct an object whose type is the same as that of 0, construct another object of that type from an initializer list containing 0, and copy-assign the object the other object
>>
>>61773550
Jesus fucking Christ, C++. I was hoping some of those, particularly {} vs (), were syntactic sugar and he was just havin' a meme.
>>
>>61773572
In theory he's right, that's what all those things mean for more complicated types
But in practice, since ints are primitives, it mostly is just syntactic sugar all around
>>
hey /dpt/ does anyone have experience programmatically creating meshes.I'm working on a program that creates a conjoined box mesh based off points that the user inputs. The way it works so far is the user plots the points where they want the box to go and for every point 4 vertices arranged in a square around that point are added into a list. After that what suppose to happen is the indices are for the triangles are create to make to conjoined boxes, but this is where I'm having my problem I can't seem to figure out away to create the triangles, my indices are either referring to vertices that aren't there or making triangles from the wrong vertices.

I tried using a for loop to loop the through the points and create the triangles for each box using i in the loop as the offset this worked for points 1-2 and one box was created but anymore points and it gives and start using vertices that aren't there.
        
for(int i=0; i<points.Count; i++){
//left face
triangles.Add((i)+4);
triangles.Add((i)+1);
triangles.Add((i));

triangles.Add((i)+1);
triangles.Add((i)+4);
triangles.Add((i)+5);

//top face
triangles.Add((i)+5);
triangles.Add((i)+2);
triangles.Add((i)+1);

triangles.Add((i)+2);
triangles.Add((i)+5);
triangles.Add((i)+6);

//right face
triangles.Add((i)+2);
triangles.Add((i)+6);
triangles.Add((i)+7);

triangles.Add((i)+7);
triangles.Add((i)+3);
triangles.Add((i)+2);

//bottom face
triangles.Add((i)+0);
triangles.Add((i)+3);
triangles.Add((i)+4);

triangles.Add((i)+4);
triangles.Add((i)+3);
triangles.Add((i)+7);

}
>>
>>61773697
Yeah I have experience with this stuff but it's a little unclear to me what you're trying to do.

Can you draw a picture?
>>
File: 1469564325345.png (375KB, 642x629px) Image search: [Google]
1469564325345.png
375KB, 642x629px
>>61770973
r8 my project structure.

.
├── CMakeLists.txt
├── README.md
└── src
├── CMakeLists.txt
├── eternity
│ ├── CMakeLists.txt
│ └── src
│ └── eternity.c
└── libeternity
├── CMakeLists.txt
├── config.h.in
├── include
│ ├── config.h
│ └── libeternity
│ ├── args.h
│ ├── config.h
│ ├── error.h
│ └── util.h
├── src
│ ├── args.c
│ ├── error.c
│ └── util.c
└── test
├── CMakeLists.txt
└── test_args.c

8 directories, 17 files
>>
>>61773747
> CMake
its trash
>>
File: 1467937781261.png (38KB, 890x670px) Image search: [Google]
1467937781261.png
38KB, 890x670px
>>61773697
>That loop
>>
Is
assert("OP is a faggot");
guaranteed to pass? I mean, is there something in the standard that guarantees that string literals cannot begin at NULL?
>>
>>61773747
>cmake
Lol
.
├── README.md
├── src
│ └── eternity.c
├── include
│ ├── config.h
| ├── args.h
| ├── config.h
| ├── error.h
| └── util.h
│ ├── args.c
│ ├── error.c
│ └── util.c
>>
>>61773771
The null pointer is guaranteed to never be valid
>>
>>61773771
string OP = "is a fag";
assert (OP == "is a fag");
>>
File: conjoined boxespng.png (12KB, 800x600px) Image search: [Google]
conjoined boxespng.png
12KB, 800x600px
>>61773726
The orange dots are points that the user places, the black ones are the vertices created around it.
>>
>>61773802
>== to compare strings

lmao
>>
File: Bantday1leafgirl.png (59KB, 750x783px) Image search: [Google]
Bantday1leafgirl.png
59KB, 750x783px
Yo anime watchers, what's the best book for learning R?
>>
>>61773811
Whats wrong with it?
Beside the obvious of why the fuck are you not using a bool.
>>
File: halp.jpg (72KB, 1280x720px) Image search: [Google]
halp.jpg
72KB, 1280x720px
float getAdjustedRate(float TimeSinceStart, float OldEndTime, float NewEndTime) {

return rate;
}



alright I'm too tired and my brain has stopped solving problems so I need help completing this function. I have a thing running at rate=1. I can get timeSinceStart and endTime. I need to get a new rate so it ends at newEndTime.

timeSinceStart is guaranteed to be less than both the old and new end time.
>>
>>61773832
O(n)
>>
>>61772268
>C++ and Java
>useless to a EE/CE
horrible advice

Java is shit but it's a good language to know if you want to work on embedded devices
>>
What do I need to create an android app easily

i do not know java can i do it in something else
>>
>>61773845
>oh god my asserts are going to slow down the debug build
nani?
>>
>>61773845
I'm not aware of any string comparator that isn't O(n) runtime
Hell I'm not even aware of any standard print methods that aren't O(n)
>>
>>61773852
Scala
>>
>>61773858
>nani
kys
>>
>>61773863
not him, but how come?

do you have any resources to follow?
>>
>>61773881
You haven't answered my question of why O(n) matters in asserts.
>>
>>61773843
Don't you just multiply (oldEndTime-timeSinceStart) by (newEndTime-timeSinceStart)?
>>
>>61773892
It runs on the JVM so you can call a lot of the Java Android libraries that you need. It also uses functional programming paradigm which can be nice once you get used to it.


Programming in Scala 3rd edition is generally the go-to resource for learning it.
>>
>>61773892
http://scala-android.org/
>>
>>61773809
Hmm so it's kinda like an extrusion... it's 3d then?

So it creates 4 vertices per click?

My advice would be to create an index array for rendering a cube, then for each user click minus one, append onto a new index array the cube index array + 4.

Somethin like this:
GLuint cube[] = {look it up in the superbible};
GLuint scratch_cube[36];

GLuint * mk_block_extrusion_array(int num_clicks) {
GLuint * rtn = malloc(36 * (num_clicks - 1) * sizeof(GLuint));
memcpy(scratch_cube,cube,sizeof(cube));
for(int i = 0; i < num_clicks - 1; i++) {
memcpy(rtn + 36*i, scratch_cube, sizeof(cube));
for(int i = 0; i < 36; i++)
scratch_cube[i]+=4;
}
return rtn;
}

This will create some duplicate geometry but that's easy enough to filter out, and to be honest it doesn't matter if there's some duplicate geometry outside of performance woes, assuming everything is being textured the same.
>>
>>61773984
Thank you

I want to make a FOSS fitness app that will have all the functionality of a closed source "free app". I'm going to submit it to f-droid.
>>
>>61773166
>But with C++ you can't opt out
yes you can. or rather, it's kind of the default. almost all C++ features are actually opt-in. you do so by using them. you only pay for what you use (one of the core design principles of C++), and even still, the vast majority of abstractions are implemented with literally zero added runtime cost compared to functionally equivalent C (they generally inform the *compiler*, not the runtime). some features, like templates, constexpr, and "constexpr if", even have what can arguably be called "negative" cost, as their functionality can only be matched in C with (potentially egregious ab)use of the preprocessor, which isn't technically a part of the language itself, but rather a simple (type-unsafe, error-prone) metalanguage (or "extended copy/paste", take your pick). with constexpr/if, though, you can have robust, type-safe, higher-order, compile-time execution of arbitrary (albeit obviously pure) C++ code, all without the use of the preprocessor
>>
File: 1437517263126.gif (320KB, 280x480px) Image search: [Google]
1437517263126.gif
320KB, 280x480px
>>61773933
Arigato
(oldEndTime-timeSinceStart) / (newEndTime-timeSinceStart) worked. You pushed me in the right direction though.
>>
>>61774037
My bad for fucking up with the algebra, but my good, I guess, for helping nudge you closer to the solution. Good luck with whatever you're working on.
>>
>>61772496
Two reasons:
It is somewhat advanced.
It will not teach you now to program.

You'll need some understanding of Discrete Math and programming to read comfortably and understand Introduction to Algorithms.
>>
>>61773809
Very important- are you planning to also generate UVs for this? This changes how you approach this problem entirely.
>>
>>61773774
That's fuckin BASIC good luck cross-compiling and doing repeatable automated builds and deployment.
>>
>>61773239
>>61774010
Not that guy but how do I restrict a team from doing specific types of initialization in C++?
I thought the point he was making was that if you have to build ways to operate on data you can always just not build that stuff to have people not use it. And you can remove any problematic systems they've made and fix their code if you do.

Coordinating programmers when they have features they think they can use to good effects that they shouldn't use is difficult.
>the vast majority of abstractions are implemented with literally zero added runtime cost
Except not. They're theoretically zero cost abstractions but compilers are not that good. They fail to inline all the time. Unless you're constantly inspecting your disasm throughly you will take tons of runtime costs in even trivial circumstances in C++.
But if you don't inspect it you'd never know I guess. So I suppose that's why people still believe in zero cost abstractions. If you follow compiler author conferences they're constantly talking about their difficulties with this.
>>
File: Untitled.png (10KB, 587x140px) Image search: [Google]
Untitled.png
10KB, 587x140px
I just found the gayest function in scipy
>>
>>61774074
Yes, I was planning on allowing the user to choose what texture the conjoined boxes had.
>>
>>61774109
>trapezoidal rule
Of course it's fucking gay. Numerical analysis is for homos. Real men (Analysis analysts) do Darboux integrals.
>>
>>61774149
I think the solution I posted will still work for that if the textures repeat. It gets a little more complicated if they don't. You'd have to map the index array that my solution would generate to a vertex array and then transform the UV coordinates for each box. I'm assuming you'd use a grid texture atlas which makes the transform of the UV coordinates as easy as adding an offset.
>>
File: 1501979289983.png (160KB, 695x900px) Image search: [Google]
1501979289983.png
160KB, 695x900px
>>61774109
reading this post made me imagine some fratboy grepping through scipy docs and yelling to his chad buddies "dude I just found the gayest function in this framework"

What language does Chad program in? Does anyone have a /dpt/ version of this?
>>
I'm new to all this pointer business.
#include <iostream>
#include <string>
using namespace std;

// returns a pointer
// takes two addresses
void* total(void* a, void* b)
{
return (*a) + (*b);
}

int main()
{
int x = 23;
int y = 3.1;
// pass the address of x and y and dereference the result of total
cout << *total(&x, &y) << endl;

return 0;
}


Now it says that void* is not a pointer-to-object type. What do?
>>
>>61774250

>has never seen an irrational
So he has never taken the square root of a non-square integer?
>>
>>61774283
>sepples
found your problem
>>
>>61774250
Virgin language: C, Haskell
Chad language: Python, Javascript, Matlab
>>
>>61774299
What about C++ makes this incorrect?
>>
>>61774250
Chad programs in scheme of course. And the virgin programmer Javascript.

>>61774283
What in God's name are you trying to do other than segfault anon? Anyway if you wanna make your kernel bitchslap you:
return a + b;
...
cout << *(int*)(total(&x, &y)) < endl;

It should compile but it will crash.
>>
>>61774311
I just want to avoid generic types
>>
>>61774283
You gotta typecast, anon. Besides, you should be using templates in this situation.
>>
>>61774203
Thanks anon,I appreciate you taking the time to help me.
>>
>>61774323
Well then you have separate functions for each type you're adding. There's C style generic higher order functions like so though:
int arr[] = {3 2 1};
int cmp(void const * a, void const * b) {
return *(int const*)a - *(int const*)b;
}
int main() {
qsort(arr, 3, sizeof(int), cmp);
}

You can't dereference void*. Void* is a pointer sans type information. You have to cast it.
>>
>>61774373
Ok, but I don't want to typecast in the function, I will typecast where I call the function
What should be the return type of the function?
>>
>>61774402
But anon, I want to avoid manual casting. if you do cout << 23 + 3.1 << endl; it will cast it by itself
>>
>>61774420
What do you mean? It casts to a string?

Well that happens automagically through the power of operator overloading.

There's a million operator<<'s defined for the type cout is.

You have to cast yourself if you're writing your own shit.
>>
>>61774250
These memes are supposed to be a dubious depiction of one outrageous caricature vs another, not some kind of 'chad master race' propaganda.
>>
>>61774283

Okay, let's look at this function:
void* total(void* a, void* b)


You're taking two pointers and returning a pointer. But the pointers are void pointers, which means the compiler can make no assumptions about what it is a pointer to. It could be a pointer to an int, or to some 14 gigabyte struct.

return (*a) + (*b);


So here you are trying to dereference a and b and sum the values being pointed at. The problem: you're using void pointers. There is no possible means by which the compiler can ever know how to add these. They could be 8 bit integers, 32 bit integers, a 16 bit integer and a 64 bit float... or really anything since it's a + operator in C++.

And somehow the result of all of this is supposed to be coerced into a pointer... and then dereferenced. Even if the compiler could deduce how big of objects you were trying to sum, the result would not be a pointer to the sum, it would be the sum interpreted as a pointer. So if you had the value 23 at address 0x400000 and the value 3 (not 3.1, since you can't store a floating point number in an int; the term stands for integer, meaning it stores positive or negative whole numbers or zero -- did you fail math?) at address 0x400004, rather than some address 0x400008 containing the sum of these two numbers being the return value, you'd return 0x1A (or 26), which when dereferenced, would likely result in a program crash (since the page containing address values 0 to 4095 should be intentionally invalid).
>>
>>61774283
>dereferencing void
To dereference a pointer the compiler needs to know the type of what you're dereferencing. If you dereference a void it complains because what type should it produce? You can't store a void or operator on a void. So it doesn't make any sense.

But it seems like you want a generic function. Templates can do this.
>>61774408
>what would the return type be
Whatever your result should be. I'd expect either float or integer.
>I'll cast where I call the function
In that case you need to change the type of the arguments in the total function to whatever you wanted to cast to.
>>61774481
Yes. But 4chan has gotten stupid because poes law.
>>
>>61774481
Yeah but where's our dubious caricature comparisons? That's what I wanna know. I get tired of the same old degree memes, anime girls holding SICP, and poo in loo.

No shit that Chad the Autodidact doesn't really exist.
>>
>>61774283
>void*
Don't use void pointers.
>>
>>61774597
But they're useful. Using char* pointers instead is stupid desu.
>>
>>61773826
>UK

Holy shit.
>>
>>61774597
What's the problem with using void pointers? Instead of having 50 pointers bloating a struct, you can use 1 void and 1 variable about the type it's actually pointing at, then cast before use.
>>
>>61774103
>how do I restrict a team from doing specific types of initialization in C++
tell them to prefer braces for consistency and to avoid the most vexing parse. and in all trivial cases, the compiler automatically generates inlinable, optimizable, constexpr-if-possible, noexcept-if-possible, exactly-what-you'd-expect implementations of default constructors (if members are default-constructible), copy constructors/assignments (if members are copyable), move constructors/assignments (if members are movable), and aggregate initialization (for pod/default-layout types), each of which have their place and should be left to the compiler in all but non-trivial cases

>They're theoretically zero cost abstractions but compilers are not that good
they're a lot better than you think. many are quite seriously zero-cost in concrete implementations, and more yet for at least trivial/common use cases. and many changes to the standard have been made specifically to allow compilers to implement better optimizations (added value categories, guaranteed copy elision (formalizing/guaranteeing RVO), alignas, noexcept, constexpr (automatically whenever possible, even higher-order) lambdas, and more). of course, if you want the absolute best possible performance, then yeah, you obviously do have to be aware of some things. but i mean... no shit, right? the same would apply to C in many cases (not like C compilers can do perfect automatic SIMD vectorization or cache optimization either). it's not magic. but it's pretty damn good, all things considered

>Unless you're constantly inspecting your disasm throughly
i do, and you should too. check out godbolt.org

>you will take tons of runtime costs in even trivial circumstances in C++
i assure you this is incorrect. there are (avoidable) edge cases, sure. but keep in mind C++ has been changing in order to facilitate new optimizations and compilers have been maturing for decades
>>
>>61774646
>Don't have 50 pointers for everything in your struct!
>Just cast everything all over the place all the time!
Which of these seems like a more organized and reusable approach when working on a team?
>>
File: 1502018942678.png (154KB, 2048x1536px) Image search: [Google]
1502018942678.png
154KB, 2048x1536px
Reminder to never trust pajeets.
>>
>>61771015
Rewriting your rewrite of Scala in Go in Rust
>>
File: uv.jpg (60KB, 903x684px) Image search: [Google]
uv.jpg
60KB, 903x684px
>>61774149
Right, so the limitation is you are only allowed one UV point per vert, so if you want something to unwrap you need to plan how you are going to UV it because you need double verts at the seams. I drew a picture of what you are probably going for.

Now how to do it. I've generated a cubic bezier tube and I found the best way was to start by making a line struct that's just two vector3 s. For each of the 4 sides, generate an array of lines for every control point. See pic in green. You need to calculate the tangent and normal for every control point, then rotate the normal around the tangent (then multiply by half-thickness then add the control point location)

Now you have the 4 line arrays and you easily convert those to to an array of tri indices. The last step is to write an append function to merge a line array and corresponding tri array with another line and tri array. This is basically:
>get the number of verts in the first line array (length*2)
>append the first and second line arrays
>loop through the second tri array, and add add the number of verts in the first line array to each value
>append the first and second line array
>elminate duplicate verts and be sure to reassign any tris that are pointing to that vert.
Merge 3 times, but on the last time, don't eliminate duplicate verts so you keep the seam.

I'm too tired and probably didn't explain it well, but the takeaway is
>Figure out the formula to generate any given vert
>Then generate 4 line arrays representing the 4 sides
>Then generate tri arrays from the line arrays (tris are just integer pointers to verts)
>Then merge the lines and tris, keeping in mind that the tri indices need to be repointed when the verts are appended

Good luck this shit is annoying.
>>
>>61774684
Rewriting your rewrite of his rewrite of Scala in Go in Rust in Python
>>
>>61774665
Neither. Make a opaque data type and provide functions for the others.
>>
>>61774697
Rewriting your rewrite of his rewrite of that other guy's rewrite of Scala in Go in Rust in Python in Ada
>>
What does /g/ think of Jamie Chan? Good author?
>>
>>61774709
Rewriting your rewrite of his rewrite of that other guy's rewrite of Scala in Go in Rust in Python in Ada in Malbolge
>>
>>61774652
>they're better than you think
No. They're exactly as good as I know they are because I care about this stuff and check them and profile. I frequently rewrite things to get the compiler to do what it should do.
>standard has been altered to make optimizers more effective
They fail to inline all the time.
>not like C can do automatic vectorization either
If you rely on that and not intrinsics or assembly then how can you even profile your program? That shit is so janky it's silly.
>check out godbolt.org
Oh great. You're not a serious programmer. Why would I use an online service to compile my program when I already have a compiler which is building my program? I just disasm it and check. Trivial and closer to the real world scenario. Not to mention how upset management would be if I threw our code into an online compiler for whatever reason. I'd easily trigger IT I'm sure. They trip up over the silliest things so there's no way they'd miss me sending our code base from my browser.
Anon if you're not serious about software don't throw yourself into conversations like this.

>it's damn good all things considered
To be clear. I'm not putting down compiler authors. I'm sure they're doing the best they can and they're doing a good job. What I'm saying is that you can never be too careful in C++ as it's a big trap. To pretend 'zero cost abstractions' is a realistic claim for C++ is ridiculous frankly. If they were zero cost abstractions you couldn't trip them up.
>>
>>61774747
Rewriting your rewrite of his rewrite of that other guy's of some other fag's rewrite of Scala in Go in Rust in Python in Ada in Malbolge in INTERCAL
>>
File: eHFR2pp.jpg (196KB, 800x533px) Image search: [Google]
eHFR2pp.jpg
196KB, 800x533px
>Anon, we heard you couldn't invert a binary tree in your last interview. Are you really that bad of a programmer? Even after spending all that time on the computer?
>>
File: Nigga_what.jpg (14KB, 300x256px) Image search: [Google]
Nigga_what.jpg
14KB, 300x256px
>>61771161
>C++ is easier then C
>>
File: unis.png (92KB, 1057x641px) Image search: [Google]
unis.png
92KB, 1057x641px
>>61774677
According to hackerrank Indians rock in programming
>>
>>61774795
>tfw no qt programmer gf to bully you for your O(n^2) suboptimal algorithms
why even live honestly?
>>
>>61774801
Why did you respond to a 5 hour old post?
>>
>>61774795
I've never understood why inverting a binary tree is considered a challenge. Just turn the comparison operator in the other direction, and wa la. Now your larger elements are leftmost instead of smallest.
>>
>>61774801
People often view the lack of expressivity in C as difficulty. Not that C++ does all that much to save you there but it's clearly a step up on that front.
>>
I'm about to learn java. How fucked am I?
>>
>>61774652
"Proper" C++ classes are strictly incompatible with SIMD though. SIMD needs boring flat arrays of ints 'n floats 'n shit, or you need to somehow be seriously bound by computation to have to the time to swizzle the data to and from arrays to do SIMD on, and that only happens once in a blue moon. And C++ encourages things other than nice simple flat arrays, which ruins cache optimization.

C++ lambdas that close over variables have so many fucking pitfalls that prevent reasonable uses of them. C++ lambdas belong in >>>/csg/ desu.

Noexcept is a way to opt out of a C++ misfeature. Not a winning point of C++.

>godbolt.com
How are you supposed to use this for nontrivial projects that use like libraries and shit?

It's nice that it removes all the junk around the output of compiling with -S but doesn't really seem all that useful outside of looking at cute toys to prove that C++ compiles efficiently.

I don't really see a way to upload say a source file that uses say lmdb. Not to mention uploading source code to saass? That's serious mishandling of company trade secrets.
>>
>>61774825
Well it's never that it's difficult.
But depending on what you mean by that it's insufficient/improper.
If you have the original insertion order you can do just that but are you not just creating a inverted tree rather than inverting it?

What you should do is traverse the tree and swap the right and left nodes for every node in the tree.
Which is not the same as turning a comparison operator.
>>
>>61774860
>If you have the original insertion order
Don't need it.
Level order traversal into a queue, pop the root, turn the comparison operator around, and re-insert everything.
>>
>>61774878
>re-insert everything
That's inefficient compared to actually doing it properly.
>>
>>61774878
Sure. Works too i guess.
I certainly find my suggestion more elegant though.
>>61774892
If he does it by level it should be approximately the same though, right?
>>
>>61774892
Not if the tree is stored in an array rather than a collection of pointers :^)
>>
File: 1501269499753.gif (427KB, 978x478px) Image search: [Google]
1501269499753.gif
427KB, 978x478px
>>61774808
>tfw my school is in there
feels good man
>>
>>61774898
>more elegant
Oh for sure, but I don't really go for elegance in whiteboard interviews. I go for clarity and simplicity.

>it should be approximately the same though
I think swapping during traversal comes out to O(n), whereas level-order and rebuilding is O(2n)
>>
>>61774825
Personally, I've always taken the approach of turning the whiteboard 180 degrees and telling the interviewer to deal with it, then dropping the marker.
>>
>>61774959
>I go for simplicity and clarity
It's clearly that too.
It's incredibly easy to visualize in your head what swapping left and right nodes do. It's even intuitive.
Popping the root node, removing and reinserting nodes on a level by level basis is complex to say the least.
>>
>>61774996
and interviewer being a shy cs qt?
>>
File: 1496381905695.jpg (22KB, 612x528px) Image search: [Google]
1496381905695.jpg
22KB, 612x528px
>>61774996
>"For this exercise, please rotate the provided matrix 90 degrees in place."
>Turn the paper sideways
>Hand it back
>>
https://youtu.be/eR34r7HOU14?t=3539
>The C++ committee doesn't understand the restrict keyword
Very interesting coming from a C++ committee member.
>>
>>61774808

Knowing asians they're probably just sharing the solution
>>
I'm self taught so this binary tree shit is beyond me. I don't think I've used a binary tree let alone a red black tree before. Is reversing a binary tree just this?
>(define (invert-tree tree)
(if (pair? tree)
(cons (invert-tree (cdr tree)) (invert-tree (car tree)))
tree))
> (invert-tree '(1 . 2))
(2 . 1)
> (invert-tree '((1 . 2) . 3))
(3 2 . 1)


It looks about what I'd expect "invert tree" to mean. sry for poor spacing was written in a repl.
>>
>>61774808
>middle school has a higher score than universities
>>
>>61775083
https://leetcode.com/problems/invert-binary-tree/description/
>>
>>61774808
Actually no.
https://blog.hackerrank.com/which-country-would-win-in-the-programming-olympics/
Indians score 31st. Which I believe to be unfair as it puts them just slightly above Bjanre, they deserve more.
But they're not 'rocking'.
Also the sample size you posted is silly low. At least try.
>>
File: 1500253659850.jpg (478KB, 2000x1334px) Image search: [Google]
1500253659850.jpg
478KB, 2000x1334px
>>61774795
>>61774817
>Anon, you really can't implement a radix sort? Come on, we all learned that in freshmen year you silly goose.
>>
>>61775122
Why do they turn their heads like that? Do they have neck injuries?
>>
>>61775138
Men often find necks hot
>>
What makes Rust shit? Is it just the hugbox/echo chamber community?
>>
>>61770973
C#
>>
>>61775161
Made by SJWs for SJWs.
>>
>>61775151
Yeah but #2 from the left in >>61774795 look way better in that regard despite doing nothing weird.
If they want to do something #5's neck looks great. But it's clearly because she has to flex to hold that posture, unlike #5 in >>61775122.
>>
>>61775099
Ok that's not too hard.
> (define (tree? tree) (and (pair? tree) (eq? (car tree) 'tree))
> (define (treecons node branch1 branch2) (list 'tree node branch1 branch2))
> (define (treenode tree) (cadr tree))
> (define (treecar tree) (caddr tree))
> (define (treecdr tree) (cadddr tree))
> (define (invert-tree tree) (if (tree? tree) (treecons (treenode tree) (invert-tree (treecdr tree)) (invert-tree (treecar tree))) tree))

R8 and H8 my late night repl coding.
>>
>>61774768
>No. They're exactly as good as I know they are because I care about this stuff and check them and profile
i find that hard to believe considering i have been doing the same for a decade and have arrived at a very different conclusion

>I frequently rewrite things to get the compiler to do what it should do
i thought i was quite clear in saying that you still have to be mindful of how the compiler works in order to write ideally optimizable code. as if it even needed to be said. kind of a no-brainer

>If you rely on that and not intrinsics or assembly then how can you even profile your program
uh... yeah. that's precisely why i brought it up

>They fail to inline all the time
i don't know what to tell you. i have naturally settled into a way of writing C++ code such that i only very rarely run into this problem to begin with, and even then, it's generally an easy fix. it's not like it's a fragile or roundabout style, either. generally the only things that ever really make it anything short of straightforward are vectorization and cache optimization. which, as i said, have to be accounted for manually just the same in C

>Oh great. You're not a serious programmer
kek. i recommended it because you gave me the distinct impression that you are relatively inexperienced with C++. by the way, you can (pretty obviously) instance that service on a local server with your own compilers and configs. but go ahead and jump to conclusions based on your autistic/obsessive/tribalistic mindset. truly the mark of a great programmer, kek

>What I'm saying is that you can never be too careful in C++ as it's a big trap
i wasn't advocating not being careful. i'm saying that it's quite possible, if you are mindful, to write a subset of C++ which is as efficient as equivalent C (or more so if you want to avoid macro hell), while allowing you to make use of a number of useful/intuitive abstractions, which is absolutely, definitively true
>>
>>61775191
6/10 needs more tree
>>
File: 1501980093650.jpg (233KB, 768x1024px) Image search: [Google]
1501980093650.jpg
233KB, 768x1024px
who /drunk programming/ here???
>>
>>61775122
>tfw too stupid to understand lisp
Does that shit work in stack sequence or something?
(define (tree? tree) (and (pair? tree) (eq?
(car tree) 'tree))

what does it MEAAAN
>>
File: 000061-Twitch.png (48KB, 126x146px) Image search: [Google]
000061-Twitch.png
48KB, 126x146px
>>61775208
high
>>
>>61763939
>Lisp
>The best language to learn how to program with.

Is this correct?
>>
>>61775213
Here's the code formatted in a world where the enter key exists.
(define (tree? tree)
(and (pair? tree)
(eq? (car tree)
'tree))

In english this code is "return true if tree is a pair and if the first element of tree is the symbol "tree"
>>
File: 1494538263363.jpg (82KB, 978x682px) Image search: [Google]
1494538263363.jpg
82KB, 978x682px
Best resources for learning Python? Videos/guides, etc. ?

Sound good to learn Py3 first, then learn the differences for Py2 if I want to later? It would be my first language. I have significant amounts of time to expend on learning it as well.
>>
File: 055.png (134KB, 720x331px) Image search: [Google]
055.png
134KB, 720x331px
Do you like my code /g/?
>>
>>61775260
https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036/ref=sr_1_1?s=books&ie=UTF8&qid=1502086811&sr=1-1&keywords=Python+Crash+Course
>>
>>61775276
>thta

Bait, bait, BAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHjgfbacgkjvuegwcuhygefyauset82375y189f76htra7e
>>
>>61775197
>oh no I actually meant what you were saying
>I've programmed for decades and haven't had enough insight to realize where my compiler fails

>you still have to be mindful of the compiler
No. Clearly you don't mean that because you said that there's zero cost abstractions. If you have to be mindful there's a clear cost. If you didn't they didn't have a cost.
You stated that the vast majority of them have zero cost as a category. They clearly do not if you have to be mindful. There's some trivial ones like constexpr, move semantics that trivially do. Nobody should be impressed by that. Others are absolutely not.
And this is ignoring the programmer overhead we both (I'll humor you being a serious programmer for a second) face. It's a lot of work.
>I've settled into a way of writing C++ that avoids these issues.
Are you seriously claiming you have adapted to your compiler so well that you can avoid all issues with inlining? Because if you have then you should be of great service to compiler authors. A solid understanding of the circumstances where their optimizations work and don't work would be invaluable to them.
>I recommended it because...
No anon. There's never any reason to recommend that seriously.
If I'm already stating that I'm disassembling my code and profiling it why would you suggest that at all? You clearly don't have a clue about this shit if you think that'd be appropriate.
>you can obviously...
I didn't look at it beyond being an online compiler. Why should I? It's useless to me.
Why would I even bother with setting that up locally? It's completely pointless.
>I've moved the goalposts
That's fine anon. I agree with your newly refined stance. You can write C++ that's computationally efficient if you're very careful. But don't pretend that's where you started and don't insult others for pointing out how stupid your old stance was. Since you've changed your mind you clearly agree.
>>
>>61775276
>apples.java
>tuna.java
Remember. In Java your filename is part of code. Choose good file names.
>>
>>61775301
P.S
>kek
I have a good feeling this is coming from someone who's still in school.
>>
>>61775291
Why use this over Python the Hard Way (I heard someone mention that before)? Any other references, supplemental or complete, that you'd recommend (videos/tutorials)?
>>
>>61775202
I think it needs more d desu.

Needs some caddddddr.
>>
>>61775014
The C++ committee doesn't even understand the strict aliasing rule.

Committees belong to the trash.
>>
Is wasm a big deal for realsies? Or is it gonna be a niche thing?
>>
>>61775138
It indicates vulnerability since you're exposing one of the most sensitive parts of your body (beheadings and all). And vulnerability -> sex appeal for women. Of course when they all do it at once without good sexualized context it looks uncanny as fuck.

The stock photographer was clearly trying to capture the uncanniness of sorority group photos where there's an arms race between the women of dolling themselves up.
>>
>>61774848
>"Proper" C++ classes are strictly incompatible with SIMD though
>And C++ encourages things other than nice simple flat arrays
to be blunt, what you think "proper" C++ is or what it "encourages" is irrelevant. C++ is whatever subset of it you use. i am not advocating for the use of some "canonical" or "idiomatic" form of C++. you should absolutely be selective based on your use case. if you want the absolute best possible performance, then there is definitely a certain subset of features you should not exceed. and that's absolutely fine. it's kind of the point of C++. to address your points, though:
- if you pad/align your vector data structures properly, they will be compatible with SIMD intrinsics
- similarly, you can align data/data-oriented procedures to cache lines. and i don't think C++ really encourages non-flat data structures. the options are there but the choice is yours. and the community will certainly generally recommend flat arrays/vectors

>C++ lambdas that close over variables have so many fucking pitfalls
true. avoid capturing mutable references whenever possible. however, pure lambdas (empty closure or capture by value) are extremely useful. they are automatically constexpr if possible and aggressively inlined. they allow for highly-optimizable (even higher-order) arbitrary execution of code at compile time. you can even create "overload sets" which can be used for succinct and readable pattern matching (which, even without inlining, would only have the cost of a single non-virtual function call), and visitation of variants

>Noexcept is a way to opt out of a C++ misfeature
there are actually some optimizations in the standard library which take noexcept into account (if a type is nothrow-constructible/destructible)
>>
[1]    3279 segmentation fault (core dumped)  python server.py


excuse me?
did i just get a segfault in python?
>>
>>61774848
>How are you supposed to use this for nontrivial projects that use like libraries and shit?
it has some limitations, though you can instance it locally, in which case you'd be able to include other files. but generally if you isolate a part of your code and throw some use cases at it, you can at least quickly see if it's locally optimizable. and if that code is header-only/inlinable in within your project, you can generally expect that to carry over. if it's not header-only/inlinable, then, well, obviously you're gonna have indirections. but you'd still know if it's getting optimized well locally to that translation unit
>>
>>61775484
Segfaults can happen in any programming language. Most likely server.py calls some python which calls some C code which just tried to peep at an invalid pointer.

I doubt you're writing C so you could track down the bug and submit it to the authors of the library like a good person using free shit.
>>
>>61775522
Yeah, I know. It's not a bug, I'm just retarded.
>>
>>61775534
It is a bug desu. High level libraries shouldn't segfault. They should crash through the means of the high level language. I'm certain python has a way to throw an error.
>>
File: 1501781051195.png (25KB, 645x267px) Image search: [Google]
1501781051195.png
25KB, 645x267px
Did libgen just get BTFO?
>>
>>61775558
what does some cokehead's tweet have to do with libgen?
>>
>>61775558
What the fuck does a russian book pirating site have to do with antivirus software?
>>
>>61775568
>>61775572
Why are you asking this?
>>
>>61774848
God. I feel both of these replies are just awful.
>>61775518
>>61775471

Feel sorry for you anon. You made a good informative post criticizing a paradigm, pointing out a feature issue in C++ and error in his post well but you just get irrelevant junk back. Have a nice friendly (you) from me.
>>
>>61775580
I'm also questioning what libgen has to do with this.
And I agree with Mr McAfee I've never had my antivirus catch any actual viruses/block malware for over a decade now.
>>
>>61775558
>>61775572

He is right though. Antivirus software on modern x64 Windows systems doesn't work properly.

PatchGuard restricted modifications of Kernel mode components, you can't even hook SSDT legally anymore. Therefore 90% of AV's now only do most of job in usermode by doing trivial usermode hooking and what not. It's not really protecting you from sophisticated malware pieces anymore.

Only few AV's such as Kaspersky managed to bypass PG restrictions by doing some hard work but its not normal anyway.

TL:DR

>2017
>Using AV on modern x64 Windows OS

kek
>>
>>61775720
I still don't see how this ties into libgen. Are you suggesting the libgen pdfs are malware? What?
>>
>>61771565
Head first Java is really fun and was the book that got me into java
>>
>>61775731

No i'm just talking about AV's i dont know what libgen is at all
>>
>>61775720
ObRegsiterCallbacks still exists, it isn't great, but it works well enough for most of the shit consumer AVs need, nobody's burning 0day on retards
Anyone with a driver in their AV is 100% using ObRegisterCallbacks
>>
>>61775558

McAfee is half right. Anti-virus software can protect you from viruses that have already caused damage elsewhere, but are powerless to defend against zero day attacks since they are almost exclusively signature-based. There are techniques to protect against malware that is brand new, but they are not present in modern anti-virus software.

Regarding libgen, which is completely unrelated to the picture you just posted, it will never die, although some mirrors may go down. Scientists are too dependent on pirating research papers. If you were to go through the list of citations in your average research paper and actually had to pay for each of the individual articles, you'd end up paying an arm and a leg. Some of the articles are able to be obtained free through the university library's subscriptions to various journals, but not all of them. Meanwhile, you are getting charged just to publish your paper, so it can be read only by people who pay a fee? Fuck that!

https://www.sciencemag.org/news/2016/04/whos-downloading-pirated-papers-everyone
>>
>>61775301
>If you have to be mindful there's a clear cost. If you didn't they didn't have a cost
i'm obviously talking about runtime cost you goddamn moron. i said so explicitly in my first post

>There's some trivial ones like constexpr, move semantics that trivially do. Nobody should be impressed by that
yeah, precisely my point. i don't know if people should be "impressed", i'm just saying that the presence of such costless (sometimes even guaranteed in literally all cases) abstractions (1) is real and (2) yields a definitive benefit

>Are you seriously claiming you have adapted to your compiler so well that you can avoid all issues with inlining?
yes, for christ's sake. it's not even hard. i rarely run into inlining issues because i can easily write straightforward code that naturally avoids them. do edge cases exist for some abstractions? yeah, no shit. do i actually run into those cases? generally, no. why would i go out of my way to run into this problem?

>If I'm already stating that I'm disassembling my code and profiling it why would you suggest that at all
because you sound precisely like the type of person who could benefit from it (a lightly experienced autist with the usual case of ironically misguided optimization fever where you end up getting in your own way because you don't really understand the compiler)

>I agree with your newly refined stance
i've been saying the same thing this whole time you dumbshit
>>
Is it just me or do people like this seem completely oblivious to the complication they inherit from when they could just have written another program to do it for them?
https://www.youtube.com/watch?v=HMB9oXFobJc
>>
>>61775759
>i've been saying the same thing this whole time you dumbshit
No see >>61774010

This is like talking to a brick wall. You respond just slightly less.
>>
>>61769170
Haskell Arrays don't really have syntax.
Just define your own array class.
>>
What do you name the nodes in a double linked list? Prev and next?
>>
>>61773550
So which should I use? What if someone else in my team chooses to use a different way? I would need to be familiar with all of them
>>
>>61775974
up and down
>>
>>61775991
Mostly no you wouldn't need to know most of them.
>which do I use
Depends on context. Most of the time it doesn't matter.
>>
>>61770973
c++ is so bad that literally the devs used it to create java
>>
nothing wrong with c++ no language is perfect
>>
>>61776263
>nothing wrong with c++
Disagree.
>no language is perfect
Agree
>nothing wrong with c++ no language is perfect
Excusing errors that do not exist would be redundant.
>>
>>61776283
name 1 (ONE) thing
>>
>>61776295
We have many examples in this thread but templates being anywhere close to turing complete is a big one.
>>
So I've seen people here say that "The C Programming Language" book is more of a reference book than a book that should be used to learn C. Is that true, and if it is, what are the alternatives?
>>
>>61776359
>learning with a book
just start and google when you run into problem
>>
>>61776359
The C programming language is a book made to introduce programmers who programmed in older languages to the C programming language.
So it's not introductory to programming.
I have no idea what a good introductory book would be for C because experienced programmers normally don't read those. But I can understand the point in reading something newer like Modern C.
https://news.ycombinator.com/item?id=13054705
>>
>>61776374
>t. pajeet
>>61776387
I have experience, so I guess I'll go with it. Thanks
>>
>>61776407
>I have experience, so I guess I'll go with it. Thanks
Remember that new C is different from old C. So I highly recommend learning from someone experienced or looking into more modern literature. If only to peek. But people in that thread (i meant to post the link to the PDF they posted) do still recommend K&R. So I guess it's not too bad.
>>
File: kqUSjWQ.png (43KB, 798x356px) Image search: [Google]
kqUSjWQ.png
43KB, 798x356px
I made a meme
>>
>>61775810
But I want to do everything with only one language and one program that does even my coffee! (and that is not java)
>>
>>61776428
Chad uses Agda and Coq
>>
>>61772299
Start with algoritms only if you are mathematic,minimum know analysis or abstract algebra.
>>
>>61776482
Chad uses brainfuck, this was translated from it for your virgin eyes.
>>
>>61774787

Rewriting your rewrite of his rewrite of that other guy's of some other fag's rewrite of Scala in Go in Rust in Python in Ada in Malbolge in INTERCAL in Ruby on Rails on some idle tuesday afternoon
>>
>>61776507
Why would Chad use that brainfuck nerd shit?
>>
>>61776428
>chad
>comments
you know nothing of my ways, punny human
>>
>>61776263

By definition, if something has absolutely nothing wrong with it, then it is perfect. If it has even a minor imperfection, then by definition, there is something wrong with it. Your claim is contradictory.
>>
>>61776571
nope, check ur sumptions
>>
File: 1497198369661.jpg (53KB, 500x541px) Image search: [Google]
1497198369661.jpg
53KB, 500x541px
im in a shitty spot at work
>been asking boss for permission to rewrite one of our systems because its buggy and badly designed as fuck
>"anon we dont have time to rewrite things that work, there are plenty of new features that must be added"
>two large bugs related to that system gets pushed to production
>finally get permission to redo it
>not even sure it can be done anymore because there are so many quirks, special behavior and annoying shit to take into account
>>
File: gavel.jpg (305KB, 1920x1280px) Image search: [Google]
gavel.jpg
305KB, 1920x1280px
>>61770973
writing a theorem prover/classifier that uses a deontic logic to decide if a series of behaviors is criminal or not, and then attempts to fit a suitable punishment
>>
>>61775996
top and bottom, alternatively strange and charm
>>
>>61776667
light and dark
red and blue
deep and shallow
hell and heaven

I wonder why anon was asking that here. There's so many names you can pick.
>>
>>61776666
>satan tries to automate laws
Doubt even satan could translate laws into consistent punishment.
>>
Anyone here know how i can round to specific numbers in python? i.e. I have a tuple (-3.13,2.44) and I want to round them to the nearest 3 and 1, -3 and -1. So this tuple would then be (-3, 2).

I tried using round() and int() but those havent worked for me. Another example: (0.9,-1.9) -> (1,-1) instead of (1,-2)
>>
>>61776618

If it could be written once, it can be written a second time. You got what you asked for, now reap what you have sowed.

And just think: since you're rewriting it from scratch, you might even be able to use a different language for it.
>>
>>61776696
>thinking consistency matters in judgment
>>
>>61776618
>muh features
eh, gotta take those shekels first before entering the circle of hell
>>
>>61776704
math.trunc
>>
New thread when?
>>
>>61776704
whoops for the first example i meant (-3.13,2.44) -> (-3,3)
>>
>>61776913
math.ceil then?
>>
New thread:
>>61776941
>>61776941
>>61776941
>>
>>61776926
>>61776880
No he's looking to map a range like i think:
[0,3]->3
[-3,0)->-3 repeating across the real numbers.
Sounds to me like he wants a floating point modulus, take the remainder and add in the difference between the remainder and the target value whole number equivalents
float weirdRound(float input){
float diff=3-fmod(input, 3);
if(diff<(3/2)){diff=-diff;} //makes us 'round' down when the remainder is less than half the way to the target
return diff+input; //optionally do round() on this to get an integer or whatever.
}

If he has two arbitrary targets I dunno how you'd do this. you'd probably compare the distance to each of the different mod results and do a diff off that.
>>
hey ladies what do people use to play sound nowadays in Windows?? do people still use DirectSound?
>>
>>61776666

Try markov chains, satan.
>>
>>61778326
not sure how markov chains would apply to this
Thread posts: 329
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.