/dpt/ - Daily Programming Thread

What are you working on Jow Forums?

Old thread

Attached: a7e.jpg (1006x706, 90K)

Other urls found in this thread:

stackoverflow.com/a/23935892
docs.microsoft.com/en-us/nuget/consume-packages/package-restore#migrating-to-automatic-restore
en.wikipedia.org/wiki/Lambda_calculus
twitter.com/NSFWRedditVideo

while(1) {
puts("Please don't use an anime image next time, as it's not related to programming. Thanks!");
}

but user, programming is a subset of anime

Attached: DR7IZVoV4AAK636.jpg (645x729, 28K)

Nothing

Just finished my internship project (Mx).
>almost engineer, internship and 1 class left
>mfw focused on the project instead of the class
>failed the class
>They will probably kick me out of school this week
>soon2b neet
>mfw writing my cv rn

Attached: 1527561580418.jpg (524x1009, 125K)

Thank you for using anime picture OP-chan!

Attached: 3e482b5528eb9939244e476096995e1b--serial-experiments-lain-manga-anime.jpg (736x796, 80K)

Rust is better C

Shit can't get better

I'm learning about event driven programming in java and came across this bizarre statement in my text
EventHandler eventHandler = e -> {clock.setCurrentTime();}

I wasn't aware you could assign an event handler (or anything) to a lambda expression. Why does this work? What is really going on?

cat test.c
#include "sqlite3.h"
#include "sqlite3.c"

#define DB_FILE "db.sqlite3"

int main()
{
sqlite3* db;
if (sqlite3_open(DB_FILE, &db) != SQLITE_OK)
{ goto fail;
}

return EXIT_SUCCESS;

fail:
{ printf(sqlite3_errmsg(db));
sqlite3_close(db);
return EXIT_FAILURE;
}
}

gcc test.c -lpthread -ldl

gcc test.c -lpthread -ldl
/tmp/xxxxxxxx.o: In function `sqlite3_libversion':
test.c:(.text+0x9a234): undefined reference to `sqlite3_version'
collect2: error: ld returned 1 exit status

The error message, why does it happen?
grep sqlite3_version sqlite3.c -C6
** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
** macro. ^The sqlite3_libversion() function returns a pointer to the
** to the sqlite3_version[] string constant. The sqlite3_libversion()
** function is provided for use in DLLs since DLL users usually do not have
** direct access to string constants within the DLL.

#ifndef SQLITE_AMALGAMATION
/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant
** contains the text of SQLITE_VERSION macro.
*/
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
#endif

/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
** a pointer to the to the sqlite3_version[] string constant.
*/
SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }

Why is the definition of sqlite3_version hidden behind a preprocessor directive? What is going on here?

EventHandler is a functional interface, probably.

Currently trying to find out how to restore NuGet packages from a command line. I've tried nuget.exe, msbuild and dotnet.exe and all of them complain that there was nothing to restore, even though I've copied this codebase without any packages into a brand new Docker container. Gonna try to install a more recent version of NuGet through the Visual Studio Community installer, that's the only other idea I have. Gonna be a pain in the ass to script all this shit though. God I hate Docker.

Bonus:
cat test.c
#include "sqlite3.h"
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
#include "sqlite3.c"

#define DB_FILE "db.sqlite3"

int main()
{
sqlite3* db;
if (sqlite3_open(DB_FILE, &db) != SQLITE_OK)
{ goto fail;
}

return EXIT_SUCCESS;

fail:
{ printf(sqlite3_errmsg(db));
sqlite3_close(db);
return EXIT_FAILURE;
}
}

gcc test.c -lpthread -ldl && echo "OK"
OK

So it's obviously only that line making trouble. What gives?

EventHandler is essentially a delegate.

e -> {clock.setCurrentTime();} is just a function that takes the event that called it as an argument essentially (in this case it discards the parameter)

Anime? On MY Jow Forums?!?!?

