/dpt/ —Daily Programming Thread

Previous What are you working on, Jow Forums?

Attached: vlcsnap-2018-04-08-02h56m56s827.png (1512x1072, 1.4M)

Other urls found in this thread:

htdp.org/.
youtube.com/watch?v=Y7rq6o6UDXc
google.github.io/styleguide/cppguide.html
twitter.com/NSFWRedditGif

Make this as generic as you can

Attached: 2018-05-23-132840_1920x1080_scrot.png (1920x1080, 91K)

Made a discord bot today. Collects unique strings from shit people say and spits back Markov chains from them on command. Pretty funny.

Quit your job and make video games

Attached: 1280px-Multi_Color_Go.jpg (1280x960, 270K)

Example?

Working on an online board game

Attached: sudden death.png (1220x1248, 1.15M)

is C++ worth learning?

I know other OOP languages, never got around to C++ though

Attached: 1524898366289.jpg (1440x810, 155K)

I'll repost it here, since new thread.
r8 my fizzbuzz
#include

int main(){
char buffer[4];
char* messages[] = {
buffer,
"Buzz",
"Fizz",
"Fizzbuzz",
};
for(unsigned int i=1; i

Meh. You know one OOP language, you know them all. Maybe read up on the STL and that's about it.

Yeah it's pretty good. High performance graphics stuff, games stuff, low-level stuff, all make good use of C++

Is it a meme or is it true the vast majority of cs grads can't school? I find that hard to believe. I know people cheat their asses off in school but they can't even put together basic programs? Or are the interviews that tough

Interviews are not that hard, the vast majority of my class graduated with jobs. It depends on the school.

be prepared

Attached: cs-grad-units.png (750x1050, 183K)

There's nothing wrong with outsourcing for cheap programming
Learn to compete

thanks for using lain

You're welcome user

Why would a library wrapper specify unsigned int as a return type when the library function itself returns size_t?

someone explain me meme in pic, whats he coding and why is it funny? i dont know c++ but i read that using lots of templates is bad (whatever they are)

Attached: dirlewanger fedora.jpg (334x384, 27K)

Most libraries suck

you're welcome user
I also left the filename just for you :)

That's irrelevant here.

I mean it sounds to me like you're using a shitty library so maybe it is relevant

>whats he coding and why is it funny
They're defining a macro (replaces text with parameterized text) that creates a bunch of templated (works for many different types) operator overloads (changing what operators like '==' means).

I think the humor is supposed to come from how appropriate this use of macros are despite being heavily frowned upon (without marcos you'd just see this code copy and pasted for each operator). But I'm not sure I don't remember my sepples well, maybe there's a gem in here.

would screenshot but away from PC.
Building Sailfish OS for Nexus 9
Updating the existing image for the Nexus 5
And debugging my build for Nexus 10

I think the joke is that well written and well formed C++ code is kinda esoteric looking and hard to follow.

I could be wrong though

5/10 needs more indents.

>I mean it sounds to me like you're using a shitty library
How so? size_t is a standard return type to allow portability across platforms.

I'm a CS major done with my sophomore year, pretty great at mathematics and theoretical CS topics, but barely done any coding those past two years. I know the concepts though.

I need a basic monthly income working from home as a freelance remote developer. Any ideas on what I should be learning/doing for easy online employment?

the meme is sepples itself and the fact this stuff is even required in such a shitty language

The \'s from the macro is the only real issue. I'm sure it looks just fine for a sepples programmer. It's not hard to understand this code, the upprecase OPERAND is just replaced by the operators listed below. It's neat in that way. Which is why I think the point is more about the use of macro. I haven't quite deciphered the intent of the code though. Does this replace all uses of those operators? Maybe that's it.
It's like a
#define private public
#define protected public

taboo

>can't school?
They obviously can school. But program? I haven't met many of them in that regard but I've heard from friends that they were the best at whatever programming challenges they had to go through and it surprises me a little bit. My friends aren't bad or anything but they're not top tier by my measure.

#define define

it's defining the operators for some template class called 'unit'

I'm writing an API for ocearch.org using Java. Im gonna overlay some heat maps or some shit to help people see what contributes to shark migrations.

warning: suggest parentheses around assignment used as truth value [-Wparentheses]
if ((r->rows) =! 1){
^


What do I do wrong? Is it asking me to put 1 inside parenthesis?

bumpan

i can't be the only one that completely lost their passion for hobby coding once being employed doing it 40+ hours a week can i? I actually enjoy my work but the last thing I want to do is fire up visual studio when I get home or on my days off

>((r->rows) =! 1)
This assigns NOT 1 to r->rows
You probably wanted
>((r->rows) != 1)
To make the conditional "r->rows not equal to 1"
Good thing you looked at the warning.

Im writing a chat system inspired by Jow Forums with node express.js

I mean sure, it pads out your GitHub activity

Attached: 1521852923239.png (1072x406, 388K)

I can't believe I missed this. Thanks mate!

If I include a library in C but only end up using few functions in my program, are the unused functions still included in the executable? Do GCC optimisation clean this for me?

Attached: sci.png (549x591, 32K)

How is it being included? Dynamic linkage, static linkage, header-only?

hi carter!

Static I guess #include "my_library".
From what I understand, this, when I compile my program, main.o and my_library.o are linked. So I guess all the content of the library is inside the executable.
I am wondering if gcc optimisation can remove "useless" stuff by itself.

>he includes his SICP exercise solutions on his github repo

Aaannnd -5 points. We'll call you.

>I am wondering if gcc optimisation can remove "useless" stuff by itself.
If you use static linking with a library only you'll only have what you use. If you have dynamic linking (requires dll's on windows or so's on Linux. Or other tricky things potentially) you've compiled the dynamic library separate to the program that uses it. Then all functions that are exposed by the library are included in the shared library.

Why are you worried about this? The standard library is probably a bigger culprit when it comes to executable size.

How much time is too much time trying to figure out a programming challenge before moving on and/or coming back to it? I spent like two hours trying to figure out one this afternoon before finally giving up

>he includes his SICP exercise solutions on his github repo

"Have you read your SICP today?" Ha ha my man, just kidding, but nice solutions. I think we got a culture fit, boys. Take a look at mine over a beer? got any pictures of your wife? Ha ha, kidding my man. Let's head over to yours and cheg out some anime tiddays amirite amigo??

I'm just trying to get the best practice and try to understand what I'm actually doing.
My end goal is to end up running my code on a micro controller so I want to learn how to keep things clean.

>prospective boss inviting himself to my home during an interview
Excellent power play

As someone who mainly writes PHP, I've been interested in C++, but everyone here says C is the ultimate language. Which should I start with first? Does it matter what I start with?

might as well learn java if you learn C++, not really any point. Also you'll be learning it all your life because it's an endless sprawl.

The rules and behavior of C are small and simple. Learn it first and maybe skip C++ altogether for a similar language that doesn't have 20 years of duct-tape holding it together.

I know nobody cares but I've been going through the learn python series on YouTube and I'm having fun and going through with it. One day I'll get a tech job and enjoy life uwu

Attached: 1526954399199.png (500x350, 223K)

>My end goal is to end up running my code on a micro controller
Executable size optimization is a very niche thing. I don't expect you to get good answers from /dpt/.

>but everyone here says C is the ultimate language.
Mostly a meme. A disciplined C++ developer isn't worse than a C developer.
People claim you should learn C first. I think it's mostly a problem of poor C++ teaching materials. Because the way you 'should' do things in C++ according to your employers is very different from how you write code in C.

In my application Im adding an Auto-Update system
My idea was: application downloads the new version from mysite.com/download/ , which contains a file called 'application_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.zip"

the XXX would be a special key. The application checks if the XXX is valid by checking against a public key in the application code. The key is created using my private key.
How do I make this part? What algorithm do I use?

Pls reply

congrats user, I care. right now I'm doing some nested loop practices and can't figure it out. where are you in your learning?

>How do I make this part?
Do you mean what public key encryption you're supposed to use?
RSA should be fine. How you decide to verify if it's the correct file is something to ponder though. What kind of decrypted names are allowed? Because if you have a very regular format and allow a lot of version numbers you're exposing a rather big surface area for bruteforce.

Say the XXX string is decrypted to the format XXXX.XXXX and it's a valid version if the X's are digits.
If you allow any version number there you could rather quickly find a string that decrypts into a valid version number because they just need to find one valid version number. Every bit you allow to represent the version decreases the time to bruteforce.

But even so I don't quite see why you're so worried about this. Surely you control the site? Are you expecting users or malicious actors to redirect away from your site?

>4chanx has "vim keys"
Why didn't I know this?

Very very early.
Just working on booleans

>Say the XXX string is decrypted to the format XXXX.XXXX and it's a valid version if the X's are digits.
If you allow any version number there you could rather quickly find a string that decrypts into a valid version number because they just need to find one valid version number.

The version number is going to range from 00-99.
So I want to check if XXXX string decrpyted with the public key == the String 'valid&Version=01', wouldnt that be fairly secure?

>Surely you control the site? Are you expecting users or malicious actors to redirect away from your site?
Yes I control the site, but I want to ensure that the application never downloads an update .zip that I personally didnt sign with my private key, because malicious actor could have access to the site root I dont want them uploading a virus update .zip.

...

I'm proud of you user, keep going. Why did you pick python?

they're defining operators to do what those operators already do.

Just because it seems like the most common idk. I honestly just wanted my foot in the door and just do SOMETHING to start. Once I learn concepts and everything I know I'll change language.

Attached: CaitSith-ffvii-battle.png (327x411, 51K)

I want to start programming in D just because of community.

Attached: compiler-dmd.png (294x294, 8K)

>community
Literally nobody uses D.

I FUCKING HATE WORK.
That's it I'm gonna forget all the languages I know and just play around with useless haskell for the rest of my life as a NEET.

Attached: e73.jpg (720x401, 24K)

good luck

Attached: 1513821087297.jpg (798x809, 48K)

and you'll have terrible habits from python, but of course everyone will tell you python's fine.

It's really not. I think ruby is a much better starter language, but it gets disregarded because rails is trash

A few companies do, and the forum is pretty active, but compared to the likes of Go, yeah. I just like how their forum and other venues are friendly without feeling like hugboxes. Walter Bright also seems to be a good guy and neither a zealot nor a pushover, which is the kind of person you want in charge of your programming language.

perl 6 is actually a great starter language but gets disregarded for being dead, I know your pain

Careful. You might land a Haskell job on accident.

Protip: once you can FizzBuzz, read htdp.org/. It will get you from writing code to actually building coherent programs.

how many drivers in this python snippet?
numOfDrivers = 0
for car in cars:
print("car {}".format(car))
numOfDrivers += 1


and this one?
numOfDrivers = 0
for car in cars:
print("car {}".format(car))
print("something else")
numOfDrivers += 1


W
H
I
T
E
S I G N I F I C A N T
P
A
C
E

>learn Haskell to escape employment
>end up employed
worst of both worlds?

Attached: 1394924418614.jpg (396x353, 43K)

T-that's not possible.
The sole purpose of employment is to cripple your mind in exchange of money, so you can drown your despair in alcohol.
Haskell does the opposite of that. I think.

Attached: Confused_Karen_18.jpg (291x301, 11K)

Attached: karen haskell.png (1280x719, 818K)

>The sole purpose of employment is to cripple your mind in exchange of money
Only if you do boring mundane shit at BigCo. A good antidote to that is high-end freelancing, being a contractor and starting your own company.

brainlet here, any good reads to learn know more about OOP.

Currently learning java for test automation.

Yeah that should be fairly secure. I'm just warning you of allowing something too general.

Good luck

youtube.com/watch?v=Y7rq6o6UDXc

Attached: OOPs.png (1948x858, 152K)

it's bad don't learn it

Attached: OOPfag.jpg (400x400, 26K)

Can you post source? I want to write a Discord bot and I'm totally lost.

Is it wrong to use classes as self contained programs?

Don't listen to idiots that say OOP is bad without providing a battle-tested alternative and without saying why is it that OOP is supposed to be bad.

Only smart people get at that level on their own.
I'm not a smart person, I thought that with a job I'd get confronted to interesting problems, make production-grade stuff, meet other people more skilled than I am I can learn from, maybe even get a mentor...

It's the total opposite, they make you reinvent the wheel for the hundredth time because too jewish to pay or too stubborn to use open sores, nobody fucking knows what they're doing, people with 20+ years experience are just still there because you can't fire them and muh legacy code but only knows COBOL and refuses to do anything else...

Impl trait/existential types is now part of Rust stable! It eliminates a lot of boilerplate and lets you return unboxed lambdas.

I think I'm retarded. After four years of programming I have very little to show for it, nothing worthwhile to publish, no open source contributions, and nothing done on any projects bigger than a few files and a few hundred lines.

Attached: sadray.jpg (512x512, 147K)

it is wrong to use classes

how do i debug a chrome/firefox extension?
can i step through it as a page loads/i use the browser?
i'm trying to modify an existing extension. i can read the code and understand what different functions do, but i'm having a hard time locating the piece i need to implement my desired change.

>struggles with abstract classes
its not even confusing really.
they're like contracts/protocols.

>subhuman
kek

if thats all you need, sure why not.

Is Google's C++ style guide a meme?
google.github.io/styleguide/cppguide.html

>C++
Most certainly a meme.

>Avoid using forward declarations where possible. Just #include the headers you need.
100% meme