/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: kek.png (815x996, 732K)

Other urls found in this thread:

github.com/firecracker-microvm/firecracker/
github.com/elm/package.elm-lang.org
assertible.com/
netscout.com/arbor-ddos
secure.imvu.com/welcome/ftux/
medium.com/@mail.adnan.05/the-software-is-provided-as-is-without-warranty-of-any-kind-express-or-implied-including-but-b9cc8b91e239
twitter.com/AnonBabble

> NPM fag BTFO'ing coiners
based

nth for nim!

The threat of wireless devices.

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

>tfw trying to debug a double free
>unsure if I can use valgrind because it's a custom platform
help

Should've used Rust imo

uninstall C

how do I write this as a for cycle, do I got top to bottom or bottom to top? I have an assignment to write this both as a cycle and as a recursive function and I'm beginning to pull my hair out

Attached: Capture.png (372x214, 3K)

UB sanitizer can catch these, and there are malloc logging tools that will save you stack at each malloc/free operation so you can track down for each one. Long term solution is to stop using C already.

Post what you are working on

Attached: 1538660850130.png (852x550, 49K)

I was wrong, it wasn't a double free. The pointer was being corrupted because it was presumed to be suitably aligned and actually wasn't.

Digging some dried poop out of my ass hair

making a Jow Forums desktop client?

No, I'm making a (You) counter which will eventually be able to connect to an Arduino and alert you when you get (You)s

>and alert you when you get (You)s
pretty elaborate considering desktop notifications exist

It's not supposed to be anything practical, I just do that for fun

Attached: 1538123783129.png (494x795, 411K)

whatever makes you happy in life lad, all that matters.

What about something like this?

q = x*x;

for (i = 256; i > 1; i /= 2)
q = x*x + i/q;

y = 1/q;

>sneaked
not snuck. that article really pisses me off

Not him, but just use libnotify lmao

that's kind of what I was trying to make, but I just found it hard to wrap my head around how to actually write it out, thanks

That shit looks annoying af

>Filling out online application
>Select your GPA
>My GPA is too low to be on the chart
just fucking end me

sneaked just follows common patterns in English even if you sound like an absolute retard saying it. Just one of those anomalies.

Attached: 1535334301987.gif (733x650, 478K)

how can I get better at programming so I can customize Emacs optimally?

You know, in all these years I never wrote or even considered a for loop with a division on i

AWS is now using Rust. Based.
github.com/firecracker-microvm/firecracker/

then a bitshift will blow your mind

Convince me that we shouldn't have sacrificed you to Moloch.
>Walk into job interview
>Hear this question
Wat do?

Is that a loli?

Hello I think i'll be a valuable member of your team

Red pill me on Go, and should I learn Go or typescript for webshit?

Attached: goguy.png (256x256, 16K)

Neither.

Attached: lrg.jpg (500x656, 74K)

>safety-driven web development

haskell backends are pretty popular.
Everyone loves incredibly stable backends they can forget about.

>haskell backends are pretty popular.
no they aren't

>Everyone loves incredibly stable backends they can forget about
you'll never forget about it because if you hire a haskell programmer they'll never shut up about it

oh boy, now we get to play my favorite game of "no that doesn't count".
How many examples do you want to start with?

Attached: 1d83a67b-20cb-4019-a097-4010bc3d025e.png (1140x1856, 236K)

lets go with 3 at a time

if your number of example companies using haskel for backend is sub 100 it is irrelevant, if it is sub 500 it is not worth mentioning

based user

I'm currently learning Java. I've just remembered that JavaScript repository where a guy made a formula for checking if a number was odd or even with more than a million downloads.

Attached: 2018-11-27_17-23-50.png (946x518, 43K)

fucking based
link?

github.com/elm/package.elm-lang.org
assertible.com/
netscout.com/arbor-ddos
secure.imvu.com/welcome/ftux/
here's four.

medium.com/@mail.adnan.05/the-software-is-provided-as-is-without-warranty-of-any-kind-express-or-implied-including-but-b9cc8b91e239

