/dpt/ - Daily Programming Thread

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

Attached: 74325339_p7.jpg (1276x851, 1.18M)

Other urls found in this thread:

insights.stackoverflow.com/survey/2019#blockchain-in-the-real-world
www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
jasondavies.com/poisson-disc/
m.youtube.com/watch?v=flQgnCUxHlw
twitter.com/NSFWRedditVideo

First for C++ AMP!

Attached: 1554923157883.jpg (3000x1976, 1.82M)

working on my suicide plans

I have a list of locations and I want to reduce the number of them so the gap between them is 5m or over.

Here's what I've got so far:

gap = 0

For location in list
gap += distance to the previous location
if gap >= 5 then
add location to a new list
reset gap

The problem is, I’ll be dealing with thousands of locations in each list. Is there a more efficient way of doing this?

Fourth for C# + Visual Studio + WinForms

Attached: 1530479603435.png (1192x385, 336K)

just starting to learn opencv
Wondering if I should learn python as well or use it just with java
it seems a lot more complicated in java, and there are less resources to help

>list of locations
Is that supposed to be 1-dimensional or 2-dimensional?
Because if it's 1-dimensional, what you have is basically as efficient as you're going to get, and I wouldn't even call inefficient.
2D or more is another entire can of worms.

It's a list of objects that each constitute a location on a map, so the list represents a route on the map.

Literally the only reason to learn Java is if you are Indian.

But in essence, it's a 1-dimensional problem, meaning you cannot stray from the route?
What you have is fine.

Thanks

look into spatial partitions, quadtree, octree, etc. or if its 1D just keep track of the upper and lower bounds (right now you're only tracking the upper bound so it won't work correctly)

Because sepples is a really fucking powerful language, and every alternative tries to reduce that power in some way.
What I wouldn’t give for C++ with more metaprogramming features, no retarded obsession with backwards compatibility, terser syntax due to no longer needing to step around legacy codebases toes, and a design comittee that isn’t retarded.

What jobs do you guys have? Have you ever looked at job sites? Half of them are Java...

>What jobs do you guys have?
haha yeah this is a board full of employed programmers right guys

Thanks. I'm going to look all of that up.

>Half of them are Java
yea, and there's over a bilion indians in the world

It's frustrating that most of the tutorials for java online are indians
but it's a very sought after language where I am
I've already learned it anyway so that's not the problem

I work as a C programmer doing open source software. It's comfy.

Attached: 1543210133459.png (361x697, 371K)

Well are the locations 1D points or higher? Because that says alot about the complexity of the problem

a job means something where you get paid

here's your complementary (you), retard

I do get paid.

Have you ever looked for a parking spot in a packed place? There are lots of shitty spots open, because the nice spots have already been taken, and the only remaining good ones are for handicap (trannies and womyn).

well they aren't paying you for much seeing you're in every single /dpt/ thread

Is there a way to cause custom integer overflow in C? I want numbers to roll-over at predetermined number. It's really late for me and I this would prevent a lot of headache.

no, thats a behaviour of the CPU

you might need to move somewhere better
Where I am they are desperate for software developers

What you're really describing is just modulo arithmetic.
Chuck a `% n`s all over the place.

Just use a function

