[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: 365
Thread images: 23

File: 1389589605.png (31KB, 577x353px) Image search: [Google]
1389589605.png
31KB, 577x353px
What are you working on, /g/?

Previous Thread: >>61972090
>>
>>61980634
Bootstrap website
>>
>>61980634
Trying to learn OpenGL.
>>
Is he correct?

>>>/v/387588080
>>
About stack smashing: I realize why it happened. I had an int main() and I forgot to return a value. I guess g++ does something weird then.
>>
>>61980685
Yes.
>>
>>61980685
>>>/v/
I can spread nonsense there without anyone criticising me. Some even agree.

No they're not a reliable source for anything.
As for that particular post it's portraying C as a language that's not something most programmers you should care about don't already know.
>>
pls give me a DES hash of a 4 letter combination
can have upper and lower case letters
>>
>>61980815
She looks disfigured in that picture.
Well done artist.
>>
>>61980866

she? its a blank picture anon
>>
>>61980634
>no anime pic
shitto tsuredo desu
>>
File: 30% usage.png (444KB, 1565x783px) Image search: [Google]
30% usage.png
444KB, 1565x783px
ayy boys i made a simple win application

shit tier engine

static void RenderCharacter(
AkarinBackBuffer *buffer,
int x_origin,
int y_origin
) {
int x_size = 40;
int y_size = 80;

//this is how long the width of the window's RGB value

unsigned char *row = (unsigned char *)buffer->memory;

for (int y = 0; y < buffer->height; y++)
{
unsigned int *pixel = (unsigned int *)row;
for (int x = 0; x < buffer->width; x++)
{
if ((x > x_origin) && (x < x_origin + x_size) &&
(y > y_origin) && (y < y_origin + y_size)
) {
*pixel++ = ((255 << 16) | (228 << 8) | 255);
}
else
{
*pixel++;
}
}
row += buffer->pitch;
}
};


the white box you see is the 'character'
>>
File: scotyardfull.jpg (2MB, 2100x1580px) Image search: [Google]
scotyardfull.jpg
2MB, 2100x1580px
Working/procrastinating on making a simple turn-based board game in C.
Currently have implemented loading the game board data into a simple linked list. Each node has a list of pointers to other nodes. The board looks a bit like pic related (Scotland Yard), but A LOT smaller and simpler.
>>
>>61980929
Using HMH?
>>
Teach me C++.

I have this:

class MainClass {
void loadMyClasses();
private:
std::list<Myclass*> myClasses;
};


I want to access it from a method like this:

void MainClass::loadMyClasses() {
myClasses.push_back(new MyClass("whatever));
}


But it segfaults on me. What do I need to do to be able to intialize and use the myClasses list?
>>
>>61981015
I missed a " in my post, but that's irrelevant to my problem that.
>>
>>61980634
a paint clone in qt
>>
>>61981015
When does the segfault occur exactly?
>>
File: 1503139605047.jpg (226KB, 869x1776px) Image search: [Google]
1503139605047.jpg
226KB, 869x1776px
How does this make you feel?
>>
>>61981067
Indifferent after seeing it n + 1 times already
>>
>>61981067
Nothing because it's not anime.
>>
>>61981067
It doesn't as twitter posters do not qualify as humans.
>>
>>61981047
Somewhere in stl land during the push_back statement.
>>
>>61981067
It's fake. But it's fairly believable because it portrays a novice programmer presenting something to non-programmers.
What's lacking is comments from a bunch of other novice programmers who don't know that they should stay out of those conversations.
>>
>>61981067
This was proven to be fake, so it makes me feel like you people are dumb fucks for believing it.
>>
>>61981067
bored, I've seen this fake shit like 934 times before
>>
File: kode.png (109KB, 800x600px) Image search: [Google]
kode.png
109KB, 800x600px
>>61981067
based karlie
>>
>>61980685
half
c is important for many things but those things are things that already exist and are documented.

c will be relevant for a really long time so its still smart to learn depending on what you wanna do

no for webdev but working with systems kernels and compilers languages like ocaml sml and c should be necessary
>>
>>61981067
>/* */ comments on single lines
AAAAAAAAAAAAAAAAAA
>>
>>61981191
>Not using /* */ comments for a single line
What a fag.
>>
>>61981180
shit this actually has me lost
>>
File: 1503144877.png (34KB, 1217x115px) Image search: [Google]
1503144877.png
34KB, 1217x115px
>>61981191
shit taste

except groovy doesn't do nested comments so it's actually cancer if you want to comment out a whole lot of code
>>
>>61981191
int i;
for (i = 0; /*no_limits*/; i++) {
if (fact(i) == x)
return 1;
}
>>
>>61981015
It runs fine like this

#include <iostream>
#include <list>
#include <string>
using namespace std;

class MyClass {
public:
MyClass() {};
};

class MainClass {
private:
std::list<MyClass*> myClasses;
public:
void loadMyClasses();
};
void MainClass::loadMyClasses() {
myClasses.push_back(new MyClass());
}

int main()
{
MainClass mainc;
mainc.loadMyClasses();

return 0;
}


>>
Is this true?

>>>/v/387594304
>>
>>61981315
Yeah I got it working again. I don't even know what I changed honestly.
>>
What exactly are "property" classes in JavaBeans?
>>
>>61981371

What is meme lately where /v/ are discussing languages just so they can ask for opinions on every single /g/dpt thread?
>>
>>61981191
what if you're using the one true language?
// is a C++ abomination.
>>
>>61981015
>std::list<Myclass*>
>Myclass
>new MyClass

that was probably your problem.
>>
>>61981472
Its the same faggot. Every time.
>>
>>61981211
lines = int(input("Please enter length of X"))

for i in range(0, lines):
if i < lines // 2:
print((" " * i) + "x" + ((lines - (2 * (i + 1))) * " ") + "x")
elif i == lines // 2:
print((" " * (lines // 2)) + "x" + (" " * (lines // 2)))
else:
print((" " * (lines - i - 1)) + "x" + (((2 * i) - lines) * " ") + "x")
>>
>>61981490
// was in BCPL.
>>
>>61981532
and ; was used in ALGOL 60.
B used /* */ and thus C used it, The One True Language.
>>
>>61981013

whats an HMH?
>>
>>61981511
Nah, it compiled fine I was just a bit sloppy when I copied it down to post here.

I think I had a pointer to MainClass that wasn't set properly, so it freaked out when I tried to dereference it.
>>
>>61981586
I presume its "handmade hero". babbys first video tutorial into game dev.
>>
>>61981601

well yeah i did follow him but im planning on doing a different game that doesnt use any artwork at all. possibly just square boxes flying around.
>>
>>61981585
// comments do not originate from C++. They originate from C's distant ancestor, BCPL.
Go complain about const if you hate everything that came from C++.
>>
>>61981636
Where did I state that // originated in C++? C99 adapted it after gnu99 adapted it from C++. gnu99 didn't look to "ancestors" for comment syntax, but rather to the "new kid" on the block.
>>
>>61981636
>// is a C++ abomination.
>>
You need to implement new language and it can't have anything that's in C++, what does your language have?
>>
>>61981691
obviously directed towards >>61981684
>>
C++ is great, with the exception of all the inheritance shit and it being a bit overengineered...
>>
>>61981697
nothing
is that the punchline?
>>
What i mean is, while the code may not be pretty in some cases, the runtime performance against other languages is simply enough of a reason for me to use it.
>>
>>61981709
Just looking for new features that C++ needs
>>
>>61980929
> void
kys.
>>
>>61981707

Just don't use inheritance. I'm not even using it often in C#, why would i use multiple inheritance in C++.

It's just pain in ass
>>
>>61981742
Oh i know, i have used inheritance once so far. I have a Renderer class which i have split in three to wrap my mind around it more easily. But it doesnt impact runtime performance since it doesnt use virtual or other shit. So i use it purely as syntactic sugar :3
>>
>>61981737
MODULES
CONCEPTS
METACLASSES

NOW, C++ COMMITTEE MEMBER-ANON
>>
>>61981015
first of all use shared_ptr or unique_ptr instead of raw pointers (Myclass*)
>>
>>61981790
assuming the list owns those objects
>>
>>61981790
Don't blindly follow what others tell you to do.
>>
>>61981803
I'm not entirely sure what you mean by "owns" in this case, but they are of no use on their own and will always be accessed through the list. When they are dropped from the list they will be deleted. So I guess unique_ptr makes sense.
>>
File: 1418367667088.jpg (47KB, 637x579px) Image search: [Google]
1418367667088.jpg
47KB, 637x579px
should i read K&R before learning c++?
>>
>>61981949
C++ is difficult because it's a clusterfuck. You should learn C (through K&R) and Java before learning C++, and even then you should try to avoid writing it like either of those languages.
>>
>>61981949

Learn C, then program some time in C or other higher level language like this anon said >>61981959


don't start learning C++ if you have no experience
>>
Been spending about 8 months making a fully automated python script which uploads DOTA 2 highlight videos to youtube. The goal is to have a passive income source through youtube ads. Its been running for about 2 month now and I have 160 subscribers. I scrape the web to find the best games, parse the replay file and detect interesting game events, use ffmpeg to cut, crossfade and merge those events, add music, generate a youtube thumbnail and upload. I can upload about 20 videos a day. The channel is called RoshanTV Pub Highlights. Will this secure my financial independence /g/?
>>
>>61981949
You should only do what >>61981959 and >>61981971 tell you if you want to be a bad c++ programmer.
>>
x = [1, 2, 3, 4, 5]
y = [1, 3, 4, 5, *x]
y[-1:-3] = 3, 4
print(*y)


What is the output /dpt/?
>>
>>61981959
didnt expect to get non meme answer.
i will read K&R then. thanks.

>>61981971
my longest experience's +-2 month on python, modifying bit of maths and adds some feature in stock analysis program originally by someone else.

currently on lippman's primer, and pointer stuff baffles me.
>>
>>61982056
Well i started with C++ and so far i'm doing ok :3
>>
Also if you want to program high level you probably shouldnt do java... i'd recommend python maybe?
>>
Almost finished codecademy's Python course. Will skim through a few books before I start solving topcoder/hackerrank problems. how long will it take me to git gud on those sites? I plan on learning C and C++ at the end of the year.
>>
>>61982107
recommending python without a meaningful math library like numpy / pandas / jupyter notebook is dooming people to fail.

You either learn python to do serious shit or you're just another faggot copying scripts from stackoverflow
>>
>>61982098
>:3
Found the crossdresser.
>>
>>61981911
unique_ptr would cause the list to own that pointer.
and >>61981803
shared_ptr<myclass> would be the same (conceptually) as myclass* where once the list deletes it, it'll just remove one from the ref count. but myclass* won't be deleted until the last ref is removed.
weak_ptr is another option, but it depends on if he needs the address, or will just be using it as a reference. and how temporarily the myclass will be in the list

also >>61981015
you should probably never use std::list (a dlist / doubly linked list). std::forward_list (a slist / singly linked list) is what you probably want. but still, you probably should be using an std::vector because it has better cache locality and provides efficient iteration.
>>
Lambdas in C++ look confusing compared to C#
>>
>>61982142
they're not that bad though
>>
>>61982095
learning C won't make learning C++ easier.
K&R will teach you a lot, but it won't be that helpful in learning C++ unless you're totally new to programming

if you plan to only use C++, learning C will be pretty much a waste of your time. if you want to learn C++ pick up a copy of "A Tour of C++" by Bjarne Stroustrup. Or his book "Programming: Principles and Practice using C++". Or "Accelerated C++" by Koenig and Moo.

but if you're learning about programming, and want a good introduction K&R2 is an excellent book. plus, you'll learn C which is quite useful in itself.
>>
I want to go back to using lisp. Now, I'm more of a scheme guy since lisp is pretty damned shit for functional programming (its support for hof is horrendous even just because of function/funcall, but that also means people have strayed away from anything hof as a result), and beside, hygienic macros are infinitely better than the almost-c-style lisp macros.

But since sbcl is otherwise so good and racket is so shit despite being the best scheme implementation (notable mention: chicken, though), I can look beyond that.

Instead, what I'm looking for, is better control over the gc. For example: is it possible to (without-gcing) the entire program and to (gc) at appropriate times inside the (without-gcing)'d program to do almost-manual memory management? Object pools seem to be extremely slow, is there a way to fix them? Are there bounded-time GC options for SBCL? Non-stop-the-world ones?
>>
>>61980685
Generally yes. Though some big libraries are hard to bind to other languages and thus you need either C or C++ knowledge to work with them. In that case, though, you'd be significantly better served by writing bindings for them and using a non-shit language. In the case of rust, which is runtime-free, it is viable for all applications C is used. Even on pure technical grounds, it's often even better than C. And of course in terms of usability and programmer time it's superior always.
>>
>>61982133
I switched to std::vector<std::unique_ptr<MyClass>>, and now I'm getting segfaults on program exit. Here's my main

/* ... */

std::cout << "Ending" << std::endl;
// segfault here
return 0;
>>
>>61982269
please post whole code somewhere
>>
>>61982128
-w-
>>61982124
Oh i have no idea, i just think java is cancer :3
>>
>>61982249
>And of course in terms of usability and programmer time it's superior always.
You didn't have to add this for us to notice you were baiting
>>
>>61982299
Can't spell cuck without c.
>>
>>61982311
found the rust programmer
>>
My tea's gone cold, I'm wondering why I got out of bed at all
The morning rain clouds up my window, and I can't see at all
And even if I could it'll all be gray, but your picture on my wall
It reminds me that it's not so bad, it's not so bad at all
>>
I'm trying to understand the memory usage of simple arrays. Besides the data itself, what control data takes up memory?

Wikipedia had the following to say:
>The amount of control data required for a dynamic array is usually of the form K + B ∗ n {\displaystyle K+B*n} K+B*n, where K {\displaystyle K} K is a per-array constant, B {\displaystyle B} B is a per-dimension constant, and n {\displaystyle n} n is the number of dimensions. K {\displaystyle K} K and B {\displaystyle B} B are typically on the order of 10 bytes.
>>
>>61982056 >>61982192
i have no idea of how shit works and i thought that reading a book about "how computer works" would be boring.
in this case, i think K&R would be helpful.

>>61982107 >>61982124
>python
already i am, focused only on finance at first because currently major on it.
but then i plan doing it on C++
>>
>>61982365
in what language?
>>
>>61982327
>Rust programmer

Such people don't exist. Rust is a meme language not used in real life.

Some large companies such as Oracle wrote code in Rust and even published it, but guess what? Large companies do this all the time. They use new meme languages for fun.

Everyone will forget Rust and continue shitcoding in C/C++ getting segfaults. Just like it was with D and other "C++ killer languages".

Deal with it.
>>
>>61982373
Good >:3
>>
>>61982380
I should've mentioned: Java (not using ArrayList or anything built-in)
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
>>61982383
I'd actually use Rust over C++ but the language is far more complex than C++ itself.
>>
>>61982383
>Rust is a meme language
Oh i do agree mate, played with it a bit and it simply has no future (At least as a C++ killer)
>>
>>61982383
D has a forced GC, it never was a "C++ killer language". Rust is not only already faster than C++ and free of memory issues, it is also runtime-free, something that has bottlenecked C++ on small devices since the beginning.
>>
>>61982393
>Java
REEEEEEEEEEEEEEEE
>>
>>61982401
It's infinitely simpler, but it's harder to master the borrow checker than it is to master C++. The borrow checker is too aggressive and it's define-side instead of being call-side. Call-side would make it significantly easier to understand and let rust express significantly more concepts while retaining safety.
>>
>>61982409
Elaborate on the runtime-free part pls.
Also if you have issues with C++ on the runtime side you're probably programming badly.
>>
>>61982409
>Rust is not only already faster
>1 C++ benchmark statistically out of place
>btfo everywhere else
>GUYS RUST IS FASTER
Kys
>>
>>61982142
lambdas are actually easier than in C#. C# you have implicit captures (closures..). in C++ you have to be explicit.
// laymen
[what you want to capture] (your arguments) -> return-type { your body} (parameters-as-a-call);

captures is a comma separated list of zero or more captures. optionally beginning with a default.
[a,&b] // a is copied into the lambda, b is taken as a reference
[this] // captures (*this) by reference
[&] // captures all automatic variables by reference. and current object by reference
[=] // captures all automatic variables used in the body of the lambda by copy, and current object by reference
[] // captures nothing

params are params, C++14 lets you use auto (for generic lambdas)
the body is the body. the return type is the return type (C++14 lets you use auto there), can be omitted if its void. calling it as the same as calling a function

C# will happily take everything in by reference and not tell you. you have to explicitly make a copy to keep from modifying the original value (even though it introduced a new scope, its aliased into the scope). which is why you explicitly see var @a = a; and @a used in the lambda.

>>61982373
sure, but it won't be that beneficially to your initial target: learning C++. you'll learn tons of bad habits and "anti-patterns" from a C code base. and ignore the last 10+ years (since TR1) of the massive shift in C++ to change how everything should be done.

but if you want a nice conceptual view of how code is ran on a computer: K&R2 gives you some of this, and the benefit of C. (granted it'll be talking about the "C Abstract Machine" and not actual hardware)
>>
>>61982455
Damn, C++ got BTFO pretty badly to not to be able to compensate with the other benchmarks
>>
>>61982460
B-b-but microsoft >:(
>>
>>61982269
Figured this out. It was a problem with not defining my own destructor for MyClass.
>>
>>61982441
Runtime is large and hard to bootstrap cleanly on embedded devices. C and rust do not have that problem. On modern devices, people typically use C++ with a device-specific runtime that behaves differently from a regular C++'s, though.
>>
I'm working on a website in nodejs.. but I'm not sure whether I should use ajax with a RESTful api or websockets? Ive heard good things about socket.io but I'm still not sure. What do, /g/?
>>
>>61982460
that sure did fuck up my spacing. the edit box on chinkchan doesn't seem to use a monospace font, or preserve it.

the post was too long:
auto f = [](int a, int b) -> int { return a + b; };
f(1,2) // = 3

// and
auto inc = [&a] () { ++a; };
inc(); inc(); inc(); inc(); inc();
assert(a == 8)

// reasons for it to be explicit
int a = 5;
[=] () { a--; }; // compile error, a is read only
// explicit saying you're only capturing a
[a] () { a--; }; // error, a is read only

// by reference
[&] () { a--; }; // a is now 4
[&a] () { a--; }; // a is now 4
>>
>>61982393
A Java array knows its size, it'll also have some other information in the header too to dispatch the functions it inherits from Object I guess.
>>
>>61982455
>4 production-quality software
>1 benchmark
Choose one NSA.
>>
>>61982133
>you should probably never use std::list (a dlist / doubly linked list). std::forward_list (a slist / singly linked list) is what you probably want. but still, you probably should be using an std::vector because it has better cache locality and provides efficient iteration.

this doesn't make a significant difference if you store pointers anyway
>>
>>61982495
I'd like to add you should avoid capturing by reference (or value for pointers) if your lambda is going to outlive its scope. Also lambda defined in a class always contain the implicit this pointer, so if you do the general = capture and use a class field this might fuck you up too.
>>
>>61982480
fuck, that a = 5 should be above the 5 incs. but I digress.

>>61982480
its not really a microsoft problem. but with how lambdas are implemented in C#.. and that C# at the time didn't have a way to tell the types of values part. they are implemented by the expression library (and as part of roslyn, the compiler) which treats them like Action<Tin ..,> for things that return void and Func<Tin, .., Tout> for things that return a value. Which gets translated to the old pre .NET 2 delegates{} which can be thought of functors.
because the types are passed in via generic arguments (with a contravariant in, instead of the contravariant out) its hard to come up with a syntax that'll handle specific captures of random arbitrary automatic variables. especially when they wanted to be compatible with the old fashioned delegates.
>>
>>61982495

Thanks. I'm getting grasp of this.
>>
>>61981949
do not listen to these massive retards, start with a language you want to learn, dont start with c if you want c++
>>
>>61982515
it does make a huge difference if you are storing tons of items (it doesn't really matter because an list is a linked list, so its pointers to your items anyway) and plan on iterating over the list, and especially multiple times.

forward_list will always have a cache miss for the next pointer, and every pointer afterward if the previous pointer missed. (list is worse, because it happens in reverse too)

the only reason to use an std::list (or forward_list) over a vector is if you have some buggy code that relies on specific iterator invalidation scenarios. and even (especially) then, you should probably be using your own STL-compatible container.
>>
File: 1503147330869.png (236KB, 806x752px) Image search: [Google]
1503147330869.png
236KB, 806x752px
news website
>>
>>61982595
He should start with a language that helps him understand how the hardware works though. C/C++ is a good entry point, but not necessarily the only one.
>>
>>61982222
You can look into implementation documentation, usually they have functions to control the GC but it makes your program less portable. There's no way program without GC in Common Lisp.

There's always C with parentheses
https://github.com/tomhrr/dale
>>
>>61982599
There are plenty of scenario where lists are more suitable than vectors. For instance a highly variable sequence of elements. Even operating systems use these. The cache miss boogeyman is overrated.
>>
>>61980685
Over half of programming jobs posted in my country require you to know C/C++
So if you want job here you should learn C, but for personal projects he could be right
>>
Also there's the fact that it will probably be harder for him to go from a high level language to a lower one.
>>
>>61980685
what a fucking idiot
D wasn't created to replace C
Also
>falling for the Nim/Rust meme
>>
File: 19989310.jpg (22KB, 540x540px) Image search: [Google]
19989310.jpg
22KB, 540x540px
.C or .cc or .cxx or .c++ or .cpp?
>>
Rust is mostly a hipster language, even though it has (had) some potential.
>>
>>61982669
.cpp .h :3
>>
>>61982669
What ever you do if you program in sepples, postfix your headers with something else than .h use .hpp or some other faggy extensions sepplesfags use.
>>
>>61982669
cpp & hpp
>>
>>61982669
I like .hpp and .cpp personally.
>>
>>61982657
Is your country still in the 90s?
>>
>>61982680
This is what I use. .cpp with .hpp makes sense too.
>>
File: 1501118588580.jpg (45KB, 600x456px) Image search: [Google]
1501118588580.jpg
45KB, 600x456px
>.hpp
>>
Do you "need" to learn HTML "programming"?
How long does it take to learn it?
>>
>>61982708
suck it faggot. C already reserved .c and .h.
>>
File: 1502196559840.jpg (100KB, 770x1000px) Image search: [Google]
1502196559840.jpg
100KB, 770x1000px
>>61982669
cc
>>
>>61982714
html is aids, use a web framework with some other language that isn't dogshit
>>
>>61982708
there's nothing wrong with this
>>
>>61982719
Suck it daggot, I'll still use .h for my C++ headers.
>>
>>61982729
Just joking, i'd say actually that i'm the one doing it wrong since hpp makes it easier to distinguish from C code.
>>
File: 19748717.jpg (46KB, 545x960px) Image search: [Google]
19748717.jpg
46KB, 545x960px
>>61982725
Hey, I like hh and cc too <3
>>
I'm currently studying physics and want to get into programming but don't know what language to learn.

I have worked a tiny bit in Python in the past but it didn't really feel satisfying to me, I had the impression that too much stuff is done just by implementing functions and routines from other packages so that I never felt I really learnt much programming.

It seems C or C++ is better suited for what I am looking for but yet not sure about it. In general I'd like something where I can really learn to program and later easily transition into another language if needed. For the future I intended to work in the semiconductor industry.

Any recommendations please?
>>
>>61982656
a vector will handle that use-case better than a list.
the only reason list/forward_list are in the STL is that its stable: (memory and iterator). if all of your "hot" items are the middle, then it'll be more efficient than a vector. but if you're constantly modifying the middle of the list perhaps you should tail another look at your algorithm. and find a way to make it prefer items towards the front or back. or use a proper data structure for that workload. like a trie.

also, if you modify the collection your previous iterators will still be valid. but why not just grab a new iterator?
>>
One question, why should i use a specialised iterator class other than a raw pointer when defining .begin() and .end() functions :3?
>>
>>61982753
Fortran xddd
(I'm only partially joking desu)
>>
>>61982753
But seriously, FORTRAN, C++ or python.
>>
>>61982744
>a vector will handle that use-case better than a list.
A vector won't deal as well with fragmented memory (common), is highly inefficient at inserting and removing in the middle.
>should tail another look at your algorithm
Now are you saying all the queue/priority queue based algorithms for example are useless? This only makes you look more unreasonable.
>>
>>61982119
Someone reply ._.
>>
>>61981067
>else if (a > b && b < a)
what did she mean by this?
>>
>>61982814
redundant cancer
>>
>>61982078
1, 3, 4, 5, 1, 2, 3, 4, 3, 4, 5
>>
>>61982809
I mostly learned C++ by cppreference and cplusplus.org so I don't know how much it takes by using dedicated course websites.
Sry :3
>>
>>61982768
you'd use std::iterator_traits if you want your container to have specific behavior. such as random access, different behavior for input iterators, different behavior for output iterators. a way to do bidirectional iterations. and a custom way of doing forward iterators.
>>
Anyone here that has used Rust that can tell me what the deal is with modules? I am having a hard time understanding what the language specifies as a module. It's not a namespace like in c#/java/php etc etc because it doesn't seem possible to have a module split over multiple files. Both the new and the old books are trash.
>>
>>61982843
I'm oversimplifying though i also learned C++ STL at college but they teached without much depth.
>>
>>61982863
Nonono, the question was why shouldn't I use raw ptrs (thx though)
>>
Why are standards written by brainlets?
(1.0 / -0.0) == (1.0 / 0.0)

false
(-0.0) == (0.0)

true

Why the hell does 1/x != 1/x in some cases of x? Division by 0 does not equal Infinity. Compsci is for people too stupid to do math.
>>
>>61982883
Wtf is this shit and where did you find it.
>>
File: 113447.png (45KB, 700x700px) Image search: [Google]
113447.png
45KB, 700x700px
>>61982883
>>
>>61982883
The floating point standard has to take a lot into account, not just what would be nice mathematically
>>
>>61982753
Rust or Lua
>>
>>61982906
Lua still, rust why m8
>>
>>61982906
>>61982915
lua is TRASH
>>
>>61982915
Cause it will dominate the market in few years
>>
>>61982922
I'm not saying otherwise
>>
>>61982883
t. Someone who doesn't understand computers.
>>
>>61982078
It's not C, therefore, it's not answerable.
>>
I want to get into making programmes that have a GUI or are capable of drawing graphics. JavaFX seems like one way to go, but I kind of feel like Java doesn't have much of a place in userland. What language should I pick up so that I can make pretty things?
>>
>>61982925
This is a really fucking weak argument mate. And one you can't prove. So not even an argument.
>>
>>61982898
dumb haskell hipster
>>
File: 1498767833334.jpg (10KB, 251x251px) Image search: [Google]
1498767833334.jpg
10KB, 251x251px
>>61982935
I like you.
>>
>>61982933
I'm an assembly programmer. You're a brainlet.
>>
>>61982898
Why was Dijkstra so perfect?
>>
>>61982981
You mean you don't have a job :3?
>>
>>61982987
>>61982898
If he was he'd be a mathematician, not a computer '"''scientist""".
>>
>>61982880
here's a question that'll maybe answer it: how do you iterate over an associate array with just a pointer?
here's another: how do you iterate over a graph that you aren't sure if its cyclic or acylic with just a pointer?
an iterator acts like a pointer, but can do more complex things that just ++addr inside its logic. plus useful things like random access..

as for internal to the container, generally its just bumping a pointer. but you'd expose a nice type-safe interface for controlling how its done.
>>
>>61982902
How about they take into account basic fucking logic instead of taking into account idiots who might want to divide by zero? Even Python's devs are smart enough to just say 'fuckit' and ignore the standard.

>>61982898
>any branch of applied mathematics
>difficult
One more reason Dijkstra and compsci in general is a fucking brainlet field.
>>
>>61982753
I'm currently studying physics and want to get into construction but don't know what skill to learn.

I have worked a tiny bit in Lego in the past but it didn't really feel satisfying to me, I had the impression that too much stuff is done just by copying from instruction manuals so that I never felt I really learnt much construction.

It seems plastering or bricklaying is better suited for what I am looking for but yet not sure about it. In general I'd like something where I can really learn to build and later easily transition into another sector if needed. For the future I intended to work in the plumbing industry.

Any recommendations please?
>>
>his language is good because it has ````high order functions""
literally assembly language does this. stop holding yourself back. embrace the power of the darkness
>>
File: 1413777090510.png (1MB, 1920x1080px) Image search: [Google]
1413777090510.png
1MB, 1920x1080px
Who is your programfu?

Bonus points for:
1. The one you're stuck with
2. The one you want to be with
>>
>>61983015
Nobody wants to branch on 0 for fucking everything
>>
>>61983011
Sorry i should've specified that i'm talking about a regular C array.
>>
>>61983021
assembly language:
>can do higher-order functions
>can't run on multiple platforms
>>
>>61983021
b-but it's so hard putting my function pointer in a struct
>>
>>61982998
In programming? No, it's just a hobby. I wouldn't shame myself with the title of codemonkey-for-hire.

>>61983030
I'm sorry, but you clearly don't understand. How exactly do you think you get 1.0/0.0 to return "Infinity" in a way that would not be just as easy on performance as throwing an error? Do you think they don't branch to return Infinity?
>>
>>61983058
I am damn sure that the people who wrote the standard knew better than you.
"throwing an error"? Are you kidding me? It's supposed to just be a fucking floating point op
>>
>>61983058
Branching in code is a lot more expensive than however the FPU internally handles division by zero
>>
>>61983033
oh, well, C arrays don't expose iterators. so using std::begin on it will create a new iterator.

one reason for doing this is, say, you want to pass the iterator(s) to a function that uses the STL iterator idiom. like std::sort();
another reason is std::cbegin() for a const iterator (and all the use-cases/benefits of a const)
>>
>>61983095
Thanks for taking the time ^^
Much appreciated
>>
>>61983029
Why are javascript and scala edgy?
>>
>>61983081
>I am damn sure that the people who wrote the standard knew better than you.
No they didn't. Standards are written by brainlets 100% of the time. Take a look at W3C.

>It's supposed to be a fucking floating point op
a fucking integer op throws an error. What would stop a floating point op from doing the same?
>>
>>61982036
No. Last time I checked it was like $1-$2 per 1000 views. If anyone claims music/rights a video will become worthless.
The most viewed Dota video on YouTube has like 500k views, so I unless you're thirdworld its not a significant income source
>>
>>61983117
also, its much safer.
and more maintainable, what if you decide to change the array to an std::array, or an std::vector in the future? the begin/end code and everything that uses it will work without change.

(the <algorithm> head is a big "pro" for using iterators.)
>>
>>61983085
>branching code is more expensive than branching code
',:^)

>>61983104
I get paid $60 an hour and my job only involves dick-sucking in the figurative sense. Guess what I do.
>>
File: 1498784488337.png (124KB, 327x327px) Image search: [Google]
1498784488337.png
124KB, 327x327px
>>61983029
I love how C++ has multiple personalities. Very appropiate
>>
>>61983176
>head
header. I should proofread when before I post.
>>
>>61983017
Rude :(
>>
>>61983182
I'm certainly glad that you program only as a hobby, I wouldn't want to work with someone so ignorant of hardware.
>>
File: 1501632828581.jpg (21KB, 402x480px) Image search: [Google]
1501632828581.jpg
21KB, 402x480px
>>61983176
Yeah also i kept hitting my head against a wall every time the compiler told me it was wrong to use unchecked iterators...
>>
>>61983236
>he thinks FPU's return of Infinity couldn't simply be standardized as an error / exception
There are already floating point exceptions. I think you're the one who is ignorant of hardware.

    mov ax, 0xbeef
mov bx, 0x0000
div bx


Why isn't this okay but doing the same thing on the FPU is? It's disgusting.
>>
Would there be legal issues with a p2p message board? People could potentially post illegal content since there wouldn't be any moderation. I wouldn't think the developer could be held responsible for how his software is used (otherwise anyone who writes any file sharing software would be in prison), but what about users running nodes?
>>
>>61982883
> -inf != inf
> -0.0 == 0.0
easy
The standard is set so that error panic is not thrown. Actually using inf, -inf, and NaN is bad, anyways.
>>
>>61982661
Nim is the meme to end all memes but rust is genuinely good.
>>
>>61983660
>rust is genuinely good.

haha oh wow
>>
>>61983660
remember when nim had case and underscore insensitivity for identifiers?
foo_bar_baz == foobarbaz == FOOBARBAZ
remember when it'd also import all symbols into the same "namespace"?
so you'd need global unique identifiers that don't rely on casing or fucking underscores?

thats when I noped out of learning nim.
>>
>>61982643
(without-gcing) disables the gc for the form enclosed. (gc) performs a gc pass. If (without-gcing) the entire program and (gc)ing from time to time still works, then that would make several applications more reliable (with regard to expected latency, for example). Without this ability, or without either a pauseless or a bounded-time gc, then lisp becomes very hard to place in a stack: there are low-level languages for low-level tasks, scripting languages with significantly more libraries for scripting, and desktop programming languages for everything inbetween. Java may be downright painful to use while lisp is just the opposite, but it has azul which makes it superior, along with all its libraries.

I'd be looking at bone lisp or carp before I'd look at dale but that's a bit beyond the point. sbcl is a huge attraction for common lisp vs anything else.
>>
>>61983719
Yup. The devs are clinically insane. "b-but they fixed it!" just doesn't cut it.
>>
>>61981211
Here's a constant space solution. I don't know why I wrote this. Can greatly speed up by abusing the figure's symmetry by sacrificing space.

{-# LANGUAGE LambdaCase    #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module Main (main) where

import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Lazy as B
import Data.Monoid ((<>), mconcat, mempty)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (stderr, stdout, hPutStrLn)
import Text.Read (readMaybe)

{-# NOINLINE gen #-}
gen :: Int -> [B.ByteString]
gen height = go height
where
s = B.char8 ' '
x = B.char8 'X'
nl = B.char8 '\n'
rh = height + 1
mid = rh `quot` 2
go 0 = mempty
go r = let nd = rh - r
(# spFirst, spAfter #) | r > nd = (# height - r, (r - nd) - 1 #)
| otherwise = (# r - 1, (nd - r) - 1 #)
bldr = mconcat (replicate spFirst s)
<> x
<> (if r == mid
then mempty
else mconcat (replicate spAfter s) <> x)
<> nl
in B.toLazyByteString bldr : go (r - 1)

main :: IO ()
main = getArgs >>= \case
[w] | Just i <- readMaybe w, i >= 0, odd i -> mapM_ (B.hPut stdout) $ gen i
_ -> do
hPutStrLn stderr "Expected an odd natural number as an argument."
exitFailure
>>
>>61983590
I'm not a lawyer, but maybe if you could make it so you can't know which nodes were involved in storing/spreading a particular piece of content and node operators can't know what content gets stored/spread using their node, I think it would be pretty hard to blame any one node operator for something fishy
>>
>>61983710
>triptard
>not an argument
woooow.......
>>
>>61983590
Chunk and encrypt the content and it should be alright. There has been precedents where people were exonerated using similar software after all.
>>
>>61983926
>>61983985
Have they ever tried going after people who run TOR exit nodes? I'd imagine it'd be pretty similar, legally.
>>
>>61983660
>rust is genuinely good
>
>>
>>61983830
What is this unreadable garbage? Is this what FP retards think programming is supposed to be? This is trivial in any non-retarded language.

Pseudo code:

// assume n = 9
for i = 0 -> n { // line number
for k = 0 -> n { // position in line
if k == i // for example, 3rd line, 3rd position = * {
print '*'
} else if k == n - i { // for example, 3rd line, 6th position
print '*'
continue // both stars have been printed, go to next line
} else {
print ' '
}
}
print '\n'
}
>>
>>61984015
>Is this what FP retards think programming is supposed to be
Only Haskel """programmers""".
>>
>>61984040
What does real FP look like then?
>>
My main problem with rust is that it's syntax is needlessly bloated.

ex: let mut foo : u32 = 10;
vs
using u32 = std::uint32_t;
u32 foo{10};
>>
>>61984007
Yes, they have done so many times but usually the operators walk. The exception is when they brag about hosting cp on social media and whatnot.
>>
>>61983710
Never took a tripshit seriously, never will
>>
>>61984045
import drawX as X
monad :: drawX.draw
>>
Anyone know of any opensource/foss dotnet core projects looking for devs?
>>
>>61982753
c and x86 assembly

PROGRAMMING FROM THE GROUND UP
>>
>>61984050
>let mut foo : u32 = 10;
as opposed to
const unsigned int foo = 10?
>>
>>61983029

Visual Basic looks so sad. She should not be sad, for she now has a port to Linux in the .NET Core SDK 2.0, so even MORE people can ignore her for better languages.
>>
>>61984080
>mut
>const
What did you mean by this?

>u32
>unsigned int
ditto
>>
>>61984050
>he fell for the initializer list meme
>>
>>61984087
Ruby you should learn F* and report back
>>
>>61984106
>and report back
Good idea, as long as she never reports anything back here.
>>
>>61984090
I mean the variability specifier keyword is smaller
>>
>>61984050
The main problem with Rust is that it literally gives nothing it pretends it has. Imagine a Trump website advertising unlimited free immigration and tolerance and having retards actually advertise it. That's Rust.
>>
>>61984050
Nice cherrypicking but the comparison is
let foo = 10;

vs
auto foo = 10;

Oh look it's literally the same.........
Not to mention even in your example you had to type a shitload more since you had to add an alias for std::uint32_t in the first place.

And if you want to see a reverse-cherrypick:
const volatile struct faggots* foo = (struct faggots*)malloc(sizeof(struct faggots));

vs
let foo = Faggots { };
>>
Could anyone post the most updated Pro/g/ramming Challenges image?
>>
>>61984050
also. rust takes C++s colon cancer and runs with it. so::many::fucking::colons::everywhere::error.unwrap().

I used to hate it about C++, like using std::chrono. but after trying Rust the lack of nested upon nested upon nested namespaces is a godsend.
>>
>>61984141
btfo
>>
File: sepples.png (1MB, 1280x720px) Image search: [Google]
sepples.png
1MB, 1280x720px
>>61984141
>>
>>61984136
>be NSA
>have no argument
>keep making completely empty post on /g/
>think your lack of argument is convincing people somehow
>never address any point, ever
>think this will force people to make software in the most exploitable languages the world has ever seen so you can keep your job
>>
>>61984166
There has been 0 arguments from Rustoddlers except "muh NSA shills". KYS.
>>
>>61984141
Faggots you{ };

why is C++ so based?
>>
>>61984080
You do realise you're comparing pieces of code that don't do the same, right?
Also did you even read what i wrote?


C++:
using u32 = std::uint32_t;
u32 foo = 10;

Rust:
let mut foo : u32 = 10;

->Rust is fucking cancer.
>>
>>61984177
Faggots you;
Faggots you();
Faggots you{ };
Why is C++ so retarded
>>
>>61984190
>using u32 = std::uint32_t;
>u32 foo = 10;
lmao
in Rust it's just
let mu foo = 10u32
>>
>>61984141
Thats C not C++ you faggot
>>
>>61984141
but auto foo is mutable whereas let foo isnt right?
So they really arent the same.
>>
>>61984191
These don't even do the same thing retard.
>>
>>61983710

If we ignore for a moment that the makers of the language are massive SJWs, on the grounds that we will likely never be contributors to the Rust language standard and compiler ourselves, what specific problems do you see in the Rust programming language.

>>61984106

F*? Are you referring to F# by chance? Or is this some new language I haven't heard of?
>>
>>61984191
>Faggots you();
This doesn't do what you think it does - just another reason that C++ sucks.
>>
>>61984015
You can write 1:1 solution like this in Haskell but you and up with slow garbage like you have ;^)
>>
>>61984221
https://www.fstar-lang.org/
>>
>>61984214
Yes, but no use-case is purported here. Technically you could say that the C++ should be const std::uint32_t foo = 10; whereas the rust is correct, for instance. If you want a real comparison you need a real, small program.
>>
>>61984231
>replying to an obvious retard
>>
>>61984173
>if I ignore the entire thread I win!
>>
>>61984224
>if(a == b) return 0 and struct{int a} b; don't do the same thing hence the language is retarded
>>
>>61984243
Ruby is quite smart actually
>>
>>61984229
How dumb are you? My solution is a billion times faster than yours just by the nature of it being trivial to implement in C. My program will finish running before haskell has even loaded up its runtime environment.
>>
I just realized that C++ std::map is much better than C# dictionary.


[CODE]#include <map>

int main()
{
std::map<std::string, int> NameNumberPair{{"James", 1}, {"Miriam", 2}, {"Crazy8", 55}, {"Salladin", 100}};
for(auto &i : NameNumberPair) {
std::cout << i.first + ":" << i.second << std::endl;
}
}
[/CODE]
>>
>>61984269
i don't care if that's true or not. he's annoying
>>
>>61984269
For short bus riders, maybe.
>>
>>61984269
put your trip back on m8
>>
>>61984277
alt-c m8
try it
>>
>>61984208
The point i was trying to make is that in rust the volume of code tends to be larger than C++ for no reason.
>>
>>61984269
Ruby is clinically retarded.
>>
>>61984280
>>61984283
>>61984284
>>61984308
I'm not Ruby, but he's quite the CS academic
>>
>>61984277
you probably should know that std:map isn't exactly what you think it may be. its actually a sorted set.
std::unordered_map is what most people would call an associative array / hash map.
>>
>>61984208
Also the alias declaration is jsut written once unlike the fucking let mut. "let" doesn't do shit in the code also.
>>
>>61984277
>the std::map indexed on std::string meme
>>
>>61984329
?????
>>
To. Ruby:61984319
>dude this language is bad
>why?
>because... GC
>but your language is GC'd
>yeah but that doesnt count theyre different
>>
>>61984333
just don't index with string mate.
the performance will be shit too.
>>
>>61984335
I already told you I'm not Ruby. He's probably busy learning F* right now.
>>
>>61984351
>He's probably busy learning F* right now
Hopefully he stays busy learning it for a few more years.
>>
>>61984329
It's the same idea as if you used a std::vector as a key for your std::map. The amount of data you're copying for every stupid operation is just triggering.
>>
i wish i could filter this idiot without filtering an entire programming language
>>
>>61984333
>>61984361
>>
>>61984319
I remember that one time some anon asked a question out of curiosity (regarding some way to circumvent printing NULL with printf), I was trying to help him and the retard you're defending (assuming it isn't you) was part of the stackoverflow "that's dumb you shouldn't do it do that which doesn't answer your question at all instead" crew. So you can go fuck yourself.
>>
>>61984362
you know you can filter by trip right?
>>
>>61984361
>>61984372

What should i do then? Can i make std::map with const * char or what?
>>
>>61984389
people talk about him
>>
File: lines.png (252KB, 1231x557px) Image search: [Google]
lines.png
252KB, 1231x557px
>>61980634
How would one do something like this paper generator? I thought the easiest would be to just create it in DOM and then pdf print it, but that would depend on the users browser settings, zoom etc - so then I thought php gd, but how the shit would I draw in the angled lines correctly? is there any ready script for that?
>>
>>61984361
indeed. he should be using a better identity for the key. such as:
template <typename T>
constexpr inline auto hash(char const* s, T h = {}) noexcept {
while (*s) h ^= (h << 5) + (h >> 2) + static_cast<unsigned char>(*s++);
return h;
}

a shitty compile time hash.
or maybe the address for identity, or anything thats not an std::string. perhaps just a const char*
>>
>>61984403
its not like anyone else here really posts or talks about the actual language.
>>
>>61984221
>what specific problems do you see in the Rust programming language.

Syntax insanity. Very noisy.
>>
>>61984389
>>61984403
Are you referring to Ruby? He's one of the better features of /dpt/
>>
>>61984420
Still much better than C#, which is about as verbose as Java of all things
>>
>>61984410

What the fuck is this code, holy shit. Does anyone actually write such C++ code?

Don't scare me...g...guys
>>
>>61982500
Oh right, thanks
>>
>>61984136
>i'm a contrarian faggot
>>
>>61984395
Yes use const char* but remember to overload the comparator for const char*, if you don't the map will sort according to pointers instead of values. As >>61984320 pointed out std::map is a sorted set and requires the comparisons to work properly.
>>
>>61984421
t. tripfag
>>
>>61984436
You're scared of some elementary hash?
>>
>>61984404
i dont get what you're asking.

can you reformulate ?
>>
>>61984435
>but atleast its not...
I really hate this deflection.
We're discussing rust, not another language.
>>
>>61984420
also, 9/10 of the time any code you'll read/see in Rust blindly just .unwrap()s everywhere.

its like Scala didn't bring Either types to the mainstream and instead of calling Left/Right (Scala terms here), you can just map/flatmap over the values. creating a coherent flow. instead of most of the time ignoring the error.
>>
>>61984459
It's reasonably safe to assume that OSGTP internally compares every language to C#
>>
>>61984471
>map/flatmap over Either in scala
They finally made it right-biased, huh?
>>
>>61984474
it even works here: C# 7 > C# 3
both lexicographically and logically.
>>
>>61984446

i just changed std::string to const char* and it works just like before

values printed are same
>>
>>61984457
The service creates ruled paper based on margin inputs etc and it also adds those angled lines, I am kind of stuck at how I would do those angled lines in php.
>>
So is Rust cancer or not finally? :3
>>
>>61984500
it has been that way since like 2.9 or something, whenever the first rewrite the compiler and the collections api was.
but its a shame that unwrap() is literally the same as if err == nil { return err } from go.
dataflow programming gets no love :(
>>
>>61984231

Looks kinda similar to F# and OCaml, but with apparently a better type system? What is the practical application of this?

>>61984335

Garbage collection should be reserved for languages which are not focused on performance. Languages like D and Go, which aim to replace C and are compiled to native code, should avoid the use of garbage collection entirely. Languages like Ruby, Python, Java, etc... are intended to run inside of virtual machines, and are not focused on building performant applications as much as they are on making the programmer's job easier. If you build a program in one of these languages where garbage collection could have a negative impact, you have clearly made the categorical error of using a slower language to begin with.

>>61984420

A fair point. I'm slightly more used to the syntax. It's less noisy than C++ in some areas and more noisy in others. I'm more willing to put up with syntax if it gives me a finer grain of control over what I'm doing.
>>
>>61984526
Rust is okay, but it has its caveats like other languages.
>>
>>61984511
You will notice the difference in ordering when you iterate over the map.
If you want to change the comparison used, pass the map a functor that defines the comparison such as bool operator()(char const *left, char const *right)
>>
int foo(int bar(int));

int foo(int bar[]);

someone tell me who thought this was a good idea
>>
>>61984533
>which aim to replace C
D has been outperforming various C and C++ stuff for awhile now. Your "performance" argument is not valid. Which shows your naive bias.
>>
>>61984533
>It's less noisy than C++ in some areas and more noisy in others.

Coming from C#, it's shocking. C++ is known for noise, so I understand that.

>>61984435
>which is about as verbose as Java

You don't actually believe this, do you? C# is considerably more concise because it eschews a lot of Java's verbosity, a conscious design choice by Hejlsberg.
>>
>>61984570
What the fuck?
this is better btw:
[CODE]

int foo(int (&barr)[]);

[\CODE]
>>
>>61984598
fuck
>>
>>61984576
Is garbage collection in D an optional feature?
>>
test

<pre> kek </pre>
>>
>>61984613
Technically, but not practically.
>>
>>61984613
Optional with an asterisk.
If you want to use it like a proper C superset, you can.
If you want to use it like a proper C++, theres caveats. But the general attitude in the community is a GC-less future.
>>
>>61984590
you know where to back to, turd
>>
>>61984533
>What is the practical application of this?

>similar to F# and OCaml, but with apparently a better type system

The website says
>The main ongoing use case of F* is building a verified, drop-in replacement for the whole HTTPS stack in Project Everest. This includes verified implementations of TLS 1.2 and 1.3 including the underlying cryptographic primitives.
>>
>>61984590
Say C# is about 70% as verbose as Java. That's still very verbose
>>
>>61984682
>Say C# is about 70% as verbose as Java.

You could "say" that, but you'd be wrong.
>>
>>61984519
What are angled lines used for in general?
Honest question.
>>
>>61984511
you could also use const char * const to get a possible performance boost
(const's placement in C++, but it always binds to the left unless its the first thing, then it binds to the right.)
const foo == foo const
const foo * == foo const *
foo * const != const foo *

(the const char * const is a const pointer to a const char
auto a = "some string" ; // a is a const char const *
auto b = "asdf"s; // s is a std::string in C++11

by not making an std::string everywhere you can get much faster code. strings are only useful if you're going to change them.
strings are actually a very specific vector. although not called so. they behave very similarly. they are actually defined as
std::basic_string<class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>

which does all kinds of magic. but some of that magic isn't "free." if you want to see a clusterfuck, look up std::allocator :*). so if you can avoid std::string, try to do so. they are useful if you're modifying strings but if your strings. as for passing them around, if you just want a sequence of chars then pass as
const char * const
. if you need to use the string operators then pass them as
const std::string&



fuck, this was way more ramble-ly than I expected. tl;dr: favor sonst char * const over std::string
>>
>>61984703
Unless it's <5% as verbose as Java, it's very verbose
>>
>>61984710
Please wear a trip so we can filter your clinical retardation.
>>
>>61984718

You can write an entire program as a single LINQ query. It's basically functional programming.
>>
>>61984745
>C#
>basically functional programming
/dpt/
>>
>>61984653
Is Alexandrescu the one making all the decisions currently? Does the community actually have a real impact on the development of the language? Last I checked D was a long time ago.
>>
>>61984710
>auto a = "some string" ; // a is a const char const *
>auto b = "asdf"s; // s is a std::string in C++11
thanks for the heads up
I don't think I am going to use auto very much
>>
>>61984533
its a dependently typed F#, with refinement types. with a huge emphasis on being used for SMT (and some internal MSFT Research stuff with Z3).
F* : F# :: Idris : Haskell.

as for practical: as practical as any research language...
but it can be compiled to other languages like OCaml and C#. and I think there may still be an F* to C compiler..

there's some neat stuff written in it, like formally-verified cryptography libraries.
>>
>>61984767
>he can't write lambdas and such in C#

kek
>>
>>61984767
LINQ is FP
>>
File: 1503162441.png (118KB, 1306x1111px) Image search: [Google]
1503162441.png
118KB, 1306x1111px
>>61984270
Don't even reply to me again trashman; your little "C" program doesn't even do the right thing to begin with but here you go, here's your billion times faster C ;^)
>>
>>61984570
what seems to be the problem
one takes a function pointer as an argument, the other takes a pointer to int (the second one is bad style)
>>
>>61984786
>lambdas and such
>FP
/dpt/
>>
>>61984770
Alex and Walter are the two heads.
And it feels like it yeah, Walter is alright at listening and taking criticisms and differing opinions.
>>
>>61984842
Well, /dpt/ thinks common lisp supports functional programming, so.
>>
>>61984846
I don't understand why anyone would work on a dead language other than to be able to translate things written in it into a not-dead language
>>
>>61984790
LINQ is just as FP as C is OOP
>>
>>61984793
Of course the C program is gonna be slower at high N because it uses no memory, while yours uses O(n). Rerun your test with n = 9.
>>
>>61984533
>languages which are not focused on performance
You're fucking retarded, stop posting.
>>
And some people think that JS is a suitable language for teaching monads
>>
>>61984710
>references for indexing
pls no
>>
>>61984862
LOL
>>
>>61984576

First of all, the performance hit of a garbage collector is often not felt during benchmarked applications, which run for a short while and often don't involve lots of memory being allocated and deallocated. If you make a user application that is supposed to run for however long that user wants that window to be open, they're going to want to not deal with any sort of interface lag, and they're going to not want memory to bloat up unnecessarily. With RAII, you might take slightly longer to free memory if you are to tally up all of the time spent deallocating, but it won't be all at once, and it will be done as soon as possible, so the user does not need to deal with lag spikes from the GC running, and they do not have to deal with memory usage increasing until the GC eventually decides to run. It's deterministic, and easier to tune for performance. This is what matters.

Second of all, I decided to look up D benchmarks, and couldn't find much. Many of them are on the D language website. Show me some good benchmarks, would you?
>>
>>61984842
Yes, lambdas and HOFs are FP.

>>61984862
This is the dumbest thing I've heard today.
>>
>>61984858
Its a pretty notable thing when one of the biggest C++ 3re parties, and authors jump ship.
>>
New thread:

>>61984897
>>61984897
>>61984897
>>
>>61984887
I know, right? It's funny when you see Microsoft Java toddlers think they are some sort of FP wizard after writing their first fisher price lambda library
>>
>>61984864
To add onto this, you could trivially make it a lot faster by adding char* buf = malloc(n); in the inner loop, and changing the putchars to buf[k] = 'X', buffering up and writing 1 line at a time. Obviously calling putchar a 100 million times is going to be slow.
>>
Why doesn't dis work?

std::set<std::string, decltype(comparator)*> TriggerValues(comparator) {values here};
>>
>>61984839
They're both bad style. If you write an invalid declaration the compiler should reject it, not contextually coerce it to the next best thing.
>>
made a poloniex crypto bot with machine learning. https://github.com/nickwilliamsnewby/cryptochronolonic please tell anon how to make breddy
>>
>>61984871

A language which intentionally and significantly compromises performance to focus on other features cannot be said to be "focused on performance". Running inside of a VM, even with the use of JIT, is often a compromising factor.
>>
>>61984864
>O(n)

it's constant space as I said in original post, it doesn't go above 4M for 100 nor for 100k nor anything more

sorry that you had to find out this way but your code is just trash

[nix-shell:/tmp]$ ghc -fforce-recomp -O2 M.hs -o M && /nix/store/31za3ilmm0y3mqvxjg68cvwyy8xvmymy-time-1.7/bin/time --verbose ./M 100001 > /dev/null
[1 of 1] Compiling Main ( M.hs, M.o )
Linking M ...
Command being timed: "./M 100001"
User time (seconds): 6.24
System time (seconds): 0.07
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:06.32
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 4368

[nix-shell:/tmp]$ ghc -fforce-recomp -O2 M.hs -o M && /nix/store/31za3ilmm0y3mqvxjg68cvwyy8xvmymy-time-1.7/bin/time --verbose ./M 10001 > /dev/null^C

[nix-shell:/tmp]$ gcc lol.c -O2 && /nix/store/31za3ilmm0y3mqvxjg68cvwyy8xvmymy-time-1.7/bin/time --verbose ./a.out 100001 > /dev/null
Command being timed: "./a.out 100001"
User time (seconds): 44.33
System time (seconds): 0.14
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:44.50
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1224
>>
>>61984888
Again, many prominent companies have chosen it over C++. So your "Real world" argument is also invalid.

>Show me some good benchmarks, would you?
https://github.com/eBay/tsv-utils-dlang/blob/master/docs/Performance.md
https://github.com/llaine/benchmarks
https://github.com/kostya/benchmarks
>>
File: 1503163249.png (368KB, 1025x724px) Image search: [Google]
1503163249.png
368KB, 1025x724px
>>61984864
>>61984956
and before you yap your mouth about n = 9, obviously both finish too fast to time with time so I'm not going to bother beyond that
>>
>>61984723
are you saying std::string isn't dogslow and that you shouldn't favor const char * const over it? I mean, its not as retarded as QString and with SSO in C++11, it can be good but.. on interface boundaries its ideal to not expose an std::string.

internally, if you're using it for identity or as read-only, why not use the const char * const? I'm not telling him not to use a string, but in places where a const char * const will work. I use string/wstring a lot, but I know it can pretty slow for read-only strings.

or are you complaining about where my pointers are?

>>61984774
auto is nice because it doesn't do implicit conversions. so you won't have possible temporaries/copies or have the wrong type. like
std::string f = "asdf";
will do. (granted an optimizing compiler will almost always improve this).
but for non-primitives you shouldn't likely ever use = in declaration, but rather uniform initialization
std::string f{"asdf"}; // same as auto f = "asdf"s


>>61984885
oh, ofcourse not. but std::string should be passed by reference, not by value in the general case.
>>
>>61983015
>my only insult is brainlet
>i'm also a faggot
we know, dude. we know.
>>
>>61984965

Of the three benchmarks you showed, only the last actually shows figures comparing C and C++ to D. The first shows comparisons between D compilers and between some tools that handle TSV files, but does not show an apples to apples comparison of programs written in C++ to D. The second compares D to Node and JRuby -- no shit it's going to be faster. For the third, I see that D has an advantage in about half of the benchmarks here, and I will give it credit for that, but my point that benchmarks are ultimately unaffected by garbage collectors still stands. Ignoring the garbage collector, D is a very useful and fast language, but ultimately it is unwise to ignore such anti-features when considering it use.

As for your claim to many prominent companies using it... There are plenty of prominent companies using all sorts of weird languages for one use or another. But if you look at the industry as a whole, there's good reasons why D has not taken off. If garbage collection is something that is acceptable for your program, you probably aren't doing something that needs a lot of performance, and so other languages are preferred for usability concerns.
>>
How do I redefine a method returning array of parent class objects, to make it return an array of child class objects?
>>
>>61985295
If you're talking about method overriding, you can't do that. Overriden methods have to have the same signature.
>>
>>61985270
not him but just shut up already christ

if you think any language hasn't taken off because of GC, you're just retarded

99.9% of companies are not writing code where GC is an unacceptable cost. Indeed most of them want languages with GC because they want people to be productive instead of fiddling with memory all day and introducing bugs which are completely eliminated with GC.

Honestly it's sad to see that you don't seem to be any smarter than you were couple of years ago but you speak with authority out of your ass
>>
>>61985438

>99.9% of companies are not writing code where GC is an unacceptable cost
Most of these companies are writing in Java or C#, or in some web language. How many companies using C++ or C are writing code where GC is an unacceptable cost?
>>
>>61985470
>Most of these companies are writing in Java or C#, or in some web language.

Out of the ass but OK, then you agree that most of 99.9% of the companies are OK with GC'd languages. Therefore GC is not a detriment.

>How many companies using C++ or C are writing code where GC is an unacceptable cost?

"How many companies use two biggest languages without GC to write code where GC is unacceptable?" Gee, what a good question!

How about "'how many companies are using C++ or C where GC is an acceptable ``cost``"? Protip: not that many. C nor C++ are not nice to program in. Unless there's specific reason you need to pick them (library/hardware support/control), you probably won't be.
>>
>>61985594
how can you miss the point this badly
>>
>>61985594

>most of 99.9% of the companies are OK with GC'd languages. Therefore GC is not a detriment.
Goddammit, you are not getting the argument at all.

The use case for high performance languages and the use case for languages with garbage collectors do not overlap much, if at all. Those able to tolerate a GC are able to tolerate other performance issues, and do so, in exchange for greater usability. D is a language that compiles to native code and performs very well for the most part. But it has a garbage collector and it will have inconsistent performance, which is undesirable. It is intended as a replacement for C++, but it cannot perform that role because the use case of C++ is areas where a GC is intolerable. So this places it squarely into Java's territory. A D programmer might say to a Java programmer "hey, my language is faster than yours," and they'd be correct, but the Java programmer isn't as interested in performance. There's a number of other factors for them to consider that they're not going to give up for D.

>Unless there's specific reason you need to pick them (library/hardware support/control), you probably won't be.
Try high performance user applications, such as those dealing with productivity (Photoshop, Maya, Sony Vegas), or video games. C++ is highly favored here because no one using these applications appreciates inconsistent or low performance. Outside of embedded, this is where C++ shines, is this is what you cannot excel in if you cannot offer similar features. I consider languages like Rust capable of replacing C++ for these kinds of applications in the future, because on paper it offers a similar feature set (native code execution, deterministic memory management, good compiler optimizations). In practice, it has a long way to go. D could excel in the same areas, but only if it first ditches the garbage collector.
>>
Java > C++ > everything else

This is literally an objective fact
>>
>>61983590
You will have legal issues, so I hope you have a good lawyer. It depends on your state and country.
>>
>>61985946
The author of a piece of software isn't responsible for how it's used. That'd be like blaming Microsoft for child porn because some pedo was using Windows.
Thread posts: 365
Thread images: 23


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