[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - daily programming thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 24
File: cover_t.png (25 KB, 103x140) Image search: [Google]
cover_t.png
25 KB, 103x140
What programming books or books related to programming have you ordered recently edition

Old: >>55367288

>picture is related to thread
>>
>>55375964
>2016
>posting thumbnails
FUCK OFF
>>
>>55375964
garbage networks book

just download all of barabasi's papers
>>
File: images.jpg (19 KB, 324x400) Image search: [Google]
images.jpg
19 KB, 324x400
not interested in games
>>
>>55375964
There's already one here you fucking idiot
>>55375878

>redditors can't ctrl-f
>>
>>55376120
The old one was below bump limit when I posted
>>
>>55375990
How is it shit?

The paid shills on amazon gave it great reviews
>>
>>55376153
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?
>>
>>55376796
This one. The trap thread doesn't even have /dpt/ in the subject, so it's not even a /dpt/ thread.
>>
>>55376885
But it does still come up in a search for dpt
>>
>>55376893
Not if you filter by subject, which many do.
>>
what's a good text editor for coding in windows?
>>
>>55377043
Vim
>>
bump so this thread can be used next
>>
http://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?
>>
>>55379689
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?
>>
>>55380706
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.
>>
>>55380895
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?
>>
>>55381006
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.
>>
>>55381058
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+n)<123] #applies cipher to regular terms
return [(i-26+n) for i in y if 122<(i+n)<149] #loops around to a if cipher goes past z
return [(i+26+n) for i in y if 64<i<91] #loops forward to a if there are capital letters
encoded = (list(map(chr,encodeint(y))))#changes ascii back to plaintext
print(y)#for troubleshooting purposes
print(encodeint(y))#for troubleshooting purposes
print(("").join(encoded))#returns ciphered input
>>
>>55382137
i only glanced at your comments but check out if there's an rsync library for python. rsync is good for syncing stuff
>>
>>55375990
Seconded
>>
>>55382406
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.
>>
>>55382826
Thanks. I still get a problem after i fixed that though.

This time shell says " line 9, in encodeint
elif 122<reg<149: TypeError: unorderable types: int() < list()".
That does not make any sense. I am comparing an integer to element(s) from a list, not an entire list. It does not work if i try to redefine it as int() either.

 """Ceasar Cipher code"""
x = list(input("enter phrase to be encoded, letters and spaces only: "))
y = list(map(ord,x))
n = int(input("enter ceasarian key: "))
reg=[(i+n) for i in y]
def encodeint(y):
if [i for i in y] == 32:
return [32 for i in y if i == 32]
elif 122<reg<149:
return [(i-26+n) for i in y]
elif 96<reg<123:
return [(i+n) for i in y]
elif 64<reg<91:
return [(i+26+n) for i in y]
encoded = (list(map(chr,encodeint(y))))
print(y)
print(encodeint(y))
print(("").join(encoded))
>>
>>55383196
Well reg is a list(), while the numbers you are comparing it to are integers.
>>
>>55383339
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
>>
>>55385615
MLfags hate them
>>
>>55385615
they aren't

wait until you need to have multiple instances per type
>>
>>55386138
Then you should use newtypes
>>
>>55386419
What an ugly, anti-functional and retarded solution
>>
>>55386459
It's the best we got, bro. If you wanna allow multiple inconsistent instances then you lose the prolog for types magic
>>
>>55386474
>it's the best solution we got
no
>>
>>55386485
ye

We must not allow the barbarians who want implicits to taint our language!
>>
File: 1463174335918.jpg (98 KB, 865x924) Image search: [Google]
1463174335918.jpg
98 KB, 865x924
What would she do?
>>
>>55386613
>she
>>
File: 1460411498656.jpg (128 KB, 900x675) Image search: [Google]
1460411498656.jpg
128 KB, 900x675
>>55386639
Yes, she
Got a problem wit that?
Fight me irl

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

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.
>>
>>55386613
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?
>>
>>55386894
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)

