/dpt/ Daily Programming Thread

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

UMARU-CHAN EDITION

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

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

mattgemmell.com/what-have-you-tried/
catb.org/~esr/faqs/smart-questions.html


What are you working on?

Other urls found in this thread:

people.sc.fsu.edu/~jburkardt/datasets/knapsack_multiple/knapsack_multiple.html
people.sc.fsu.edu/~jburkardt/datasets
stroustrup.com/Programming/std_lib_facilities.h
twitter.com/NSFWRedditImage

>reverse engineering
i wish

Linear types will save systems programming

Agreed. I wish someone had already turned sequent calculus into a nice looking programming language, though. It's hard. SILL is alright I guess.

Abandoning types will save programming.

>What are you working on?

Exploring the deepest, darkest corners of Racket. Advent of Code 2017 (Day 12).

Working on network communication between independent ros robots.
Multicast information works now. I can multicast any ros message and publish it in a remote ros workspace

In C++, is it bad to constantly switch between private public and protected members instead of having one huge block for each kind?

As shown in this picture

Are you ever going to do an actual project, Rakect-kun?

not bad per se but will get hard to read later on

>Rakect
that's Rajesh to you sir

decreasing the space complexity of my memory editor

like what?

got it, that's what i thought

not bad if you have some other blocking principle that's obvious

you're supposed to link to the previous thread you massive faggot

don't deviate from our traditions!!

Well, OP is a Red*** spy that trying to infiltrate us

thinking about how to adapt my knapsack solver for tail call recursion

rn it looks like
loop over items:
conditional:
recursive call and conditional:

return


which works but is less readable and more ugly than a hyptothetical tail call version

found a website with datasets for np complete problems
people.sc.fsu.edu/~jburkardt/datasets/knapsack_multiple/knapsack_multiple.html
people.sc.fsu.edu/~jburkardt/datasets

Previous /dpt/ thread:

cute doggo

Bout to start a new C++ project so wanted to hear some input. Let's say I have a binary search tree, is there a way to convert every element in the tree into another element in a new tree? Like lets say that I want my new tree to take the log of every previous element, how can you do that? I was thinking of using a recursive function to do this but I'm a bit confused on how to get it to work.

Please note I'm a total brainlet.

What are some interesting graph analytics you could do on Bitcoin data? So far I've written some Mathematica to extract transaction information from blockchain.info's API and grouped all of the interactions from within the same block. There are some interesting patterns, like if you look for the largest interaction networks (e.g. those involving more than 100 individual wallets) you see these kinds of really thin funnels between two highly connected groups.

(bst (map f (traverse (bst items))))

you could start by writing a function to copy a tree element by element, that could easily be done recursively, and then just apply the function to each element as its copied
If your function doesn't guarantee that two elements will still compare the same way after they were transformed, it might be a bit more complicated

>you could start by writing a function to copy a tree element by element, that could easily be done recursively, and then just apply the function to each element as its copied
That's nonsense, because he said it's a BST, and the transformation could easily change the tree structure.

>and the transformation could easily change the tree structure.
log of every element shouldn't

user made it quite clear that it won't work if the ordering is screwed.

Iterate through the tree and make a copy one node at a time, applying the function to each value. There are many ways to do this, but depth first search and breadth first search are two easy to implement options.

If it's a monotonic function like log then the structure of the new tree shouldn't change. Otherwise you have to build up the new BST based on the values of the new nodes.

>log of every element shouldn't
He was giving that as an example. I doubt he is specifically interested in that in particular.

>user made it quite clear that it won't work if the ordering is screwed.
You're right. My bad.

What happened to the user who was trying to make a Doom map renderer?

Am I just being retarded, or are Maven and Gradle completely autistic? It feels like I have to jump through hoops just to get something done that I shouldn't have to put this much effort into.
Is it me or is the Java ecosystem a complete unbelievable clusterfuck?

This may be better suited for the /sqt/ but whatever.

How the fuck do I compile examples from Programming: Principles and Practice Using C++ where it uses "std_lib_facilities.h" on OSX 10.13.1?

I get all sorts of warnings and errors and shit. Using -std=c++11 fixes somewhat but it's still got issues linking or whatever. Tried -stdlib=libc++ and -stdlib=libstdc++ neither fixed shit all the way.

I just want to compile fucking hello world lmao which I could already do but I want to go by the book and use the .h files as given.

I've been thinking of fucking around with C++ lately and making a Doom launcher that downloads mods and maybe sets up source ports automatically. It's probably already been done but I could use the practice.

Does anyone know any good GUI libraries/tools to use for this kind of thing?

Qt is cross platform and fairly easy to get into.

>Am I just being retarded, or are Maven and Gradle completely autistic?
Both, actually. They are complete autistic, but why are you being retarded and using a language that makes such tools relevant?

Thanks for the help, any ideas are good.

Yeah it was just an example but I was thinking of doing something simple like the log example first and then moving on to something more complicated but as I'm still on the planning phase I haven't figured out what. The order remaining the same would be preferable.

>Does anyone know any good GUI libraries/tools to use for this kind of thing?
ncurses.

I wanted to make a bot (not on Sup Forums) for the practice and I figured since I've been wanting to make an Android app anyway, this would be much simpler practice, since I know Android Studio uses Gradle.

I've never met a build tool that wasnt autistic. What are you trying to do user?

What is the most brutal but most rigorous way to go get proficient at python? I know some syntax and thats about the extent of my programming abilities.

