/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

github.com/sirdoombox/Overwatch.Net
github.com/SunDwarf/OWAPI
pastebin.com/GezFqTHT
paste.debian.net/894238/
toptal.com/c-plus-plus/interview-questions
twitter.com/SFWRedditGifs

Other op is a faggot. this is the real thread now

bump

I'm trying to make a Pong game in Java using Model-View-Controller design pattern. I have a fully functional Menu with textfields for player names, a spinner for ball speed and a button to start a new PongGame window. I also have a Model where all neccessary variables will be stored.

My problem is this:
I need to use the same instance of Model in the PongGame window to preserve the settings from Menu. How do I launch a second JavaFX window while being able to access Menu's instance of Model?

Is it possible to send either the whole Menu object containing everything or the Model object containing the variables I need to access?

Any ideas?

composition
Java uses references, after all

Alright /dpt/
I need some help

How can I do the following in Python:
>Open a file containing a list of words
>some of the words if reversed are also words on the list
eg: rotator and rotator or redrawer and rewarder
>how do I check which of the words in the file can be reversed to create another word in the file?

I tried making 2 sets and checking using reversed() and [::-1] but no luck at all...

Does anyone use Pascal nowadays?

for each word a in file
for each word b in file
a == reverse b

dictionary map every word to both the word and its reverse and see if you get any collisions

O(n^2) ;)

in Haskell this is just

import Data.List (nubBy)
main = (readFile filename) >>= (print . nubBy test . words)
where test a b = (a == b) || (reverse a == b)

I fucking swear if I ever meet people responsible for creating git I will punch them in the face.

I have a uni project and starting this year we are required to use git instead of svn, and so far git seems to be worse in every imaginable way possible.

git is strange yes, but svn is prehistoric. Learn git, after that you'll never go back.

or with Kleisli composition

f = k print . k (pure . nubBy test . words) . k readFile
where k = Kleisli
test a b = (a == b) || (reverse a == b)

f filename

Is there any reason for using Cilk or Cilk++ now that C++ has concurrency support?

I am a supervisor on a programming course at uni.
This is example code of a 2nd year student:
int* function(){
int *x = new int;
*x = 5;
return x;
delete x;
}

...

They're kind of getting it. Was the first year just a bunch of waffle?

Are you not teaching RAII?

somebody rate my common lisp snippet

What does ">>=" for?

github.com/sirdoombox/Overwatch.Net

Trying to make progress on this, no idea where to go with it now though seeing as it's functional.

Not really sure what to add so I'm open to suggestions for new projects - I really like writing API's for stuff like this, parsing web pages is really enjoyable with AngleSharp.

Any other suggestions are welcome, I have quite bad insomnia at the moment so I really need something to work on.

wtf is this
Kleisli seems to be a constructor of a data tyoe

rewrite it in python

bask in the glory

github.com/SunDwarf/OWAPI

Already been done.

I'm having so much fun playing around with Ruby. If Java is Blighttown, Ruby is the first time you look up and see the sky while riding the elevator out.

Too short.


Ruby's a fun language.

for composition of functions with necessary contexts such container types like IO, Lists, Maybe, Either, Reader, State, or even trees.

RIP my computer

Beautiful, I know. Brings a tear to my eye every time.

Ruby is valley of the drakes?

Lmfao, my program found a pastebin that had someones ok cupid username and pass
pastebin.com/GezFqTHT

My previous work had CVS stop complaining

Ruby is the glimmer of hope you get the first time you see the fresh air.

So, anor londo then?

I would actually consider learning ruby/ rails if I didn't read it being a hipster language

>so far git seems to be worse in every imaginable way possible.
If you check out, update and commit, it's basically the same. What are the ways in which it's worse?

Can anyone tell me how to run up a check?

I need an idea for a simple game to do in pygame?

Don't use python for games, that's not what it is meant for. Pick a new project.

I want to. Just please give me an idea.

You are going to be disappointed in the end, python is great for a lot of things. But it is shit for gaming. Don't do it.

Goddamnit, I don't care. I just want an idea.

I will not support your bad habits, come up with a different project and I will help you.

I need to do it for a project.

No, pick another project and I will help you.

I have to do the fucking project in pygame. It's a requirement.

No, pick another project and I will help you.

Alright i'm just gonna do snake.

No, pick another project and I will help you.

i need to learn VHDL in this nigth, any siggestions?

get out of Sup Forums and start now.

bind

it is, because that way it can have a different . from the category typeclass (you have to hide the regular prelude .)

Anyone do the amazon online assessment? I feel like I'm going to get fucked.

paste.debian.net/894238/

for no reason.

No, it's excellent for developers. Dynamic typing is 100% useless.

what

>replying in the wrong thread because the OP pic triggers you
your tears are delicious

That's not beyond the parameters of the question

What the point of this image user? It just show a white square on my computer, it's not even animated

what is this

delete ur account

It's very high resolution and most of the anons here are kiddos on their mom's laptop or basement lurkers with terrible CPUs that choke on an image as big as that.

Weird, it load just fine for me and I don't have any problems

Yeah same here, but I'm on a decent browser on a decent OS and a decent computer so these things have never done more than take a few seconds to load.

Test the initial vales to the list then push them onto a stack and pop them back off into a string so they're in reverse order and test that value with every item on the list. Can use a map to speed it up a lot.

Writing a pascal compiler for compiler class; Haskell is starting to become semi big because of its prime number abilities (the names are related atleast)

Associative array will make it much faster

class Integer {
int* i;
public:
Integer(int ii) i{ new int{ ii } } {}
~Integer() { delete this->i; }
};

