/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1557795403605.jpg (1160x1426, 309K)

Other urls found in this thread:

cprogramming.com/tutorial/shared-libraries-linux-gcc.html
crunchyroll.com/new-game
tenshi.spb.ru/anime-ost/Naruto/TV2.OST-II/20 Girei.mp3
youtu.be/ZOlXkj-RO-M
youtube.com/watch?v=viCewgX6xak
gcc.gnu.org/projects/cxx-status.html
twitter.com/NSFWRedditGif

Should you link your debug build with debug libraries too or is that stupid?

2nd for haskell tiddie monsters

Attached: 1528867689165.png (850x1200, 1.18M)

If your IDE supports debugging into libraries and fetching their code for that then that's a very good idea.

Yes, but if there's a performance hit that makes development unpleasant, just make two debug build configs, one with only your project as debug build and the second with everything debug, and only use the second when you need to debug a bug in the library.

Woa! You made that all in JavaScript, user? Good job, it's amazing!

Attached: 0733cb4e965dfaa9a1c06d4ec20a219f.jpg (1364x2048, 227K)

Cute image.

Of course. Why would that be stupid?
A slight annoyance I have with Arch Linux is that it doesn't provide versions of libraries with debug symbols, so I sometimes have to go out of the way myself to compile them with it in. But that doesn't matter too much, because I don't need them 99% of the time.

Attached: 1554230601061.jpg (537x594, 45K)

t-thanks

With C++20's concepts will it be possible to give a default implementation? Or better something like haskell's MINIMAL pragma

nothing give me something to work

Attached: 1557095870225.jpg (640x500, 56K)

Fuck, replied to the wrong post.

Write a to wasm compiler.

That would make a good anime though.

how do I do that and what does it do?

Attached: 1547444306906.png (383x681, 458K)

I dun get it, how do you "use a compiled library", in C and C++?
If I have the full source code of that library, can't I just put it inside my project and use that directly?
What would be the difference then?
And do those building instructions for the library even apply to me if I just copy the source of it and build it myself in some different way?

Attached: dy.png (536x628, 372K)

You can already do that now.

cprogramming.com/tutorial/shared-libraries-linux-gcc.html

are there any good programming animes? Real programming not that hacking the firewall of the mainframe shit.

Attached: 1557121358396.png (1280x800, 1010K)

>If I have the full source code of that library, can't I just put it inside my project and use that directly?
Some projects have very non-trivial build systems, so it would be a lot of wasted effort to try and reimplement it into your own. Sometimes that is actually viable, though.
>What would be the difference then?
If you did it correctly, technically there should be no difference. But it is much better for everybody involved if you reuse system libraries instead.

Tools like pkg-config (or a build system that uses it) are extremely fucking helpful.

new game maybe, but it has zero actual programming

no

Attached: 1558719448834.webm (640x480, 2.65M)

>animes
>s
Also, I'd say things like "Gochuumon wa Usagi Desu ka" are the most relevant to programmers.

If Javascript is your way of saying C++ then yeah. Thanks!

Attached: 1556660156875.png (1645x1009, 188K)

>.cxx

Is there some kind of problem?

>1. Read program source code
>2. ???
>3. Output wasm
wasm (short for Web Assembly) is a binary executable format for web browsers.

>What are you working on, Jow Forums?
I got mouse input working for my client/server to forward keyboard and mouse from a Windows machine to a Linux machine over TCP. I was able to get mouse movement and clicking working fully. I still need to implement keystrokes and figure out how I will need to handle special keystrokes like alt+f4. Another thing I need to implement is a way to lock the mouse and keyboard input while I am interacting with one machine and not the other.

Attached: scrot.png (1920x1080, 463K)

Depends on what you name your headers.

how

.hxx sounds weird.
.cpp makes me think of CP

Just use normal overload resolution my dude

why the fuck would "real programming" make for a good anime? programming is fucking boring you dumb nerd

Yes.
With concepts it always just chooses the most specific overload. If a type doesn't satisfy one overloading, it'll choose a different one that does.
So basically that means you can do this:
[/code]
template
void foo() { /* default */ }

