[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: 320
Thread images: 38

File: extremely sexual.gif (2MB, 500x281px) Image search: [Google]
extremely sexual.gif
2MB, 500x281px
old thread: >>61579801

What are you working on, /g/?
>>
First for C.
>>
>>61585395
Project with angular front end, mvc/aspnet c# backend. Been working on it for a year and we are going live in a month. No personal projects atm though
>>
File: 4hacker.jpg (134KB, 748x641px) Image search: [Google]
4hacker.jpg
134KB, 748x641px
third for why the fuck is emacs still single-threaded
>>
>>61585438
Lisp is beautiful. But not that code. If you knew lisp you'd know that code is pure evil. I thought he wanted his homework done for him so I gave him a solution that would be absolutely useless for him. If a student pulled out call/cc on a homework assignment in my class, you'd better believe I'd be intrigued and want to talk to him about lisp.
>>
So what arguments might you possess on the proposal that C is the god harboring language and all other languages are mere attempts to abstractify and dumb down the syntax for proto-human organisms commonly referred to as "normies"?

You must own yourself, spawnling.
>>
>>61585500
c is the only programming language
take a fucking hint why linux uses it
>>
>>61585510
because torvalds is autistic
>>
>>61585512
torvalds didn't create c u fucking nigger
>>
>>61585417
What does it do?
>>
>>61585512
Autists make the best prorgammers, though.
>>
>>61585523
web app. Not intranet, but set up specifically for employees. Manages paperwork, file uploading to an external file server, assigning courses and tracking the completed work for each user and each tree of subordinates from any given user. Also set up built in localization. The permissions are fucking horrendous and the user stories are huge novels of contradicting and nonsensical details. Been working on it for a year
>>
>>61585551
I would say it's currently around 100,000 lines of code
>>
File: 1468882928057.png (199KB, 439x392px) Image search: [Google]
1468882928057.png
199KB, 439x392px
Employed Haskell programmer here
>>
>>61585570
nice
>>
>>61585485
>Lisp is beautiful
For a commie tard language.
>>
>>61585551
Why does it have to be in the browsers and not just a standalone program? Is this how every piece of software will be made? I don't like this mang.
>>
>>61585395
my suicide note.
>>
>>61585586
when you say the haskell programmer is of type employed, is 'employed' type a monad or a real job. also where does a haskell programmer work?
>>
>>61585418
>multithreaded text editor
why

it's not an ide, doing that makes no sense
, besides don't GDB, make, and REPL plugins/commands spawn their own processes anyway
>>
File: m02.jpg (160KB, 778x423px) Image search: [Google]
m02.jpg
160KB, 778x423px
>>61585612
>where does a haskell programmer work
>>
>>61585601
i mean, if you want thousands of employees across the country working with the same data, you don't want it to be installed locally. You would have to have a central database somewhere anyway, no point in having the software installed on every computer when you can host the webserver with the database and make it a website.
>>
is anyone here autistic enough to have learned Terry Davis's HolyC?
if so, what's it like
>>
File: fuck_this_fucking_course.png (109KB, 922x606px) Image search: [Google]
fuck_this_fucking_course.png
109KB, 922x606px
>>61585617
sure, but it would be nice if I print out a few 100K/MB of text and not have my entire text editor be useless for the next 30 mins
pic unrelated
>>
>>61585622
>Yes sir i did give you a burger, there's just nothing occupying the burger space right now because the cook told me order up without passing the burger immediately sir. I COMPILED CORRECTLY GOD IS TO BLAME
>>
>>61585418
we should write our own editor :^)
>>
>>61585688
with spacemacs keybinds by default and malbolge as an extension language :DDDDDDD
>>
    movups m0, [expq + offset_pq]       ; exp[p0].re, exp[p0].im, exp[p1].re, exp[p1].im, exp[p2].re, exp[p2].im, exp[p3].re, exp[p3].im
movups m1, [expq + offset_nq] ; exp[n0].re, exp[n0].im, exp[n1].re, exp[n1].im, exp[n2].re, exp[n2].im, exp[n3].re, exp[n3].im

movu m5, [lutq + offset_pq]
movu m6, [lutq + offset_nq]

mova m15, [mask_5]
vgatherqpd m3, [inq + m5*8], m15 ; in[p0].re, in[p0].im, in[p1].re, in[p1].im, in[p2].re, in[p2].im, in[p3].re, in[p3].im
mova m15, [mask_5]
vgatherqpd m4, [inq + m6*8], m15 ; in[n0].re, in[n0].im, in[n1].re, in[n1].im, in[n2].re, in[n2].im, in[n3].re, in[n3].im

mulps m5, m3, m0 ; in[p]reim * exp[p]reim
mulps m6, m4, m1 ; in[n]reim * exp[n]reim

xorps m5, m14
xorps m6, m15

shufps m0, m0, m0, q2301 ; exp[p]reim -> exp[p]imre
shufps m1, m1, m1, q2301 ; exp[p]reim -> exp[p]imre

mulps m0, m3, m0 ; in[p]reim * exp[p]imre
mulps m1, m4, m1 ; in[n]reim * exp[n]imre

haddps m5, m5, m5
haddps m6, m6, m6
haddps m0, m0, m0
haddps m1, m1, m1


Is SIMD asm /dpt/-enough for /dpt/?
>>
File: 128704028121.png (55KB, 657x527px) Image search: [Google]
128704028121.png
55KB, 657x527px
>>61585395
New

When python 3 removed input and made raw_input the new input so that you can only receive a string reply from a prompt... Has this made receiving integers from prompts less efficient?

In other words:
is
a = input('enter number: ') in v2
faster than
a = int(input('enter number: ') in v3

????
>>
Is it against the rules if I show the game I've been working on? You have a house in a town and the goal of the game is to kidnap little lolis from around the town (there's a park and a school right now), and you take them to your basement. I've got the barebones of the breeding system done now, every loli that is spawned by default has random eye color, hair color and skin color., but the ones that will be birthed will depend on yours and the mother lolis genetics.
>>
How would you write this, /dpt/?

std::map<string, int>::const_iterator pos = boneMap.find(name);

if (pos == boneMap.end())
{
return -1;
}

return pos->second;
>>
>>61585812
I mean, does it matter? The difference in speed is going to be so tiny. If your program is going to bottleneck it's not going to be there.

