/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous thread:

Attached: daily programming club.jpg (1280x720, 166K)

Other urls found in this thread:

gitlab.com/bunu/Sup
en.m.wikipedia.org/wiki/Midpoint_circle_algorithm
youtu.be/iSmkqocn0oQ?t=203
automatetheboringstuff.com/chapter0/
dev.maxmind.com/geoip/legacy/geolite/
en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
twitter.com/SFWRedditGifs

first for php is a good language

please do not lie in my thread

Attached: 1501391022850.jpg (559x813, 29K)

a cute

Attached: 1464182159411.png (733x722, 499K)

>get new job
>everything is written in Java
>call everyone brain-dead Pajeet street shitter
>start to rewrite in C
>fizz buzz proof of concept done in only 5 days
>fired for not doing my job
???

Attached: 1502032056584.jpg (680x680, 69K)

Monthly reminder to use #![feature(nll)].

Please do not post anime while speaking to me
Your opinion is not valued

Attached: anime on 4chan.jpg (897x445, 202K)

What's the most anime language out there?

the emoji coding language

suicide

lisp

ArnoldC

>the emoji coding language
>suicide
>lisp
Are these different names for the same language?

why doesn't this work Sup Forums, do i have to declare input outside the do?

do {
int input = get_game_input();
int computer_choice = get_random_type();
std::cout

yes

Common Lisp because Lain uses it.

look up the word, "scope", lad.
then logically think about your problem.

maybe

underrated

Yes, while checks it's conditions outside the loop. That variable only exists within the loop.

You can do this if you really want to hide input within a scope
{
int input = 0;
do {
// c0de
} while (input != 0);
}

You can place pairs of curly brackets freely within your code like this. It's a neat way to avoid otherwise conflicting variable names

How would a draw an ascii circle given a radius? I can't seem to figure it out.

Hey lads. I decided to rewrite my Sup Forums image scraper in Python + TkInter. I previously wrote it using C++ and Qt almost 2 years ago, but I got tired of recompiling it (and it not compiling because of an error because of new Qt versions) and getting it to compile whenever I use windows. I am wondering if anyone of you got any tips for me? Don't really use python that often.
I do have some questions. This doesn't use that much ram on startup. Around 19 mb but when I start downloading images from threads, it jumps up to 250ish mb. Sometimes it goes up to 500 mb but then goes back down to 200ish. Any tips on how to fix this?
gitlab.com/bunu/Sup Forums-scraper

en.m.wikipedia.org/wiki/Midpoint_circle_algorithm

x = cos(phi)
y = sin(phi)

for -Pi < phi < Pi

Julia 0.7/1.0 will be here any day now. I'm looking forward to it.

>m.

redpill me on using auto on c++ 14

Attached: R14kkDj.png (651x522, 88K)

Use it always unless you have types shorter than 5-6 letters or if you explicitly want readers of your code to be able to see the type. Treat explicit type declarations as documentation.

It's a total shit comparing to actual Hindley–Milner type deduction in Haskell and Rust.

so basically making auto smart pointers make C++ 14 like a low level language that copies C but is basically like writing python or java code.

Why's that?

Because it doesn't consider the actual uses of the variable type of which it tries to deduce, only the value it's being initialized with. I.e. in C++
void foo(uint8_t);
//..
auto a = 0;
foo(a);

will deduce a as int, while in Rust
fn foo(_: u8) {}
let a = 0;
foo(a);

Will deduce a as u8.

>_: u8
that's not exactly the same as auto though.

Why would it not deduce as int? These are two separate expressions and the auto type is properly deduced based on its own expression.

try:
from effort import diploma
except:
clean_toilets(until.death)

>disgusting Rust shill tries to draw parallels between Rust and Haskell
>again
Friendly reminder that a language designed by and for low-IQ web devs who fancy themselves "systems programmers" can never be in the same league as Haskell.

Attached: rust-dev.jpg (400x400, 19K)

l o l! !!

Because it makes auto less powerful for generic programming.

Fuck off Simon "cuck" Jones. You functionalfags and rustfags belong to the same shit tier.

Get out, dirty plusmonkey. You are only slightly above Rust, but still in the retard corner.

That's not an issue with Auto by itself. It's an issue with C++ not having return-type overloading.

is auto only for primitive types?

Can anyone recommend a good first language to start self learning if I don't have any specific projects in mind?
I've googled this many times but there are a million different answers and they each have their own reasons. The more I try to research what to start with the more confused I am.
I've heard a lot about Python as a beginner language though; what do you guys think if starting from there?

No.

Attached: file.png (1104x386, 57K)

>Fuck off Simon "cuck" Jones
Eh, Extremely British Man isn't blessed with enough dpt-tier autism to be that smug and disconnected from reality.
Exhibit A:
youtu.be/iSmkqocn0oQ?t=203

Try actually watching the videos you link instead of only reading the title, tard.

What happens if a value from a primitive is used on main in the main stack but is send to every function as reference?

Is like being on the heap but at the same time being on the stack?

Python's a reasonable choice. It's not incredibly modern, but there are an enormous number of learning materials and a shit-ton of high-quality libraries for pretty much anything you'd like to do.

I could go on for ages on why there exist superior languages to Python, but it really is probably the best language to start programming in.

>Can anyone recommend a good first language to start self learning if I don't have any specific projects in mind?
Go. It's simple enough for a beginner to fully grasp in a reasonable time span, it has all the necessary features for a beginner, and none of the idiosyncrasies and cruft found in languages like Python or C#, so when you get a hang of it, you won't have to unlearn anything.

Try watching it yourself, you dumb fuck.
I watched it a few times back in the day before even seeing the title.
It's light years more balanced and un-smug than most "muh pet language" ideologues, to say nothing of dpt-tier discourse like "hurr durr FP>POO Peano Provers Rustfags BTFO".

I second this. As the creators of the language said Gol had been conceived as a language for retards so it ought be good for beginners.

Python's a decent choice, because you can get small-scale shit working incredibly fast - the wide ecosystem with support for almost everything helps a lot.
It's very useful to contrast and compare with another language while doing Py shit, though.
If you haven't programmed before, give this one a skim:
automatetheboringstuff.com/chapter0/

You're being baited.

Thanks a lot guys! I will definitely look into Python and go and try to make some time to start learning them.

Yeah, that's possible.
Then again, a decent chunk of dptards are literally that blinded by their autism.
But you're right, it's better to assume b8 until proven otherwise.

I'm serious, fucktard. Try actually watching it and then come back and explain what it has to do with smugness levels. I understand that the title has mislead you to the conclusion that Monad Man is very humble and recognizes the deficiencies of Haskell, but the actual video has nothing to do with it.

If you'd be so kind to use a tripcode, I'd like to filter your posts.

Fuck off back to FB, tard. You'll find your mindless antics are more acceptable back there.

>I understand that the title has mislead you
weak b8 m8
I've already mentioned I don't give a fuck about the title.

However, for the benefit of the audience, here's a few of the ways how meme man is less retarded than dptards (low bar, I know):
- he doesn't claim "side effect free" is panacea, and throws some bantz at side-effect free stuff at the very timestamp I linked
- he doesn't spiral down into "FP is wank / OOP is POO" level retardation, instead highlighting the cross-pollination between different languages and paradigms

And I've already mentioned that you're a FB-tier retard who links to videos without watching them, and that you will be unable to explain how this video backs up your narrative. Which has been confirmed by your repeated deflection attempts. ;^)

