/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pastebin.com/aePUDgL4
youtube.com/watch?v=xZT-3ssYD7Y
learngitbranching.js.org/
adventofcode.com/2016/day/10
tour.golang.org
robmiles.com/c-yellow-book/
code.org/diversity
pastebin.com/search?q=Sup
pastebin.com/Z1aNKdLY
twitter.com/NSFWRedditGif

Again:

So I want to actually learn how to program. I know basic stuff like strings, booleans, if-else, etc. I have passed trough that crap numerous times (in C and Python) and then hit the wall because of all the crappy tutorials and free web courses.

Step by step, what books should I learn and when? I don't think that Code Complete or Pragmatic Programmer is going to be really useful this moment as I know next to nothing in general (compared to someone that finished CS college).
And what tasks or little projects should I do between these books? And please no codeacademy or "The Hard Way" crap. I need college-like or better structure not spotty knowledge.

Is this list of books a fine choice in proper order? Anything to add? To remove?

1. Head First Java, 2nd Edition, Sierra
2. Core Java Volume I--Fundamentals (10th Edition), Horstmann
3. Head First Design Patterns: A Brain-Friendly Guide, Freeman
4. Effective Java (2nd Edition), Bloch
5. Core Java, Volume II--Advanced Features (10th Edition), Horstmann
6. Algorithms (4th Edition), Sedgewick
7. Code Complete: A Practical Handbook of Software Construction, McConell
...
Clean Code: A Handbook of Agile Software Craftsmanship, Martin
The Pragmatic Programmer: From Journeyman to Master, Hunt

1. SICP
2. K&R

Unless you really want to get into OOP, I'd recommend learning more programming languages than Java. Don't know what are good books, though.

The best way to learn programming is to work on stuff. Problems and projects.

Half of your reading list is Java shit and the other half won't give you much if you don't simultaneously apply what you learn.

C? Maybe if I will go into embedded stuff
I will look into that SCIP.
Thanks, man

I want to get paid too.
Nobody is hiring Ruby developers in this part of Europe.

I know it's Java. I want it to be Java because the market asks for it.
Personally I would like Python better

>The best way to learn programming is to work on stuff. Problems and projects.
Yes, that's why I said:
>And what tasks or little projects should I do between these books?

>the best programming book ever coupled with a shitty c manual.
no

Too many books with overlapping content.

An algorithms textbook should be near the top of the list. Honestly it would be the first thing I read. It might be useful to purchase the Core Java books, but only as a reference. Reading them cover to cover will waste too much of your time. The Head First Java books seem outdated, and design patters are not that important honestly. Certain design patterns are useful to know, but I would Google them on a case-by-case basis.

Here's my recommended reading list:

1. An algorithms text. Sedgewick's book is well regarded. Personally I read CLRS, but it is too mathematical for many people.
2. Core Java for the Impatient. It has a fast pace but is well written. You can always Google topics that were explained too quickly.
3. Effective Java. Good book.
4. Whatever you feel like learning next. I would recommend some domain specialised book, such as a text on concurrency or machine learning.

Remember that you will learn infinitely more by trying shit out and Googling than by reading books, so don't rely on books to turn you into a good programmer.

Then you should still learn more than just Java. I'm not saying ditch Java entirely. Just that you should take other things up, so you will know more than OOP.

Anything that interests you.

Thanks.
Algorithm first? Just test algorithms in Python then and switch to Java later?

>Remember that you will learn infinitely more by trying shit out and Googling than by reading books, so don't rely on books to turn you into a good programmer.
Afraid of becoming a googler with shit portfolio that would turn away potential employers
But I hear you. This way all the info will stick

So this is the power of JetBrains™

Ok. I have definitive interest in C too so I might play around with it too
Guess It's fairly easy to switch when everything is inspired by C
And definitely look up some more advanced databases stuff like optimization

try Atom
all of the resources, 56% of the capabilities

>Algorithm first? Just test algorithms in Python then and switch to Java later?
It might be optimal to read an algorithms text concurrently with a Java text. You can use the algorithms text to practice the syntax.

>Afraid of becoming a googler with shit portfolio that would turn away potential employers
I'm not discouraging you from pursuing personal project, just know that best way to finish such a project is to rely on your ability to find relevant info on the Web, rather than through books.

