[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: 324
Thread images: 56

File: 666.png (26KB, 480x280px) Image search: [Google]
666.png
26KB, 480x280px
What are you working on, /g/?

Old thread: >>62025163
>>
>>62034793
Refuck 1.0.
>>
File: 1498769524294.jpg (60KB, 980x158px) Image search: [Google]
1498769524294.jpg
60KB, 980x158px
>OOP
just say "no"
>>
Currently planning to extend emacs to support live shared library reloading.
Unless somebody knows tool that can already do that?
>>
Lolis
>>
#include <stdio.h> /* cracks knuckels */

int /* sisp energy drink */
main() /* puts on the hoodie */
{ /* eurobaet intensifies */
printf("Let's CODE\n");
}
>>
File: 055.png (134KB, 720x331px) Image search: [Google]
055.png
134KB, 720x331px
What do you think of my code?
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>62034793
First for(isprime(p) == 1).
>>
>>62034849
Aaaaaand, Compile error. GJ
>>
>>62034853
Die please.
>>
>>62034853
you're hired
>>
>>62034793
Can a dumbass learn programming?
>>
>>62034828
>indians use X so I must stop using X too so that nobody calls me a pajeet
Indians use water too, anon. Are you going to stop drinking water?
>>
>>62034893
no
>>
>>62034853
>age < 50
>"You are young"
milfhunter
>>
File: 1502975142536.png (154KB, 2048x1536px) Image search: [Google]
1502975142536.png
154KB, 2048x1536px
Can indians teach you how to write code?
>>
File: 1436819922136.webm (156KB, 320x240px) Image search: [Google]
1436819922136.webm
156KB, 320x240px
>>62034853
>}else{
>>
File: gd.jpg (34KB, 626x366px) Image search: [Google]
gd.jpg
34KB, 626x366px
>>62034864
What are you smoking
>>
>>62034914
POO
>>
>>62034897
Indians don't use clean water
>>
>>62034893
Yes
>>
Fixed my laptop and made a quick implementation of binary search
#include <iostream>
int binarySearch(int* array, int target, int min, int max) {
if (min > max)
return -1;

int midpoint = min + ((max - min) / 2);

if (array[midpoint] > target) {
return binarySearch(array, target, min, midpoint - 1);
} else if (array[midpoint] < target) {
return binarySearch(array, target, midpoint + 1, max);
} else
return midpoint;
}

int main() {
int array[] = {3, 6, 8, 12, 14, 17, 20, 21, 26, 32, 36, 37, 42, 44, 48};

const int numTestValues = 9;
int testValues[numTestValues] = {0, 3, 12, 13, 22, 26, 43, 44, 49};
int expectedValues[numTestValues] = {-1, 0, 3, -1, -1, 8, -1, 13, -1};

for (int count = 0; count < numTestValues; ++count) {
int index = binarySearch(array, testValues[count], 0, 14);
if (index == expectedValues[count])
std::cout << "test value " << testValues[count] << " passed!\n";
else
std::cout << "test value " << testValues[count]
<< " failed. There's something wrong with your code!\n";
}

return 0;
}
>>
File: smug_ran.jpg (632KB, 709x1063px) Image search: [Google]
smug_ran.jpg
632KB, 709x1063px
pi = atan(1.0) * 4.0
>>
File: K85ZWV2F_400x400.png (108KB, 400x400px) Image search: [Google]
K85ZWV2F_400x400.png
108KB, 400x400px
Simple reminder that if you're a beginner, Java is the best language to learn. Plenty of flexibility, easiest introduction to OOP you will find and heaps of documentation.
>>
>>62034897
>Indians use water
stop lying
>>
File: will_this_do.png (35KB, 679x260px) Image search: [Google]
will_this_do.png
35KB, 679x260px
man perlootut
>>
>>62034931
clearly this is best style
if (cond) {
;
}
else {
;
}
>>
>>62034954
pi = 22 / 7 -- good enough
>>
>>62034954
fuck off back to wdg
>>
Why does /dpt/ love Udemy so much?
>>
>>62034954
Did you just try to be smart?
>>
>>62034938
>Modern compilers help idiots, who don't return values for a non void main. Still, you suck.
>>
File: tll.jpg (69KB, 682x371px) Image search: [Google]
tll.jpg
69KB, 682x371px
>>62034974
>>62034954
>he cant remember .1415
>>
>>62034974
>integer division
good job
>>
>>62034978
Can I fuck off too? I just came from edc
>>
Which programming language should a brainlet like me (try to) learn? Python? I want to make some cool simple linux apps.
>>
>>62035002
Haskell
>>
>>62034951
Why use C-style array and not std::array?
>>
>>62035002
python is low effort with immmediate reward
>>
>>62034999
Prelude> 22 / 7
3.142857142857143


get with the times granddad
>>
>>62035002
Cool, simple and linux is an anagram of perl, you do the math.
>>
File: 1489239551758.jpg (83KB, 355x369px) Image search: [Google]
1489239551758.jpg
83KB, 355x369px
>>62034995
>he doesn't know it's .1416 because of rounding
>>
>>62034974
>>62034999
 pi = (double)22.0 /  (double)7.0


fix'd
>>
>>62035021
Prelude> pi
3.141592653589793
>>
>>62035054
but then I can't seem ``clever'' for knowing 3 digits worth of approximation...
>>
>>62034974
pi = 3 // close enough
>>
>>62035007
>Haskell
Are you memeing me or what? I looked at the homepage for haskell and their example is confusing as fuck

primes = filterPrime [2..]
where filterPrime (p:xs) =
p : filterPrime [x | x <- xs, x `mod` p /= 0]

What does this mean?

>>62035015
Is it as capable as other languages? Am I better off learning something else?
>>
And now to try to get my GCC project to work on windows... Wish me good luck.
>>
>>62035090
python is a good language if you aren't a master programmer, and everything else you could probably learn is absolute shit
>>
Where do I start with programming? Are sites like codeschool good?
>>
>>62035090
That's obviously complicated for someone who doesn't know Haskell, try the wikibook or the"try it" bit on https://www.haskell.org/


Python will rot your brain
>>
File: smug_ran1.jpg (180KB, 1732x1593px) Image search: [Google]
smug_ran1.jpg
180KB, 1732x1593px
double zeta(double s)
{
int nmax = 10000;
double dt = 0.001;
double sum = 0.0;
for(int n=0;n<nmax;n++)
{
double t = n * dt
sum += pow(t,s)/(exp(t)-1)/t *dt;
}
return sum / tgamma(s);
}

pi = sqrt(sqrt(zeta(4) * 90))
>>
>>62035090
>What does this mean?

Spend 30 minutes learning it and you'll know? What is the point of learning a language you already know?
>>
>>62035111
Will learning python make it easier to learn other languages later or is it non-transferable?
>>
>>62035090
Haskell is a pure functional programming language. It's esoteric because mathsy academic types like it that way.
Python is good enough for a beginner, you'll find that you can do a lot just by googling shit and gluing bits of what you know together. It's reasonably capable for making stuff.
>>
>>62035120
Just link https://en.wikipedia.org/wiki/Approximations_of_%CF%80 and be done with it

Post cute anime girls at least
>>
>>62035130
It's somewhat non-transferable. If you're learning for the sake of learning, learn C++.
>>
>>62035130
it may with enough effort
>>
>>62035142
I'm a brainlet who can't into math, Python looks pretty comfy desu
>>
>>62035114
https://www.python.org/downloads/
>>
>>62035130
Python is no lingua franca but it'll help.
>>
>>62035142
Haskell is good for a beginner, you just don't start off by showing them tsuff like that.
Python is NOT good for a beginner because it ruins them as a programmer forever.
>>
>>62035142
>esoteric

question mark
>>
>>62035114
no
>>
What is the hardest language?
>>
>>62035161
>https://www.python.org/downloads/
Wow, I'm learning so much looking at this download page, pretty sure my distro has python already anyway, I was asking which is the best learning resource.
>>
>>62035179
C++

Show me a man who knows all the rules for initialization and I'll show you a liar.
>>
File: asmspasm.png (48KB, 1136x862px) Image search: [Google]
asmspasm.png
48KB, 1136x862px
Working on an ASM interpreter for PIC16F877A "emulation". Just got finished implementing the logic for symbols. Next up: macros.
>>
>>62035179
any OOP trash
>>
>22/7 is accurate to 3 digits
>2 2 7 is three numbers
???
>>
So with MinGW gcc on windows, do I use .a or .lib libraries? I.e. linux or windows ones?
>>
>>62035179
bash
>>
>>62035179
malbolge
>>
>>62035179
Ook
>>
>>62035165
>Python is NOT good for a beginner because it ruins them as a programmer forever.
What makes you say that?
>>
>>62035183
I don't know, sadly
>>
>>62034853
Walk into google, ask to speak to the manager, give him a firm handshake and tell him you wanna work there.
}else{ kill yourself
>>
>>62035152
I tried learning C++ when I was younger but I think I'm too brainlet
>>
>>62034941
haahahaha guys
OOP backwards
is
POO
comdeuy geauld
>>
File: trashkell_on_suicide_watch.png (448KB, 580x1500px) Image search: [Google]
trashkell_on_suicide_watch.png
448KB, 580x1500px
>>62035142
Reminder that actual mathematicians hate trashkell and trashkell programmers.
>>
>>62035212
Mindlessly parroting /g/ memes 24/7 does things to people's brains
>>
>>62035193
brainlets will use it to show that they are aware that the fraction exists. when in reality all they're doing is adding extra operations for worse results.
>>
>>62035212
1) The language is incredibly poorly designed.
2) A lot of awful practices fall under the term 'pythonic'.
3) The language does not have a type system, or any kind of static verification.
>>
File: C.jpg (54KB, 699x381px) Image search: [Google]
C.jpg
54KB, 699x381px
>>62035231
>>62034887
>>62034931
What is wrong with } else {?
this is the book I'm daring and they show it as examples
>>
>>62035252
>muh static typing
>>
File: 1416742514827.jpg (36KB, 640x496px) Image search: [Google]
1416742514827.jpg
36KB, 640x496px
>>62035252
You forgot that meaning of ``pythonic'' changes every week

w.r.t. 3 IIRC there was some PEP few years ago which let you put annotations on functions which would them be checked ahead of time but I don't know what happened to that; definitely step forward if you _have to_ use Python though.
>>
>>62035243
>actual mathematicians hate trashkell and trashkell programmers.
hey, I consider myself an actual mathematician and I like haskell
>>
>>62035270
nothing wrong with } else {, these autismos just cringing at your lack of spacing. }else{
>>
>>62035252
Interesting. Welp, I'll give Haskell a go and if I'm too brainlet I'll ruin myself with python, I'm not planning to work as a programmer or anything just wanna learn a language to do small projects in when I think of stuff/add things to other peoples projects.
>>
>>62035270
it's just personal preference
whitespace doesn't matter in C
>>
>>62035279
python's dynamic typing doesn't bother me so much because it tends to raise errors on type mismatches rather than just rolling with it like PHP or Javascript.
>>
>>62035288
Use the wikibook, it's quite slow.

You could also start with C.
That might be more beginner friendly.
>>
File: sweetie.png (169KB, 400x400px) Image search: [Google]
sweetie.png
169KB, 400x400px
>>62035283
>I consider myself an actual mathematician
>>
>>62035179
Assembly
>>
>>62035270
it's ugly.
[spoiler]I actually really like the way it looks I'm just memeing to fit in with the cool programmers[/spoiler]
>>
>>62035298
Get the fuck out, you hardly even program and constantly fucking avatarfag and shit on everything

MATLAB is not a real fucking programming language you brainlet
>>
>>62035297
C is more transferable than python? I mention python because I notice a lot of small linux apps are done in python.
>>
>>62035328
If you like python just use it, don't listen to /g/ memers trying to persuade you
>>
>>62035270

The eye scans for a lone closing }.