If you are just curious, you could always create a timer before and after the operation and find out. It probably takes a fraction of a fraction of a second longer
>>
>>61585840
>std::map<string, int>::const_iterator
first off I'd get an auto
but I have to question why you're using std::map
>>
>>61585812
I don't think you can enter numbers fast enough into the input stream to actually see a difference anyway.
>>
>>61585839
so they drove you out of agdg and now you're spreading your filth here?
>>
>>61585840
(second (bonemap name))
>>
>>61585839
It hasn't stopped you in the past sick tuck.
>>
>>61585848
I am sending bones to the GPU. For this purpose, they need to be tightly packed into a vector. I do not want to send the bone names to the GPU, because that is useless data for rendering purposes. I do, however, want to keep a map of names to bone-ids, because I need that for reading bones from model files (as parent-child relationships in model files are declared using bone names).
>>
>>61585840
I would rewrite in a language which isn't complete garbage.
>>
>>61585839
what are you gonna do with that? If you had made something that wasn't so retarded, you might have been able to show it off to an employer some day, but now you've gone and made something you can never show to anyone in person and have to hide all the assets from anyone that might use your filthy computer
>>
File: scren.png (212KB, 568x431px) Image search: [Google]
scren.png
212KB, 568x431px
>>61585852
>>61585866
The art isn't graphic or anything, how am I sick? I am merely satisfying the market.
>>
what reasons might I have for using malloc in C++?
>>
>>61585890
you might have to call some see that needs something that is free-able?
you might not want a constructor to be called for some reason?
>>
>>61585889
r u a ju?
>>
>>61585395
please tell me this isn't supposed to be a "dragon"
>>
File: ancap.png (200KB, 547x402px) Image search: [Google]
ancap.png
200KB, 547x402px
>>61585889
>I am merely satisfying the market.
>>
>>61585807
as long as you're shitposting you're good on /dpt/
>>
>>61585890
>he doesn't even now about hoops sepples goes trough when ever you use new
Some zero cost abstraction right there.
>>
File: scren.png (46KB, 450x414px) Image search: [Google]
scren.png
46KB, 450x414px
>>61585883
I'm pretty proud and excited about the genetics system I've implemented (mainly because I know next to nothing about genetics, but it has been a fun learning experience). I think an employer would be impressed with it.
>>
>>61585909
Did you include racial IQ and behaviour?
>>
>>61585902
nukes are a helluva drug
>>
>>61585889
if you wanted to satisfy the market, you could go put on some booty shorts and stand on the market corner giving out 5 dollar hand jobs. You would have a better chance of finding someone who says yes than finding someone who wants to play your shit loli game
>>
Why are coders, people generally perceived as socially inept and misanthropic, among the more tolerable people on this shitty board? Jesus Christ, there are so many arrogant teens/early 20s faggots on /g/ who think they understand everything when they actually don't know shit about anything. Really awful community.
>>
>>61585924
that's a cool post but have you tried haskell? or are you still using lameass imperative oop trash from 12th century india
>>
>>61585908
I know new uses it, but I was asking why might a programmer use it
>>
>>61585909
>wow anon thats super impressive. We want to hire you, but we had to call security because what you just showed us borders on child pornography
>>
>>61585931
Yes. Yes. Yes. Yes.
>>
>>61585922
I would play anon's loli game.
>>
File: scren.png (56KB, 567x422px) Image search: [Google]
scren.png
56KB, 567x422px
>>61585922
You seem to be pretty angry at me for some reason, I can't imagine being so upset at somebody I don't even know for a game he is making that I've never played.

>>61585913
I definitely plan on implementing behavior, but right now the genetics system only affects physical traits of the loli. Here is an example of the traits you can view of a successfully kidnapped loli.
>>
>>61585945
I remember these exact images being posted a year ago, filthy imposter.
>>
>>61585945
this is pretty fucked up bro
>>
>>61585953
not much progress maybe
>>
>>61585839
do it
>>
>>61585920
I cannot support this thread
as everyone knows, dragons represent satanic forces
>>
>>61585945
I can 100% support the concept of Loli breeding tycoon

You could implement a market system where you can sell them globally to different buyers for prices based on dynamically changing desirable traits. Like, Arabs may pay great amounts for virgin lolis.

Then you could have a transport aspect of the game where you have to choose the best way to distribute lolis. Like, if you put 100 on a boat in a shipping container and 20 die on the journey. This triggers more 'heat' from police as part of the outlaw mechanic of the game.

If the lolis get elderly (18+), you can start whoring them out or chop them up and put them into feed for the current herd of growing lolis.
>>
>>61585840
In Rust, this is just
let int = boneMap.get(&name);
>>
>>61585840
By using pig-disgusting exception-throwing methods, like any sepple piece of shit would do.

return boneMap.at(name).second; // could throw std::out_of_range, but who cares lol
>>
File: 1350594293765.jpg (111KB, 500x500px) Image search: [Google]
1350594293765.jpg
111KB, 500x500px
The following function runs rather slow:

VertexBoneData emptyData;

for (unsigned int i = 0; i < amount; i++)
{
boneData->push_back(emptyData);
}


Amount in my current case is the number 3024. Is there a faster way to add a large amount of the same data repeated over and over again to a vector?
>>
>>61586234
exceptions are considered harmful.
>>
>>61586274
>>61586271
C++ is considered harmful.
>>
>>61586271
boneData.reserve(amount);

Call this before your loop, you may be doing a lot of unnecessary reallocations.
>>
>>61586271
Add `boneData.reserve(boneData.size() + amount);` before the loop.
>>
>>61586278
Software sucks. That statement is more reliable than saying that the sun will rise tomorrow.
>>
File: 1499449150729.jpg (799KB, 1080x1080px) Image search: [Google]
1499449150729.jpg
799KB, 1080x1080px
>>61586311
>>61586307
That sped it up quite a bit! Thanks!
>>
for(int i = 0, n = strlen(plainText); i < n; i++){

//Get key 0-Indexed.
if(isupper(key[i])){
ki = (key[i] - 65) % keyLen;
}else{
ki = (key[i] - 97) % keyLen;
}
printf("K(i) = %i\n", ki);


Why do i get the result "1,0,2,4,3" instead of "1,0,2,14,13" when using the key "bacon"?
The first 3 ints are correct but the last two are ten lower then they should be.
>>
>>61586342
All software is bad, but not equally bad. There is a difference between mediocrity and an infinitely dense void of confusing bullshit, of which modern C++ is neatly in between.
>>
>>61586365
I'm going to assume because keyLen is 10.
Why are you even taking that remainder here?
>>
File: opengl-next-vulkan.jpg (235KB, 720x480px) Image search: [Google]
opengl-next-vulkan.jpg
235KB, 720x480px
Any people with experience with vulkan here? Can it really be true that you have to make an entire Graphics Pipeline for every set of shaders you have? Or am I missing something here?
>>
>>61585395
I'm working on an automation tool which will automatically apply for jobs so that my unemployed ass can spend less time searching and more time shit posting.
>>
>>61586427
productive. I like it <3
>>
>>61586401
No, you're missing a lot.
You init your shaders first.
You then init a pipeline layout where you specify what your shaders consume.
You then init the pipeline itself and specify your shaders in VkGraphicsPipelineCreateInfo.
Then you write the fucking descriptor sets and descriptor sets layouts and you allocate them.

Then you're finally fucking done.

So much fucking boilerplate but at least its not openfuckgl.
>>
>>61586653
> So much fucking boilerplate but at least its not openfuckgl.
Just use Unity :^)
>>
>>61586653
Holy crap thanks dude. This actually clears up a lot
>>
What language should I learn?
What socks should I buy?
>>
>>61586734
>What language should I learn?
Depends on what you want to do.
>What socks should I buy?
Depends on what you want to do.
>>
>>61586734
C.
White ones that go up to your ankle.
>>
>>61585945
Release when
>>
>>61586734
Rust/Haskell
Striped thighhighs