>>
>>55386894
what are you trying to do? what about using a loop?
>>
File: 1420500175412.jpg (438 KB, 900x2134) Image search: [Google]
1420500175412.jpg
438 KB, 900x2134
Assuming I only know some C, with which one of this books should I start? I'm studying EE if that helps.
>>
>>55386998
this image is bait, right?
>>
>>55386998
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.
>>
>>55387063
>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)
>>
>>55386955
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;
}
>>
>>55387496
static only applies in the context of classes

int x = 0;
void foo() { ++x; }
>>
>>55387516
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.
>>
>>55387539
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.
>>
File: Quo78RP.png (13 KB, 418x359) Image search: [Google]
Quo78RP.png
13 KB, 418x359
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
>>
>>55387567
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.
>>
>>55387596
global-ness and access are completely unrelated
>>
>>55387616
Would you say all variables defined in a class are global?
>>
>>55387632
no
>>
>>55387646
the why would you say a static variable thats part of a function which is part of a class is global.
>>
>>55387660
What?
>>
>>55387673
class has a function. function has a static variable.
according to what you are saying that static variable is global.
>>
>>55387708
yes
global = static
>>
>>55387708
also analogous is that functions are themselves globals of function (pointer) type
>>
>>55387730
so then how are the variables defined in the class not global. The scope should be the same for the two.
>>
>>55387748
they might not be static
>>
>>55387757
It sounds like you arent really sure what you are talking about since you arent referring to scope here.
>>
>>55387772
>it sounds like you don't know what you're talking about because you disagree with me
global doesn't mean public
>>
>>55387779
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.
>>
>>55387824
>>55387779
it's not about scope
>>
>>55387845
>global variables arent about scope
Alright. confirmed not knowing what youre talking about.
>>
>>55387845
Just to further rub it in
>In computer programming, a global variable is a variable with global scope,
>>
>>55387869
>>55387878

struct x {
int y;
}

is y global?
>>
>>55387539
>globals are evil but statics are not
I cringed.
Clearly you are an enterprise OOP professor.
>>
>>55387748
>>55387708
>>55387660
>>55387567
>>55387730
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.
>>
>>55387936
yes, unique member shared across all instances
i.e. a global state
>>
>>55387902
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.
>>55387935
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.
>>
>>55387967
i've said before it's got nothing to do with lexical scope
>>
>>55387960
Let me make this easy for you.
void foo()
{
void boo()
{
static int x;
}
}

Is the scope of x global?
Protip its not.
>>55387982
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.
>>
>>55388008
x is a global state
boo is impure
>>
>>55386138
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.
>>
File: 1458270874589.jpg (46 KB, 560x400) Image search: [Google]
1458270874589.jpg
46 KB, 560x400
>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, /g/?
>>
>>55387960
No, because the variable is not accessible from all translation units - it is constrained to file scope.
Here's a quick example for you.
>>
>>55388032
The scope does not matter
It is global STATE
>>
>>55387967
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.
>>
>>79583629
>being stuck in a career related to CS

id rather be a neet
>>

>>79583692
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

>>79583921
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


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

Do you think it sounds fun?

>>79584469
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
>>
>>55388026
ask >>>/sci/
>>
>>55388076
Tell me what you think of this conversation /g/
I will want to kill my self if i work coding?
>>
>>55388026
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
>>
>>55388097
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.
>>
>>55388112
>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.
>>
>>55388037
>he honestly thinks a global variable has nothing to do with scope when the very definition of a global variable contradicts him
>>55388032
let it go. He doesnt understand scoping.
>>55388042
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.
>>
>>55388159
for fucks sake's stop bringing up scoping, we disagree with the fucking definition not the implication. you're just restating your view.

if global variables just meant lexical scope then there's no way people would be so fucking opposed to them
>>
>>55388159
>let it go. He doesn't understand scoping.
Yeah I kind of gathered that after I made that post. Oh well.
I'm certainly not going to be dwelling on it while I go have myself a nice dump.
>>
>>55388076
T
H
I
S please
>>
>>55388173
>we disagree with the fucking definition
No, you just dont know what you are talking about. The concept of global vs local variables was created in the context of scope.
>>
>>55388207
Once again you're just restating your fucking view. I already said I disagreed that it was about scope, that's what we were arguing about.