I personally advocate the open { newline approach, which makes scanning for code blocks even easier. But I'm a heretic that uses C#.

// Some shit
int i = 15, j = 20;
if (j < i && sky.IsRed())
{
// Do stuff
array[j] = i + j;
}
else
{
// OP is gay
WriteLine("Very gay");
}
// More crap obscuring your vision
j = -10;


This is just visually superior, admit it. Look how shit it looks below.

// Some shit
int i = 15, j = 20;
if (j < i && sky.IsRed()) {
// Do stuff
array[j] = i + j;
} else {
// OP is gay
WriteLine("Very gay");
}
// More crap obscuring your vision
j = -10;
>>
>>62035328
Yes.
>>
>>62035320
>can't do anything other than throw out strawmen and other non-arguments
Absolutely PATHETIC
>>
>>62035179
Binary.
>>
>>62035365
Upvoted
>>
>>62035365
Binary isn't a language, it's a number representation.
>>
>>62035355
int i = 15, j = 20;
if (j < i && sky.IsRed())
array[j] = i + j; /* do stuff */
else
WriteLine("Very gay"); /* you're gay */
j = -10;
>>
>>62035377
Downvoted
>>
>>62035363 (failure)
>>
>>62035377
01100110 01110101 01100011 01101011 00100000 01101111 01100110 01100110 00100000 01100010 01110010 01100001 01101001 01101110 01101100 01100101 01110100
>>
>>62035373
>>62035384
>>>/r/eddit
>>
>>62035328

Both are transferable. Learn both.

Python is highly productive very fast, and is transferable to all arenas of coding.

C is much slower to be productive but teaches you loads about programming, and its transferable to things like data processing, embedded systems etc.

Both are useful to learn in different ways.
>>
>>62035288
Don't listen to the idiotic memesters here. Haskell is considered one of the most difficult languages that only fedora wearing faux-academics use.

Python is an excellent language to learn for scripting and educates you on the core principles of programming. Java is also an excellent choice.
>>
#include <iostream>
using namespace std;

class Ball {
private:
string color = "Black";
float diameter = 5.0;

public:
Ball(string givenColor, float givenDiameter)
: color(givenColor), diameter(givenDiameter) {
/* in which cases should I do the following?:
* color = givenColor;
* diameter = givenDiameter;
*/
}
void print() {
cout << "Ball: Color - " << color << ", Diameter - " << diameter << endl;
}
};

int main(void) {
Ball B{"Red", 10.0};
B.print();
return 0;
}


Now my question is, what's the difference between initializing the members before before the function body and assigning them inside the body?
>>
>>62035397
Please elaborate.
>>
Python is fucking shit. Learn C instead.
>>
File: e61.png (117KB, 680x788px) Image search: [Google]
e61.png
117KB, 680x788px
>>62035377
Master computer scientists don't need languages to write their programs. We're able to write whatever we need manually in binary.
>>
>>62035452
0101010101110000011101100110111101110100011001010110010000100000011011010111100100100000011011010110000101101110
>>
>>62035439
>X is fucking shit. Learn Y instead.
Go back to kindergarten.
>>
File: fed2.jpg (8KB, 480x360px) Image search: [Google]
fed2.jpg
8KB, 480x360px
>>62035439
t. Fedora tipping idiot.

Python is a fantastic language for scripting.
>>
>>62035415
>>62035420
Thanks lads, any recommended learning resources for either C or Py?

>>62035439
You make a compelling argument, care to expound on it?
>>
File: tips.png (161KB, 265x281px) Image search: [Google]
tips.png
161KB, 265x281px
>>62035476
>whoever disagrees with me is a fedora!!
>>
File: 1502118989244.png (504KB, 721x717px) Image search: [Google]
1502118989244.png
504KB, 721x717px
>>62035486
>>62035490
Please learn C#
: <<<<<<<<<<<<<
>>
>>62035452
I'm going to take the bait. Binary itself is not a language, you would be writing in machine code for whatever architecture you are using. At the end of the day, binary is just another number representation much like decimal and hexadecimal. Based on the fact that you could write machine code in binary, you could also write it in decimal or hexadecimal (Which is the most common format for machine code).

:^)
>>
>>62035515
Java is better
>>
>>62035520
What is it about writing in binary you're too stupid to understand? Nobody said anything about it being a language, dumb brainlet.
>>
>>62035521
>t. pajeet
>>
>>62035520
01110100 00101110 00100000 01100010 01110010 01100001 01101001 01101110 01101100 01100101 01110100 00100000 01110111 01101000 01101111 00100000 01100011 01100001 01101110 00100111 01110100 00100000 01110111 01110010 01101001 01110100 01100101 00100000 01101001 01101110 00100000 01100010 01101001 01101110 01100001 01110010 01111001
>>
Java is far superior to C#, no doubt about it.

