/dpt/ - Daily Programming Thread

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

Attached: 1550596680298.jpg (1920x1080, 229K)

Other urls found in this thread:

youtube.com/watch?v=QCwkZCMsRpM
sourceware.org/bugzilla/show_bug.cgi?id=10134
stackoverflow.com/questions/8759868/java-logical-operator-short-circuiting
twitter.com/NSFWRedditVideo

your mum

Attached: denerding programming.png (642x181, 19K)

youtube.com/watch?v=QCwkZCMsRpM

desu tho installing graphics drivers is one of the most painful things in existence

Disagree, programming just works the way computers work

Give me something to program

Attached: 1527765405703.png (3930x5000, 1.58M)

AGI

gravity simulation

Finished working on a library for google's fallbackcaptcha api.
I have no idea what to use it for though...

Hello World

Planetary orbit simulation that accepts dates and positions planets accordingly.

Attached: 1371709777889.jpg (600x600, 121K)

relativistic n-body simulation

fizzbuzz

>RESOLVED FIXED
sourceware.org/bugzilla/show_bug.cgi?id=10134

Attached: 1549453119433.jpg (450x450, 28K)

I've had some similar issues opened on bugtrackers for projects I'm a part of. Although it wasn't pointing out anyone in particular, but they were extremely ass-blasted.
I just think it's funny most of the time.

How do I into opengl? Its such a big fucking mess

theres plenty of good tutorials

Sure, but he is right about it being a mess.

My strategy is to learn enough to make it do what I need it to do and leave at that
I haven't touched any extensions and I don't have much of a clue of what it's doing beneath the hood

>make it do what I need it to
What are you trying to make it do? Do you want to restrict your application to somewhat modern GPUs?

I wasn't the person asking, just saying how I dealt with it when I was writing my game engine
Stuck to the OpenGL 3 spec which is enough to have it work on computers at least 10 years old

If you want even wider hardware support, OpenGL ES 2 is the best bet, because it'll work on complete piles of shit like the raspberry pi. But something like a game doesn't really need to worry about running on something like that.

I dont care about compatibility let some other guy do the porting if it ever gets on github. I just want to set it up for windows with opengl 4.6

Actually should I be using direct2D instead? Dont know if it supports C.

2 is missing alot of features over 3, and 4 doesnt over that much over 3 unless you're an AAA developer squeezing as much out as possible, 3 was the sweet spot for mine

Working on a viewer for Gerber files..potenially a g-code generator late on..
Can confirm mess

Just make sure your graphics layer is dead simple and not too tied in with the simulation layer, that way you can port shit easily to other libraries if you ever need to.

Attached: wewew.gif (220x220, 15K)

OpenGL ES isn't the same as "normal" OpenGL. It stripped a lot of shit out, such as the entire fixed function shit, and some other stuff. GLES2's usage isn't too different from OpenGL 3, but they removed a lot of the convenience stuff too.
It's what you'd use if you want maximum portability, non-desktop included. I actually work on a project where we also target low-powered ARM boards and such, so we use GLES.

>Can confirm mess
The amount of statefulness is the worst part. It's too easy to accidentally rely on existing state, so you have to go around doing shit like glBindFramebuffer(GL_FRAMEBUFFER, 0); at the end of all of your functions, just to make sure.

Being stuck on an old version means I can't use the OpenGL 4 explicit state shit.

the statefulness just means you need to be careful and aware of what you're doing, like said make the graphics layer as simple as possible
if you have to add state resets at the end of every function that's probably a design issue

Part of the issue is that it's actually library code, so the user can use it in retarded ways and even call their own GL functions, so I need to be extra careful about state.

What's the point of the move constructor/assignment operator in C++?

When would you ever want to copy the "head" of something while leaving the actual object in-place in memory?

Is there a good, "render ready" 3D file format that supports material animations and has a useable C library or am I doomed to parse gzip compressed ASCII interchange format or write wrappers to proprietary sepples libraries to closed formats?

Why in the living hell would you do this?

Attached: sepples.png (720x239, 36K)

I don't really know shit about 3D animations, but I think glTF was a format for something like that.

A gf

I don't know any, the state of 3D file formats is pretty shit

Because C++ doesn't have move-by-default semantics Rust has, so you have to waste your time putting std::move and waste execution time maintaining empty-but-valid states.

