/dpt/ - Daily Programming Thread

This is /dpt/, the best subreddit of Jow Forums

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

catb.org/~esr/faqs/smart-questions.html


What are you working on?

Attached: timetocode.webm (1152x648, 2M)

Other urls found in this thread:

pastebin.com/2VDTUse7
edx.org/course/cs50s-introduction-to-computer-science
twitter.com/NSFWRedditVideo

fucking hate you umaru filth

Attached: execute.jpg (1920x1080, 124K)

It wasn't a bad show honestly if you get through the first episodes, especially the second season was great, very lovable characters next to umaru

Should I learn idris or Haskel for making games?

thought you were talking about what i posted before you said second season

There's substantial overlap but you should start with Haskell

Anyone has experience with GTK3 and object oriented programming?

Rate my sparse matrix
pastebin.com/2VDTUse7
Also fuck python for not allowing the returning lvalue refs

why aren't you overloading the index operator?

Attached: scat.jpg (636x932, 24K)

Lol check out wdg, the entire threads about whole trying to understand what (i => () => i++)(0) does like it's some super advanced shit.

>exercise says use O(1) memory
>assume they mean one variable
>actually a 256 big array is still O(1)
Goddamn I'm an idiot, every fucking time

What programming language is that?

O(1) means it takes a constant amount of memory for any input (or at least the part of the input you're concerned with, e.g. the length of an array)

Js, but it also works in C#, and i assume other languages.

o(1) means that the complexity of foo(N) is the same for any N.

>rmake function with closure containing parameter i
>return function that increments i and returns i
>return that function
>call first function with 0, initializing a copy of i to 0 and returning a function to ++ it

Wow, so hard. Basically a functional "private" variable. Fucking brainlets

>>return function that increments i and returns i
>a functional "private" variable.

Not a function/functional then.

Attached: 1458021070656.png (6925x8708, 1.93M)

Something didn't work, I might have been just retarded

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

Go back to the other thread you're forcing.

>try to use python code
>it runs out of memory and fucks everything up
>turns out you manually have to call the GC unless you want for it to use FOUR GIGABYTES of ram parsing a JSON file (in C, this is like a few kilobytes)

>user learns how to use streams.txt

Yes, if you load everything into memory, it will be in memory. What did you expect?
You either use a stream and read it line by line, or you read it all at once.

Streams are slower, but way less memory usage.
Loading it all into memory is faster, but as you can see, it uses 4gb of memory for a huge file.

Hello, I have a question for y'all, how would I reference a variable without adjusting the header file of a class? I have a class, that's called transaction type, and I'm trying to sending some of that information out.

Alternatively, how would I send some of that information out to another function?

Not being able to adjust the header file has gotten me stumped since night.

Attached: help1.png (1919x1027, 141K)

Also second part of it, don't think it's too important, but I'll go ahead and care

Attached: help2.png (1919x581, 59K)

I'm thinking about diving into all this b-but what does a programmer actually do? What do you do with your skills? What's the real world application?

Attached: 2d891be4f569dbf373ac85aa607fac3c423069db1adec57816a61e0bcd951c34.jpg (1000x1000, 92K)

Which is the best way to encode something in base 36 (digits 0-9 plus letters A-Z)? Take groups of four bytes and convert them into 6 letters?
I don't know what btoa does to use arbitrary bases.

there isn't a single encouraging line of code in these screenshots and I don't understand the question either

Reminder that all algorithms use O(1) storage.

>big O notation is just simple asymptotic analysis that any kid learn at high school during math classes.
>somehow questions about big O notation are on every single /dpt/ thread.
How?

being a wage slave is the real world application, if you're lucky enough to find a job

Depends on what you want to do?
Web dev -> Make websites, and stuff that websites use, probably have 1gb of node_modules
Data science -> Collect your data and sell it to facebook, make it look pretty in a graph while doing it
Embedded -> Make some shitty robot from 20 years ago with 128mb ram overheat with your C application, because your boss is too much of a boomer to upgrade anything
Mobile dev -> Collect data, but mask it as some kind of app and sell it to facebook
Big Data -> MapReduce, but it takes 2 weeks to do it, you also use Scala now
Machine Learning -> Change the stuff until it eventually does close enough to what you wanted, probably will only kill a couple people with the end product, no biggie
Everything else -> Copy paste from stack overflow until it does the thing

webshit
enterprise back office hell
embeded
gaymen
hpc/scientific computing
In roughly that frequncy

I don't even understand the basis of this bait desu

We humans are lazy creatures and we tend to mistake a lot in math operations, however we are creative.
Computers are absolutely obedient creatures and are capable of making mathematical operations blazing fast but they are like golem in the sense they don't have creativity.
Programmers use their creativity to translate their orders into mathematical operations so computers can execute them.

>algorithms have to be run

I didn't write it, so I can really say if it was the most effect way of doing things.

Basically, what I'm trying to do is send the infromation that I circled and send it to "printTranscationHistory." That's all that I'm trying to do; however I'm having issues, because I can't change the header file and this block all of my ideas to print that information out.

Attached: 1.png (594x470, 45K)

No, it was a 300mb file. Just a poorly written JSON parser.
Manually invoking GC didn't help either, so I had to rewrite the code to be streaming.
Just streaming with mmap in C would be faster than any of this garbage, I bet you $1000

just call printTransactionHistory inside those functions, having updated the member variables in the bankAccountType object

You're using Python. You obviously don't want performance or efficiency.

I know that, that's why I called myself an idiot

But when n is small, like 10, in my mind O(1) feels like c should be less than that

Someone else used it, this is a project from Github.

nope, O(1) could be more memory than all the computers on earth could store, so long as it has a constant upper bound

How do you make a cronjob with send-notify functional? I wrote the entire path out in the script (usr/bin/notify-send) but it's not actually sending it.

Is int arr[INT_MAX] O(1)?

if INT_MAX is a constant

Yes

Why do people think COBOL kills your soul?

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

Allocating bigger memory takes more time.

Wtf is a binary tree?

Attached: screenshot.png (1045x616, 453K)

...

If it's not a constant this is also O(1), assuming the array is not initialized to zero, O(n) otherwise.

A tree made of 1's and 0's

Binary tree is a tree where every node has at most 2 children

we're talking about memory

It's a tree where every node has at most two children.

It's a tree in the category of binaries, what's the problem?!

that's transphobic

>Using C is faster than python
Yes, python, the slowest language people actually use, is indeed slower than one of the fastest languages people use.

You are correct!

Do they? I just thought it was old and slow and devoid of ergonomics. You need to type a lot to get very little going on.

A program running on a physical computer with fundamentally limited storage is not an algorithm.

Oh you are right.

>complete
>almost complete
Perfect and complete, retarded Pajeet.

Wait, what's the insertion logic here? It's not BST and it's not Heap

That's what everyone I've ever talk to who had anything to say about COBOL have said. Working with COBOL earns you lots of money but kills your soul.

I don't know, myself. I've never gotten near the language.

that's a traversal not an insertion

Don't use people's shit that you don't want to use.

According to the Church-Turing thesis it is.

it's heap

Attached: screenshot.png (1414x718, 531K)

Probably because you get labeled as the cobol guy and from now on you only get cobol jobs.

Well Turing was a gay

HOLY SHIT YOU SHOULD KILL YOURSELF. IN FUNCTIONAL PROGRAMMING FUNCTIONS ARE VALUES. JUST GO NECK YOURSELF YOU FUCKING BRAINLET YOU ADD ZERO VALUE TO ANYTHING IN LIFE.

>bullying in /dpt/
that's illegal don't do that

Attached: 6-4aQ-Qp_400x400.jpg (400x400, 28K)

Classic nigger mentality.
>the free shit isn’t good enough
Neck yourself.

This has got to be some of the worst code I have ever seen. If an employee brought me this I’d fire them on the spot.

Dunning Kruger

Not their fault, Python's.
No other options, unless you want to port everything to C.

Isn't that true of any specialisation?

>no other options
There’s that nigger mentality again. Make it yourself you lazy sack of shit.

This is why we need ChainLink. Distributed json parsing on the blockchain.

>”you’re well experienced in functional programming. Therefore if you say anything about it, then it proves you know nothing. Or it proves you’re well experienced. But not moderately experienced.”
Ha, you sure got me.
???????????
Stop asking stupid fucking questions and wasting space. Read a fucking book if you don’t understand it like the rest of us you nigger.

Have you really looked at the world in the last 20 years?
What do we do? We run everything. Your reality is becoming software defined. Slowly, but surely.

There isn't anything like Keras or Scikit-learn for C, as much as I'd with there were. So I have to use Python code, which sucks dick.

Are courses on edX good?
Like this one for example: edx.org/course/cs50s-introduction-to-computer-science

idk anone do it and tell us

i think the lectures are way too long

Attached: 1550681714029.gif (500x255, 1.56M)

How can I add a manually-built dependency to my CMake project?
To clarify: I forked some other code that already comes with a makefile, and modified it a bit. That then produces an output that the rest of my project depends on. (In my case it's an auxiliary executable but it could be a library or something else with the same effect.) Now I think it'd be nice if it could be automatically rebuilt as necessary (i.e. only if I change the code again AND only if I'm building the part of my project that depends on it).

From what I can see, there's add_custom_target(), but the docs say it will "always be considered out of date". This is despite being able to specify the files it depends on with the DEPENDS option (at least I think that's what it does, I'm not clear what the docs are saying in this instance). I guess make itself will minimise the amount of unnecessary work if nothing changed, but still.
Then there's add_custom_command(), which seems to fix that, but the problem then is that from what I can see I would need to use add_dependencies() to ensure the relevant target in my project properly depends on this external executable, and that only takes a target - as created by a call to add_external_target(), but apparently NOT by add_custom_command().

Surely there's a better way?

>Keras or Scikit-learn for C, as much as I'd with there were
Write it.

If that's the worst code you ever seen, you must not get out much

You're fucking fucked mate, big time.

Fuck
I really don't want to convert the external project entirely over to CMake

Attached: 1551579507981.png (215x301, 53K)

Your only hope is to make your cmake file try to compile it by executing whatever build system your dependency has, and then locating the generated library files and making them available to your code somehow. You'll have to assume the build structure of the dependency won't ever change in the future (like, the targets all end up in the same place always). So yeah good luck. You're in deep hell now. Enjoy spending more time fucking around with the build than actually coding the application.

t. dev of a C project with 40% makefile source code

>defending that heap of shit

I think it's not that bad, I don't intend to keep it updated from upstream (it was last changed in 2011) and it's a relatively simple case of running "make" and grabbing the binary it spits out in a well-defined location.

I think I might just leave it on manual building for now, though. I don't intend to change it more (and therefore rebuild) any time soon so it'll be fine until then.

You better hope it really is that simple.

One would think that, even though a custom target will always be "rebuilt", in this case it's just calling "make". The makefile itself will handle dependencies and incremental compilation for that target.

programmers using The Java:
>wear clothes
>great each other with a handshake
>eat like civilised humans
>enjoyed a formal education

so called "sepples coders":
>always naked
>great each other with sexual intercourse
>eat humans
>have aids and ebola

programmers using The Java:
>wear clothes
>greet each other with a handshake
>eat like civilised humans
>enjoyed a formal education

so called "sepples coders":
>always naked
>greet each other with sexual intercourse
>eat humans
>have aids and ebola

programmers using The Java:
>wear clothes
>greet each other with a handshake
>eat like civilised humans
>enjoyed a formal education

so called "sepples coders":
>always naked
>greet each other with sexual intercourse
>eat humans
>have aids and ebola

++i is not functional