Why the fuck would you want to be Micro$oft's cuck?
>>
>>62035545
>C# isn't for pajeets
>>
File: 9Upehjj.jpg (485KB, 1280x720px) Image search: [Google]
9Upehjj.jpg
485KB, 1280x720px
>>62035521
Say that again if you dare
>>
File: IMG_20170822_194608.png (155KB, 720x625px) Image search: [Google]
IMG_20170822_194608.png
155KB, 720x625px
Can someone please explain to me what is going on here?
I can't wrap my head around it for hours now.
>>
>>62035424
Depends. If you can do straight initialization from the given parameters, do it like that. If you need to convert the parameters, then obviously you should do it in the constructor.
>>
>>62035564
Java is better
>>
>>62035567
>google
>youtube
>>
File: 848.png (205KB, 659x525px) Image search: [Google]
848.png
205KB, 659x525px
why cant any of you learn oberon? not smart enough?
>>
>>62035584
dumb frogposter
>>
>>62035534
01000001 01110100 00100000 01101100 01100101 01100001 01110011 01110100 00100000 01001001 00100111 01101101 00100000 01101110 01101111 01110100 00100000 01100001 00100000 01101110 01100101 01110010 01100100 00100000 01110111 01101000 01101111 00100000 01110100 01110010 01101111 01101100 01101100 01110011 00100000 01110000 01100101 01101111 01110000 01101100 01100101 00100000 01101111 01101110 00100000 01100001 00100000 01100010 01110010 01100001 01111010 01101001 01101100 01101100 01101001 01100001 01101110 00100000 01100010 01101111 01110100 01110100 01101100 01100101 00101101 01101111 01110000 01100101 01101110 01101001 01101110 01100111 00100000 01100110 01101111 01110010 01110101 01101101 00101110 00100000 00111010 01011110 00101001
>>
>C#
>>
File: C.jpg (63KB, 491x648px) Image search: [Google]
C.jpg
63KB, 491x648px
>>62035486
>Thanks lads, any recommended learning resources for either C or Py?

Read this.

