/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1542716388818.jpg (1465x2048, 300K)

Other urls found in this thread:

youtube.com/watch?v=orXCkE7QSwg
sites.math.washington.edu/~morrow/336_12/papers/ben.pdf
youtube.com/watch?v=jmTwlEh8L7g
automatetheboringstuff.com/
gitlab.com/9898287/nixwriter
twitter.com/SFWRedditImages

ur mom lol

reposting

mask = np.zeros((rows, cols, 2), np.uint8)
mask[crow-30:crow+30, ccol-30:ccol+30] = 1


why do I get the error
TypeError: slice indices must be integers or None or have an __index__ method

crow and ccol values are 213.5 and 320.0 so I thought it was because crow value wasn't a round number so I added 0.5 to it, but that didn't fix it.

Beginner programming here, what can I do better or more efficiently in this code?
def reduce(n):
n = abs(n)
ctr = 0
factors_list = []
for i in range(2,n+1):
if ctr >= 1:
break
if n % i == 0:
factors_list.append(i)
factors_list.append(int(n/i))
ctr += 1
return factors_list


def isPrime(n):
return 1 in reduce(n)


def primeFactorization(n):
if isPrime(n):
return reduce(n)
factors = reduce(n)
primeFactors = []
while True:
for e in factors:
if isPrime(e):
primeFactors.append(e)
factors.remove(e)
else:
factors.extend(reduce(e))
factors.remove(e)
if len(factors) == 0:
break
return sorted(primeFactors)

Males look like THAT?

Attached: maxresdefault.jpg (1280x720, 158K)

This. D is better

Sure, but being better than a pile of shit doesn't mean that D isn't a pile of shit also.

the error says that you can't pass float as an index. both crow and ccol are float. convert them to integer.
try round(crow), round(ccol) or int(crow), int(ccol)

C++ is good! Prove me wrong!

Attached: C++ in a nutshell.png (1016x98, 72K)

D is the greatest language there is. It will rise.

Debugging my DLL injection based software. There is just so much complexity, I don't know how to make it simpler. Reasoning about this program is almost impossible, because I even have to deal with stuff like mismatches runtime libraries, anti RE code, my own bugs of course, the link between the Injector and the injected DLL.
It has been crashing at random points for weaks now and people are complaining, and with every update by the software that I inject into it gets weirder and weirder, things that should IMO never crash are now crashing the app.

Nobody codes like this.

I tried that, but I think python only accepts numbers as int, so int crow doesn't work.

>Outdated standard
Not an argument.

How is adding new stuff supposed to remove old stuff?
I'm getting real tired of the "C++XY+3 will fix everything and make C++ not actually shit" meme. You fags have been spouting it for 10 years, yet C++ still complete garbage.

Woah man you take that back

youtube.com/watch?v=orXCkE7QSwg

C++14 allows you to remove that entire trailing return type, for one.
You obviously don't actually know anything about C++, so I suggest you stop shitting on things you're not familiar with.
C++ code simplifies with each new revision.

You still didn't explain how adding new shit removes old shit.
Also
>Breaking the ABI every 3 years
Fucking amazing choice there, guys.

incredibly moe
the language doesn't though

Attached: 1468197421600.jpg (400x400, 23K)

They really have. Since 03 they've constantly been crying wolf like this.
It's been so long now I don't understand why people haven't either abandoned it by making a good replacement or why they don't take their language development seriously and actually make proper features. Is the language proposals all hammered down by people who don't want the language to be good?

leave the standard to academic circle jerk community

C++ has its uses. I recommend it as a first language whenever a normie asks. It's such a bad language that they end up quitting and hating programming forever, and I save programming jobs from becoming over-saturated.

jokes on you. c++ is getting me interested in programming again. the power and complexity is addictive.

>You still didn't explain how adding new shit removes old shit.
I literally just told you.
>C++14 allows you to remove that entire trailing return type, for one.
Wanna know what was added that allowed you to remove it? automatic return type deduction.