If both of you think it's about scope then maybe it is and I'm wrong on the definition. Why are people always so pissy about globals then? Makes no sense if it's just scope.
>>
>>55388230
>I disagree with the cs community on what a term they made up means
>>
I bought in to the ReactiveX meme. Is it going to be easier to learn if I just switch over to the purer FP languages?
>>
>>55388251
I literally just said that if both of you disagree then you're probably right. I didn't know that it meant scope, that makes no sense to me. Why do they bang on about it being bad if it's just scope?
>>
>>55388230
>Why are people so pissy about globals then?
Part meme, part retardation, part actual reasons.
>>
>>55388159
>Scoping is pretty important if you dont want to start naming variables AAAAAAAAAAAAAA12435b.
You don't end up doing that. You typically think up a naming system for any given set of variables, and it stays distinct and novel enough. Counters included. If you want variables to be deleted after a call you just delete the ones you need to, or you reset them to a default at the function's entry point. If you want a certain value, you just call its function and then use the global variable you know it sets.

Batch also has another form of scoping when you call subroutines / functions, the parameters you call with are accessed via %1 %2, etc. As a whole scoping just automates all of this within a simple and intuitive set of rules. Obviously you have some problems when explicit becomes implicit or inherent, I tend to have to think how to do what I want to within a for loop or something, and get around the scoping.
>>
>>55388253
why not go full meme and choose Haskell with reflex instead? I wouldn't call any of the language on the ReactiveX list (Scala, Clojure) "purer" FP languages
>>
>>55388349
>ReactiveX
If using Clojure, why would I choose to use this then just busting out core.async?
>>
>>55388349
That is what I wanted to meant. I actually just started very recently using RxJava and I kept leaking objects all over the damn place.
>>
>>55388383
>then just busting
*rather than
>>
>>55388390
I was memeing a bit, unless you use reflex-dom (for web apps), reflex doesn't have any built-in external observation, so you will have to build up that part yourself.
>>
File: 125px-Tcl.svg.png (11 KB, 125x265) Image search: [Google]
125px-Tcl.svg.png
11 KB, 125x265
is tcl a good meme or a bad meme?
>>
>>55388679
Nobody's ever heard of it so it's not even a meme
>>
>>55388705
I'm looking for a scripting language with decent regular expression integration
>>
>>55375964
why would i order books when i can just steal them off the internet for free. yfw google is solely responsible for killing the publishing industry
>>
>>55388712
decent pattern matching* integration
>>
File: graph.png (101 KB, 1630x948) Image search: [Google]
graph.png
101 KB, 1630x948
Finally got to play with tensorboard. It's cool but images tab is absolute dogshit.
>>
>>55388725
why did you feel the necessity to change regular expression integration into pattern matching integration?
>>
>>55388752
because you can still have string pattern matching without regexp like in Lua
>>
>>55388276
>I didn't know that it meant scope
it doesn't, they're just retards
> Why do they bang on about it being bad if it's just scope
they obviously can't tell you because their teacher only said "avoid global variables" and they took it for granted
>>
>>55388712
python's re module can do everything
>>
http://www.kernel.org/doc/Documentation/CodingStyle

>If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.

What did he mean by this? Avoid depending too much on state variables?
>>
Can someone explain how to get this scraper to work?

http://pastebin.com/HrfENCvs

When I run it and do SPIDER it just returns

>>> SPIDER
<SoccerwaySpider 'soccerway' at 0x3abf090>
>>
>>55389319
that's cause it's an object?
try calling start_requests
>>
>>55389310
>Avoid depending too much on state variables?
I have no idea how you got that conclusion
but no, he's implying that if you have that many levels of indentation, then your function is doing too many things and you should break it up into smaller functions
>>
>>55389310
He means that you don't need anymore than 3 levels of indentation. And much more compact and versatile options exist instead of continuous nesting.
>>
>>55389425
>>> SoccerwaySpider.start_requests()

Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
SoccerwaySpider.start_requests()
TypeError: unbound method start_requests() must be called with SoccerwaySpider instance as first argument (got nothing instead)