If it feels too slow and low-level for you then switch to python. For python use their official tutorial and documentation, they have one that goes way down to beginner level. I used it to get the lay of the land and it moved way too slowly for me so it would be just right for a non-developer. If even that is too high level google it, there are a billion "python for dummies" tutorials out there.
>>
>>62035567
It is the recursive function.
>>
>>62035584
>oberon
Is that the guy who got his head crushed by the mountain in game of thrones?
>>
File: 1500261898309.jpg (197KB, 935x799px) Image search: [Google]
1500261898309.jpg
197KB, 935x799px
>he doesn't write in the thinking man's language
>>
>>62035584
>dumb enough
>>
Which language would Chad use?
>>
>>62035633
Rust
>>
File: SCREEN.jpg (1MB, 3000x2400px) Image search: [Google]
SCREEN.jpg
1MB, 3000x2400px
>>62035606
https://en.wikipedia.org/wiki/Oberon_(programming_language)
>>
reposting

>>62034972
>>62035215
Because scanf is only changing one byte of the integer. Try this:

#include <stdio.h>
#include <stdint.h>

int main() {
int32_t i = 0x0000ca00;
ungetc(0xfe, stdin);
scanf("%c", &i);
printf("Welcome to deadbeef %x\n", i);
return 0;
}


On a little endian machine it should output:

Welcome to deadbeef cafe



>>62035410
I was just memeing.

I was just showing that C has multiple namespaces.
>>
>>62035647
Looks like a language for only the most dedicated of autists
>>
>>62034959
This
>>
>>62035647
>Oberon is designed with a motto attributed to Albert Einstein in mind: “Make things as simple as possible, but not simpler.” The principal guideline was to concentrate on features that are basic and essential and to omit ephemeral issues. Another factor was recognition of the growth of complexity in languages such as C++ and Ada: in contrast to these, Oberon emphasizes the use of the library concept for extending the language. Enumeration and subrange types, which were present in Modula-2, have been removed; similarly, set types have been limited to small sets of integers, and the number of low-level facilities has been sharply reduced (most particularly, type transfer functions have been eliminated). Elimination of the remaining potentially-unsafe facilities concludes the most essential step toward obtaining a truly high-level language. Very close type-checking even across modules, strict index-checking at run time, null-pointer checking, and the safe type extension concept largely allow the programmer to rely on the language rules alone.

>The intent of this strategy was to produce a language that is easier to learn, simpler to implement, and very efficient. Oberon compilers have been viewed as compact and fast, while providing adequate code quality compared to commercial compilers
>>
>>62034959
>OOP
POO
>>
>>62035633
A better question is which language is the virgin language?
>>
>>62035686
C
>>
>>62035655
what the fuck
>>
Is it possible for a humble brainlet to learn C++?
>>
>>62035712
No.
>>
File: 1492999812505.jpg (252KB, 1926x2176px) Image search: [Google]
1492999812505.jpg
252KB, 1926x2176px
>>62035579
I will be watching you when you next time try to solve your crappy maven dependency conflicts.
>>62034959
>>62035674
C# is much forgiving for beginners. Easy packet management, compiling and you don't need fucking maven plugins for building a jar.
>>
>>62035718
I knew a mexican who knew C++ and he wasn't that bright.
>>
Message Handler:
MODULE Figures; (* Abstract module *)

TYPE
Figure* = POINTER TO FigureDesc;

Message* = RECORD END;
DrawMsg* = RECORD (Message) END;
ClearMsg* = RECORD (Message) END;
MarkMsg* = RECORD (Message) END;
MoveMsg* = RECORD (Message) dx*, dy* : INTEGER END;

Handler* = PROCEDURE (f : Figure; VAR msg : Message);

FigureDesc* = RECORD
(* Abstract *)
handle : Handler;
END;

PROCEDURE Handle* (f : Figure; VAR msg : Message);
BEGIN
f.handle(f, msg);
END Handle;

PROCEDURE Init* (f : Figure; handle : Handler);
BEGIN
f.handle := handle;
END Init;

END Figures.


Extending to:

MODULE Rectangles;

IMPORT Figures;

TYPE
Rectangle* = POINTER TO RectangleDesc;

RectangleDesc* = RECORD
(Figures.FigureDesc)
x, y, w, h : INTEGER;
END;

PROCEDURE Draw* (r : Rectangle);
BEGIN
(* ... *)
END Draw;

(* Other procedures here *)

PROCEDURE Handle* (f: Figure; VAR msg: Figures.Message);
VAR
r : Rectangle;
BEGIN
r := f(Rectangle);
IF msg IS Figures.DrawMsg THEN Draw(r)
ELSIF msg IS Figures.MarkMsg THEN Mark(r)
ELSIF msg IS Figures.MoveMsg THEN Move(r, msg(Figures.MoveMsg).dx, msg(Figures.MoveMsg).dy)
ELSE (* ignore *)
END
END Handle;

PROCEDURE New* (VAR r : Rectangle);
BEGIN
NEW(r);
Figures.Init(r, Handle);
END New;

END Rectangles.
>>
>>62035424
Oh wait, you meant what's the difference, ignore my last post then

The difference is that members are default-initialized if you don't explicitly initialize the members in the list.
Also you can only initialize const members in an initialization list, not in a constructor body.
>>
>>62035712
To learn it to the point where you can slap together buggy shitty unmaintainable apps? Sure.
To learn it all? Impossible.
>>
>>62035740
His code was probably full of UB.
>>
>>62035712
>learn C++?
Depends on what you mean. I think you mean that you could possibly understand and write C++ code that does something.
Yes of course you can.
To get all of it and be an 'expert'. You'll probably struggle for a long ass time.
>>
How beneficial is sicp? should I bother with it or is it just a meme
>>
>>62035743
Looks like a cute language
>>
>>62035761
I just mean learn enough to write simple apps in it, nothing fancy.
>>
>>62035775
Yeah you can do that no problem.
>>
I need to store project specific data with emacs.
The data should be stored in file that might be changed outside of emacs.
Emacs will have listener and be in sync with the data file.
What's the best way to do this, my search results didn't provide good solutions.
Sqlite is one solution but I think bit too complex, I need only key value store.
Using hashmap or assoc in emacs and serializing would be one option too but I feel it's hacky and elisp should provide inbuild functions for this shis.
>>
Why so many programmers don't work with programming after 15 or so yeas of programming?
>>
>>62035784
Are you Indian?
That's just the work culture there. You move up to management positions with experience. Almost regardless of if it's appropriate.
>>
>>62035784

Because its shit demeaning monkey work for retards who ask the impossible of you with no spec or idea what they actually want or how to get it.
>>
>>62035712
>current year
>brainlet still wants to learn C++

