/dpt/ - daily programming thread

What programming books or books related to programming have you ordered recently edition

Old: >picture is related to thread

Other urls found in this thread:

pastebin.com/k6iHkAjS
twitter.com/AnonBabble

>2016
>posting thumbnails
FUCK OFF

garbage networks book

just download all of barabasi's papers

not interested in games

There's already one here you fucking idiot
>redditors can't ctrl-f

The old one was below bump limit when I posted

How is it shit?

The paid shills on amazon gave it great reviews

its written for losers without any exposure to mathematics. its garbage as a reference and utterly handholding

unless you're doing advanced statistical mechanics on networks, complex networks are mathematically easy and incredibly intuitive. stick to the papers by barabasi and friends, they're well written and easy to understand

So which /dpt/ are we using?

This one. The trap thread doesn't even have /dpt/ in the subject, so it's not even a /dpt/ thread.

But it does still come up in a search for dpt

Not if you filter by subject, which many do.

what's a good text editor for coding in windows?

Vim

bump so this thread can be used next

pastebin.com/k6iHkAjS

I'm trying to cast a ray in SDL, it kind of works, but its rather jittery and is barely functional.

Can somebody look at it and see if I made a mistake?

Ok, so I discovered that its jittery because I'm multiplying normalized_x and normalized_y.

The more I multiply these values the less jittery it becomes, but the line will also go inside the box.

If I don't multiply these values it just crashes and I'm not sure why.

I finished making a python package in PyCharm that I am going to use for interfacing with a couple websites. It's structure looks like this:

python
├ amazon
│ └ products_to_amazon.py

└ custom_lib
├ __init__.py

├ website_import_export
│ ├ __init__.py
│ ├ customHTMLParser.py
│ └ import_export.py

└ credentials
├ __init__.py
└ credentials.py


So I just created products_to_amazon.py, then typed in import custom_lib, but I get an error saying "no module named custom_lib". What do I do to make my custom_lib a module that is accessible?

products_to_amazon.py can't look outside of its directory. You can try doing import ...custom_lib, but I'm not sure that'd work.

The easiest solution would be to copy custom_lib to the amazon directory.

I am going to use custom_lib for many projects. This is just the first one. Is there any way to make it some sort of module that I install with pip? And maybe have it auto update it if I upload it to a website?

I'm not a python guru, but I'm pretty sure in Python's installation directory there is a folder that contains all of the default libs. You could try copying your library into there.

My main concern is keeping this library synchronized across multiple computers and servers. I do coding on two desktops, a laptop, and work with 3 servers. The laptop and desktop keep most of their data in sync using a dropbox folder mapped to the J: drive, but I am wondering how I would keep the servers synced. Maybe if I wrote a script that uses one server as a reference and updates the others....