Here's some more examples:
Adding concepts allows you to remove SFINAE and concepts emulation hacks
Adding metaclasses allows you to remove lots of boilerplate in class definitions
Adding allows you to remove tons of comparison operator boilerplate
Adding fold expressions allows you to replace recursive template functions with much simpler code
Adding type deduction in general allows you to omit lots of long type names with a simple short keyword
Adding constexpr allows you to replace template metaprograms with normal compile-time evaluated C++ code
Adding non type class instance template parameters allows you to replace code like this std::cout

Attached: 1529877157739.jpg (1280x720, 886K)

>And yes even a curl cli would shit the bed to. I'm sure software exists in the OSS for this.
Yeah, curl -C - url automatically determines where your download dies and then tries to ask the remote server for only the bits it still needs so you don't have to start over again.

And every piece of C++ software is magically going to be updated to the latest version of C++ when it gets released?
You will NEVER again have to deal with the old garbage?

Why the heck is this image so hard to find source on. Fuck.

Attached: 1480407501488.jpg (1042x1101, 84K)

1. that "old garbage" isn't an issue in the slightest for anyone who isn't retarded
2. new code bases can use the new stuff
Nice goal shifting the goal posts though

I used to like c++ because it made things easier and I was an inept programmer. Doing something in C looked nearly impossible. Sad times

Attached: 41gHB8KelXL._SX377_BO1,204,203,200_.jpg (379x499, 27K)

Sucks being you then I guess.
t. non retarded C++ programmer who finds it easy to program in C because I used to use C exclusively.
Boy am I glad I use C++ now though.

thanks for finding it for me

Attached: unknown.png (378x347, 139K)

I haven't found it because I still don't know the artist.

What are some common techniques in regards to development of decentralized and/or federated applications?

An obvious one is blockchain.
CRDTs are a strong candidate but immensely complicated, and I think are an ongoing research subject.
Yeah that's kind of it.
Am I missing anything?

so what I'm hearing is that it's a bunch of "features" that are actually bugfixes and patches over previous deficiencies? Great, C++ is almost a stable language, 35 years later.

Attached: 1497064251513.gif (500x281, 1.4M)

What is the best way to become a truly good C++ developer? I use it for years now, but sometimes I still forget some random stuff from the standard and it causes bugs. Should I just read the whole standard, is that even possible? Is there some document that focuses on the most important parts?

>What is the best way to become a truly good C++ developer?
The fewer braincells, the better.
I suggest some sort of substance abuse.

>I still forget random stuff from the standard
sounds like you're trying to do stuff that's too complicated for your own good.
try some of the simplifications from the more recent versions of C++.

I can't wait for C++35 where they'll finally make it good.
:^)

My problem today was not that hard in retrospect. I used Qt and had an inner and outer layout, normaly Qt takes care of deleting their widgets when a window was closed, but simply because I declared the inner layout first it crashed.

I thought it was some weird stuff in Qt, but it turned out it was simply because C++ objects get deleted in reverse order of declaration.
Now if I didn't use Qt I might have remembered that as a likely source of the error, but since I searched in the Qt doc instead it took me quite some time to find the bug.

Lmao say what you want but C++ gets better every revision.

Attached: 1518673610694.jpg (1266x900, 904K)

improved shit is still shit though

>hur dur dur

elisp parser with megaparsec for a super mega top secret project that will hopefully pad my resume so i can find another job and buy girlpills

anyone know how to use labview

Why are you trying to promote C++
It's not even a hipster language, everyone uses it already

It's a form of choice-supportive bias, since deep down he realized he wasted a lot of time learning a pile of shit.

based and girlpilled

>"C++ is shit! look at all this syntax bloat!"
>Actually later revisions simplify all that
>"N-No it doesn't!"
>*gets proven wrong*
>*shifts goal posts* "T-T-There just bug fixes lol!"
>*shifts goal posts again* "I-Its still shit!"
Yeah, you don't have an argument.

Attached: 1518794817932.jpg (2000x1400, 506K)

Going from a 0/10 language to a 1/10 language is no accomplishment desu

Attached: 1541281924933.png (750x850, 735K)