....
>>
>>62035800
>Are you Indian?
kek
>>
>>62035784
they get aged out by the industry
if you didn't escape into management or at least become a head developer, you get replaced by young blood who is actually WILLING to work insane hours and no overtime because they don't have a family to feed.
>>
File: 4fb.jpg (66KB, 680x680px) Image search: [Google]
4fb.jpg
66KB, 680x680px
Oberon-2 is where it's really at.

MODULE PointerBirds;
IMPORT Out;

TYPE
BirdRec* = RECORD
sound* : ARRAY 10 OF Char;
END;
DuckRec* = RECORD (BirdRec) END;
CuckooRec* = RECORD (BirdRec) END;

Bird = POINTER TO BirdRec;
Cuckoo = POINTER TO CuckooRec;
Duck = POINTER TO DuckRec;

VAR
pb : Bird;
pc : Cuckoo;
pd : Duck;

PROCEDURE SetDuckSound* (bird : Duck);
BEGIN
bird.sound := "Quack!"
END SetDuckSound;

PROCEDURE SetCuckooSound* (bird : Cuckoo);
BEGIN
bird.sound := "Cuckoo!"
END SetCuckooSound;

PROCEDURE SetSound* (bird : Bird);
BEGIN
WITH bird : Cuckoo DO
SetCuckooSound(bird)
| bird : Duck DO
SetDuckSound(bird)
ELSE
bird.sound := "Tweet!"
END
END SetSound;

BEGIN
NEW(pc);
NEW(pd);

SetCuckooSound(pc);
SetDuckSound(pd);

Out.Ln; Out.String(pc^.sound); Out.Ln;
Out.Ln; Out.String(pd^.sound); Out.Ln;

SetSound(pc);
SetSound(pd);

Out.Ln; Out.String(pc^.sound); Out.Ln;
Out.Ln; Out.String(pd^.sound); Out.Ln;

(* -------------------------------------- *)
(* Pass dynamic type to procedure *)

pb := pd;

SetDuckSound(pb(Duck));
Out.Ln; Out.String(pb^.sound); Out.Ln;

pb := pc;

SetCuckooSound(pb(Cuckoo));
Out.Ln; Out.String(pb^.sound); Out.Ln;

(* -------------------------------------- *)

SetSound(pb);
Out.Ln; Out.String(pb^.sound); Out.Ln;

pb := pd;

SetSound(pb);
Out.Ln; Out.String(pb^.sound); Out.Ln;

(* -------------------------------------- *)

NEW(pb);

SetSound(pb);
Out.Ln; Out.String(pb^.sound); Out.Ln
END PointerBirds.
>>
>>62035810

That's why he's a brainlet.

Or maybe he wants to maek gaems
>>
Is it too late to learn basic?
>>
>>62035810
what are you trying to say? write it in brainlet language, is C++ not the master-race language?
>>
>>62035851
when was its time?
>>
>>62035800
So what do you do if you don't get management?
McDonalds toilets?
>>
>>62035851
Nope. Go for it, and never listen to what /g/ memers here tell you.
>>
>>62035870
if you're not a retard, you retire early
>>
>>62035868

C++ was never the master race language.

OOP frankenshit
>>
>>62035877
at 40?
What you're supposed to be a millionaire by then?
>>
PROCEDURE power(x: REAL; i: INTEGER): REAL; 
VAR z: REAL;
BEGIN z := 1.0;
WHILE i > 0 DO
IF ODD(i) THEN z := z*x END;
x := x*x; i := i DIV 2
END;
RETURN z
END power;
>>
>>62035909
Which language is it?
>>
>>62035424
You can test what happens with simple classes, and providing the different type of constructors. The embers of your class will get default initialized, for example.
Here's a minimal version that shows possible behaviors:
#include <cstdio>

struct A {
A(int val = 0) : val(val) { printf("A\n"); }
A& operator=(const A& other) {
printf("A copy\n");
val = other.val;
return *this;
}
int val;
};

struct B {
B() { printf("B a.val %d\n", a.val); a = A(1); }
A a;
};

int main(void)
{
B b;
printf("%d", b.a.val);
return 0;
}
// output
//A
//B a.val 0
//A
//A copy
//1
>>
Am babby, starting web dev from scratch. Currently on html and will move on from there.
>>
>>62035929
embers => members
>>
឴>programming in any other language than BASIC
>>
>>62035975
this guy gets it. BASIC is chads language
>>
>>62035924
Oberon-07
>>
>>62036004
Is Oberon the fedora language of choice?
>>
I completed a university program in math and programming, stopped working for two fucking years and now I'm trying to get back into it by working on pretty basic stuff. I feel like a chump.

>Write an algorithm to find the first common ancestor of two nodes in a binary tree. (Not necessarily a binary search tree.)

Truly feel like a winner.
>>
File: fpide.jpg (86KB, 600x311px) Image search: [Google]
fpide.jpg
86KB, 600x311px
>>62035975
>not programming in Pascal
>>
PROCEDURE
Oscillation
*;
CONST dx = 0.19634953; (*pi/16*)
VAR i, n: INTEGER;
x, y, r: REAL; S: Texts.Scanner;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.po
s);
Texts.Scan(S); n := S.i; Texts.WriteInt(W, n, 6);
Texts.Scan(S); r := S.x; Texts.WriteReal(W, r, 15);
Texts.WriteLn(W);
i := 0; x := 0.0;
REPEAT x := x + dx; i := i+1;
y := Math.exp(-r*x) * Math.cos(x);
Texts.WriteReal(W, x, 15); Texts.WriteReal(W, y, 15);
Texts.WriteLn(W)
UNTIL i >= n;
Texts.Append(Oberon.Log, W.buf)
END Oscillation
>>
File: 1485835324544.jpg (263KB, 764x551px) Image search: [Google]
1485835324544.jpg
263KB, 764x551px
>>62036099
is this what it feels like to be /pascal/?
>>
reminder that you can did this in idris and it work and that's why idris is them wrist language ever made
data x: Nat
>>
>>62035179
javascript
>inb4 not a real language
>this
>>
>>62036170
>>
>>62036131
>tfw you are four identical twins conjoined at the brain and three of them are parasitic so only their brains developed so now you actually look like this but instead of being very smart you just have four simultaneous consciousnesses that bleed into each other and trying to present yourself as a single holistic individual has taken years and years of practice
>>
File: pascal.png (8KB, 706x60px) Image search: [Google]
pascal.png
8KB, 706x60px
>>62036131
Being a Russian student is what it feels like to be Pascal.
>>
>>62034987
>modern
>18 years old.
> If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument;10) reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int,the termination status returned to the host environment is unspecified.
>>
>>62035011
I can take C-arrays in functions without knowing the length.