I'm not sure what argument I need to use
>>
>>55389452
> kernel.org
>break it up into smaller functions
Function calls are expensive.
>>
>>55389504
that time you tried calling a function on the class instead of on an instance of the class
>>
has anyone here done any significant work with .NET Core yet? any thoughts?
>>
>>55389534
I'm a complete programming noob, unfortunately I need to slog through it to get a scraper to work.

Spoonfeed me.
>>
>>55376005
im thinking of buying /torrenting this one. Any reviews?
>>
>>55389546
try
SoccerwaySpider().start_requests()
>>
>>55389558
using design patterns when you're hobby programming doesn't make sense
you use patterns because your boss forces you to, and he does that because he thinks it'll make your code easier for his other employees to maintain
>>
>>55389565
>>> SoccerwaySpider().start_requests()
<generator object start_requests at 0x04604F08>
>>
>>55389577
>t. pajeet
>>
>>55389558
Just read it: http://gameprogrammingpatterns.com/contents.html
>>
>>55389581
it returns one result at a time
the thing it returns is whatever Request returns
which appears to be part of that scrapy library, so I don't know what its members are
try printing it
for i in SoccerwaySpider().start_requests():
print i
>>
>>55389622
<GET http://www.soccerway.com/national/brazil/serie-a/2010/regular-season/matches/>
>>
>>55389644
I don't know what that is
instead of print i, try print vars(i)
>>
>>55389708
{'_encoding': 'utf-8', 'cookies': {}, '_meta': {'cup': 'brazil-2010'}, 'headers': {}, 'dont_filter': False, '_body': '', 'priority': 0, 'callback': <bound method SoccerwaySpider.parse_matches of <SoccerwaySpider 'soccerway' at 0x3c0f0f0>>, '_url': 'http://www.soccerway.com/national/brazil/serie-a/2010/regular-season/matches/', 'method': 'GET', 'errback': None}
>>
>>55389735
you're gonna have to read the scrapy documentation because I don't know how it's supposed to work
I took a glance at it and apparently this request object
>>55389644
is supposed to be used by something called the "Downloader" which will then send the response to the spider
where I assume is where you use it
>>
>>55389777
Will look into it, thanks.
>>
Can someone explain exactly how raycasting works? I tried reading this: http://lodev.org/cgtutor/raycasting.html ,but I can't wrap my head around how the "2D camera" works.
>>
>>55375964
Picture is also shit
>>
Haskell type classes have way more problems than I initially thought

It's virtually impossible to write generic instances
>>
I'm trying to modify a struct's vector via a pointer inside a function like so:


struct node_t
{
std::string value;
std::vector<node_t> children;
};

node_t * last_node = NULL;

void add_node(std::vector<node_t> &nodes)
{
node_t node;
node.value = "";

if (some_condition)
{
nodes.push_back(node);
}
else
{
if (last_node)
{
last_node->children.push_back(node);
}
}
last_node = &node;
}



But when I go to the else condition to push new node into the children, the vector stays unmodified outside the
void add_node
function.
What am I doing wrong?
>>
>>55391037
That code makes very little sense.
>>
>>55391037
:22
>3>
please

Also, this.
>>55391116

So you are globally caching the last node? But then you add the node you just created to the children of the last node then replace the last node? I don't what you are trying to do. Ever hear of the XY problem?
>>
>>55391156
I'm trying to create a tree of nodes. Each node in the tree can have N amount of child nodes.

The last_node is just a shortcut so I can get to the last child node so I dont have to recursively loop through all of them.
>>
File: filetree.png (49 KB, 440x251) Image search: [Google]
filetree.png
49 KB, 440x251
>>55391199
Pretty much like this pic related.
>>
Best way to write C on windows?

>no linux pls
>>
>>55391368
MinGW, and a text editor of your choice?
>>
>>55387587
Are you talking about minification?
>>
Is this valid in C?
int CharToInt (char x, char y) 
{
int n = x - y;
return n;
}
>>
>>55391468
yes