Just finished putting the final touches for a BMR calculator.

pastebin.com/aePUDgL4

Maybe one of you fucking weeaboos will find this useful, you know, change your life and shit.

Thanks again m8

>babby's first basic input and arithmetic console application

>OOP
It took me years to unlearn the bad habits of Java-flavored OOP. It isn't really about objects and it doesn't help you program. Shoulda called it inheritance-driven obfuscation or something.

Nah man. I'm just tired of having to go to the internet to find a calculator every few weeks.

At least put that shit in a pretty GUI.

Make it motivate you somehow.

So as part of an internship I've been working for the past few months I've been developing a Task Scheduler (similar to Windows Task Scheduler). It runs 24/7 as a service that communicates with multiple thin clients, through a SQL database. I wanted to have the clients communicate with the service through TCP/IP but the other devs said that would be overkill so I've had to deal with the issues of database interaction.

It's running pretty well, but there's a situation I'm afraid of. In case of SQL exception (if the server is down or connection faulty), the internal representation for a task in memory of the service may become different than what is being stored in the persistent database. (Tasks are represented as an object within the service, created from data in the database, and when a task is modified/run by the service it updates the DB with new info)

How would you handle an isolated SQL exception to make sure the database is up to date in this case? The service can't stop everything and wait for the connection to open back up as it wakes up and runs on a timer every 5 seconds.

inconsistent spacing
absolutely disgusting

>elif chain as long as a switch
Typical crossboarder

>up as it wakes up and runs on a timer every 5 seconds.
Polling? We're in 2016 user. Polling is forbidden (except for embedded).

I don't need motivation. I just need to adjust my diet depending on my physical goal

Besides, I work solely from the console as my home server is headless.

There's no switch statements in Python

Whose the crossboarder now? Because you should go back to /lgbt/

It was the method suggested to me. I'm pretty new to this, they probably should have just bought a 3rd party scheduling application but of course I'm going to take the challenge if it's suggested.

But yes, timer wakes up every 5 seconds, runs its routine, sees if any tasks need to be run, runs them, etc. This isn't the most advanced operation and the senior devs run scripts that use polling regularly so the standards aren't high.

Out of curiosity though, what would be better than polling for a scheduling application written from the ground up?

You have a Python else if statement that is comparable in size to a switch statement from other languages for a fucking CLI application when Python has ways around this. RTFM.

projects you should do
>palidrome checker
>coin flipper
>countdown timer using config files
>folder/file encryptor
>IRC Bot
>encrypted client/server chat service
>encrypted facebook chat client

>Python has ways around this
Well?

Where's the switch alternative you faggot?

Leaving my house cuz dad wants to turn me into my battered divorced mom lel

>get back to old avr project
>it doesn't work
fuck. and I don't even know where it crashes, but it crashes for good, even watchdog doesn't reset it
just fuck my shit up

RTFM

>Out of curiosity though, what would be better than polling for a scheduling application written from the ground up?

You compute the next event date and schedule a timer for that time. And when you wake up you compute the next...

How do I sync code between laptop/pc and a friend? I was thinking git but then the repo would have tons of commits, I'm now thinking one private repo for everything I'm working on then when it's ready for release I move it into it's own repo that only has one commit then delete it from the private repo, is this the best way?

weak copout brah
u lost

I have to use C++ to interact with a media player SDK so I'm learning that and seeing why people get frustrated with it. C++ seems powerful and easy to write but kind of annoying to read other peoples undocumented work when it revolves around classes and templates scattered all over headers as well as overloading allowing for variable function arity, default parameters are also confusing sometimes. That seems like a real nice feature but I hate having to reference the headers to find out what the same function will do if I pass it x args instead of y args and type considerations on top of that.

>I was thinking git but then the repo would have tons of commits
Where would be the problems?

kek you got fucked user

Still working on my Day 11 solution for Advent of Code. Dicking around to find enough optimisations that can live with the exponential state space growth.

Found this video of Day 10, it's pretty cute.
youtube.com/watch?v=xZT-3ssYD7Y

everytime I wanted to make it so my pc or friend could get minor changes I'd have to make a commit, before it even works it'd have 10+ commits so there'd be 10+ commits of unfinished non working code