void doThis (int* arr, int len);
With std::array I have to know the size
void doThis(array<int, 5> arr);
>>
If you can't understand what this does, you shouldn't be posting here:

PROCEDURE SinI(x: LONGREAL) : LONGREAL;
VAR
a, c, z, tmp: LONGREAL;
BEGIN
IF ~Finite(x) THEN (* sin(NaN) and sin(INF) must be NaN *)
RETURN x - x
END;
x := Rem(x, PI2); (* reduce x into [-PI,PI] *)
a := CopySign(x, 1.0);
IF a >= PIo4 THEN
IF a >= PI3o4 THEN (* ... in [3PI/4,PI] *)
a := PI - a;
x := CopySign(a, x);
ELSE (* ... in [PI/4,3PI/4] *)
a := PIo2 - a; (* rtn. sign(x)*C(PI/2-|x|) *)
z := a * a;
c := CosC(z);
z := z * half;
IF z >= thresh THEN
a := half - ((z - half) - c);
ELSE
a := 1.0 - (z - c);
END;
RETURN CopySign(a, x)
END;
END;

IF a < small THEN (* return S(x) *)
tmp := big + a;
RETURN x
END;

RETURN x + x * SinS(x * x)
END SinI;
>>
>>62036326
std::array<int, 5> arr;


doThis(&arr[0], 5);
>>
>>62036356
if you haven't suck my dick, you don't belong here
>>
>>62035721
>Being too dumb for Java
You will never make it, pajeet
>>
>>62036356
Is this the code that powers the jackhammer dildo in your ass?
>>
>>62036363
That basically nullifies the reason of std::array
>>
>>62036326
template <int n>
void doThis(array<int, n> arr);

isocpp says to do this, but I don't trust it not to bloat code horrifyingly
>>
>>62036376
At least he has good taste in anime characters

Does anyone here know Rust?
>>
>>62036365
>>62036391
>asspained brainlets
It's sad that this is what /dpt/ has been reduced to.
>>
>>62036407
Ruby knows Rust
>>
>>62036410
t. brainlet
>>
File: 1482218444311.jpg (112KB, 675x949px) Image search: [Google]
1482218444311.jpg
112KB, 675x949px
>>62036407
Ye
>>
>>62036402
if you look at >>62036406
the code produced should be almost all the same, so duplicating it per template instance is completely redundant
>>
>>62036410
You should work on wifi connectivity next to coordinate the dildos in your mouth, hands and ass to pump in unison.
>>
>>62036423
t. idiot who doesn't even know what >>62036356 does.
>>
>>62036451
t. brainlet
>>
>>62036427
is it gud
>>
>>62036406
>template <int n>
>void doThis(array<int, n> arr);
Soooo, are they going to fix it to be just
 void doThis(array<int, int n> arr);
in future or what
>>
>>62036466
Have you done C/C++ before (not him)
>>
>>62036490
some C++
>>
>>62036466
I like it. It is saner than C++, hardly any corner cases in the languages you have remember. Also no OOP, more FP-oriented.
>>
File: ybu.jpg (35KB, 602x533px) Image search: [Google]
ybu.jpg
35KB, 602x533px
Why are there so many bullies here?
>>
>>62036356
>Brainlets don't know what this does
>>
>>62036441
The question is, will the compiler be smart enough to not emit a shitton of repeated code?
Unless the function gets inlined, I don't trust it not to. Never inspected the disassm, though.
>>
>>62036505
Avoid then. Rust's memory management model is very much unfamiliar to a normal C++ user. Although one would argue Rust's way is more fault tolerant
>>
File: 1494521313303.jpg (108KB, 762x613px) Image search: [Google]
1494521313303.jpg
108KB, 762x613px
>>62036522
Because I've arrived
>>
>>62036522
brainlets deserve to be bullied.
>>
PROCEDURE RealToString*(x: LONGREAL; n, frac: LONGINT; plusChar, plusExpoChar: CHAR;
noZeros, noExpoZeros: BOOLEAN; VAR s: ARRAY OF CHAR);
CONST
MaxDigits=18; (* have to be <= 18 *)
VAR
z:LONGREAL;
e,l,h,i:LONGINT;
neg:BOOLEAN;
d:ARRAY MaxDigits OF CHAR;
BEGIN
z:=x;
IF n>MaxDigits THEN n:=MaxDigits END;
IF (n<=0) OR (frac<STD) OR (LEN(s)<n+8) THEN RETURN END;
e:= Reals.ExpoL(z);
Reals.IntL(z,h,l);
neg:=FALSE;
IF e=0 THEN (* 0 or denormalized real with ABS(x)<2^-1022<=10^-308 *)
h:=0; l:=0;
IF frac>=0 THEN (* reduction of total number of digits by frac? *)
i:=frac+1;
IF i<n THEN n:=i END;
END;
ELSIF e=2047 THEN (* IEEE codes for Not a Number *)
IF (h=PlusInfinityH)&(l=PlusInfinityL) THEN d:=PlusInfinityString
ELSIF (h=MinusInfinityH)&(l=MinusInfinityL) THEN d:=MinusInfinityString
ELSIF (h=IndeterminateH)&(l=IndeterminateL) THEN d:=IndeterminateString
ELSE d:=NaNString END;
COPY(d,s);
RETURN;
ELSE
IF z<0 THEN neg:=TRUE; z:=-z END;
e:= (e - 1023) * 301030 DIV 1000000; (* log(2)=0.301029995 *)
IF e>0 THEN z:=z/Reals.Ten(e) ELSE z:=z*Reals.Ten(-e) END; (* use positive powers of ten *)
IF z<1 THEN z:=z*10;DEC(e);
ELSIF z>=10 THEN z:=z/10;INC(e) END;
(* x = z * 10^e with 1<=z<10 *)
IF (e<0) THEN
IF (frac=SC0)&(e>-4)&(n-e<=MaxDigits) THEN (* 0.012 instead of 1.2E-2 *)
DEC(n,e);
z:=z/ten[-e];
e:=0;
ELSIF ((frac>=0) OR (frac=STD)) THEN (* produce numbers like 0.00012 *)
z:=z/Reals.Ten(-e); e:=0;
END;
END;
IF frac>=0 THEN (* reduction of total number of digits by frac? *)
i:=frac+1;
IF e>0 THEN INC(i,e) END;
IF i<n THEN n:=i END;
END;
z:=z+5.0D0/Reals.Ten(n); (* rounding *)
IF z>=10 THEN z:=z/10; INC(e) END;
IF n<=9 THEN i:=n ELSE i:=9 END;
z:=z*ten[i-1];
h:=ENTIER(z);
i:=n-i;
IF i>0 THEN
z:=z-h;
z:=z*ten[i];
l:=ENTIER(z);
END;
>>
File: tumblr_nz0jt3jM421sbzv20o1_500.gif (2MB, 500x522px) Image search: [Google]
tumblr_nz0jt3jM421sbzv20o1_500.gif
2MB, 500x522px
>>62036522
It's going to be okay
>>
File: 1496948011567.png (611KB, 780x720px) Image search: [Google]
1496948011567.png
611KB, 780x720px
>>62036544
t. THAT guy who got bullied by chads in school and now acts tough on internet
>>
I use C-style array and std::vectors
Is this a wrong decision?
>>
>>62036567
i was home schooled and was the best of my class
>>
>>62036567
i was and still am chad, i don't even understand all this nerdy bullshit, i'm only here to bully
>>
>>62036326
But you do know the length. It's not explicitly written in the function signature but it's there, right where you declared the array. How does that make it any different from having a function take an std::array reference?
>>
Should I even get an IDE for python on linux or just write text files?
>>
How difficult is it to make a toy programming language?
>>
Man, project euler's difficulty ratings really blow. May as well ignore those completely.
>>
>>62036649
Python already exists, anon
>>
>>62036642
you absolutely need an IDE for python if you're working on a large project in it because it's a huge pain otherwise
>>
>>62036667
?
>>
>>62035288
Don't listen to the autists here. In most colleges python is the first language you learn, who do you trust more, users of an anime image board or scholars?
>>
>>62035903
your arms stop working properly
>>
>>62036667
Yeah but I want to dick around with my own, just so I can see what stupid constructs might be fun.
>>
I haven't done any proper programming in a while, but after getting annoyed that I couldn't find a decent quality pack/batch of some manga I decided to make a few scripts to rip and package shit you find online. I don't really know shit about bash or web shit, but I actually got something kinda-working, good enough for me to download what I wanted at least.