why not just return x - y
>>
>>55391468
yes, but what's the point of this
>>
>>55391502
>>55391544
Cryptography assignment familias.
>>
>>55391544
Not him but
CharToInt('n', 'a');
Would let you know that 'n' is the 13th character of the alphabet.
C's char-int conversion can be useful for things like that.
>>
File: image.jpg (2 MB, 2592x1936) Image search: [Google]
image.jpg
2 MB, 2592x1936
feeling p comfy
>>
File: winnieEntersTheOtherWorld.gif (982 KB, 320x287) Image search: [Google]
winnieEntersTheOtherWorld.gif
982 KB, 320x287
>>55391644
>posting from an iphone
>upside down picture
>rock band controllers
>hp laptop
>wall indicates that the picture was likely taken in a basement
>>
>>55391691
mommy would be sad if i left
>>
>>55391588
That's far too trivial to have it's own function.
It's also implies that whoever wrote the function doesn't understand C.
chars are already an integer type, character literals are ints and not chars, and every time a char/short is used in arithmetic, it's converted to an int anyway.
>>
>>55388076
I too fell for the college meme. If you know how to google you can teach yourself how to code pretty well. Half the kids in my classes just copy pasta from stackoverflow/etc changing few variables, don't be tricked by the educational jew believing you need a degree to be hireable I know quite a few people who never went to college and are making good money programming.
>>
Why is functional style programming so damn good?
        let queue_family = instance::PhysicalDevice::enumerate(&instance)
.flat_map(|physical_device| physical_device.queue_families())
.filter(|queue_family|
queue_family.supports_graphics() &&
surface.is_supported(&queue_family).unwrap_or(false)
)
.nth(0)
.expect("No compatible device found");
>>
>>55391809
that looks like a god damn mess
>>
I should just kill myself, shouldn't I?
http://pastebin.com/Tyjnjb1p
http://www.xarg.org/tools/caesar-cipher/ (not mine, just what I was implementing)
>>
>>55391644
does your keyboard work like in should in linux? mine drives me crazy

fucking HP .....
>>
i'm a little confused at this part in SICP. it's teaching local state variables and there's a part where you have a function
(define (make-withdraw balance)
(lambda (amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"insufficient funds")))


you can then (define johnsAcct (make-withdraw 100)) to create an object and use (johnsAcct 40) to withdraw 40 dollars from the account for example. i understand how the creation phase works, because you are calling the function make-withdraw that needs a parameter balance. but i don't see how you can say (johnsAcct) 40 to withdraw 4o from it. i don't see how the amount parameter 40 is being passed to the expression inside of make-withdraw
>>55391691
>not living with mom
spotted the javababby
>>
Guys if we all worked together on a single application we would have a large good application that would make a lot of money. Let us all work and keep allowing contributions towards a single project.
>>
>>55391885
I'll make the logo.
>>
>>55391813
How would you write it then faggot?
>>
>>55391885
Because it worked so well the last 40 times.
https://wiki.installgentoo.com/index.php//g/_projects
>>
>>55391885
i'll make the CoC
>>
>>55391908
Well lets make it work
>>
>>55391885
I'll write some shitty method in assembly that's unmaintainable.
>>
>>55390801
No, it really isn't.
>>
>>55391885
What would it do?
>>
>>55388712
Just use any language and a regex library, instead of limiting yourself to a shit language just because "mommy, it has good regex integration!
>>
>>55392107
Java is the best language your opinion is invalid
>>
i mentioned to an 18 year old guy at my work that my university blocked my internet bc i used a torrent to try to download a linux distribution legally and he started going off about TOR and stuff, and thinks he's a hacker. he told me that he's notorious online and he can't mention what his username is or he'd be in trouble bc i'd definitely recognize it. i tried to convince him he should go into CSCI classes at the community college he's about to go to and then get a degree at university but he was dismissive and said he can already hack but seemed secretly interested. he said he had experience with C++ so i made a practice program on the whiteboard we have
bool isEven(int n){
return (n%_ == _);
}

