/dpt/ - Daily Programming Thread

Pure edition

Previous thread:

Attached: simon peyton jones.png (388x496, 199K)

Other urls found in this thread:

youtube.com/watch?v=iSmkqocn0oQ
youtube.com/playlist?list=PLSE8ODhjZXjYutVzTeAds8xUt1rcmyT7x
phoronix.com/scan.php?page=news_item&px=GCC-C2X-C-Standard
github.com/victorqribeiro/naiveCorners
github.com/nlohmann/json
github.com/yhirose/cpp-httplib
tensorflow.org/beta/tutorials/text/nmt_with_attention
youtu.be/QtQt1CUEE3w
twitter.com/SFWRedditVideos

First for sepples.

Attached: c++ anime 3.jpg (806x720, 80K)

So what's /dpt/'s opinion of Swift now that it's not locked to OSX, and open source?

thank you for using an anime image
more like cripples

I started a project to do exactly this with Python. You might find the Python package Mido useful. It's quite simple and will let you convert MIDI into training data and back to MIDI etc.
I collected a lot of MIDI files, about 90 correct examples (it's easy to get incorrect examples), and they all get uniformly converted to the same sized matrix. I can give you them if you want. Collecting training data for this task is quite difficult because you need lots of fixed size pieces of music that need to be simple (small) enough for the network to learn. They can't have weird time signatures or small divisions etc. And there are some weird bits of MIDI data that could mess up your serialisation process.

cute!

xth for haskell is useless youtube.com/watch?v=iSmkqocn0oQ

It's slow as shit and full of retarded design choices. Doesn't even work on winblows.

At what point should one try to learn SQL? If you can phrase it as 'when one is confident in creating X in language Y" Id be extremely happy

Attached: 1562411398219.jpg (1280x1828, 532K)

never

its the first thing you should learn. It's simple as fuck and some jobs require SQL and nothing else

my first data analyst job was working as a basic bitch SQL monkey for the Federal government

but that makes you wanna kys no?

>data analyst
lol do you really like that shit?

Understanding relational algebra and databases is fundamental stuff:
youtube.com/playlist?list=PLSE8ODhjZXjYutVzTeAds8xUt1rcmyT7x

>Understanding relational algebra is fundamental stuff
yeah, no, fuck off wheenie

SQL is actually kind of interesting to learn because of how declarative it is. Learning to write code with joins and group-bys is an extremely powerful and expressive style which should be aspired to when writing APIs for your own systems.

God I wish that were me

Are there any recommended Rest and JSON libraries for C++? I need some basic bitch stuff for a quick job.

Attached: 869EE253-87C0-4939-9B31-EA5AD2DDEF8B.png (316x490, 108K)

I mean, you can just code monkey your way through life. Nothing wrong with that.

I'm still a data analyst but I've since been promoted a couple of times. The SQL job was comfy and easy, but not very rewarding.

I like Data Analytics because it's about storytelling; deriving insights and distilling them into a form that the normies can understand. I do quite a bit of coding (Python) and don't use SQL at all anymore.

I prefer it to software work because business people actually care about and respect my work. And to be clear, I'm a data analyst not a data scientist. Data scientists (we have them as well) basically tweak algorithms. I have no interest in that.

anyone quit drinking coffee and found their focus improve? I quit, got headaches for the first few days but then my focus started improving by a noticeable amount.. I get in the flow a lot easier now and find myself wasting less time on stupid websites

>and find myself wasting less time on stupid websites

Attached: inquisitive pepe.png (225x225, 7K)

Thanks. Using that line for my data analyst interview :)

>relational algebra
>databases
>above code monkeys
uhm..

the point is that code monkeys use them without really understanding them

phoronix.com/scan.php?page=news_item&px=GCC-C2X-C-Standard

so, a while back I developed this simple algorithm to detect corners on a image, I named it naive corners, because I know it's naive. you can take a look at it on my GitHub

github.com/victorqribeiro/naiveCorners

how do i learn to code?

the year of our Lord 2019 you can't ask a question like that. there's literally thousands of video and text teaching how to do just that all over the internet

which language should i start with?

Python? C#? Javascript?

Don't worry, user. Let me finish my ice cream, then we will learn JavaScript together.

Attached: cce3394d847c025afd13b162e5a8e746.jpg (800x1200, 114K)

what are you trying to program? a web page? a game? a desktop application? a mobile application? Think of something you want to do, search the internet for the best way to do that (the right technology) and go from there.

i want to get a job

you will hate programming then. I recommend other areas if you want your job to be in tech. my brother is an electrical engineer and he had to take algorithm back on college, he hated it and he is very smart. programming is either fun or tedious, if you're trying to get into it for the money, I think you won't like it. personal opinion

attending engineering for pure programming is a no-no

Doing what you fucking piece of shit.

Become webdev

is there any string to int function in the c++ std library that doesn't throw an exception on failure (but instead just returns a default value passed as argument if it fails)?

use stringstream

I just want to make a game using my own game engine, get rich and live on an island.

satan no

>JSON
github.com/nlohmann/json
>REST
github.com/yhirose/cpp-httplib

ideally you'd write a stoi which returns a variant of , and then just call something like value_or.
In Rust, this is just:
let parsed = s.parse::().unwrap_or(42);

no idea how these work
I'm a cnile during the day

>only done 2 semesters so far in Business Informatics
>got a job in webdev for the summer
>people are all cool and helpful, easy to learn in this environment
>8 hours workday, meal break included
>pay is pretty good as well
I don't know what dpt has against webdev, it's easy, fun and even as a first year student I get paid a good amount.

Convince me NOT to go ahead and learn C++. I know JavaScript inside and out and would like to try out C++. Give me any good reason why I shouldn't before I go ahead and do it.