>>61586748
>programming in regular socks
shiggy diggy
>>
>>61586760
>>programming in regular socks
Actually, I program barefoot most of the time.
>>
>>61586746
I want something multipurpose to learn the basic principles with. The socks are for improved coding/comfort and occasional legposting.
>>
>>61586766
Fucking disgusting.
>>
>>61586748
>white socks
not pimpin'

>>61586752
in about 30 seconds if you keep that up
>>
>>61586777
What
>>
For people who use
void foo()
{

}

style in sepples, how do you write constructor initializer lists?
>>
>>61586773
Why the fuck would I want to wear socks or shoes around my house?
Bare feet is more comfortable.
>>
Give me reasons why I shouldn't go full ruby.
>like perl, nice for hacky oneliners
>like python, without whitespace and other crap
>human-readable code which makes fun to write
>>
>>61586783
void MyClass::MyClass( )
: member1(1)
, member2(2)
, member3(3)
{
}
>>
>>61586792
it's a German thing

>>61586796
because coffeescript exists
>>
>>61586783
MuhClass::MuhClass() 
: _muh_filed(0), _another_field(10)
{
}
>>
>>61586792
Because programming socks improve your abilities.

>>61586801
Germans have different reasons.
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>61586798
>>61586804
People actually defend this retarded syntax?
>>
>>61586710
https://github.com/atomnuker/mpv/blob/master/video/out/vo_vulkan.c#L1444

This is generally the sequence you should follow.
>>
>>61586770
>legposting
Pick some long multicolored socks then
>something multipurpose to learn the basic principles with
If you're refering to the basic principles of how programming works, then pick any programming language, preferably something that has garbage collection so you don't have to worry about that shit. I would recommend something C-like such as C#, Java or one of the other high level languages. If you want to know the basic principles of the particular programming language, then pick a simple language such as Python.

In any case, I would not recommend a low-level language, even though they are the best languages. If you are an absolute beginner you should try to ease yourself into it. Going balls to the wall and picking C or Assembler to begin with is simply suicide.
>>
>>61585586
I'm sorry.
>>
I am trying to build a bot for cryptocurrency but having some trouble with the buy list. I want the bot to figure out on its own (without intervention) when the best time is to buy.

I collect first 5 buy orders with the API of the market and want the bot to determine what the best buying position is (without human interfention). The buy function is already tested and working no need to worry about that.

Below I have posted several buylists examples, the order with the arrow is as illustration of where I want the bot to buy in.

Example 1:

Price:                Amount:
0.00004789 64.47159971
0.00004362 example <-------- the order needs to be placed here
0.00004361 128.43288429
0.00004359 34.10957392
0.00004358 499.82162883


The order should be placed at 0.00004362, since the 0.00004789 is way higher and low amounts.

Example 2:

Price:                 Amount:
0.00110315 158.09238424
0.00105804 example <-------- the order needs to be placed here
0.00105803 63.02394783
0.00105788 35.95463452
0.00105782 845.85935683


The order should be placed at 105804 since 110315 is way higher.

Example 3:

Price:                 Amount:
0.00207072 15.41045841
0.00205354 example <-------- the order needs to be placed here
0.00205353 1231.49999250
0.00203350 0.09370000
0.00203329 62.24255008
0.00203323 0.54499918


The order should be placed at 0.00205354, ignoring 207072.

Example 4:

Price:                 Amount:
0.00244414 12.41045841
0.00244385 example <-------- the order needs to be placed here
0.00244384 25421.49999250
0.00243350 55.09370000
0.00243221 62511.24255008
0.00240323 875.54499918


The order should be placed at 0.00244385 since 0.00244384 has a big buy wall (25k).

What is a good way to get the results I want? I am using Python.
>>
File: 1376813888542.jpg (33KB, 285x281px) Image search: [Google]
1376813888542.jpg
33KB, 285x281px
>>61586810
>Because programming socks improve your abilities.
This is honestly one of the lamest and most retarded maymays to plague this fucking board.
It wasn't funny fucking 2 years ago or whenever it fucking started, and it certainly isn't funny now.
>>
>>61586812
>defend
?

You asked me how I do it, and I posted how. A lot of C++ syntax is overly verbose, but luckily C++17 constructs are addressing this issue.
>>
>>61586828
He's not that anon who asked.
How is C++17 improving it?
>>
File: Thumbs up.jpg (48KB, 474x460px) Image search: [Google]
Thumbs up.jpg
48KB, 474x460px
>>61586813
Oh, cool! Thanks dude!
>>
>>61585510
Torvalds, like most C programmers, don't know what their talking about when it comes to C vs better languages.

C++ is just simply better for everything that C can do including kernel development.
>>
>>61585839
Are you that lolisim dev?
>>
>>61586854
C++ doesn't even have designated initializers.
>>
>>61586796
Ruby is so fucking slow that it's even an annoyance when writing programs that aren't performance critical.

Comparing Perl to Ruby is also laughable here, at the very least because using Perl for "real" tasks is so convenient that you will probably do it anyway.
>>
>>61586854
Stroustrup, like most sepples programmers, don't know what their talking about when it comes to sepples vs better languages.
C is just simply better for everything that sepples can do including kernel development.
>>
>>61586854
Rossum, like most Python programmers, don't know what their talking about when it comes to Python vs better languages.
Lisp is just simply better for everything that Python can do including kernel development.
>>
>>61586827
it's just more gay propaganda masquerading as a meme
>>
>>61586902
>Lisp is just simply better for everything that Python
it's not as funny when everyone already agrees
>>
>>61586908
normies can't read lisp
>>
>>61586854
if you honestly believe that you're a fucking cock eating faggot.
>>
>>61586827
Being extra comfy helps.
>>
>>61586817
Thanks
>>
>>61586922
no one can read lisp it's why we have editor plugins do it for us
>>
File: lisp_is_dead.png (29KB, 1154x612px) Image search: [Google]
lisp_is_dead.png
29KB, 1154x612px
>>61586908
Yet again Lisp-tards are delusional.
>>
>>61586927
t. blub