and he was completely dumbfounded even when i told him what % and == do. have i just lost sight of how bad normies are at this sort of thing, or is he hopeless?
>>
>>55388745
Is that a gui for tensorflow?
>>
>>55392130
>Java
>Good
The java language is okay at best. C# did 'heavy-OO' in a much cleaner and better way.

But Java with a capital J (oracle, the standard library, the 3rd party library ecosystem etc.) is horseshit.
>>
Okay lads I've used a shitton of high level languages like Python and JavaScript but I want to dig deep. Should I focus on C or C++ nowadays?
>>
>>55392164
Depends.
If you want to write kernels Assembly/C.
If you want to write libraries C/C++.
If you want to write applications C++/Rust.
>>
>>55392156
Java and C# are practically the same which proves you know nothing about Java. You just have a hate boner for Java because you fell for the Java is shit meme
>>
>>55392164
C++ is a high level language
>>
>>55392143
kek
>>
>>55392225
he wasn't joking or pulling my leg btw. he was really serious and defensive when i poked fun about it. he said that you should just divide the number by 2 and check if the number is even, but then i told him the machine itself doesn't know innately whether a number is even and he got irate
>>
>>55392181
Of course they are similar. I think C# did it better because it learned from Java's mistakes (it does generics better, LINQ was a killer feature, and I'll admit I haven't played with Java Streams).

Outside the languages proper and looking at the libraries/frameworks Java is awful.
>>
>>55392244
Ask him why he doesn't have bitlocker installed to protect his files if he's a hacker.
>>
>>55392143
>>55392244
desu it can be confusing to many beginner programmers I use to forget which number you are suppose to divide by For example 10 % 2 I wasn't sure if it is 10 being divided by 2 or 2 divided by 10 at first then got that it is you subtract the right side 2 by 10 however many times it can go in and you get the remainder of what is left over
>>
>>55392164
C++ with its standard library are enormous. It's a huge commitment to learn it.
>>
>>55392272
C# has even worse generics than Java.
>>
>>55392279
You're kidding, right?

>desu
Stop that.
>>
>>55392302
No it's true a lot of beginner programmers would have trouble with that
>>
>>55392319
You shouldn't patronize them and assume so little of them.
>>
>>55392332
This is what I have seen in many different programming classes as a ta
>>
>>55392319
I think the issue here is that he was claiming to be a notorious hacker but didn't know what a modulo operator was.
>>
>>55392360
You don't really use modulo operator for that. You do need a strong foundation of how computer networking works
>>
>>55392379
Fucking kill me
>>
>>55392379
That depends on your definition of hacker tbqh. Though I think you'd be hard pressed to find anybody giving a presentation at DEFCON who doesn't know what a modulo operator is.
>>
>>55392410
>>55392430
Define "Hacker". If it is in the general sense you would just need to know computer networking and it is possible to not know about modulo operator being one.
>>
>>55392467
Oh gods, you can't possibly be this thick.

Do you think computer networking is just plugging cables into boxes, and what the difference between a switch and a hub is? How the fuck are you going to hack anything with just that tiny amount of knowledge?
>>
I know a little bit of C and a bit of Python, I realised Python is slow for me so I wanted to start learning C or C++
Any books you could recommend?
>>
>>55392511
It is way more then just that and it has to deal with how different computer IP addresses actually interact and work together based on different protocols. You need to understand the vast amount of information on it to really know what you are doing. .
>>
>>55392522
On C:

- C Programming: A Modern Approach
- Pointers on C.

On C++:
- C++ Primer
- All the Effective C++ books.
>>
>>55392562
How about Java tho?
>>
>>55392568
Stay away from it.
>>
>>55392553
And yet, somehow, you believe that there's no math required?