Your sprawling mess of a language is just growing more bloated. The old retardation is still there, even if you try to distract from it with some other shit.
5% of a language being acceptable and the rest being shit and written off as "just ignore that bit" does not constitute a good language. In fact, it constitutes a very bad one.

>*gets proven wrong*

SICP is intended for total beginners right....? I lurk here for tips and it's posted so often I brought it without doing much research. If I read/work through the exercises for 2-3 hours per day how long do you think it will take to finish? I've only been programming for a year and only in c#, c and sql. I want a more complete picture of how a computer actually works. I don't understand what happens between the transistors, machine language, assembly language and the high level languages. It seems wrong to be programming when I really don't understand how a computer works.

Attached: 2ct5c35.png (1919x1080, 1.06M)

SICP is a book for people who want to roleplay as technowizards it doesn't really teach you anything useful

dunno but it looks good on your library

Funny you post that image because modern C++ removes a lot of code bloat in C code bases without sacrificing efficiency, and improving correctness.

>Your sprawling mess of a language is just growing more bloated.
Still spouting this? Even though I just showed you wrong here? is the post that proves you wrong

>Still spouting this? Even though I just showed you wrong here?
Good job just ignoring the rest of what I said.
Whatever helps you cope with the poor decisions you made, I guess.

Good job ignoring the whole post that proves you wrong.

It'S a different kind of bloat. You can write some things in a nicer way, but the language itself becomes bloated and you can be sure that many people will use the new features incorrectly. And yes that is partially the fault of the language, languages should be easy to understand and logical.

c++ coders coping mechanism:
>everything will be better next standard

>You can write some things in a nicer way, but the language itself becomes bloated
This isn't an issue.
Just don't be retarded, there.
>and you can be sure that many people will use the new features incorrectly
This is an appeal to retardation, and that is not an argument.
>languages should be easy to understand and logical.
What do you think the new revisions are doing?

A language full of a million legacy features is an issue

this: it's not actually very useful of a book. also ! theres nothing wrong with not knowing how different parts of a computer work user. most compiler developers have very little knowledge of distributed systems, and most plt type theory people dont know too much about operating systems

usually you accumulate broader knowledge by doing projects in different subfields.

so for example, youd gain a lot of knowledge about computing in general by, say, taking a cs101 class, reverse engineering some malware, making your own language, hacking on some hardware project. there's no single set of things you have to do either, just try to do projects just outside your comfort zone, that challenge you without frustrating you

youll get there :>

I don't hate C++, but I think too many features are not always a good thing.

Except it isn't, because a lot of those features are actually just abuses of legitimate features that still have uses.
The others are C shit.

float Q_rsqrt( float number )
{
floatint_t t;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
t.f = number;
t.i = 0x5f3759df - ( t.i >> 1 ); // what the fuck?
y = t.f;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}

SICP is academic wankery

Still have no idea where they got that number.

Almost all the new features C++ is adding are all useful and needed.
Especially concepts, metaclasses, and static reflection.

1. Just gonna throw this out there, but "reduce" is a terrible name for a function that gives out a list of factors. It is easily confused with a higher order function of the same name, which applies a function over a list with an accumulator.
2. You are currently calling reduce twice when checking for primality at the start of the primeFactorization function, when you could do this once. Consider:

factors = reduce(n)
if 1 in factors:
return factors
primeFactors = []
# Rest of code continues here
3. In checking for primality later in the function, there's faster ways to do it than iterating over every possible factor. For instance, you could check only the numbers up to the square root of n, and short circuit (return false early) if you find any factors at all (since if it's prime, it shouldn't have any).

sites.math.washington.edu/~morrow/336_12/papers/ben.pdf

On page 9 is a section for "finding the optimal magic number."

That is the most boring bit.

It could also have been found by brute force. There aren't that many floats, you can check them all and see which one gives most accurate results.

no one?

Attached: Dh3Q3SFU8AAj8-B.jpg (699x350, 51K)