I have a few days off so I might get to work on making mpv act like an external player for Emby, mpv seems to have IPC support using JSON so that should work.
>>
Does this thread have any genuinely skilled programmers? Or is it all just memers?
>>
File: 1503237831496.jpg (138KB, 1356x1017px) Image search: [Google]
1503237831496.jpg
138KB, 1356x1017px
Define "skilled".
>>
>>62036744
Are you hiring?
>>
>>62036744
right here anon :^)
>>
>>62035577
I have done binary trees and factorials before but this is nothing like it.
>>
>>62036774
Show something.
>>
>>62036851
use Sexuality::*;

#[derive(Debug, PartialEq)]
enum Sexuality {
Gay, Bi, Straight
}

trait Are {
fn are(self) -> Sexuality;
}

struct Traps;

impl Are for Traps {
fn are(self) -> Sexuality {
Gay
}
}

fn main() {
assert_eq!(Traps.are(), Gay);
}
>>
I haven't written a line of code in months. Is there any recovering from this, or should I give up now? My goal was to become employable without a degree.
>>
File: 1499727539509.jpg (25KB, 390x478px) Image search: [Google]
1499727539509.jpg
25KB, 390x478px
>>62036863
>tfw someone reposted my meme program
>>
>>62036877
Why did you make a faulty program?
>>
I want to make a Doom-like engine for fun. Should I use OpenGL or SDL/Allegro/whatever software bitmap renderer? Not in terms of performance, more like in terms of basedness.
>>
>>62036910
It compiles at runs fine, what's faulty?
>>
>>62036863
>'are' moves 'self'
What did you mean by this? If you find out someone's sexuality they die?
>>
>>62036925
Anyone implementing Are gets turned into Sexuality, can't you readß
>>
>>62036919
Returns the wrong value
>>
File: 1497188478681.jpg (11KB, 343x345px) Image search: [Google]
1497188478681.jpg
11KB, 343x345px
>>62036952
>Implying traps aren't gay
>>
>>62036667
>do I fit in yet guise?
>>
Is it possible to write to stdout of a process from stdin of another process in C, and how might I do this?
>>
So why isn't rust the replacment for c++ we always wanted i was wondering looking around the internet best lasngauge for development of fast GUI big interfacing for graphics and i think some people not many only most of them said rust is becoming more and more pungent os i wasnt looking and c++++ came up something like that but it's propreitarious software for made by windows corporations and i looked at them they used to use c++ for their os or some assembelance language along side ASCII C something like that and it looks interresting but rust is the real deal from what io've read on the internet it comes to show that c++++ or c++ or ASCII C is not here for long because of safe develop[ment inviorment and different approach to pointing to the harddrive and safe spinning i think but what ever you guys think about rust vs c++++ vs c++ vs ASCII C ???
>>
File: 1492977987480.jpg (94KB, 421x834px) Image search: [Google]
1492977987480.jpg
94KB, 421x834px
>>62037052
>>
File: Oh boy here we go.png (180KB, 429x519px) Image search: [Google]
Oh boy here we go.png
180KB, 429x519px
>it's 4 hours into overtime and two of your colleagues begin to casually discuss pros and cons to various methods of suicide
Anything I should do besides reminding them to commit today's progress before leaving office?
>>
>>62037052
>ASCII C
You made my day.
>>
>>62037074
asdfC++vfdshdC++dfhdgfrdhdfbC++gfhfgh
>>
>>62037098
remind them that 3D women are NOT important
>>
>>62037098
remind them that they are there FOREVER
>>
What's worse:
> tests longer than implementation (3x or more)
> comments longer than code
> type signature as long as or longer than code
>>
Are the vi hotkeys popular because they're actually good or because vi and vim have been around so long?
>>
>>62037098
shotgun to mouth is the best option by far
>>
>>62037236
tests are worse
>>
>>62037237
>vi hotkeys popular
lol
GNU Emacs hotkeys are propular
>>
>>62037237
Both. Some vi keys are better than others. Also modal editing is faster and easier to remember because you just press a single key and have it do stuff rather than pressing a combination of keys (not that the latter isn't *fine*, it's just slightly worse)
>>
>>62037239
This. I wonder how many people survived after trying to off themselves with 9mm and ended up being vegetables
>>
>>62037160
Nah, the place closes at midnight. Just two more hours to go.
>>62037239
Thanks for the tip, but we're in Europe.
>>
How do I start with programming? Do I buy some book?
>>
>>62037331
Install linux and look up an online intro to python.
>>
>>62037331
start with python move to c get a gist of things then move to c++/rust/go and enjoy a strong tool kit
>>
File: kon.jpg (414KB, 850x1268px) Image search: [Google]
kon.jpg
414KB, 850x1268px
>>62037331
masturbate to sexy anime girls
>>
What book should I read about data structures if I want to pass an interview?
>>
>>62037331
No need to install anything, just use the browser you already have.
https://www.w3schools.com/js/default.asp
>>
>>62037331
do the angry bird tutorial on code.org
>>
>>62037352
This. Note that the linux installation step isn't there because python wouldn't work on windows, but because only putting yourself into the situation where you can't use your operating system without making some custom scripts will guarantee you actually get into the programming.
>>
File: ProgrammingAbstractionsInC.jpg (200KB, 385x500px) Image search: [Google]
ProgrammingAbstractionsInC.jpg
200KB, 385x500px
>>62037395
>>
>>62034793
Trying to decide between installing emacs on windows or wasting time trying to figure out a way to get variable declarations inside for loop initialization in C to work with Visual Studios.
>>
>>62037395
Introduction to Algorithms
>>
>>
File: 8QWXFgUwsxk.jpg (33KB, 540x488px) Image search: [Google]
8QWXFgUwsxk.jpg
33KB, 540x488px
>>62037392
K-ons are not for sexual pleasure.
Stay away from them, especially form Azusa, creep.
>>
>>62037425
I only recommended installing linux because it's so easy programming in linux as opposed to fucking with graphical IDEs and installing shit in Windows.
>>
>>62037452
isurewq!
>>
>>62037452
You must live in bizarro world. Installing something like Pelles C, Dev-C++, Lazarus or even PyCharm on Windows and getting right onto programming is the easiest thing in the world.
>>
>>62037483
Easier than opening the terminal, typing vim script.py, tying out your stuff, closing the file, then typing python script.py?
>>
File: UNF.jpg (942KB, 2048x1536px) Image search: [Google]
UNF.jpg
942KB, 2048x1536px
>>62037451
K-ons are for rough, sweaty sex!
>>
>>62037495
$ vim script.py
bash: vim: command not found
>>
>>62037521
Very funny, replace vim with nano.
>>
>>62037495
>vim
Yes, much, much easier for a beginner. All those IDEs are actually usable without any prior knowledge or research into them at all. You can open it up for the first time and immediately begin programming since the environments visually present their functions using suggestive icons or descriptive text labels.