Do you see the inconsistency of your position?
>>
>>55392572
Unless you want a job.
>>
>>55392586
A job that you hate.
>>
>>55392596
I use Scala most of the time, but I need to know Java for about 5% of the time, when I'm dealing with legacy Java code or using a Java library.
>>
>>55392181
>Java and c# are practically the same
C# has much cleaner syntax, I'd love to see it replace java as the standard for easy cross-platform development. Also, java VMs are laggy, JIT compilation is objectively superior in terms of efficiency.

>>55392430
>glorified security conference
>hackers
OMG GUIZ I CAN USE METASPLOIT AM I A 1337 H4X0R YET??
>>
>>55392573
It is a lot of heavy math calculations all which require no modulus so back to the original statement you don't necessarily need to know it for that.

>>55392572
Why stay away from Java when all the jobs are for Java
>>
>>55392642
>lots of heavy calculations
>but never a modulus operation
I... I'm quite impressed that you believe this.
>>
>>55391368
MSYS2.
>>
>>55392642
>java
>jobs
Hello prajeet, how's life in the code monkey sweat shop treating you?
>>
>>55392642
What happened to Ruby? A couple years ago it was the shit if you wanted to get a cool job.
>>
>>55392741
It's true all the jobs in Western countries such as America and Canada most of the programming jobs are in Java. Deal with it.
>>
>>55392753
Surprise, it was A FUCKING MEME
>>
>>55387583
Reposting.
>>
>>55392787
How are we supposed to know? Is a cache miss likely for the first scenario?

>hurr hey guys is this thing gonna be in cache or not
Dipshit
>>
>>55392759
>all the programming jobs are in java
All the plebian programming jobs are in java.
FTFY
>>
>>55392787
I don't ponder on this kind of shit for "smaller elements", let the compiler try to optimize it if it wants to. You should run your experiment and tell us, faggot.
>>
>>55392857
which are still most. Usually beginner programmers will take a java job for a few years then transition into a harder language such as C++
>>
>>55392903
I suppose you regard yourself as a l33t h4x0r because you use C++
>>
>>55392814
I wrote something else and then decided you didn't actually read / understand my post, and deleted it. You probably couldn't give a good answer anyway.
>>
>>55392942
Ah, the old >I realised my post was stupid, almost admitted it, but decided to insult you instead
>>
File: m8b7gr9.png (91 KB, 800x600) Image search: [Google]
m8b7gr9.png
91 KB, 800x600
>>55392642
>no modulus
If you can't understand the basic operators of a language, you're not a hacker...
>>
Is LibGDX any good?

What is the best option if you want to make a 2d mobile game?
>>
>>55391037
if the STD vector pushes by reference then the node will be garbage out of scope. Try creating a note_t pointer, newing it, then throwing it into the vector instead.

Psst.. also.. use nullptr instead of null. it will save you a lot of trouble later on when overloading functions. You will pull your hair out not understanding why the function func(int i) is called instead of function func(ptr p).
>>
>>55393075
I'll push my erect cock along the vector of your anus and give you an STD.
>>
really makes u think huh
>>55393036
it's a framework, not an engine. if you go into it with that understanding, yes it's good. you need a solid understanding and grasp on java, and you need to learn libgdx and build the "engine" so to say before you make your game.

buy a couple books on it and be prepared to not be able to work on your game itself for a while. on the upside, once you create your "engine" atop the framework you can re-use it on subsequent games. it'll take time
>>
>>55392964
The post was fine. I more or less reiterated that I said "Generally", and didn't care how someone filled it in with their idea of a typical case. All the information you need to provide a meaningful answer is already there. An inability to realize this is not indicative of an error of the part of the author, it's an indicator that someone doesn't want to use their head. ie, elaborating would probably be a waste, and it'd be more viable to just wait for the possibility of someone who gets it on their own, the first time.

Think about it. In what sorts of cases would you be passing around small elements through otherwise expensive function calls? It shouldn't be assumed a call will be inlined.