If you honestly think that C++ is somehow not suitable for writing kernels in, you actually have absolutely no idea what you're talking about, and you have no clue about kernel development or programming languages.
>>
>>61586952
What C++ features are useful in kernel development?
>>
>>61586945
better != more practical
>>
>>61586965
Templates
RAII/smart pointers
Move semantic
>>
>>61586969
>Templates
Good job halving your icache hit rate
>>
holy c is called holy c for a reason you fucking cia nigger.
>>
>>61586965
All of them except for exceptions and rtti.
And even those become useful once you implement the runtime support for them but exceptions are crap anyway, and you don't really need rtti.

C++ features are good for programming in general. A Cfag wouldn't know.
>>
>>61587006
what even makes it different from C?
>>
>>61587011
it's holy wtf are you stupid?
>>
>>61587010
name one thing you can do in c++ that you can't do in c..
/kill you're self
>>
>>61586985
It actually promotes icache locality by facilitating inlining, jumping around is way worse for the cache. Plus it makes in-place generic data storage possible, see the eternal std::sort vs qsort shitstorm for more.
>>
>>61587030
implicitly free memory unintentionally by taking a smart pointer to something inside a container
>>
>>61587030
> name one thing you can do in c++ that you can't do in c..
Write an efficient generic sorting function.
>>
>>61586854
He is right about C++ having bad standard library though
>>
>>61587034
aggressive inlining by itself is already something you don't want in a kernel, a small memory footprint is more important
>>
>>61587043
post the code
>>
>>61587030
That's easy, and I'll name a few off the top of my head:

Efficient containers through use of templates, and the ability to be specialized and optimized for specific types of types.
RAII
Move semantics
constexpr functions
type traits

I'm sure there's more.
>>
>>61587030
accidentally invalidate your iterators
>>
>>61587048
It's not the best, but it certainly isn't bad. That's just a meme.
And it's been improving a lot since C++11, and especially since C++17.
>>
>>61587049
Good point, but it's relevant mostly for embedded systems.
>>61587050
https://github.com/llvm-mirror/libcxx/blob/master/include/algorithm#L3996
>>
>>61587094
Bullshit, language revisions haven't fixed STL at all. Where's the non-retarded vector<bool>? Where are the good streams? Where are the efficient maps?
>>
>>61587091
>accidentally
You can't have you iterators "accidently" invalidated.
You were stupid and didn't bother to lookup under what conditions your iterators get invalidated.
You probably tried to use an iterator after deleting an element behind it.
>>
>>61587094
I've never understood how piling shit onto a pile of shit is supposed to make it better.
>>
>>61587106
>revisions haven't fixed STL at all
It's not broken.

>Where's the non-retarded vector<bool>
You can't just break backwards compatibility (although I wish they would with C). It's a mistake and it'll probably stay unfortunately.

>Where are the good streams?
In the standard library. Literally the only thing people complain about is the syntax, and I agree, it sucks.

>Where are the efficient maps?
It's trivial to write your own. It's not like I said that the stdlib is _finished_ improving, it's still improvING.
You can't call it bad. Consider that we now have std::optional, std::variant, std::string_view, and std::filesystem. It's improving, just slowly.

>>61587110
No, it's like putting your favorite topping on your potatoes.
>>
>>61587155
>C++XYZ is filled with garbage features
>B-but C++XYZ+3 is g-going to fix everything! J-use you w-wait!
Can we end this farce already? Just fucking put it down.
>>
>>61587155
>It's not broken.
>Here are all the mistakes we can't/won't fix (maybe in 6 years)
>>
>>61587172
And yet it still manages to be more usable and efficient than C.
>>
>>61587198
This has nothing to do with C, though.
You fags really have been repeating this same garbage for ages, and the language is still a massive broken clusterfuck.
>mode efficient than C
Are you fucking serious? C++ is FAR more inefficient than C.
>>
>>61587213
>Are you fucking serious? C++ is FAR more inefficient than C.
Care to provide examples? Because my experience with C++ tells me otherwise.
>>
>>61587213
>C++ is FAR more inefficient than C.
Only if you write it in an inefficient way. C++ lets you be lazy and use prepackaged datastructures and algorithms, but also gives you the freedom to drop down to C and optimize where it's necessary.
>>
>>61587231
Except it's not necessary because the standard containers are plenty efficient. In fact you should not be dropping down to C at all.
>>
>>61587228
Go look at any real benchmark. 99% of the time, C wins. Your memelang doesn't even have restrict pointers.

>>61587231
C++ literally encourages you to write in a retarded and inefficient way.
>>
>>61587241
>because the standard containers are plenty efficient
It's very hit or miss, it's not hard to make a map faster than std::unordered_map.
>>
>>61587237
>u
Ah, C users are just kids.
>>
>>61586823

Could someone answer this question?
>>
>>61587241
>standard containers are plenty efficient
Then why does every bigger sepples project implements their own container?
>>
>>61587311
They don't.
Maybe one or two do, but that's because they're retarded, or they're stuck with a shitty implementation of the STL.
>>
>>61585889
Github repo?
>>
>>61587339
Why would you talk about sepples if you have never programmed in it and have never seen sepples projects?
>>
>>61584095
>std::vector doesn't have small size optimization
Correct. LLVM use their own vector internally for this reason. I do believe it's mostly because of stack space use and not cache misses though. But both are valid reasons.
I don't really see the situation where you'd care much about a cachemiss when accessing the first element of a vector. And I hope that CPUs can understand the vector as a construct enough when it's 'zero cost abstractions' are optimized away so you don't take the full cachemiss.

But generally C doesn't let you express generic structures efficiency.
>>
>>61587377
Is the small size optimization really that useful on a generic vector? Unless it's a vector of chars I can't imagine you'd get much space locally.
>>
>>61585395
Why is she being so lewd?
>>
>his github contribution graph doesn't look like this
literally baka @ you desu famalam
>>
>>61587377
>. LLVM use their own vector internally for this reason.
C++ is such a fucking joke

CS fags are a bunch of dumb fucks warming the planet
>>
>>61587476
>working an anything but your own projects
B A K A
A
K
A
>>
>>61585812
>more efficient
Depends. Any reading from stdin would have you interpret the stream. If this were C and you input a binary integer stream for instance you wouldn't need to convert it. If it's input as strings you need to convert it.
The reason one method would be faster than the other is if you have to jockey types back and forth. If input() doesn't understand that you wrote int(input()) in the semantics of the language (most interpreted languages don't). The code generated wouldn't skip any hypothetical string conversion and it would go from raw stream -> string -> int.
>>61585844
>>61585849
Depends on what you're doing. Some programs use stdin to process streams of data from other programs (for instance if you use ffmpeg and omit the output file and put a - on the end of your args instead it outputs to stdout, which can be redirected to stdin for other programs).
I say that if you use python you should be 100% accepting of its limited speed and simply ignore that. If you attempt to consider performance in the language you lose any gain you'd have from using python over something like Java, C or C++.