you may want to tweak your b8 to account for me doing literally that in

by the way you're aware that at least two different people aren't exactly fans of your weak attempts at shit stirring, right?
gotta step up your shitposts laddie

How do i recognize user's country based on their ip? I don't want to use some 3rd party service where i have to send data to some remote location

dev.maxmind.com/geoip/legacy/geolite/ + one of the many legacy geoip libraries

class Player()
{
HP hp = new HP(100);
}

class HP()
{
static int HP;

public HP(int i)
{
HP = i;
}
}

>tfw this is how java let you pass by reference primitive values

Attached: 1520644479179.png (288x415, 178K)

You can host a local geoip database/server. There are a fuck ton of these out there so just find one suitable for you and that's it.

Java is bad

>Cnile still butthurt Java fixed his pet language's error-prone const-related retardation
how long are you going to embarrass yourself?
Please, post some more Pajeet-tier-formatting code that demonstrates how clueless you are.

Are you implying that Java isn't incredibly error prone?

What's wrong though? I mean I'm not even using Java but I don't see it as a problem that just sounds like a shitty design from your part.

>Encapsulating a single int behind an entire class

Reminder that what he actually says in the video is that languages are evolving away from imperative programming and towards the "Nirvana" of pure functional programming with limited side-effects restricted and separated from pure code using the type system, i.e. what modern Haskell is doing. He's also explicitly stated many times that FP is superior to imperative programming and is the future, all of which constitutes the "smugness" you keep implying, so again, it's clear that you didn't watch the video, and that you've failed to understand it even after being called out and watching it. Now fuck off back to FB, retard.