int main()
{
Integer i{ 3 };
}

...

>not using numeric literals

>not using numeric literals
:D
class Integer {
int* i;
public:
Integer(int ii) i{ new int{ ii } } {}
Integer(const int& ii) : Integer{ const_cast(ii) } {}
~Integer() { delete this->i; }
};

> DELETE THIS

toptal.com/c-plus-plus/interview-questions

Any more of these? Link related.

Heard you wanna fight faggot

>88kb
That's just so wasteful

Not sure if this is the best place to ask this but here goes nothing.

I've been reworking some GLSL shader stuff lately, when suddenly I realized something. Almost every time you read a tutorial on how to use shaders in OpenGL they first write a shader class:

class Shader {
...
bool load(const std::string &name);
...
void setUniform1i(const std::string &name, const int i);
... and so on ...
};


So then they can have multiple shaders going around at the same time, like this:

Shader foo, bar;

foo.load("whatever.shader");
bar.load("somethingelse.shader");

foo.bind();
foo.setUniform1i("crap", 1234);


But why?

In OpenGL, only one shader can be active at any given time. You must glUseProgram(...) a shader before it can be used. You can't even set uniforms and attribute streams without binding a shader. Why use a class for containing a shader and wrapping the glUniform*() calls in member functions, when you can't even use/call them if the shader hasn't been bound?! I know there are bindless shader extensions that allow you to change uniforms without binding a shader, but those aren't very widespread yet.

So *what* purpose does a shader class serve? What do they do that I can't do by just keeping a few GLuint variables around that contain program IDs, then binding them with glUseProgram() and setting uniforms and streams manually (or through VAOs)? OpenGL is not OOP, the shader program is part of the global state, so an OOP shader class approach does not work with it very well.

A global shader manager that prevents the same shader program from being loaded multiple times and takes care of the cleanup I can understand. But not classes for individual shaders.

Have I misunderstood something?

Convenience.

I don't see much convenience in having to lug around references/pointers to shader classes when all I really need is one unsigned integer that identifies the shader program I want to use next.

Good for you then.

Is Trump going to make it harder for Canadian grads to work in the US?

Why is there two active /dpt/ threads?

Because some weeb felt compelled to shitpost an OP with anime.

We're evaluating the mods to see if they are doing their job properly
To nobody's surprise, they aren't

I made this one because the other used a Sup Forums image, which inevitably devolves into political discussion (hence they're usually deleted)

We can keep both going and use this as the new one

I recently got a job offer as a python programmer. I am to write modules for odoo erp. I've got a small assignment to do with odoo and I hated it. The documentation sucks, examples are for old versions atc. Plus it's nothing great, writing bussiness logic modules. But I'll get 30% more than at my current job. Should I take it?

I don't know much about opengl/graphics in general. But I know that games use multiple different shaders depending on the scenario.

Best example I know is that Saints Row 2 on the PC has inside and outside shaders. Things lighten up if the game detects you're inside. And also that bullshit brown overlay that they use to make it realistic but makes it look like shit

People feel the need to use OOP everywhere.
>What do they do that I can't do by just keeping a few GLuint variables around that contain program IDs, then binding them with glUseProgram() and setting uniforms and streams manually (or through VAOs)?
Nothing, except perhaps convenience. And also API independence (so you can swap OpenGL for Direct3D for example).

Every time someone tells me that C is hard or complicated, I am convinced that they have either been programming for less than a year, or that they are unintelligent.

People tend to mistake simplicity for complexity.

>games use multiple different shaders depending on the scenario
You can have 1000 shaders loaded if you want, but only one of them can be actually bound at any given moment. A shader program is made up from multiple individual shaders (vertex/fragment/geometry/etc.) but it's still just "one" program, like you link multiple object files to make an executable.

And only the active shader can have its attributes changed. If you have shaders "foo" and "bar", you can't say "bar.setUniform3f(...)" if the shader "bar" is not bound at the moment. If you do, nothing happens. That's exactly my point: why wrap them in classes when the member functions can do nothing if the shader is not bound? It's pointless abstraction.

>API independence
Not what I'm doing. All my code is OpenGL. Vulkan maybe in the future, but I'm not maintaining multiple renderer backends. Direct3D? Screw that proprietary shit.

>why wrap them in classes when the member functions can do nothing if the shader is not bound
They can, they just have to do glGet to get current program, glUseProgram to set the selected program, glUniform and then glProgram again to restore.

How long does it take to normally learn .net?

.NET is a massive animal, and you really just keep learning it.

That goes for any programming language, really. You've got to define what your target competency level is.

That being said, you can learn C#/.NET enough to perform most basic tasks in a few months, but it's just a massive toolbox and the tools you use on a day-to-day basic will be different than anyone else.

>.NET is a massive animal
does .NET implement leggable?

Which leads to a horrible number of unnecessary state changes. Shader changes are the second-heaviest changes that exist (render targets are the heaviest).

Yeah, I think I've done my decision: no OOP in my shader system.

char *sChar(size_t s) {
char *str = (char *)malloc(s);
memset(str, 'x', sizeof(s) -1);
return str;
}

Well I'm dead for my interview tomorrow then.

What the fuck is wrong with you cunts?

Someone yesterday had a Javascript interview in an hour and thought he could know enough for the interview.

Learn a skill before you ask someone to pay you for it, dumbass.

Well the job asked for a lot of languages but it was in the preferred section. I already knew about mysql when they wanted t-sql so I thought I could transfer my skills there. So it's them who decided they wanted me to try me out not the other way around.