I was redirected here when i started a thread about finding a bug in my python code. I am a beginner, so go easy on me.
I am trying to program a ceasarian cipher, but it only returns a blank list.
"""Ceasar Cipher code"""
x = list(input("enter phrase to be encoded, letters and spaces only: "))
y = list(map(ord,x))#changes plaintext to ascii
n = int(input("enter ceasarian key: "))
def encodeint(y):
return [32 for i in y if i == 32] # keeps spaces
return [(i+n) for i in y if 96

i only glanced at your comments but check out if there's an rsync library for python. rsync is good for syncing stuff

Seconded

The 3 last returns are unreachable and never executed because the first return ends the function.

The first return just adds the integer 32 to the list every time it encounters a character that equals 32 (space).

Try inputting "a b c" and you'll see it returns the 2 spaces.

Thanks. I still get a problem after i fixed that though.

This time shell says " line 9, in encodeint
elif 122

Well reg is a list(), while the numbers you are comparing it to are integers.

Sorry, to expand this, you are basically putting in:

122 < [55, 32, 56, 32, 57] < 149

bump so that this thread can be used next

why are type classes so based

Bump because this is a nice thread

MLfags hate them

they aren't

wait until you need to have multiple instances per type

Then you should use newtypes

What an ugly, anti-functional and retarded solution

It's the best we got, bro. If you wanna allow multiple inconsistent instances then you lose the prolog for types magic

>it's the best solution we got
no

ye

We must not allow the barbarians who want implicits to taint our language!

What would she do?

>she

Yes, she
Got a problem wit that?
Fight me irl

pic related - it's the last thing you'll ever see

Don't you know in this modern age of debauchery and deception a guy dressing up as a girl is clearly a "she"..

Anyway back on topic. I'm procrastinating on my chip8 emulator in rust. Finished the rom loading code and I'm really not looking forward to figuring out what graphics / sound library I'm going to use.

she would put it in your butt

I'm at a loss. I need to accept multiple lines of input in python using raw_input. But it only allows one line. What do I do?

while input() != '':

I dunno why made this, but I think it's funny.

import random

def do_while_cycle():
class Checker(object):
def __init__(self):
self._condition = True
def __call__(self, condition):
self._condition = condition

class Yielder(object):
def __init__(self):
self._checker = Checker()
def __iter__(self):
return self
def __next__(self):
return self.next()
def next(self):
if self._checker._condition:
return self._checker
raise StopIteration()

return Yielder()


for do_while in do_while_cycle():
i = random.randint(0, 12)
print i
do_while(i < 10)

what are you trying to do? what about using a loop?

Assuming I only know some C, with which one of this books should I start? I'm studying EE if that helps.

this image is bait, right?

you don't really need that much CS as EE. but intro to algorithms is a good place to start if you want to go in that direction.
Tao of programming is really short, not hard to read.
Knuth is highly mathematical and imo a waste of time if you haven't read all the others.
Compilers isn't strictly necessary but fills in a lot of gaps of how languages are written
also liked pragmattic programmer.

Nope, it's in the wiki. Although I didn't understand if the article about the first book was sarcasm.

Thanks for the insight, senpai. Have some dancer.

>nonwhite
>ugly
>Sup Forums books includes design patterns
cancer

>SICP god tier
>Seasoned Schemer "best-in-their-own-world tier"
definitely (or maybe the person who made it hasn't ever read any of the books)

Have some Skully before he fucks up, then.

Wouldn't this just keep repeating the inputted text over and over?

I cant remember. In c++ if I want a variable in a function to update each time the function was called, would the function need to be static or the variable. Or both. I feel like both need to be static. Something like
static void foo()
{
static int x=0;
x++;
return;
}

static only applies in the context of classes

int x = 0;
void foo() { ++x; }

I figured it out. Only the variable needs to be static.
Also Im not sure what you were trying to demonstrate. I cringed seeing a global variable. Its also a work around that doesnt meet what Im trying to accomplish.

static variables are effectively global

Generally, which executes more quickly in C++ when passing smaller elements to functions:
-Passing by reference and incurring a cache miss on access
-Taking the time and memory to create a copy, then accessing it off the top of the stack. Probably all on one cache line.

I'm writing a test program for this and will look at the assembly, but I'm wondering if anyone has a sort of heuristic they tend to use in these decisions. General understanding.

what the hell are those .io games using to compile that javascript code you see when inspecting the code
I am sure that's not closure compiler, I just tested it with "advance_optimizations" and I am disapoint

you mean effectively a private variable.

What's the name of this scrolly thing in iOS? The official name they use in documentation and stuff, so I can look up how to put one in an app.

global-ness and access are completely unrelated

Would you say all variables defined in a class are global?

no

the why would you say a static variable thats part of a function which is part of a class is global.

What?

class has a function. function has a static variable.
according to what you are saying that static variable is global.

yes
global = static

also analogous is that functions are themselves globals of function (pointer) type

so then how are the variables defined in the class not global. The scope should be the same for the two.

they might not be static

It sounds like you arent really sure what you are talking about since you arent referring to scope here.

>it sounds like you don't know what you're talking about because you disagree with me
global doesn't mean public

thats not the point. Its doesnt sound like you understand scoping.
I had to make an interpreter twice, one with lexical scoping and one with dynamic scoping, so I understand what global variables are and what their scope is. But since you arent talking about scoping Im inclined to say you dont know what you are talking about.

it's not about scope

>global variables arent about scope
Alright. confirmed not knowing what youre talking about.

Just to further rub it in
>In computer programming, a global variable is a variable with global scope,

struct x {
int y;
}

is y global?

>globals are evil but statics are not
I cringed.
Clearly you are an enterprise OOP professor.

not quite.
static is 'unique to the translation unit'.
That is, when a variable is declared static in a header file, each translation unit which includes this header will get its own file-specific version of this variable.

In the case of classes, when a member is declared static, this is a unique member shared across all instances of said class - no instance gets its own version of this member.

yes, unique member shared across all instances
i.e. a global state

Is y's scope global. You cant talk about global variables without talking about scope. Since you dont understand scope I dont intend on having this conversation. Ive had to implement classes and structs in functional languages so it depends on how exactly the class is done. Ive seen some where the scope was not global for the variables.
No its not OOP that did it. Its functional programming. Rule is typically you arent allowed to use global variables and after a while you get used to helper functions.

i've said before it's got nothing to do with lexical scope

Let me make this easy for you.
void foo()
{
void boo()
{
static int x;
}
}

Is the scope of x global?
Protip its not.
This is honestly too sad to read. I suggest you read up on scoping though.
You seem to have confused the fact that global variables are effectively static with static variables having a global scope.

x is a global state
boo is impure

If you need multiple instances per type, it might be an indicator that typeclasses are not the right abstraction, since typeclasses are generally meant for canonical things. Usually if you need multiple instances, you use record-passing instead. newtypes with instances come in handy when you need to fit something into an interface that already uses typeclasses, but is definitely a cludge.

>be physics grad student in condensed matter
>have solid mathematics and theoretical comp sci background
>but have little to no programming training
>minimal experience as I feel my way around some high level programming languages in order to produce numerics and plots for my theses
>have a quantum computing research position lined up at the end of my master's
>mfw
What am I in for, Sup Forums?

No, because the variable is not accessible from all translation units - it is constrained to file scope.
Here's a quick example for you.

The scope does not matter
It is global STATE

I learned to program in batch, where I did not use setlocal / endlocal (batch's scoping). While I see the reasoning, both in the immediate and longer term maintainability of writing superfluous helper functions that put jumps in the executable everywhere (which if branch prediction fails causes a cache miss or slowdown of some other sort), I don't care for the religious "GLOBALS = EVIL" and "static = useful tool, but be careful ;)" attitude.

I wrote some fairly efficient shit with complex control flow and inter-function relationships, using all global variables. I just wish people would make their point and move on. It's not hard, and it isn't a big deal. You're more or less doing manually what the compiler is doing with the call stack, minus the copies for the most part.

Also, fuck "rules". Hybrid notions of a given system, or paradigm, are the only useful approaches.

>being stuck in a career related to CS

id rather be a neet
>>

Have you done CS work? The money is great but most people get tired of the work after a few years. Talk about soul-sucking

Why? can you paint me a picture of the typical day or link to a blog/article that describes why CS stuff is soul-crushing? it seems like it would be comfortable work


Do you think sitting in front of a computer for long hours typing out code is fun?

Do you think it sounds fun?

If you have an access to an electric kettle, nice music, and take intermittent physical activity breaks it could be okay, I guess.

Better than using the internet while earning zero money

79571802
I fell for the computer science meme but unlike the 50% of the sperglords who do cs I'm good at it and I found a good job. However I totally agree college is a scam and not worth the cost, especially since you can teach yourself everything using the Internet. You pay for the name and the networking

79584600
My friend studied engineering. He got a job that pays well doing diagnostics on predator planes. He can't wait for the day he can quit. STEM jobs definitely have their drawbacks. It can become mind-numbing work

ask

Tell me what you think of this conversation Sup Forums
I will want to kill my self if i work coding?

quantum computing is an enormous area of research
it's quite possible to do research in that field and never see or touch any code at all

I'm pretty sure that nearly zero of the people that frequent these threads feel that way.

We've spent most of our lives sitting in front of a computer.

>it's quite possible to do research in that field and never see or touch any code at all
That's what I'm hoping for desu.

>he honestly thinks a global variable has nothing to do with scope when the very definition of a global variable contradicts him
let it go. He doesnt understand scoping.
Scoping is pretty important if you dont want to start naming variables AAAAAAAAAAAAAA12435b. Its also easier to manage if you limit the variable to the scope its used in.