>Snoyman
>not Snoyboy

>make list of tuples in python
>for some reason one of the tuples isn't ordered in the same way I put it in
>going insane trying to figure out what the fuck is going on
>mfw one of the tuples had accolades instead of brackets and the font made them look so similar I completely missed it even when looking at it closely for 15 minutes

alright, fuck the default pycharm font

Probably grab & runs by students.

Isn't Rust just NPM with pointers?

Source Code Pro if you're looking for recs.

No, it's OCaml with pointers

I'll just go with my good old friend Consolas

Explain generics to me simply /dpt/, like I am a cute but confused anime girl.

Instead of one particular dick you can fit any dick you want into your tight pussy

a guy larping as a girl should get it better than most

you want to make an addition function
Everything is fine because you're only using ints.
but then you come across a float.
now you're getting a type mismatch because ints are different than floats.
You could make four different functions to handle
>int int
>int float
>float float
>float int
But that's stupid, and tedious!
So imagine one function, who's arguments are "as long as they are numbers, I'll handle the rest".
Look how much easier that is!

It's kind of like anime, which is also very generic

fn f(n1: T, n2: T, n3: T) -> ::Output
where
T: std::cmp::Ord + std::ops::Mul + std::clone::Clone,
::Output: std::ops::Add + std::fmt::Display,
{
let mut arr = [n1, n2, n3];
arr.sort();
return arr[2].clone() * arr[2].clone() + arr[1].clone() * arr[1].clone();
}

Attached: 25591838.jpg (743x635, 47K)

f : fg sd: h[] n :: sd[]::nf f : fg sd: h[] n :: sd[]::nf f : fg sd: h[] n :: sd[]::nf f : fg sd: h[] n :: sd[]::nf f : fg sd: h[] n :: sd[]::nf f : fg sd: h[] n :: sd[]::nf

I'm a Physics student interested in programming, all my class mates are absolute retards when it comes to it so I don't really have any point of reference for where my skill should be at, so I'm reduced to asking here and hoping I don't memed.
So I recently did a online technical assessment for an internship, made for 2nd yr students (20 yr olds) for reference. There was one programming challenge that involved in roughly 30 minutes (rest of the hour was for the multiple choices) to make a function that would take a selection of coin denominations and a number, and then produce that number with the minimum amount of coins used. Eg, given 20, 10, 5 and the number 30, the function would return 20 and 10. I somewhat struggled with it, only managing to get 5 of 10 test cases working, so clearly I'm missing some knowledge here on a specific algorithm I should had applied (which I guess comes with not studying compsci), but what I'm wondering is, how easy should this had been for someone applying? I know it's not uncommon for these to ask hard questions and see how you get on, but again not being a compsci student and not having anyone to compare my skill to, I have no idea if this was one of those or not and it's kind of fucking with me. Like obviously I know I have loooads to learn but, am I actually just retarded or actually roughly average with some shit I need to pin down?

Give it to me straight, Jow Forums.

Attached: amiretarded.png (1014x720, 1.02M)

I thought about this problem for a while, annoyed by thought of having to resort to having nested loops. This is my attempted at rectifying that, which I also believe managed to make it computationally cheaper. In everyone's favorite language to boot.

function birthday(s, d, m) {
// s has to contain enough elements such that Σ s >= d. Furthermore,
// it also follows that m has to be GTE than that number of elements.
if (Math.ceil(d/5) > Math.min(s.length, m))
return 0;

let possible = 0;
let prev = 0;

// Let P_n = s_n + s_(n+1) + ... + s_(n+m), it then follows that
// P_(n+x) = s_(n+x) + s_(n+x+1) + ... + s_(n+x+m) = P_(n+x-1) - s_(n+x-1) + s_(n+x+m)
for (let i = 0; i < m; i++)
prev += s[i];

for (let i = 0; i < s.length - m + 1; i++) {
possible += +(prev === d);
prev = prev - s[i] + s[i + m];
}

return possible;
}