std::string str;
int x;

std::stringstream stream(str);
stream >> x;
if (stream.bad())
x = /* default */;
n.b. inefficient as fuck

actually that should just be if (!stream)

depends what you mean by "learn", it's piss easy to pick up a basic, working knowledge of SQL as you go. mastering SQL is complicated by the many slightly different implementations. i wouldn't bother sitting down to read a book about it or anything unless i specifically wanted to be a database guy, or i had some performance issues or something

Lisp is the most powerful programming language.

A good source would be Bach's chorales.

>maid outfit
>programming socks
>suddenly better code
i genuinely hate this someone help

Attached: 9848_NuttedOn.png (128x128, 21K)

Template (which you need for generics) code is ugly as fuck.
Also, lots of historic pitfalls. If you don't do things the modern way e.g. because you found some older shit on stackoverflow, you're likely fucking yourself over.

u gay, homie

C++ templates are easier to read than C macros tbqh

Not even nearly as powerful as C++

Good morning /dpt/, today will be working on a minimal gui library for opengl.

Attached: dec_pdp-11-tan.jpg (800x1000, 96K)

Lisp with templates when?

templates with lisp

yeah, but C macros are unwieldy enough that they don't get used _that_ much.
C++ templates get used constantly and can get incredibly complex.
If you just use them like C macros they're definitely better though.

i am now interested in c++. can you show me how to implement reader macros in c++?

You're fortunate enough to not be working on the same codebases I am then.
Also they're easier to debug.

what about both

Attached: Screen Shot 2019-07-07 at 8.38.16 AM.png (726x924, 144K)

thank you for your sacrifice.

based

"no"

Attached: 1562329093235.png (900x900, 680K)

so, I'm trying to do my first simple AI project. From what I see AI maps inputs to an output. What if I'm trying to feed information into AI just to generate something similar to that information? Like, for example, I'd feed the AI pictures of 1000 human faces and the AI would generate a random one based on what it learns from analyzing those 1000. There isn't any kind of input there really, right? Or is the input a 'hidden' random number?

you probably want to start with something simpler, but if you're feeling ambitious, look up generative adversarial networks (GANs).

Thanks! The example i stated was actually just an example, i want to generate just simple strings of a fixed length that's all i need

i don't know what language/framework you're using, but i got started with the Keras library
it's pretty simple to use.

Tell us about it

Will use just that, thanks for the help!

Attached: c7facddd38afb590a7b471fb906df3dc.jpg (300x403, 32K)

Yesterday I needed to place tens of logic gates and writing their coordinates manually was painful, I just need enough of a gui to place things and then dump their coordinates to a file.

Attached: 2019-07-07.png (256x256, 917)

Based

It is though? Even if you ignore that it's just basic set theory, SQL was literally designed to be used by the 'average' person.

How do you people handle time/calendar management? I want to try and go from programming at random when I feel like it, to being able to do it in a more contiguous schedule or at least measure how much time I spend on it (accurately).
I want to find out if I'm getting better or worse at this, and how to be programming more often. My list of projects grows while my list of completed projects stays the same.
I want to try and limit my time learning new things and spend some of it on actual practice too.
Any tips? I've tried pomodoro with some success.

Attached: 6cbebb48ea085c2253989c04b5df2ee99d41f2a5f38621685983cc22f8eb0176.gif (500x282, 1.35M)

>create GitHub account
>[email protected] could not be verified
wtf

Enforcing a work schedule is for absolute brainlets with the slave mentality
Just stop starting new projects and finish the ones you're working on, if that is important to you

Get a job

I feel like programming is different from most jobs. It's very easy to say "I'm going to spend 1 hour moving these boxes around" vs "I'm going to spend 1 hour thinking in abstract mathematical constructs". Even if I'm sick and tired I can do the former, the latter is a little more tricky.
I certainly couldn't get a programming job with my current cadence. For me it seems like I do my best work at late hours of the night. I'm trying to find a way to capture that and do it whenever. So that I can do this >finish the ones you're working on
more reliably.

i transcend time and space

Here's a secret, programmers do not go into to work, sit down, and do 8 hours of programming, although they may pretend to

A combination of normal macros and operator overloading.

struct _binary_string{
std::string str;
template
_binary_string& operator

But they should

No they shouldn't, because programming isn't manual labour and you can't solve a problem if you haven't figured out the solution

that's not a reason

>Have to poo
>Take laptop to the loo and work on projects
Who else does this?

Yes it is
If you tell a programmer to write a program an they haven't given it appropriate thought they're going to write a shit program, and that is the reason why many programs are shit

this is neat. so this occurs at parse time?

Why though?

Learn as in I can hold a junior job or do something actually useful instead of SQL version of Fizzbuzz

Attached: 1561927048735.jpg (1000x1412, 282K)

>const_cast
but for what purpose

as the other user said, check out GANs. rob miles has some videos about them on computerphile. they seem pretty tricky to implement but i'm sure there is a simplified version.
also from what i understand the input is random noise, so you're correct. if there was no input, the network would give the same output every time.

That's the primary reason.

Has anyone found a package or something to translate language, hopefully englishchinese, locally? Every link I find is either an online translator or google/azure api related. I don't want to require an internet connection (or run out of requests or all the other things that can wrong with apis).

I don't need it to be good either.

deep learning
train a model
use it locally

Just make your own user
tensorflow.org/beta/tutorials/text/nmt_with_attention

A ton of work in that case. Just doing a english->chinese->english joke mode for a comedy program.

just use markov chains to be honest

It was exactly what I was looking for. I found an example that does pretty much exactly what I need and it comes with a video explanation. youtu.be/QtQt1CUEE3w


Thanks again! I got everything set up in one afternoon.