Relatively speaking npm isn't that bad. Or at least not as bad as Gradle/Maven/Make. As for what I was trying to do, see

stroustrup.com/Programming/std_lib_facilities.h
is it included in "" quotes or in ?

Maybe I misunderstood you in , post the command line you entered and some errors you get

What font is that?

>rigorous python

Verily Serif Mono Book

>What is the most brutal but most rigorous way to go get proficient at python?
you can't even do that with C++

Started trying to learn to code 4 days ago

How long until things make sense and I can breathe a program into existence

in double quotes
I compiled with cc -std=c++11 hello.cpp, the output is too long to post, but tl;dr clang: error: linker command failed with exit code 1 (use -v to see invocation)
with a tons of undefined symbol spam

if I use -stdlib=libstdc++ I don't get all that, but I get the error:
dc++ hello.cpp
In file included from hello.cpp:3:
./../std_lib_facilities.h:36:10: fatal error: 'forward_list' file not found
#include
^~~~~~~~~~~~~~
1 error generated.

about 7 time units

Don't worry, you'll get used to the feeling of shit never entirely making sense and feeling out of your depth.

I think it should work with cc -std=c++11 -stdlib=libc++ hello.cpp

What does /dpt/ think of C#? My internship will be entirely in it but I've only written C, C++, and a bit of Java

my feeling with android development is there's probably a Google-endorsed (TM) method to do it and anything else will be a massive pain

How would you go about finding the closest "key locations" to another?
So if a location is given as (12,4), how would you find and show the 4 closest "key locations" relative to that?

I was thinking of using vector magnitudes but I'm not entirely sure.

go though every key location and calculate the 4 closest

It's Java but with a bunch of extra crap piled on top.
You'll probably prefer it to C++ or Java.

The Google-endorsed (TM) method seems to be Android Studio, but I feel like IDE/toolkit developers somehow forget that the whole point of writing a build system and/or wrapper should be to make things (like like dependency resolution for example) simpler, not more complex. Granted, maybe it's easier to accomplish in Linux.

gib colors

this.
It was my first language and once I tried Java, I knew, I loved it.

>C# is stronger-typed because of value types

what language

That was bizarrely specific and highly assumptive of you.

It also excises a bunch of Java's mistakes.

The only one I can think of is the whole
>Generics
thing.

Default VAssistX colors

Guess you're one of the other two anime-posting faggots, then.

Sup Forums is an anime website. I'm not , either.

Cool, I'm cautiously looking forward to it now

Back to /r/anime.

Is C++ good as a starting point into programming?
Our hack of a prof wants to start teaching it to us but from what I've picked up on on here it's basically worthless.
Should I just drop the class and do my own thing?

It depends. If you don't try to jump in the deep end and take it slow, it shouldn't be too bad. I'm not going to lie and tell you that it won't be at all challenging though.

>Is C++ good as a starting point into programming?
Nope. Completely awful language for beginners (or anyone).

>from what I've picked up on on here it's basically worthless.
I guess it's useful as a C with RAII, templates and the dot syntax sugar for high-performance systems.

> and the dot syntax sugar
C++ doesn't have that

If you don't already know programming then it'll be an uphill climb.
Learn Java or C# to get your head round general OOP and how classes/objects work.

As for when/where it's used, it depends on the industry. It's the de-facto for anything that requires real-time processing like games, but for most things other languages are fine.

C++ isn't useless, it's just easy to criticize.

>there are only 2 anime posters

>C++ doesn't have foo.bar()
What did the friendly /dpt/ poster mean by this?

That won't scale well when the number of key locations becomes larger.
You'd be going through 1000 locations, of which maybe 10-20 are useful for any given location.

C++ doesn't support the Uniform Function Call Syntax

>there are more than two anime-posting regulars on /dpt/
Go back.

>Uniform Function Call Syntax
What is it?

>It's the de-facto for anything that requires real-time processing
He used to work in logistics so that might have something to do with it then.
I guess I'll at least sit in, I've never really done shit with programming before though so it might be somewhat pointless.

>C++ doesn't support the Uniform Function Call Syntax
How is this relevant? I said he has the dot syntax sugar for method calls, i.e. foo.baz() instead of foo_baz(&foo).

>he doesn't know

when bar() is not a member you can't foo.bar() in C++

you can in Rust, D, Nim and some others

>1000
that's fine

No, I don't know.

What you want to call a non member function as a member function?

Why would you want to? Isn't that bad practice?

> for method calls
that's not dot syntax sugar, that's just bullshit that everything has

>That won't scale well when the number of key locations becomes larger.
>You'd be going through 1000 locations, of which maybe 10-20 are useful for any given location.
Just use a k-d tree.

Why would it be bad practice?
f(o, x, y) is the same as o.f(x, y), it's just sometimes nicer to chain method calls than write nested function calls and it's a poor man's infix syntax.

Can someone explain the K&R exercise 2-6 for me? I feel like I don't get the question, Im not a native english speaker but still... What are they actually asking for here?:

Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.

Not when hits 100k or 1m
If there's a more efficient way to do it then better to do it like that.

much faster coding

>that's not dot syntax sugar
You seem to be suffering from some weird delusion that "dot syntax sugar" is some kind of official synonym for UFCS, which it isn't. I just told you what I meant by it: it's syntax sugar for something that's easily doable without it.

Arguing about syntax.

I (almost) always prefer to use o.f(x, y) for clarity.