Oh. Uhm. The memeing here influenced me into buying it. I've been lurking here science I started programming, about a year ago and I've never once seen something posted about SICP till now... Why do you guys put it in pictures if it isn't worth reading..... So I shouldn't even bother with it? Can you suggest me a better book? I've read that "Introduction to Algorithms" is good but it's $150. "The Art of Computer Programming" is another I've heard of.

Maybe I should just do a CS course on udemy or is that a really bad idea?

I know I'll never be able to fully grasp all of it. It's part curiosity but it does seem weird to me that I don't understand what's going on beneath my code. I watched a couple lectures put out by different universities on CS. One was MIT. A lot of it I did not understand.

>most compiler developers
Hm. I didn't realize they were a thing but I guess something has to right the compiler.

Attached: steinsgate09-08.jpg (1280x720, 51K)

>The continue keyword in C# doesn't increment the loop variable
LOL

Attached: laughing-emoji[1].jpg (800x770, 71K)

I want to tease and tickle kurisu and force as many cute moans out of her as I can!

Meh, I think people overthink this stuff. You actually have so much time in an average life, you can read tons of books and reading SICP will most likely not hurt you so if it interests you just go for it imo. If you want to save money you can download an ebook and see if you really like it.

How long are you going to post this disinfo for?

>Why do you guys put it in pictures if it isn't worth reading
Jow Forums is full of cs students and people who think they're cyberpunks

how to get started if interested in computer vision? any specific languages or softwares I need? any good beginners guide?

i dont think theres any single book, you should just pick subfields and then read relevant literature in the subfields

i think if you just want general knowledge, you can always go online and take like, actual CS courses. mit and stanford are really good about having openly accessible curriculum, and if a given course doesnt offer the textbook for free you can always pirate it off libgen

It's an introduction to programming that's enamored with lisp.
>It seems wrong to be programming when I really don't understand how a computer works.
You'll find that that applies all the way down to (and including) assembly right now. Certainly less so on the lower levels. It's not a realistic expectation to have to understand every part of the system down to that level. And you'll find that programming is mostly about expressing intent in a structured way that allows you to express more intent rapidly rather than visualizing every step in the process. You could call a json parser and try to think of exactly how it extracts the data into the structure you later access. But it doesn't help you accomplish a goal assuming it works and is good enough for you.
>transistors, machine language, asm
Anything below asm is mixes between trade secrecy and well known. And some asm instructions are secret aswell (youtube.com/watch?v=jmTwlEh8L7g this was a fun watch).
>Why do you guys put it in pictures if it isn't worth reading
It is 'worth reading'. It teaches you thinking for the most part. I never read it as a newbie so I can't say if it really starts you off on the right foot when you're impressionable or something. It's not like reading it has completely changed how I think about programming or anything like that. But think it was well written. I don't know of a better book that teaches you programming over teaching you a language.

Don't use that book. It's a huge waste of time and nobody uses Scheme. Use composingprograms.com, it's SICP rewritten in Python.

Some functional programming isnt bad, makes you think about state and side effects and now many imperative languages use functional constructs to some extent.

>Python
>Doesn't even have TCO
How on earth is that supposed to work for functional programming?

>And some asm instructions are secret aswell
I went to black hat this year and somebody had spoke about a CPU fuzzer they had written. it ended up discovering an undocumented ASM instruction that executes all following instructions in ring 0 in a certain brand of processors

>certain brand of processors
I think we can all guess.

Yeah, sandsifter. That's the guy i was linking to, Christopher Domas. He found a secret separate RISC core inside CPUs.

Thank you

Automate the boring stuff is a good resource for beginners as well. automatetheboringstuff.com/

>Seinfeld.jpg
What's the deal with functional programming?

Starting from chapter 7

I didn't even read it, I jumped head first into C; but someone else might get something out of it.

Why gtk is more popular than qt?

Qt's MOC makes it close to impossible to wrap and deploy as dependencies.

Rate my dd front-end
gitlab.com/9898287/nixwriter

Attached: 1542680170320.jpg (636x773, 32K)

Qt is sepples garbage.
GTK is pretty shit too, though.

>gitlab.com/9898287/nixwriter
starred upvoted liked followed watched