If you want performance in python you write C functions and bind to them. I'm sure you could write an OK C function that reads stdin effectively for you and converts to the right types if you really cared.
>>
File: 1448712987446.jpg (118KB, 900x641px) Image search: [Google]
1448712987446.jpg
118KB, 900x641px
>>61587491
>not putting your personal projects in private repos on github so you can still get green squares in your contribution graph
extremely baka
>>
>>61587109
my point is that it is done implicitly
intuitively, if I realloc() my buffer, I know that it can be moved. However, for a language that presents itself as """""''"""`'`'`'"""high level"""`'''`'`'"" :^)
C++ still surprises you by invalidating your iterators when you add/delete elements, because they are really just pointers in disguise.
The whole point of abstraction is to hide that shit away, yet in C++ I have to keep even more inside my mind when programming.
>>
>>61587411
Well. I don't use a small size optimized vector but llvm does use them. They don't tend to use things just because. They wish llvm to be a great compiler backend and it is. JAI achieves it's great compile times using it (and not being a hog at the front end like C++ is). So I don't doubt that they know what they're doing.

The nice thing about a small size optimized vector is that it's just an optimization. It doesn't change the semantics of your program. It should be in the standard if they cared. Imo the C++ standard is overdefined. It's not the C way and that's why many people object to it and you get large libraries like Boost.

It's difficult to appreciate how much it matters though.
Chandler talks about llvm datastructures and their use here:
https://youtu.be/vElZc6zSIXM
It's a talk that presumed knowledge from this talk though:
https://youtu.be/fHNmRkzxHWs
Both are worth a watch.
>>
>>61587522
>being a slave to Sjwhub commits
>>
File: 1501075816324.png (283KB, 1024x1099px) Image search: [Google]
1501075816324.png
283KB, 1024x1099px
>>61587549
>h-hey look guise i attached SJW to $OBJECT's name now you can't enjoy or use $OBJECT
"no"
>>
>>61587522
>giving your code for free

fucking lol, at least use bitbucket instead of shitty github
>>
>>61587525
Stick with C, its at your level :^)
>>
>>61587566
Its not even just that desu.
Trying to show off your commit history is as sad as kids showing off their steam achievements.
>>
>>61587567
>bitbucket
>just use a platform that has 0 community because i said so lol
no
>>
File: face.jpg (9KB, 180x201px) Image search: [Google]
face.jpg
9KB, 180x201px
>>61587571
listen here you piece of shit
I have to use this shit language called "C++" every fucking day
It's not "too hard"
I am not a "brainlet"
It's just a language created with the sole purpose of giving you nice abstractions above an existing language is an absolute fucking failure if it in fact requires you to have to understand _even more_ than before - what the fuck is the point of encapsulation at all in that case
>>
>>61587593
>stop doing things i don't like
t. 0 commits in last 365 days
>>
File: C++ designers at work.gif (1MB, 338x180px) Image search: [Google]
C++ designers at work.gif
1MB, 338x180px
>>61587479
>>
>>61587609
2*
But i just started another project
>>
>>61586827
Of course it isn't funny, it's just fact.
>>
>>61586392
I'm trying to make a Vigenere Cipher. keyLen should be 5 because thats the length of the "Bacon" key string.
>>
>>61587522
How am I supposed to use a private repo on github? I don't want to share my own private projects because its embarassing.
>>
>>61587775
>being embarrassed to share something on the site that hosts left-pad
You shouldn't be.
>>
File: Untitled.png (11KB, 1003x207px) Image search: [Google]
Untitled.png
11KB, 1003x207px
>>61587476
But that's just private stuff, have some more on GitHub.
>>
>>61587597
>muh community

bitch you want to have your code up somewhere private or you want to flap your dick around like a faggot?nobody cares if you want to play tetris with your shitty activity monitor, only bored retards who don't know how to make use of their time do so.

If you had such a big project/product that needed contributors so badly it wouldn't matter at all if it was on github or bitbucket or even MS's service

What the fuck is this new github gay shit?Literally worse than people sucking dick for likes on jewbook.
Have fun naming your variables to PC-standards so people won't get triggered if you get a little edgy with your naming
>>
>>61587659
le xdd

eipc maymay m8


:^)
>>
>>61587854
kys
>>
File: cobol-60.png (140KB, 629x797px) Image search: [Google]
cobol-60.png
140KB, 629x797px
I wonder how come Perl doesn't have this.
>>
>>61587597
>0 community
You said you wanted green dots or whatever. Why does community matter if it's a private repo and you're not gonna open source it?
He should have recommended gitlab though.
>>
>>61587917
i actually wanted to say gitlab but bitbucked came first into mind

Whatever... anything is better than github, that if one chooses to upload his code on the internet, which i don't see a good reason for
>>
>>61587806
holy shit you sound incredibly triggered and low IQ

i feel bad for your parents, the shame they must live with
>>
>>61587476
Reminder that the industry average lines of code per day judging from shipping size is 10 loc.

Most of your shit is gonna be deleted.
>>
>>61585688
I'll make the logo!
>>
>>61587934
I actually think bitbucket is better. It gives you a customizable web interface which allows you to create your own graphs for unlike anyone else. But gitlab is more for the general crowd so I recommend that to people.
>>
File: Girls.jpg (77KB, 600x536px) Image search: [Google]
Girls.jpg
77KB, 600x536px
>>61587945
>he actually aspires to be average
>he holds up his 10 LOC/day average as if it's something to be proud of
>>
>>61587973
Perhaps you didn't get it. Point was that your commit size isn't important it's what you commit. So you bragging about your commit size means you probably don't care about your programming efficiency.
>>
>>61587546
>32:25
>move constructing is slower than return by value
>because C++ has a language bug
Fuck, why do people still use this SHIT
>>
>>61588017
>muh less lines of code is better meme
by your logic not programming at all is more efficient and makes you a better programmer
>>
>>61588062
Yes if you could not program at all and get your task done you'd be an amazing programmer.
0 memory use
0 runtime cost
0 compile time
0 development time.
S+ score.
>>
>>61588062
>Shitting out haphazard code and boilerplate makes you a better programmer.
Java codemonkey detected.
>>
>>61587937
>let me just call names because i got no counter-argument
if you had "the time" to reply with your garbage you might aswell explain your reasoning faggot
>Low IQ
>muh iQ jewish invention
Congrats on accepting false pseudo-science, human intelligence is not limited to memory & pattern recognition(although many people would agree that those are the most important functions of it)