Hence, I don't think you can give an answer I'd find valuable. I got lazy and bailed on you the last time, but this post is for you.
>>
>>55391809
Might just be me, but it looks really cluttered and hard to read. It looks complicated, not complex.
>>
File: keanu mfw.jpg (71 KB, 587x545) Image search: [Google]
keanu mfw.jpg
71 KB, 587x545
>mfw people don't know recursion can be iterative
>mfw people think that recursion and iteration are some kind of opposites
>>
>>55393112
Okay then which is the best gaming engines out there for 2d games and 3d games right now to use?
>>
What is the OpenGL/DX equivalent of physics programming?
>>
C++ primer is great once you have a bit of knowhow and just want to look certain things up, but I'm not really a fan of the order things are presented for beginners.
>>
>>55393199
There's no good C++ book for total beginners desu.

Even "Programming Principles and Practice Using C++" isn't that great.
>>
>>55393171
no idea desu. honestly you'll get more out of making your own engine in libgdx than using a prebuild engine. think of it as grinding to level up. you may think getting your game made as quickly as possibly is the be-all-end-all, but you'll learn more about the entire system of game development with the libgdx route without having to be on the bare metal. i'd recommend you take your time on the long road and learn about libgdx with the understanding it's going to take a while
>>
Can someone tell me why the fuck this doesn't cause a memory leak?

static PyObject* decode(PyObject* self, PyObject* args)
{
Py_buffer buffer;
PyObject *retval;
uint8_t *decoded;
uint8_t ch;
size_t i = 0, j = 0;

if (!PyArg_ParseTuple(args, "y*", &buffer)) return NULL;
if ((decoded = (char *) malloc(buffer.len)) == NULL) return PyErr_NoMemory();

ch = ((uint8_t *)buffer.buf)[i];
for (i = 0; i < buffer.len; ++i, ch = ((uint8_t *)buffer.buf)[i])
{
if (0x0A == ch|| 0x0D == ch) continue;

if (0x3D == ch)
ch = ((uint8_t *)buffer.buf)[++i] - 106;
else
ch -= 42;

decoded[j++] = ch;
}

retval = PyBytes_FromStringAndSize(decoded, j);
Py_DECREF(decoded);
return retval;
}


I've created a uint8_t pointer called "decoded", and I've malloc'd it some memory.
Now, if I fucking call
free(decoded)
on the third last line, it results in a memory leak. If I use
Py_DECREF
instead, no memory leak.
>>
>>55375964

Still procrastinating on finding a graphics library for this chip8 emulator I'm making to learn rust.

I'm also looking at this ugly piece of code for rom loading and thinking there has to be a much better way of doing it.

fn load_rom (&mut self) {
let path = Path::new("C://Roms//INVADERS");
let mut f = match File::open(&path) {
Err(why) => panic!("couldn't open file: {}", why.description()),
Ok(file) => file,
};

let mut data = Vec::new();
let size = match f.read_to_end(&mut data){
Err(why) => panic!("Not valid utf8: {}", why.description()),
Ok(num) => num,
};

if size > 3583 {
panic!("Rom too big: {} bytes", size)
}

let mut y = 0;
for x in data {
self.mem.ram[0x200 + y] = x;
y = y + 1;
}
}
>>
>>55393112
Why do people think pointers are such an abstract concept. It's completely intuitive once you get to practice it for a few weeks.
>>
>>55393130
tl;dr
>>
>>55393358
Okay.
>>
>>55393330
Nigger use try!()/expect()/unwrap() instead of match/panic (in that priority order).

When I was implementiong a GB emulator I found making the rom a Box<[u8]> to be better than a big [u8; XXX]. Then I make rom_loading unrelated to my Cpu type and just pass it a Box<[u8]> when constructing it.
>>
Rust is a great systems programming language, because it's designed by people who know how to check privileges
>>
>>55393330
When did it all go so wrong for Rust?
>>
>>55393475
Rust is right tho you all need to check your white and mathematical and programming male privileges not everyone can be gifted mathematically
>>
>>55393330
Is Rust inherently so ugly?
>let
>let
>let
>let

What the fuck, are we back in Biblical times dictating the nature of the universe?
>>
>>55393509
Yes. When you write code, you are master of all you survey.
>>
>>55393550
terry please
>>
>>55393509
Try declaring a global :^)
Thread replies: 255
Thread images: 24

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.