vim is an arcane labyrinth compared to any of those, not to mention what you have to go through if you want to do some actual debugging as a beginner without an IDE which already has it built-in and functional.
>>
What's the easiest way to set up SDL in Windows? Is it just by using something like Visual Studio or Eclipse?
I'm trying to do it manually using NP++ and mingw, but I'm getting "Cannot find reference to WinMain" among other things. I don't know what to do..
>>
>>62037627
Try to pass /subsytem:console or something like that to linker.
>>
Why isn't /dpt/ working on open source project?
>>
>>62037683
we've got a promising browser in the works
>>
>>62037683
My code is ugly.
>>
>>62037702
But you aren't.
>>
>>62037709
<3
>>
>>62037657
I'm not really that experienced with linkers.
Are there any good reading materials for learning about manually linking libraries?
>>
>>62037683
because /dpt/ is about shitposting, not programming
>>
>>62037683
I uploaded some of my shit to github, good enough.
>>
NEW THREAD
>>62037763
>>62037763
>>62037763
>>62037763
>>
>>62037683
making new threads is already taking all my time
>>
>>62037316
they'll be back tomorrow
>>
>>62037827
this picture does funny things to my penis
>>
what is the proper way to have variables shared between threads when only one thread writes and the other reads (no real risks) in C++?
Do I just declare global variables?
>>
>>62035193
Accurate to four digits - 3.142.
>>
>>62038030
you store them in a file and have them both have access to it, dont forget to have .lock files
>>
>>62035616
based
>>62035633
chad has an army of betas to program for him
>>
>>62035252
It depends what you want to do with it... If you just want to do some algorithm with it, I think it's enough
>>
>>62035567
There's no error in your code... Look at the movement "from.. to.." it's good, the only thing is that disc does not represent a disc but the number of discs composing the tower
>>
>>62036441
>the code produced should be almost all the same
not quite; the rather important difference is that in the template version, n is a constant expression, which allows for potentially many implicit and explicit optimizations depending on the nature of the doThis function

>so duplicating it per template instance is completely redundant
each instantiation is specialized for a given constant value of n; constant expressions involving n which can be computed at compile time (potentially any pure C++ expression/function/lambda on any statically/predictably-sized values/types at this point thanks to constexpr) are unrolled/inlined until the point where they are used in a non-constant expression, then those values (also visible to compiler optimizations) are stored directly in the binary, intermediate values are discarded (maybe cached by the compiler but not added to the assembly), and the assembly for the instantiation ends up being what you'd get (after the other usual optimizations) for just the non-constant expressions given the cached constants and the non-constant value(s). or it would be, except it's a template instantiation so it's probably inlined. it may not always be a big difference (though even trivial cases can benefit, like if the compiler unrolls a loop because it's obviously deterministic due to a constant boundary), but in more complex cases it can eliminate potentially many runtime operations

>>62036528
>The question is, will the compiler be smart enough to not emit a shitton of repeated code?
yes, only one (probably inlined, especially if constexpr) instantiation is generated for each unique value of n used. and in fact, similarly to intermediate/unused constexpr values, constexpr functions and instantiations used only in constant expressions and not at runtime are discarded

>Unless the function gets inlined, I don't trust it not to
template functions are inline by default except in the case of explicit instantiations
>>
>>62038782
Is loop unrolling really worth it for all the icache misses you're going to take with the code bloating up?
>>
>>62035597
should I go py 2 first or 3 instead and back to 2 if needed?
Thread posts: 324
Thread images: 56


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