I like Rust's trait based generics. Makes the code intent clearer.

that's not computer science, that's basically a math question

>::Output
lol no decltype

Programming interview / test questions are fucking stupid and rarely have any bearing on actual programming. Just merely a math problem like the other user said. Or an overly specific problem to test your problem solving skills. Granted that's a high-school tier one and i'm honestly surprised you haven't come across it before. project euler isn't bad if you want to test yourself on more silly shit like it though. Just keep reading more, and maybe go through CLRS if you want an in-depth on algorithms.

I honestly miss this in Rust
That being said, decltype is less clear

Am i missing something or is this just a shitpost to try to write rust as ugly as possible?

based

So, do you think most people who applied would had been able to get 10/10 working in the time given?

I honestly don't understand how a code can be either ugly or beautiful? How can an AST have a scale of beauty?

looks like it took all the ugly bits of C++ lel

Its the type of question that's easy if you know the answer and hard if you don't
ie. a terrible fucking question

Why not?

I'd wager 60% of applicants would pass it.
And probably 40% of those did extensive """studying""" in the form of googling common programming interview questions.

>Why
I asked how

...

autism, basically

You're really just proving it isn't popular by mentioning rare obscure shit no one's ever heard of like that. You're making my point for me.

It's quite easy if you've studied CS, but it's exactly the sort of problem where the naive 'algorithm' (i.e starting with the biggest coin, taking as many of those as possible, then repeating with each smaller coin) that people immediately think of breaks down in some important cases. For example, if you were changing 30 cents with quarters, dimes and pennies, you'd get 6 (1 quarter and 5 pennies) from this instead of the actual answer of 3 (3 dimes).
This is actually a straightforward dynamic programming problem, but explaining that is a whole complicated thing that takes a while to get. The Algorithm Design Manual by Steve Skiena is available free online and has a whole section on it, and there are plenty of videos on youtube to explain it as well.

There is a clear scale of beauty but it depends on multiple factors such as legibility, efficiency of syntax use, efficiency of computation, etc.
If someone writes ugly code that's unclear in its function and is super inefficient I'm sure as hell not gonna call it beautiful.
But there is a definite beauty in solving problems as elegantly as possible

whats the best answer?
my immediate thought was to just recursively search a possiblity tree starting with the biggest coins first but maybe there's a better way

I see, thanks anons you've helped me out.

Yea that's the exact method I went for. I'm gonna start going through project euler questions and hopefully that'll give me a better grounding in this stuff, I've been intending to get onto studying algorithms properly but there are other areas in programming I want to refine beforehand.

It's obviously a shitpost. It takes three arguments, drops the smallest, and sums the squares of the other two. The output of all this is then required to have a human-readable text representation for no reason I can see. All of this could be much more clearly expressed as a couple different functions.

So basically if it's not clear to you it's not beautiful?

Just reworked a number of list related subroutines in a batch script. Worked on the first try.

Feels surprising and unsurprising at the same time, man.

Attached: 081018-40-Theory-Mind-Brain-Philosophy-Psychology-Consciousness.jpg (1200x900, 482K)

>there is a definite beauty in solving problems as elegantly
'beauty' and 'elegance' are two different words for the same subjective thing
'beautiful' code is just programmer autism

hello dpt, which choice of language would be best for a homosexual programmer such as myself?

Not necessarily.
There can be beauty in other aspects such as using the shortest amount of possible characters or using a highly efficient algorithmic approach that is well implemented.

G-Code so you can communicate to your 6 axis dildo machine

Is there a tool for visualizing python calls on windows?
totally not a brainlette

what

what lang?

>Using continue in C# doesn't increment the loop variable
fucking LMFAOOOOOO

So you're saying terse code + minimum Big O = beauty?

how long are you going to keep doing this?
Don't you have a life you need to be getting back to?

something like this

Attached: HezWg.png (3903x789, 489K)

Attached: unknown.png (1920x1080, 106K)