>functional interface
>delegate
These words are new to me but I will do a bit of research on them, thanks!

your literal problem is that sqlite3_version only exists when SQLITE_AMALGAMATION is defined
your actual problem is that you're trying to include sqlite3.c

Yes, and why does sqlite act that way? Why doesn't it define sqlite3_version if I'm making an amalgamation?
What's wrong with including sqlite3.c? It can in some circumstances be mildly superior to static linking.

stackoverflow.com/a/23935892
This is essentially how i did it in my build framework.

docs.microsoft.com/en-us/nuget/consume-packages/package-restore#migrating-to-automatic-restore
Array of methods here:

>dotnet CLI: use the dotnet restore command, which restores packages listed in the project file (see PackageReference). With .NET Core 2.0 and later, restore is done automatically with dotnet build and dotnet run.

>NuGet CLI: use the nuget restore command, which restores packages listed in the project file or in packages.config. You can also specify a solution file.

>MSBuild: use the msbuild /t:restore command, which restores packages packages listed in the project file (PackageReference only). Available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017. nuget restore and dotnet restore both use this command for applicable projects.

>trying to listen to donald knuth explain something
>he's stuttering like hell
>it's almost impossible to make out what he's saying if not listening carefully
Why aren't they editing the interviews before publishing them?

Because they expect the audience not to be lazy retards?

Got two junior dev job offers, one in C++, the other in Java using Spring as a framework. Salary is roughly equivalent. The C++ one if for a company that's been around for about twice as long (30+ years) and seem to have its shit more together. I personally enjoy C++ but seeing how most people in Jow Forums despise it, I assume C++ development in a professional context must be hell.

What do? this brainlet right here will unironically let you have an influence on his career.

what language are you better at?

Now that you guys have made explicit that lambda expressions are functions, and that the event that calls it serves as a parameter, the notation
e -> method

or more generally
e -> {statement;}

reminds me of the functional notation in learned in my abstract algebra course. iirc if we wanted to express a function f(x, y) = x+y we could write
f : (x, y) -> x + y
and more generally,
f : input -> output
Is this notation similarity coincidence?

Trying to cross compile a c++ project which depends on SDL2. Compiles fine natively, made a few changes to CMakeLists, pointing the linker to the new libraries, now I get

error: no matching function for call to 'min(int32_t&, int)'

on what appears to be the first function call in the first file in the compiler. What am I doing wrong?

>seeing how most people in Jow Forums despise it
Are you seriously considering taking job advice from NEETs who at most flip burgers? Read on the companies you're applying for, glassdoor or whatnot. Read on what sepples and java devs do. Etc etc. Don't ever take Jow Forums seriously and decide everything yourself.

do whatever language you feel your more comfortable with

Hey, I have two STEM degrees and work at the front desk of a fairly nice hotel, asswipe.

Check the resulting string that invokes g++. Maybe something's not right there.

And you give job advice for people looking at developer careers?

dotnet restore at the root of the project lol

Still working on a reader for the /prog/ db dump, as a sort of homework to get used to the stuff used in work. All that's left for a minimum useable program is a search for keyword functionality as I said before, but of course I went down the rabbit hole and found a way to refactor yet again my button custom control code. That took another day.

Attached: SddsProg.UI_2018-06-16_22-42-24.png (1310x1080, 119K)

Total CMake newb here; it didn't seem to output any makefile, where can I find said string?

I didn't give the career advice.

oh fug really, i wanna DiE

Wait. CMake generates the makefile (or some other project file, it has many options). You then invoke the makefile to build the project. How do you build without one?

what is /prog/ anyways, i only started browsing Jow Forums this year

lol

The 2nd most autistic board in the universe, right behind /jp/.

I was just curious to hear Jow Forums compare their experience working dev jobs using both languages, desu. I'm taking everything with a grain of salt.

Yotsuba's sikret 4letter board.