template
void foo() { */ types satisfying Foo will get this overload */ }
[/code]

Just finished my number-recognizing neural network. Excited

Attached: NeuralNetworks.gif (464x600, 433K)

speed it up

Note that this is possible with sfinae too, all that Concepts does is give it syntax which isn't eye cancer.

Sucks, it's clearly a 'y'.

>Note that this is possible with sfinae too
No. You have to disable the other overload by inverting the conditions.
If you don't, you get compiler error complaining about ambiguous overloads.

doing it the stdio way barely got me a second less
might try reading the whole thing char by char later to see how it compares to getline but I doubt push_back is an issue.
did a quick research on this and it seems hardcoding values almost always puts C++ in advantage while generating them in a loop gives Java an advantage so in this case (reading from unknown source) it has to be IO related though I am not sure how a VM can do it better than a native lang.
>can you try this
I don't have nodejs installed
rude!

crunchyroll.com/new-game

Attached: ng.jpg (1280x720, 187K)

Sure, I was taking it as a given that you were expecting a Foo overload. If not the. concepts is new.

>crunchyroll

>I am not sure how a VM can do it better than a native lang.
jit compilation

is it bad practice to name a table in a database a date? Say I create one table per hour and want to identify them by the hour they were created?

>crunchyroll
fuck off

Why does Nene have such shit taste in code formatting?

Using getline and then sscanf is dumb because first you're taking the data from the stdin buffer and copy it into your own buffer, then let sscanf run over that buffer to generate the number. Instead of just letting sscanf use stdin directly by using fscanf. You're saving a full buffer copy for the exact same result.

because she is a self taught programmer

JIT compilation is worse than AOT.

Thank you for reminding me to add the other ending condition