Exactly, why are you doing this?

You can not do that.

Sure.
Don't nirvana fallacy this shit tho, it's still streets ahead of C/++ in terms of avoiding footguns.
Still horrible verbosity and a retard-oriented straitjacket in terms of expressivity, so I'm not touching it with a ten foot pole if I can get away with it.

This is some high-effort bait you have here. Good work, user!

java doesn't pass by reference primitives, only objects are passed as reference.

if I want to pass a single int as reference I have to make it a class.

We live in a world of side effects.

>explicitly stated many times that FP is superior
[citation needed]

Neat thanks.
Although i'm a brainlet, how do i tell what range is this for example? 206.125.172.0/22 is it like 172.001 - 172.220 ?

No shit sherlock.

Or you can just make a class method and call it instead?

en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

Java doesn't pass by reference at all, everything is pass by value. Reference types != pass by reference.

>as a reference
Make it an attribute of the fucking Player object, you dingus

Sounds like bad design desu though it might be less troublesome (and cumbersome) to switch to C# instead

how do I pass by reference in java?

The /22 tells you how many bits from the right don't matter: In this case, it's /16 + /6. So, the last byte doesn't matter at all, and the least significant 6 bits of the second-to-last byte doesn't matter too.

Attached: Screenshot_20180320_094046.png (573x137, 10K)

You don't/can't. You have to wrap it in an object and mutate the shared object.

Do what you are doing..

Fuck I'm an idiot, /22 counts from the left. Just use a netmask calculator for brainlets like me.

so basically he's correct:

>it's still streets ahead of C/++ in terms of avoiding footguns.
Not really, it's just Java footguns cause the JVM to explode instead of just segfaulting and crashing, which is much, MUCH easier to debug.
Java let's too much shit slip by at compile time. I'm not saying C/++ aren't like wielding a knife with no handle, but Java is like trying to massage your foot with a sledgehammer

>towards the "Nirvana" of pure functional programming
Literally lying through your teeth - you gotta keep your b8 a bit more subtle.
Again, for the benefit of the audience, and to counter the usual FP/non-FP extremists:
The "nirvana" in the video is safe+useful, haslel is in the safe+useless corner, mainstream langs are more towards the unsafe+useful corner.

>b-b-b-bait!!
Extremely desperate. Anyone can watch the video and see that it's exactly what he says, low-IQ FB poster.

>java doesn't let you pass by reference
The absolute state of that language

>only quotes a third of the sentence
>accuses me of lying
Here's the full quote:
>the "Nirvana" of pure functional programming with limited side-effects restricted and separated from pure code using the type system
You've exposed yourself as subhuman.

Yeah java sucks shit and int is immutable.
Doesn't mean you can't solve your problem another way. Why do you pass your HP anyways? it should be controlled by the player which handles actions made to it.