If you know the RHS object will not be used after the move operation, move semantics permit you the LHS to "steal" the resources of the RHS object. This can avoid costly extra de/allocations.

Move by default is cancer, enjoy spamming clone to shut up the borrow checker

I will never understand rvalues

References work fine in 95% of cases. At least I see where very costly copying is performed, as opposed to it being called implicitly. So much for zero-cost abstractions.
Not with this attitude.

>glTF

Almost what I want, but no material animations.

Yeah, I get that part, just curious when it ever shows up that you need to leave a RHS object in-place. Like a linked list -- when would you need a "new" first node while keeping the the rest of the RHS object the same in-memory?

Are the use cases similar to copy-constructor/assignment but more efficient becasue of avoiding a new object allocation?

Alright then, I WILL understand rvalues

You might need to keep the RHS object around like say if you're doing some blind copy of a game object or you are copying const buffers around.

std::move IMO comes in very handy when copying temporarily allocated strings or vectors around without having to resort to nasty pointer hacks.

>Are the use cases similar to copy-constructor/assignment but more efficient becasue of avoiding a new object allocation?
It avoids any new heap allocations or other resource acquisitions inside the object, that's the important part.

If you just have a dumb struct that owns nothing but itself, then move semantics have no advantage.

Okay, that makes a lot more sense, especially the part of avoiding new allocations within the object itself. Didn't think of the advantages of using it with nested classes.

Math brainlet here.

I have a 3d point (X, Y, Z). I have a set of rotation values in degrees per axis (X_rotation, Y_rotation, Z_rotation). I have to rotate the point around the origin by those rotation values. What's the equation for this? Or better yet, is there a python module that'll do this for me?

plz send help

Attached: 1531351120914.png (586x578, 37K)

import rotate_3d_point as solution

point = 10, 20, 30
solution.run(point, (90, 180, 270))
Is what I always go to.


Use a fucking matrix or some shit.

x = cos(theta)*x

Hello, gimbal lock. Learn quaternions.

that's a complicated question
if you have an X,Y,Z rotation then that's 3 rotations so you need an order in which those rotations are applied

I'm not the one who generated the data, it came structured like this.

Yeah, I realized that. It's probably just X -> Y -> Z, but if not I can just mess around with it until it looks right. There's no documentation, so it's all trial and error.

try googling Euler angles

Which programming-related field is the most fun and has the best work-life balance? I want to know what I’m getting into before specializing

Everything but game dev

Everything about Lisp and Haskell, because being unemployed is the best work-life balance.

What's wrong with game dev?

What would you recommend for someone interested in programming itself and logic? I basically just want to program and make money, I’m not too particular. I want to know what to specialize in, but I’m okay with mastering something difficult if it means increased salary and job security.

why does C do funny stuff like type decaying?

I thought it's a pure language

>html styling
>programming general
>PROGRAMMING

I think you'll have better luck in /wdg/ my friend.

Alright, fucking off to /wdg/

inb4 html is turing complete

> programming must be turing complete

Attached: images.png (225x225, 4K)

is that a rooster and the sun?

It's the cock programming language

It's a coq

Attached: coq.png (240x159, 13K)

Need some architecture/design advice.

I'm making a file manager in Rust with the backend as a library so it's easy to make different frontends. If you imagine an API for a library that you can build a file manager with, it may not be complicated at first glance (simple calls to open tabs, change their current path, get their contents), nice and synchronous. But there's also an asynchronous part to file managers: contents of directories can change. And now we're in thread hell.
Basically, the backend needs to run a thread that waits for directory changes and reports them somehow. That "somehow" is the problem at hand. Due to ownership restrictions that Rust imposes, I can't just run a callback from that thread, because for it to be useful it would need unique mutable access to data that the frontend owns.
I could wrap that data in an Arc, but in Rust that's a sign you're doing something wrong.
Another option is to go full asynchronous and just let the backend be its own thread[s] that frontend communicates via channels with commands and events. So basically RPC instead of plain method calls.
Or it could be half-asynchronous with only the notification part running in a thread with some form of communication and everything else could be done via method calls, but that could be even more complicated.

I dunno, either you figure this out for me or it'll be RPC and I will be too ashamed to put the project out there for people to use.

Attached: rust_shutterstock_70023793-800x460.jpg (800x460, 180K)