But it only works on hand-written numbers :(

Attached: NeuralNetworkButFASTER.gif (466x600, 561K)

blobs are the best practise when it comes to db.

are you retarded?

that's much faster

both jit and aot compilation output native code. jit compilation allows optimizations based on live execution analysis.

I guess I don't understand the situation. Why can't you just have an unconstrained template as the "default" case and more specific templates/regular functions for "explicitly implemented" types?

can you explain?

I'd like to do
operator ==(T a, T b) { return !(a != b); }
operator !=(T a, T b) { return !(a == b);}

then enforce a way to implement at least one of the two
I don't see how I can do that with normal overloading

0.6 second difference (3.4 -> 2.8) still 0.6 second slower than dotnet solution which reads line by line and validates conversion to int. maybe it's pattern parsing and va_list?

Have a generic one which calls the other and is selected by sfinae only if the other exists.

I expected slightly more than about 20 % speed increase.
The C# code might still be faster because int.TryParse is specialized to grok digits into a number, while scanf will have to parse, verify and match the format string as well. Maybe try using atoi instead.

it's a single line to install node, cmon you can do it

>Nenecchi will never optimize your code
why even

it's not her taste, it's the code style of the project enforced by a linter

Attached: 1533953748166.gif (540x405, 316K)

C++20 already introduces the spaceship operator with solves this particular case.

>it's not her taste, it's the code style of the project enforced by a linter
This is what fascism looks like:
if (cond)
{
statement;
}

What input are you fags benching this shit with?

pgo can do the same

>pgo can do the same
no. or explain how you would pgo something like eval()

Sane and good languages don't have eval, so no need to worry about it.

tenshi.spb.ru/anime-ost/Naruto/TV2.OST-II/20 Girei.mp3

Have we seen a greater anime soundtrack album since then? almost every songs are dope (Girei.mp3...)

Enjoy implementing an eval substitute for your shitty DSL then.

Eval is this kind of thing that only exists because it can (or for debugging purposes). Your original post was about optimization. Don't move the goalpost.

>eval substitute for your shitty DSL
Why the fuck would I do that?

youtu.be/ZOlXkj-RO-M

strings as template parameter type? i have never seen a library do this before.. What's the name of the library?

how do you think your browser is executing javascript? source code files (scripts) are fetched from the internets then passed to eval(). truth is that eval is incredibly powerful but only to the imaginative. you are a -∞x programmer.

Attached: nani.webm (1280x720, 412K)

Subete ga f ni naru has some programming (they talk about C), but it's not a programming anime.
The ending also has programming themes: youtube.com/watch?v=viCewgX6xak

@71245749
>source code files (scripts) are fetched from the internets then passed to eval().
No they are not. They are passed to a JIT interpreter. Browsers are not written in JavaScript (...yet).

It is not a library. I wrote it.
It's using C++20 class type non type template parameters. Basically the string literal gets contextually converted to cestring (constexpr string) which is taken as the template argument.
The reason I'm doing that is so I can index SQL statements at compile time in a way that also enables me to iterate them at runtime, and lazily compile them upon first use.
The alternative was putting the SQL statements in an array and manually compiling them all.

Here's the implementation of it.
template
static std::optional stmt_index;

static std::vector statements;

template
static void bind_args(sql::statement &st, First &&first, Rest&& ...rest) {
st.bind(i, std::forward(first));

if constexpr (sizeof...(rest) > 0) {
bind_args(st, std::forward(rest)...);
}
}

template
static auto statement(Args&& ...args) {
if (!stmt_index) {
auto st = std::make_unique(db.compile(src).value());
statements.emplace_back(std::move(st));
stmt_index = statements.size() - 1;
}

auto &st = *statements[*stmt_index];

if constexpr (sizeof...(args) > 0) {
bind_args(st, std::forward(args)...);
}

return std::make_pair(st, st);
}

Any arguments passed in get automatically binded to the statement.
The underlying sql::etc stuff is just a small wrapper I wrote around sqlite3.

isn't bind_args possible with a single thing? like
st.bind(i, std::forward(rest))...;
or something like that?

Not in my sqlite3 wrapper, but now that you mention it I could easily implement that.

Oh wait, never mind that post. I see what you're doing there with the ellipses now.
No, because then i wouldn't increment.

oh I see

>int.TryParse is specialized to grok digits
yeah I might go with getchar + atoi later. I just skimmed Console.cs of dotnet and it seems the standard lib implementation is merely a shadow with the actual implementation being kept internal as a part of the runtime. My guess is that it does native getchar calls until a new line character

wait I wonder if you could do something like
st.bind(i++, std::forward(rest))...;

Are you benchmarking IO and serialization? Wtf?

wow these c++20 features look great shame they won't be in any compilers till like 2030

Imagine actually writing a C++ compiler

I was unsure whether the increment would happen before or in-expansion but after trying it out it seems it works.
Also how you wrote it is apparently a syntax error so I just changed it to
(st.bind(i++, std::forward(args)), ...);

and it compiled.

GCC and Clang already have half of C++20 implemented before it's even out yet. C++17 for example was already fully implemented in GCC the moment the standard was released.
How do you think I'm using a C++20 feature in my project right now?
MSVC too has experimental C++20 support or so I've heard.

imagine not only writing a C++ compiler but doing so in C++

Attached: evil tama 2-min.png (2916x2160, 1.6M)

Is that a syntax error? Also that's a neat use of the comma operator. I'm surprised you can't just have statement...; expand to statement1; statement2; statement3; etc where they all have part of the pack

shut the fuck up cniles

>half
you mean half of the trivial changes, not half of the huge TSs adding big features

GCC 9 currently has most of all the trivial changes implemented.
As for the big ones, it has two of them completed, and the other two are in progress. Pic related.
You have no idea what you're talking about.
gcc.gnu.org/projects/cxx-status.html

Attached: 1555418892966.png (1026x177, 27K)

>transactional memory
>big
1 compiler has 1 big C++ 20 feature implemented

this

I want modules now
goddammit, it's the current year FFS

>95% of "trivial" changes (, class type template params, constexpr new/delete aren't really trivial) + 1/3 of the big features are implemented.
Yep, sounds like half of C++20 to me. It's pretty on track to releasing on time if you ask me.

How can tm work without a runtime?

modules are for gay pythonistas

headers are the fucking worst

Actually I like how the computer isn't really sure. Mimics an actual human.
>what the hell is that? Looks like a Y but he said it was a number. A 4 maybe? Oh it's actually a 4? wow.