Go watch bill nye and name your variables after his gender-spectrum bullshit so github would comply with your project
>>
File: 1355977278620.png (158KB, 454x404px) Image search: [Google]
1355977278620.png
158KB, 454x404px
>>61585605
Tell me what text editor you are writing it in so I can make fun of you for that
>>
File: file.png (14KB, 852x299px) Image search: [Google]
file.png
14KB, 852x299px
>>
File: indentation.png (66KB, 597x255px) Image search: [Google]
indentation.png
66KB, 597x255px
>>61588062
Not him, but less lines of code is usually better than being Microsoft and write 10k lines for something that could be done in 100.

More lines of code doesn't equal better code.
>>
i'm installing gentoo!
>>
>>61588121
>||
They use this to append?
>>
>>61588112
>although many people would agree that those are the most important functions of it)
Precisely. IQ isn't the ultimate indicator of intelligence, but if you have a low IQ you're far more likely to be stupid than someone with a high IQ. I'm sure you don't have a problem with IQ when you post your bell curve images showing how inferior niggers are.
>>
>>61588136
no, print i if no value was found in the map.
>>
File: fizzbuzz.png (55KB, 480x270px) Image search: [Google]
fizzbuzz.png
55KB, 480x270px
>>61588121
>>
File: cobol-60.png (16KB, 398x188px) Image search: [Google]
cobol-60.png
16KB, 398x188px
>>61587910
It's getting better and better.
>>
File: 1375670617230.jpg (233KB, 503x503px) Image search: [Google]
1375670617230.jpg
233KB, 503x503px
>Update my archlinux system
>There are always like 10 random haskell library packages being upgraded for some reason
It's time to uninstall this shit from my computer.
>>
>>61588189
>Been reading the Idris book
>Have Idiris installed from the community repo
>A single package, everything is statically linked, ~150Mb, works for me
>For some reason Arch decided to refactor Haskell packages in late June
>Now Idris requires ghc (800+ Mb) and like 30+ small packages with dynamic versions of common Haskell libs
I removed Idris since I'd read the book by that time, I have no idea why they did this.
>>
>>61585889
Wait is this the infamous loli sim?
>>
>>61588189
760 MB I saved by removing that shit.

>>61588240
I see why they did it, but it's still annoying.

>>61588244
Yes.
>>
>>61583180
>Neural network propaganda
Does this happen?
>>
>>61587476
>Xtreme go horse possible detected
>>
>>61588137
You think after i explained my reasoning for IQ not being a relevant indicator of intelligence, that at the same time i post IQ bell-curve images and larp about being whiter than a nigger?

I'm not that hypocrite my friend, essentially nothing objectively indicates someone's intelligence.
Making good decisions in life would be closest way for it, since many geniuses gave life to kids who turned up to be rather stupid in comparison to their parents.But that's the beauty about it:the ability to think about the future & choose the best course of action to one's best ability
>>
I'm a noob and need some advice please:
class MyClass {
public:
bool const operator==(const std::string& arg) {
//make comparison and return appropriate value
}
}

//...

std::vector<MyClass*> vector_of_pointers;
//populate the vector

//...

auto foo = std::find(vector_of_pointers.begin(); vector_of_pointers.end(); "bar");


Now obviously this doesn't work. Now, how can I make it work?
I could always use a vector of objects instead but I'd like to avoid that if possible. Is there a better way than manually looping through the vector, and basically reimplementing std::find but with added dereferencing?
>>
>>61588396
Operator== is defined on MyClass values, but the vector stores pointers. In general, you don't really need to store pointers in a vector, just store values directly. If you really need to store pointers, store them as std::unique_ptr's and provide your own comparison function that would dereference them before comparing.
>>
>>61588396
How about:
auto foo = std::find_if(pointers.begin(), pointers.end(), [](auto *ptr) {
return ptr == "bar";
});
>>
>>61588441
>return ptr == "bar";
shouldn't it be return *ptr == "bar"; ?
>>
>>61588441
this, except you forgot to dereference ptr
>>
>>61588505
>>61588512
Yeah my bad, or just replace "auto *ptr" with "auto ptr".
>>
>>61588519
That just makes it less clear
>>
>>61585395
smart anime poster
>>
>>61588436
I was using pointers because I reference the objects from a few different places, so a shared_ptr actually looks interesting.

Or I could refactor things to use the direct objects in this particular instance, though I'm learning C++ and want to experiment with some stuff.

>>61588441
This is actually pretty much what I was looking for. Though >>61588519
shouldn't it be
 ...[](auto ptr) {
return *ptr == "bar";
}

? I.e. take in the pointer, then dereference before comparison?
>>
Which language or technology should I learn to maximize my chances of getting a good job? I already know the basics of programming so it's mostly picking up the syntax and familiarize with how it works
>>
>>61588571
Haskell
>>
>>61588571
>>61588581
Forgot the rest of the post

Chances are you won't get a job programming Haskell, but you will acquire useful skills that are becoming more and more transferable as all languages adopt FP
>>
>>61588571
What do you want?

You can learn Assembly and earn $300k, but good fucking luck actually finding one of those jobs. Or you can learn Javascript and get employed within the week, but you'll be earning $30k and be working only with pajeets and niggers.
>>
File: IMG_0932.jpg (31KB, 318x314px) Image search: [Google]
IMG_0932.jpg
31KB, 318x314px
>>61585889
Amazing. Whether you should have made this abomination or not isn't important, what matters is that you can. And you did. Some people will call you a sick fuck, and they're right, but I see the big picture. What you're creating is a form of art, not too removed from Marquis de Sade and his writings. Offensive and disturbing, absolutely. But maybe historic.
>>
>>61588560
Doesn't matter if you declare auto *ptr or auto ptr, but you have to dereference before comparing.
>>
>>61588614
Wait, but if you declate a *ptr, won't you get a pointer to a pointer?

Or wait I think I'm a nigger. The find_if will pass a MyClass* either way, so declaring either 'ptr' and '*ptr' in the predicate will work, right?
>>
>>61588647
Yeah it's gonna be MyClass * either way.
>>
>>61588647
That's right.
>>
>>61588683
>>61588693
Thanks! And today I learned C++ lambdas.

Unusual syntax but makes sense
>>
File: 1501014959169.jpg (33KB, 217x395px) Image search: [Google]
1501014959169.jpg
33KB, 217x395px
Wrote a multithreaded proxy checker in python. I am just learning how to use multithreading efficiently, does anyone see obvious way to optimize that I am blundering?