Use branches.

Stop committing to master unless you're merging good changes, both of you.

You can merge commits in one commit with git. Everything is possible.

It looks cool but what is it? Could you share the src?

Use git but learn how to branch and rebase.
learngitbranching.js.org/

Assuming one knows absolutely nothing about programming, whats the best way to get started?

>I was thinking git but then the repo would have tons of commits
Well that's sort of the point.

>I'm now thinking one private repo for everything I'm working on then when it's ready for release I move it
What.

Just make your own separate branches and follow trunk based development.

Visualisation of the solution for: adventofcode.com/2016/day/10

Learn the basic with python. After that do a lot of C (or ASM or Fortran) and OCaml.

Random user going through uni right now, what about java OOP should I try and look out for in order to not make it a habit/not let it effect my coding habits in other languages?

so a branch called 'syncing' and a readme in it explaining this branch is jus tused to sync code between my pc laptop and with my friend wouldn't look bad?

code.org

Realtalk: If I take an internship after having graduated and held a real job, will I be unemployable after that?

Furthermore, will I be seen as overqualified for an internship?

I need to know if I'm going to have any chance of surviving as anything other than a parasite

Load a bunch of instructions into some bot and have them execute their instruction as soon as they're holding at least 2 microchips.
The instructions are simply to give their high or low numbered microchip to another bot or to an output bucket.
while (!done) /* run commands */
{
done = 1;
for (i = 0; i < BOTS; i++)
{
if (bot[i].idx >= 2)
{
done = 0; /* keep running */
int low = min(bot[i].store[0], bot[i].store[1]);
int high = max(bot[i].store[0], bot[i].store[1]);
for (j = 0; j < 2; j++) /* give */
{
int addr = bot[i].send[j].addr;
int mode = bot[i].send[j].mode;
struct bin *to = (mode == BOT) ? bot : out;
to[addr].store[to[addr].idx++] = (j == LOW) ? low : high;
}
memset(&bot[i], 0, sizeof(struct bin)); /* wipe bot */
}
}
}

You and your friend need to go look up some git tutorials to learn how to use it properly instead of trying to force it to work with the shitty workflow idea already in your head.

And nobody gives a shit if your commit log isn't aesthetically pleasing, who gives a shit.

It looks like it dependent of the scheduling.

It depends on what kind of person you are and what types of learning you're receptive to.

If you like lectures you might want to try a free CS course on edx.
If you like reading books on your own there's suggestions for that.
If you like tutorials there's those online.
If you like games there's things like Shenzhen I/O.

Those are just methods of learning though, even then it's hard to say what to learn in what order. Some people do better learning from the ground up (like starting with ASM or C), others the opposite (something more like Go or Python).

Go seems very nice for beginners but I'm not sure what resources there are for learning, I learned it from reading the spec and already knowing other languages.
Maybe this tour.golang.org

I'm writing a library to scan through a JPEG and maybe do some EXIF shit, I dunno. Why the hell is the JPEG spec so awful? It really makes me appreciate formats like PNG more.

Is this satire?

robmiles.com/c-yellow-book/

Great book for any beginner, has a good intro to programming before you touch any code.

Free PDF on page.

I am a different user but I want to make sure you didn't ignore my post

I didn't reading the site now

it's not, if you try to execute commands as you read them in, no bot will have enough microchips to send them to other bots.

The Little Schemer
The Seasoned Schemer
The Scheme Programming Language by Kent Dybvig
Realm of Racket by Matthias Felleisen

>it's not, if you try to execute commands as you read them in, no bot will have enough microchips to send them to other bots.
Let me rephrase. The actual commands (where is the commands source file) are made to avoid race condition?

Dpt, it's been four months. Im not getting another job and I just don't know what to do. At the moment, suicide is a serious consideration, but so is making a mobile app, though I don't have the slightest idea what to make.

What do I do?

Why would you have a race condition?
You don't need multithreading for this.

If you kill yourself, you will never have a job ever again.

Take a nap, go for a run and stop stressing and try to brainstorm something to make, if you need cash then find a shit job while you work on getting better at programming through your side project

no. what's the problem?
code.org/diversity

Are you seriously the same user who's been whinging about this for weeks?