>I assume C++ development in a professional context must be hell.
That will entirely depend on your colleagues/code base. It can be great, it can be hell.

cmake --build .

No idea then, never used this flag.

We had text-only boards (named "textboards") until a few years ago. They had their own quirks and personally I miss it a lot. There are a few alternatives around but the people have spread thin, you know.

Also, fucking lurk moar.

>Yotsuba's
Is this the waifu of this "mot" guy I keep hearing about? I saw a picture of him getting banned in 2008, is he still around?

could you explain what to look for, though. What would be missing from the makefile, wherever it may have been?

here is the fundamental problem with c++
>any given problem
>at least 10 ways of solving it that are all considered standard
>no concise way to make different standard solutions to the same problem cooperate

bunch of cartoon loving degenerates

anime website

The syntax is rather shit too.

Programming is just applied anime.

The syntax (not counting templates and namespace disambiguations, which are ugly as balls and which you should do everything you can to avoid using) is one of its few redeeming qualities.
Especially since you can basically control it.
... operator...(...) {
...
}

std::imgay is beyond annoying
and "using namespace std" is le bad practice :(((((((((((((((((((((((((8

Just a word of caution: "min" is a name that is usually used as a macro (MS does it in its winapi headers), so I'd advice against using such a name. But in your case it's unrelated.
As for what to check: first see to it that the object file cobtaining your "min" function gets created. Then that its prototype is properly included. Then in the link stage it should get linked.

a::b::c

>"using namespace std" is le bad practice :(((((((((((((((((((((((((8
Only in headers. It's bad practice in headers because it leaks the scope into the including implementation file.
In implementation files it's fine and anyone who says otherwise is just parroting mindlessly without actually understanding the above.

On a second thought, maybe it is a vendor specific macro you are using. So when you cross-compile, the necessary header is not included.

>letting your code get to this stage
The natural evolution of a five-star C programmer.

Yup. It's pretty awful.
Haskell can be almost as bad, since:
A) you sometimes need to use parentheses in a type expression more or less the same way sepples uses angle brackets
B) there's no sepples-style overloading so every '::' is replaced with an actual word in the middle of a camel case identifier
C) it's much prettier when you so happen NOT to need parentheses but it's very unintuitive to try to figure out when that actually is
D) sometimes you can use $ instead of parentheses which is also much nicer but it's unintuitive to figure out when that is as well

In implementation files it's still harmful because it can lead to ambiguity if you're importing multiple namespaces.
It's always best to import symbols individually so that if the reader of your code is confused he has the opportunity to know precisely what symbol you're referring to.

at least haskell has the sweet (.)

but if it's bad because it leaks the scope in to the implementation file, what's bad about it in the implementation file?

modules could have prevented this

Has anybody ever used the tadpole operator?

that's pretty funny actually

not really. only if you are using large files. if not its fine. but why do you need to use the whole stl anyway?

if you want you can just to
using std::cout, std::endl;

~~o

My advice is to take the C++ job and stab someone in the neck for putting const on the wrong side.

Eh I guess. But if you're using a symbol defined in multiple namespaces and you've imported all of them, you should always use the disambiguated form of the symbol anyway. It's also good practice to include, after a using statement, a comment containing every symbol you use from that namespace without disambiguation, so your reader knows what the unambiguous symbols are from.
My whole point was it isn't. But actually I rescind that point, it is. See:

can someone explain bitshift operators and what their usecase is? i was scanning through bticoin's code and saw a lot of things like this happening
(int)x>>(int)y | (int)i>>(int)j;

>for putting const on the wrong side.
There is no wrong side. The const refers to whatever's left of it, or whatever's right of it if it's the leftmost token. Putting const in as the second token of a declaration specifier is just as valid as putting it in as the first token, as they mean exactly the same thing.

what's so funny user?

In terms of what your machine is doing, it is shifting the bits
i.e. if you have some byte abcdefgh then abcdefgh >> 3 = 000abcde

in practical terms, this means you can do efficient multiplication by powers of two among other things

bitshift operators literally take the register and shift the bits either left or right eg 11110 rightshifted once would be 01111 (or 11111 depending on how your shift works). It's exactly like bit rotation except instead of taking the bits that fall off the end and putting them back at the start, it drops the bits that fall off and adds either a 1 or 0 for each bit that was lost at the start.

Why is (->) both a type constructor (a -> a -> a -> ... -> a) and a kind constructor (* -> * -> * -> ... -> *)? I thought Haskell didn't have sepples style overloading?

It's a cute feature that makes sense but I had never considered doing before

ah i see. there were about 50 or so of these 'bitshifts' in the hashing lib. its so that the hashing function can be performed as fast as possible?

>const modifies to the left
vs
>const modifies to the left BUT
It's not so much the habit, as the retarded logic some hide behind to justify it (usually, ironically, not confusing some hypothetical group of novice programmers)

holy shit why is working with unicode strings on windows such a pain in the ass.

Yes. Bitshifts are a very cheap operation in hardware. On some platforms (e.g. ARM) they can be done in sequence with other arithmetic operations essentially for free.

t. nigger

because in unicode a character and a byte aren't the same thing which is terrible

don't worry, user, the next revision will fix everything

Attached: ugu.jpg (425x359, 28K)

citation? I find it hard to believe they would be faster than add/sub operations. unless you are on an ancient cpu

Whatever whitey. Not him but you should know even in anime the white girls prefer black dicks. It's never actually shown this way but we both know the nerdy yaoi fangirl is imagining the seme as black. He's basically the bull and the cute little uke is the emasculated sissyboy racecuck, except without a girl involved and instead the uke fills that role too, because the fangirl would ideally want to be the girl except she refuses to mentally insert herself in that way because she's so nerdy and self conscious. Not that we blacks would want her anyway, white traps are even better than white girls. Traps aren't gay. Especially not 2D traps. Fuck your degenerate 3D traps / girls, anime shotas is where it's at.

i think he is right. i am looking through cryptonite hashing algo and they seem to use a lot of bitshifts as well. see pic.

Attached: Screen Shot 2018-06-17 at 23.48.05.png (1534x986, 201K)

they would use bit shifts because it is logical to do so, not because they are faster. I would expect hashing algorithms to contain a lot bitwise operations

Why are you including sqlite3.c? Build that as a separate object (or use a pre-built DLL) and just use the API in sqlite3.h

>an unironical literal gay nigger weeaboo who programs
fuck this planet i'm done existing

guys I don't know what to work on that'll be interesting.
I'm just really saddened over the fact the majority of stuff I have experience with is in JS
I just want whatever I work on to matter to me

tfw too unintelligence to find something that is exciting

If your code looks like this it says more about you than the language.

What saddens you so much about JS?
I'm not saying you're wrong to feel that way. You're definitely right to feel that way, it's shit. I'm just saying you should think about WHY you feel that way.
Because that "why" might be the answer to your writer's block.
i.e make a better language

y is diversity a bad thing

>>no concise way to make different standard solutions to the same problem cooperate
If you want to enter political territory with the "muh diversity" shit, this is basically an allegory for races coexisting but NOT getting along WHATsoever.
Unless you're a white nationalist, it should be obvious why that's a bad thing. In sepples it's a bad thing for basically the same reason, but in code.

wow... i am looking into this now. fuck this stuff is so low level. kek

Attached: Screen Shot 2018-06-17 at 23.57.58.png (1530x970, 237K)

file in question contains

#include

which defines the function min

>coincidence
Absolutely not. Lambda expressions/anonymous functions in programming are an implementation of lambda calculus: en.wikipedia.org/wiki/Lambda_calculus

A combination of Unicode not being a simple format and Microsoft's decision to use UTF-16 back when they originally implemented support for it.