https://pastebin.com/sMFzgWjy
>>
>>61585839
jesus christ
>>
>>61588715
It'll make more sense after you learn how the variable capture list works.
>>
>>61588715
You should probably read on captures:
http://en.cppreference.com/w/cpp/language/lambda
>>
File: moon.jpg (14KB, 480x360px) Image search: [Google]
moon.jpg
14KB, 480x360px
>>61588719
>multithreading
>python
>>
>>61588741
Did this post fulfill your daily social interaction for the day?
>>
>download SoloLearn
>start C# course
>a few minutes in it wants me to install Visual Studio
Is there an app I can use to learn anywhere?
>>
>>61588719
>multithreading and urlib
just use gevent based requests you mong
>>
>>61588762
Yeah, it's called "a book".
>>
>c++11 doesn't allow auto parameters in lambdas
Fugg, all of you lied to me
>>
Wrote game engine in C.
What statically typed language should I use with it?
Don't want to write whole game in C and """scripting languages""" suck.
>>
>>61585975
fuck off Artorious
>>
>>61588793
C#
>>
>>61588793
You should rewrite it in Rust.
>>
>>61588783
generic lambdas were introduced in C++14
>>
>>61588762
Why wouldn't you use VS if you're writing C#?
>>
>>61588804
fuck off microcuck. C# isn't even a real programming language.
>>
>>61588783
Use C++14 which is basically a slight improvement over C++11 that addresses all the crap that's inconvenient.
>>
>>61588793
>Wrote game engine in C.
Neat. 3D? or just a 2D engine?
>>
>>61588591
I want good money and good work environment, what's the middle path?
>>
>>61588793
What is in a game engine?
>>
>>61588804
seconded. it's easy to call into C libs and C# is a great language in its category (in other words it beats the shit out of Java)
>>
>>61588819
Because I'm on my phone.
>>
>>61588814
and you should stop posting.

>>61588834
3D

>>61588842
Resource manager, functions to initialize the graphic system and functions to manage it, GUI and way to load plugins.
>>
>>61588853
That sounds very uncomfortable.
>>
>>61585622
>implying that haskell programmers could talk to people all day as a job
>implying haskell is not sperglang
Try harder anon.
>>
File: 1499479373631.png (29KB, 741x568px) Image search: [Google]
1499479373631.png
29KB, 741x568px
struct A {
float foo[2];
float bar[8];
};

struct B {
float foobar[10];
};

union {
A a;
B b;
} shiggydoo;


in C++, can i write a float to shiggydoo.a.bar[0] and then read the same value back from shiggydoo.b.foobar[2]?
>>
>>61585883
If the engine is well programmed he should be able to swap out the Loli assets for other less offensive shit.
>>
>>61588871
Kill yourself dumb frogposter.
>>
>>61588865
I know, but I need to learn at some point.
>>
>>61588839
>good money
I guess become a good corporate Java code monkey

>good work environment
The tech industry is such a meme nowadays that you're either going to be working with pajeets, or in """progressive""" enviromnments.

You want to look for systems programming or something, but these aren't very easy to find. The assembly-type job at $300k is pretty much perfect in my opinion but yeah, you're gonna have to work on that.
>>
>>61588871
You should be able to but the best way to be sure it testing it
>>
>>61588861
>3D
What API are you using? I'm interested, because I am writing one too and is concerned about the amount of spaghetti I have around vertex transformations. What architecture are you using?
>>
>>61588441
>>61588614
>>61588683
>>61588693
>>61588738
My segfaulting, thrice-refactored piece of shit finally works as expected and is much more elegant to boot. Why do people even use stackoverflow when /dpt/ exists
>>
>>61588904
>the best way to be sure it testing it
what if it's undefined/implementation-defined behavior and it ends up breaking later on
>>
>>61588762
C# and VS is really one of the things where you just go with the flow.
Every part of the C# ecosystem is tied into VS/Windows.
There's Mono, but again, it basically tries to replace VS as the provider of that ecosystem.
>>
>>61588871
You """can""", but it would be an undefined behavior. Reading from "inactive" union member is an UB, and "active" union member is the one which was the last written into.
>>
>>61588908
>What architecture are you using
This for cross platform graphics
https://github.com/bkaradzic/bgfx
Stole the resource manager from horde3d, does not yet implement animation system.
>>
What language can I learn on my phone?
>>
>>61588934
wrong

https://stackoverflow.com/questions/15277819/are-anonymous-unions-acceptable-for-aliasing-member-variables-in-a-struct
>>
>>61588871
Sometimes. Most compilers would compile that in a way that would let you do so, but the ability to do it is not guaranteed by the standard
>>
>>61588871
C++11 §9.2/19:
>If a standard-layout union contains two or more standard-layout structs that share a common initial sequence, and if the standard-layout union object currently contains one of these standard-layout structs, it is permitted to inspect the common initial part of any of them. Two standard-layout structs share a common initial sequence if corresponding members have layout-compatible types and either neither member is a bit-field or both are bit-fields with the same width for a sequence of one or more initial members.
i'm not sure but the float arrays are probably layout-compatible types?
>>
>>61585812
As others have said, there's no effective difference. But you should note that v2's input() used to be more like v3's eval(input()) -- which is far less efficient than doing int(input()).
>>
>be developing in python cause muh fat dev time
>implementing some iteration
>shit runs and even does the right thing !!!
> but converges slowly as fuck
>can't figure out why (hey maybe the algo is just shit)
>editor says nothing
>py2 and py3 interpreters say nothing
>after reading the code a bunch of times and trying to improve notice I randomly wrote +- instead of +=

fuck you pythonfags you fucking retards
>>
>>61589006
you're the only retard here
>>
>>61589006
I hate python too, but this is the fault of your dumb ass.
>>
>>61589006
how's that python's fault you drooling retard
you could have made the same mistake in any other language
>>
>>61588989
>the float arrays are probably layout-compatible types?
They are, but in the specific example he gave he's not writing to the initial part of A, so that section of the standard isn't relevant
>>
>>61586969
RAII is not a legitimate benefit for a kernel, if you really have trouble doing memory management you need to get the fuck away from kernelspace.
even if it was taken as exclusively a way to prevent bugs, it fails entirely by requiring you to watch it's steps all the time just to see if it frees correctly.
the truth of the matter is that RAII is a good idea for a high level language in theory, but it ends up being worse than garbage collection when you're at a high enough level that it is causing less problems than it's fixing, and at a low level it ends up being too complicated to ever be relied upon.
>>61587034
>promotes icache locality by inlining
which is going to be irrelevant when you literally run out of l1 cache because you've inlined so much
>qsort shitstorm
oh no the overhead of an indirect function call
may as well just off myself now
if you need to sort in your hot path you should write your own algorithm, otherwise you're a dumb code monkey that has no good reason to be writing anything important.
and, allow me to remind you that inlining function pointers is still entirely doable by a compiler, it's not a language feature.
>>
>>61588031
It's not a language bug you fucking idiot.
It's called Return Value Optimization or RVO.
>>
File: Untitled.png (24KB, 906x577px) Image search: [Google]
Untitled.png
24KB, 906x577px
>>61588937
>does not yet implement animation system

OH BOY
YOU ARE IN FOR SOME !!!FUN!!!
>>
>>61588989
>i'm not sure but the float arrays are probably layout-compatible types?
A.foo and B.foobar are layout-compatible on the first two elements. A.bar is not compatible with B.foobar though because of implementation-defined alignment of structure members.
>>
>>61589050
>>61589074
is there nothing i can do