If you know how to write software, then you shouldn't have trouble getting a job. There's plenty of companies looking, and willing to hire anyone who's got the skills and isn't autistic.

If you don't know how to write software, then why are you complaining about being unhirable? Learn to program. You clearly have internet, and that's quite literally all you need.

The instructions can result in a bot having 3 values at the same time.

hahahaaaaaaa
ffs
all these web-crap cats are so fucking SJW it's hilarious

>, but so is making a mobile app
Terrible idea.

People are looking for programmers. You just need to be more aggressive with your applications, and lower your standards.

>tfw when you fix bugs in your botnet after not working on it for 8 months

>Why would you have a race condition?
See this post for more info

Is there a central place I can get this yet? Having to check threads for updates is why I stopped using it a long time ago.

The instructions don't give any bot more than 2 values, but I assumed it would, so I just wrote every bot as an array with a current index size.

Turns out it doesn't matter for this case.

>The instructions
Can you share?

see

I already gave you the link to the problem in

My standards are "if they're hiring and I have a way to get to get to them I'll apply"

I know how to write software but I still can't get a job. It's a sellers market, and I dont have the three years of work experience needed to make coffee for the real employees

nope. this is probably as good as it gets for now:
pastebin.com/search?q=Sup Forums+browser

I want the instructions list. It's not shared on the link you gave me. It's defining the problem but there is no inputs.

why don't you read the entire page?

I read it. I see no instructions list. Maybe I'm dumb. But if you can show them to me.

i have a list of colors in python

and i want to e.g.
my_list[10][20] = (255,0,0)


basically fill the point x = 10 and y = 20 with the color red

but it is not working


halp

Oh you might have to log in or something to get it.

Here's a pastebin if you really insist on not making an account.
pastebin.com/Z1aNKdLY

thx

In what fucking society did diversity brought any advancement?

It's actually the case that successful and efficient systems bring economic progress that in the end results in people gravitating to that location and system from all around

When that same system advantage over competing system falters (droughts, plagues, social security and gibsmedat, wars, whatever) some "diverse" people leave or just form clans and stab other groups with knives until this civil unrest results in massive flight of more capable people.
And that's how you get bunch of Libanonian-Levantine orthodox christian economists in France (they ran away in 70's).

Diversity brings instability.

People don't have to have different place of birth, fuckhole or skin color to have different ideas.
Like, I am white guy in Croatia (99,9% white) and we barely agree on anything here.

Guess leftist interventionists like their groups so they can shill for votes.

stop helping him, he does this everyday and he's simply autistic
why does he even come here if he doesnt have a github?

nvm fixed

Because I come here to enlighten code monkeys like you.

What's /dpt/'s opinion on pthreads?
Personally, it's my favourite multithreading library and I don't understand why other languages don't straight up copy it in making their own libraries.

Ada's threading in sightly nicer, to be honest.

You can use pthreads on literally every platform that matters, so I don't see any drawbacks.

I really do wish I could shove pthreads functionality into my programs putting all relevant variables in a struct and sneaking in a struct through the SINGLE void pointer it allows per worker.

Post some links to good programming music.

*without putting all relevant variables

>I really do wish I could shove pthreads functionality into my programs putting all relevant variables in a struct and sneaking in a struct through the SINGLE void pointer it allows per worker.
Valid complaint, but as you explained right after it's really easy to get around so it doesn't bother me much

Why/how?

I'm asking because I just recently had to use java's concurrency libraries and it's just
>JUST

width = 200
height = 100

// generate a 200*100 list
my_list = [[0 for x in range(width)] for y in range(height)]
my_list[10][20] = (255, 0, 0)

The number one thing Java encourages you to fuck up is to make every "part" of your simulation its own object, with its own level of encapsulation. What ends up happening is you create all these layers of indirection and 99% of them are useless and redundant. Ever hear of a Chinese fire drill?

The best thing you can do for yourself is to spend some time in a language where data is data and code is code and you can't make "objects." You need to be aware that in most cases, this is enough to make your program work, and even in the rate situation where you NEED encapsulation (to guarantee data integrity) there are other ways to achieve it. C, Scheme, and Haskell are some good options here. Pick up one or more of these languages as soon as possible.