The locations have properties latitude, longitude, geopoint and distance (to the previous location if we're past the first one).

So what job do you have and what's the salary?

Yeah the most efficient way to do that is a quad tree. If you just compare it to the last point you've added it's not going to be correct because it could be closer to another previous point, you need to test all of them and the quadtree makes that efficient

Thank you. I want to kick myself for not seeing that.

the pay is waay better than your regular pajeet jobs shitted everywhere

>b-but they ARE DESPERATE for developers
and people still fall for this, lmao!

What's the pay?

I manage low level networking kernel code for a fortune 500 company. I make over $100k a year.

Attached: 1507942627726.gif (304x429, 1.99M)

he gets unlimited access to RMSs toe cheese

Nice. Did you study CS? What were your qualifications before you got it?

Thanks man. I'm going to read up on quadtrees.

a good third of my class have secured employment before the course is over
I haven't personally tried yet because I've been focusing on the work and haven't found time
but I know there are a lot of people out there looking for graduates

even webshits get paid at least 130% more

Taking a break from ML to bone up on my C++, as I'm going to be doing some reinforcement learning. Gonna miss python, but elegant C++ can be more beautiful, it's just more work.

>arhuuu muh webshitters get paid X so why da fuk arent u doing webshits

Attached: 459e90f45b64e5c42f80030ad5b0b906.png (808x455, 364K)

connection error

Why does the company I applied for seem to forget about me... I did some coding task for them, and they said they were going to have a internal discussion about it, it was 2 weeks ago. Easter is now over, and still nothing, I really not wanna say yes to the PhD I was offered (even if it's paid pretty good).

They're also comparing silicon valley ridiculousness to everywhere else, not taking the 10x increase in living expenses into account, or the fact that some people really, really don't want to go to the US.

>it was 2 weeks ago
I got offered an interview after a month or two after doing a company's screening test, already forgot about them at that point

But I'm in a Slack channel with them, so I would guess it was easier to not forget about it. I think I'll wait a few more hours, and then ask them if they have some status update.

>insights.stackoverflow.com/survey/2019#blockchain-in-the-real-world
>Developers in India are the most likely to say their organizations are using blockchain technology.
What is with india and old memes?

being ignored means they dont want you

It is pure desperation and destitute environment.

I just finished writing my program in Eclipse, and I am getting some awful errors

For some reason after compiling the program a few times, my entire computer starts to lag. The mouse drags across the screen, windows start opening slowly, nothing is responding. Eventually my entire computer freezes and I have to crash it and restart.

What is going on?
The program is java so it should handle garbage collection automatically

you program is garbage and your computer is attempting to collect it

>sitting around waiting for the response from 1 place hoping it will happen
Noob mistake user, never do this for anything in life. Send a thank you email, and maybe a follow up email (ask if you could improve anything etc), but don't wait around and expect anything back.

Anyone who has to repeat the same thing a large amount of times will quickly learn to minify the useless parts (talking to you after you've failed) and just ghost you.

Should spend that time working on the next interview, fuck that shit.

did you close your resources?

Idk, you mean my Jframe window? yes I always close them

Also I am trying to post the code but it keeps giving me "connection error"

If you're white and want a job learn Rust or Go. If you're Indian, learn Java.

I'm so happy for the sudden increase of Touhou posting on Jow Forums.

>using java for UI
did you actually expect a working program?

The techniques you are thinking of are either "Midpoint Displacement" or something Veroni/Delauny related.

www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ jasondavies.com/poisson-disc/ m.youtube.com/watch?v=flQgnCUxHlw [45 min]

To speed up your code you need to segment the entire map into zones and have lists of points for each zone. Don't forget to check distances in neighboring zones just in case a closeby point is near the border.

I feel like this is a stupid question, but I need help on solving this in java:
I store the location of a player in a array with 64 entries, which is displayed as a 2D (8x8) grid. Since the players are only supposed to move up, left, down and right, I need to check their new position with their current position and see if the new position is allowed by the rules.
By logic I would substract their new position with the current one and check if it equals to -8(up), +8(down), -1(left), +1(right).
Since I need to check if the number is -8 and not just negative I can't just use an simple if statement, so how would I do this?

Attached: thinking.jpg (417x417, 23K)

what's with all the pajeets in here

write a function that turns x,y coordinates into a position on your array, that handles edge cases correctly

This may look like dodging the question, but why not use an 8x8 2D array instead of a 64 entry unidimensional array in the first place? It would make computing coordinates much simpler.

int x = pos % WIDTH;
int y = pos / WIDTH;
/* adjust (x, y) -> test(x, y) -> accept or rollback */
pos = y*WIDTH + x;

But it would probably be better to just use a 2D array in the first place... If you make it 10x10 then you can even have a perimeter of bounds check markers.

pajeets are teople poo

Attached: 1497673109701.jpg (549x720, 77K)

Reminder to enable LTO.

Attached: 1542251026401.jpg (1920x1080, 873K)

Thinking about how much JavaScript rocks

Attached: 655b64a60ba4c4e7e70c045dd5d88cb0.jpg (540x810, 52K)

That's a pretty cute doll js-kun.
However Javascript does not rock. It's better than Python at least.

I've lost interest in programming lately and can't be arsed to do anything else than play video games. I realize that games are a waste of time but I can't even motivate myself to write a single line of code.

Intriguing proposition and I'd gladly hear the reasoning behind the stance you've taken regarding this language that most definitely rocks

Attached: 8815e2bfdeb119e14ae57951aea120c1.jpg (1280x1920, 220K)

how do I get VS Code to indent single-line if statements / loops?
It only indents if I use braces, and if I don't use braces it just plops me at the beginning of the next line so I have to press tab.

the ABSOLUTE state of sepples mental illness

Attached: auto main.jpg (776x447, 43K)

1. it is dynamically typed, and thus hostile to performance
2. it is not AOT compiled

That's just a retarded Rust wannabe
Real C++ programmers don't even use trailing return types at all because they're completely useless after C++14.

GC is shit

Clang is right.
reinterpret_cast is not a constant expression and is actually not allowed inside constexpr code.

You aren't completely lying, but you aren't telling the full truth here. JS is still the fastest general purpose scripting language thanks to the many brains behind the very fast JIT engine major vendors use nowadays.

Attached: e00908b6f4848d227b74e540e3294e5c.jpg (640x960, 63K)

>JS is still the fastest general purpose scripting language thanks to the many brains behind the very fast JIT engine
what a stupid thing to say
never appeal to authority as a programmer
only believe something if you know why and how

how tf do you get paid for open source

Doesn't change the fact that JS is the fastest, which is a good thing when you are talking about something that has completely uncontended, exclusive access to specific platforms.

Attached: Do-jScrU0AAAQlf.jpg orig.jpg (1546x2300, 403K)

>Doesn't change the fact that JS is the fastest
you dont know that

>but muh JIT
this is what the Self-ies actually believe

do you pray before you code? because code compiles iff if god's willing!

>JS is still the fastest general purpose scripting language
That's nice but it's still slower than AOT compiled statically typed languages.
Also, dynamic typing is shit no matter the performance.

Trailing return types are much better. What is your problem?

false

>Self
Looks interesting.

Of course, JS won't ever beat proper AOT languages, however the emphasis is on the fact that _for a scripting language_ JS is pretty darn cool.

Attached: 65fbfb5c4f80a5296074b756dc826c2b.jpg (631x631, 66K)

Really simple MATLAB/Octave question.

I want to turn numbers between 1 and 3 into vectors like this:

1 -> [ 1 0 0 ]
2 -> [ 0 1 0 ]
3 -> [ 0 0 1 ]

I also want to save these vectors to a matrix so that

[ 1 2 3 ] becomes [ 0 0 1 ; 0 1 0 ; 1 0 0 ]

Evidently loops in this language don't work like loops in normal programming languages...

x = [ 1; 1; 1; 2; 2; 2; 3; 3; 3; 3; 3; ];
x_vectors = [];
for i = x
v = zeros(1, 3);
v(i) = 1;
x_vectors = [ x_vectors; v ];
end


since this doesn't seem to re-initialise v...

They objectively are when declaring, say, functions returning function pointers.
Beats any shitty typedef any day, not to mention that using trailing return types allows you to use decltype on the parameters themselves, allowing you to omit more type declarations and therefore making said functions even more generic.
Plus, it arguably looks nicer.

My turd is the best.
Of course, it won't ever beat proper non-turd things, however the emphasis is on the fact that _for a turd_ my turd is pretty damn cool.

Attached: 1525738452464.jpg (512x512, 26K)

auto func1() -> int (*)(int, int)
{
return &other_func;
}

int (*func2())(int, int)
{
return &other_func;
}Hell yeah, gimme number 2 all day every day. SUch an objectively better way to declare return type :D

>not to mention that using trailing return types allows you to use decltype on the parameters themselves
And I just told you that's completely useless after C++14.

Not true, you can SFINAE on them.

It's always better to SFINAE on something else.

Not always, I find a lot of functions can be made more terse and readable if you SFINAE on the return type.

Now try using different types instead of int all the time, and notice how the second one (already garbage) becomes even harder to read.

Funny way to spell Haskell