it works on my machineTM

what if i static_assert sizeof A == sizeof B to guarantee the appropriate alignment
>>
>>61589037
>>61589029
>>61589016
in a sane language, compilers and IDEs would display a warning
>>
>>61589088
what warning?
>>
>>61589086
>what if i static_assert sizeof A == sizeof B to guarantee the appropriate alignment
nvm this wouldn't take padding at the end into consideration. i mean static_assert in it some other way to verify the alignment
>>
>>61589088
why would it?
foo + -bar

Perfectly syntactically sound
>>
>>61588871
i think it's technically possible for there to be padding between the members of A if the compiler aligns them to an unusually high boundary. i don't think it'd be a problem with most compilers, but if you want to be absolutely sure, there are alignment attributes for all the major compilers you could macro and use to ensure it packs the struct as you need
>>
>>61589104
like this

https://stackoverflow.com/questions/39907697/can-you-write-a-static-assert-to-verify-the-offset-of-data-members
>>
>>61589103
>>61589111
g++-6

> warning: statement has no effect [-Wunused-value]
>>
>>61589125
yeah this seems like the way to go about it thanks

is it still technically UB tho if the alignment checks out??
>>
>>61589086
>>61589104
If it works on your machine, it just means you're lucky and the alignment is 4 bytes. But in case the implementation would align on 8 bytes, you're screwed. There are means to fix the alignment size, but these are not standard.
>>
>>61585395
I know basic Unix programming (libs, files, processes, threads, IPC, sockets). I'm going to learn Windows next. What are the best practices to write portable programs for both? Are there libraries to do the job for me (so I could write one code using the library and it would run on both systems)?
What about other platforms? (Android etc.)
>>
>>61589161
i want 2 floats at the start so 8 byte alignment is fine. if i static_assert it like in >>61589129 it should work on implementations that pass the static_assert, shouldn't it?
>>
>>61589062
> [RAII] fails entirely by requiring you to watch it's steps all the time just to see if it frees correctly.
This is like the opposite of the truth. If anything, languages without RAII require you to watch your steps all the time, to remember to put that close() or free() in every return path in the correct order.
>if you need to sort in your hot path you should write your own algorithm
Well, you don't have to in C++, you can just use std::sort it would be at least as fast as your hand-crafted implementation.
>allow me to remind you that inlining function pointers is still entirely doable by a compiler, it's not a language feature.
Yet as it has been shown repeatedly itt, no compiler does this for some bizarre reason.
>>
>>61589161
Disregard what I said, the _Alignof/alignof operator is a thing since C and C++11.
>>
>>61589182
Yes, it does, by checking if the size of the array members is a multiple of alignof(type).
>>
>>61589155
That's because C is compiled. You can use pylint however which will emit W0105 in that case if that's what you want. Again, not Python's fault.
>>
>>61589158
well... undefined in terms of the standard, yes. by virtue, since we're talking about compiler-specific attributes/extensions. but it should never not work as expected on a platform which supports that functionality and where you've used it properly
>>
>>61589165
With the C preprocessor you can surround blocks of code for Windows with #ifdef _WIN32 (something like that) and #endif. There is also a constant for GNU/Linux. But use portable libraries because things will get very messy when you use multiple libraries, one for Windows and one for GNU/Linux.
>>
>>61589158
>>61589220
you should read up on each compiler's documentation of their respective alignment attributes in order to be aware of any caveats. i would hope they'd report failures/unsupported alignments, but i can't say for sure if they do off the top of my head. if any of them can fail silently, you should be wary of that (in that case i'd still verify alignments with static_asserts)
>>
>>61589214
>That's because C is compiled.
g++-6 is the GCC 6 C++ compiler
>>
>>61588826
why the fuck not?
>>
>>61589347
What does it matter? Either way both are compiled languages.
>>
>>61589221
That's what I would do but it sounds utterly dumb. Example:
inline void* myfork(void* arg, void* (*err_handler(void*))) {
#ifdef _UNIX
*arg = fork();
if (*arg < 0) return err_handler(perror());
return NULL;
#else
/* equivalent code for Windows */
#endif
}

But this is possibly reimplementing stuff someone has already done.
>>
>>61589183
>languages without RAII require you to watch your steps all the time, to remember to put that close() or free() in * the correct order.
if you think an explicit form of memory freeing requires more of your concentration than an implicit form which can fuck up out from under you in ways that can be practically unfixable, you are either too inexperienced to have a valuable opinion on the matter or actively engaging in doublethink.
>you can just use std::sort it would be * as fast as your hand-crafted implementation
in any case where the function call overhead of qsort is going to be relevant, i guarantee the same way you do that an algorithm specific to your implementation is going to have a far far greater impact than inlining functions will ever have.
an inline assembly sorting algorithm that uses your data structures directly and has been profiled and optimized by hand is never going to be beaten by a function in your standard library, that's just how it is, and if you're going to automagically exclude that as "not counting", then performance clearly doesn't matter either.
>it has been shown repeatedly itt, no compiler does this for some bizarre reason
because a majority of the time with modern cpus with branch prediction and pipelining, the ~3 cycles that creating the stack frame and returning add are of no consequence even in the hottest of loops, and the cycles required for accessing memory to get arguments are negated by the extra cache you're going to receive in pretty much any real application. (as an example, if you're using qsort once with 1 function in a loop as soon as your program starts, you probably don't have a real application)
if you want another reason, it could also be because of dynamic linking, since it's pretty unlikely your compiler is gonna go though the effort to get a copy of the stdlib qsort function and then inline that to inline the function in it. but, i don't really call that a c problem, it's dynamic linking's problem,
>>
>>61589212
is this ok?

union {
struct {
float foo[2];
float bar[8];
};
float foobar[10];
};

static_assert(sizeof foo % alignof(float) == 0, "shiiiiiiiiiiiiiiiiet");
>>
>>61589183
i really understand the mental issue of optimizing things like function calls, it sounds really easy to us and like it would make everything faster, but the truth is that it isn't of any real concern with modern compilers and modern cpus, function calls really aren't the devil.
>>
>>61589461
It looks shit, but this is the only way I know how you make portable code (or you should use a library which does this for you, but in the end it will also relie on this preprocessor crap but you won't directly see it). If a library like that would exist --which it probably does--, it would be pretty bloat, so I would just stick with using this.
You have a mistake in your code by the way, there are multiple constants like that for multiple OSes. You should use else if for the Windows part, because otherwise other OSes will compile the Windows code.
>>
NEW

>>61589577

>>61589577

>>61589577
>>
>>61589539
nvm i think i'm being retarded?
Thread posts: 320
Thread images: 38


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