Is there ever a reason to do
if (cond_a) {
if (cond_b) {
// things done when both cond_a and cond_b are true
} else {
// things done when only cond_a is true
}
} else if (cond_b) {
// things done when only cond_b is true
}


instead of the much clearer and less indented

if (cond_a && cond_b) {
// things done when both cond_a and cond_b are true
} else if (cond_a) {
// things done when only cond_a is true
} else if (cond_b) {
// things done when only cond_b is true
}


Surely any compiler is smart enough to only evaluate cond_a and cond_b once even in the second version?

what is the meaning of this error?
src/test.cpp:99:74: error: default argument given for parameter 2 of ‘void Test::add_coordinate(bool, double, double)’ [-fpermissive]
void Test::add_coordinate(bool clear, double x = 0.0, double y = 0.0)
^
In file included from src/test.cpp:1:0:
src/test.hpp:25:8: note: previous specification in ‘void Test::add_coordinate(bool, double, double)’ here
void add_coordinate(bool clear, double x = 0.0, double y = 0.0);
^~~~~~~~~~~~~~~~~~~
src/test.cpp:99:74: error: default argument given for parameter 3 of ‘void Test::add_coordinate(bool, double, double)’ [-fpermissive]
void Test::add_coordinate(bool clear, double x = 0.0, double y = 0.0)
^
In file included from src/test.cpp:1:0:
src/test.hpp:25:8: note: previous specification in ‘void Test::add_coordinate(bool, double, double)’ here
void add_coordinate(bool clear, double x = 0.0, double y = 0.0);
^~~~~~~~~~~~~~~~~~~

bottom is much better no question

it's not good programming but the condition evaluation could have side effects so you can't evaluate them only once

Only give default parameters at the declaration site, don't give them at the definition site.

>Surely any compiler is smart enough to only evaluate cond_a and cond_b once even in the second version?
probably not, but I don't think it's worth the tiny performance hit to make it look cleaner

i'm more of a top myself...

stackoverflow.com/questions/8759868/java-logical-operator-short-circuiting

>Surely any compiler is smart enough to only evaluate cond_a and cond_b once even in the second version?

Not necessarily since there's no guarantee cond_a and cond_b will be the same.

Evaluate cond_a and cond_b manually and give your results to the conditional if you're worried about performance. But not before profiling.

The thing with
If A and B:
Elif A and C:

Is retarded if A is expensive to evaluete, and there is no point to re evaluating it every time, even if retards think nested ifs are big dogma no no
You should do
If A:
If B:
Elif C:

Btw this is pseudocode not python.

that's a completely different thing
he's talking about evaluating the same condition for a different if statement, which is definitely not guaranteed to happen

I just realized that's not at all what op asked. fml

If cond_a and cond_b can have side effects they might evaluate differently

>Btw this is pseudocode not python.
good thing you mentioned that, I was just about to flame you

going to make a matrix client in java

oh thanks

there is no pouny in reevaluate if you dont have to since it might have side effects, and is inefficient.
If A and B is false, and A was false, B was never evaluated so its fine to put If B. But if A was true and B was false you reevaluate B.
Therefore there is no way to avoid reevaluation like this.
You have to write
if A
If B
Elif B

If the order of evaluation matter you are even more fucked, like say collision resolution for a 2d platformer, whether to step X or Y first. Though most people dont notice unless your levels are poorly designed.

It's simply not the same code.

>side effects

wtf I love functional programming now

it is if cond_a and cond_b are constants

Yes side effects can be a meme, but efficiency is not a meme. I bet Electron does the reevaluation and makes a new array on the heap to store the results of the evaluation so it avoids side effects and increases ram and cycles because they should all be shot by a firing squad

Underpaid, overworked, replaceable, unrespected

gamedev earns about as much as a normal programmer these days but I agree with the rest

create an algorithm that identifies stars in astronomy pictures

Why don't you just write it in node.js?

Some Google Polymer Shit for some outdated client

If I generate 1 million random numbers in one set in the range 1 to 1 million, then generate 10,000 more in the same range in a new set, is it more or less guaranteed that around 1% will match?

>unlock great benefits

Attached: 1549824773558.jpg (680x962, 67K)

Get yourself a GC.

>tfw you are a pajeet and writing docs in proper english is harder than writing code

Attached: 1502818850.jpg (780x439, 32K)

at least you're self reflected. that's good.