/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1551561830761.png (1324x1125, 210K)

Other urls found in this thread:

blog.discordapp.com/scaling-elixir-f9b8e1e7c29b
way-cooler.org/blog/2019/04/29/rewriting-way-cooler-in-c.html
twitter.com/AnonBabble

nth for Nim!

(reposting cause last thread was at bump limit, thanks for the advice so far)

Hey guys, I've just completed my comp sci 1 course for college and it really helped me get a grasp of programming and what I struggle with although we only learned C. My biggest issue with programming seems to be making algorithms or formulas to simply have things work properly. Like things involving nested loops or functions, I find it mealy impossible to make one of these on my own even though I KNOW how they work logically and the rules of them.

Is there a place I can go to improve at this or practice it? I really disliked the assignments we got to practice these (printing stars with spaces and whatnot), I feel like it was not something I'd do in an actual professional programming environment. I'd like to start with something basic then progress more.

Also, I'm starting comp sci 2 in a couple of weeks and we are learning Java. Any tips that may help me throughout this endeavor?

>What are you working on
nothing atm

4th for bloat

Attached: 1556507508346.jpg (960x720, 451K)

...

>What are you working on, Jow Forums?

A scalable game server, it's going okay but a bit slow

Everybody has been in your position. Nothing will ever beat practice. So practice on codeforces/hackerrank etc.

Best source/website to understand and practice data structures?

SignalR

I don't know any dotnet languages

hope you're using elixir or erlang.

How bloated are we talking here?

Attached: 1553404391977.jpg (960x720, 440K)

C++
Actor model doesn't fit for my use case, too much overhead in messages

2GB/s

>too much overhead in messages
kind of doubt that
blog.discordapp.com/scaling-elixir-f9b8e1e7c29b

>What are you working on, Jow Forums?
trying to figure out why I was cursed to be a brainlet

Attached: 1492872465663.jpg (1920x1080, 143K)

Just give up and become a neet. Then you don't have to think.

Brainletism can be overcome or culled with enough effort.
t. heavy impostor

are you ok retard

I'm just so lazy which ends up making me be a brainlet

Attached: 1448302183028.jpg (1280x720, 139K)

That's not real bloated

set yourself up on the effort -> reward cycle.
Set a small goal
complete it
reward yourself
repeat.
You'll soon be craving the cycle which will force you to work until you'd rather work than have the reward.

I'm currently learning GoLang, it's the first time I bought more than one book to learn a language but I feel it would be nice to master Go.

Also adding NLP to a system already on production and trying to get a new job, contemplating suicide.

so what should the reward be

Enlighten me senpai

Go is simple

whatever you like doing
an episode
a movie
anime
vidya
manga
comic
a wank
browse Jow Forums
etc
Just remember to actually force yourself to start working again in the beginning, as you'll want to default back to being a useless POS.

It is easy to learn once you get used to the syntax and understand the basics.

Some of those Indian websites like tutorialpoint and geekforgeeks can actually kind of good sometimes...

But it helps if you are searching for something specific that you know the name of. :/

AVL tree, harder than I expected

hello friends, sorting user from previous thread here.

I've got the problem partially solved (2 layer sorting)

a = {
{ ID = 1, time = 1, reply = 1 },
{ ID = 2, time = 2, reply = 1 },
{ ID = 3, time = 3, reply = 1 },
{ ID = 4, time = 4, reply = 3 },
{ ID = 5, time = 5, reply = 3 },
{ ID = 6, time = 6, reply = 6 },
{ ID = 7, time = 7, reply = 4 },
{ ID = 8, time = 8, reply = 7 },
{ ID = 9, time = 9, reply = 8 }
}

local convo_sorted = {}

for k, v in ipairs(a) do
table.insert(convo_sorted, {})
local convo_length = #convo_sorted
print("length " .. convo_length)
for k2, v2 in ipairs (a) do
if v.ID == v2.reply then
table.insert(convo_sorted[convo_length], v2)
end
end
end


any tips how to progress towards this order as output?

{ ID = 1, time = 1, reply = 1 }
|___________________________________
| |
{ ID = 2, time = 2, reply = 1 } |
{ ID = 3, time = 3, reply = 1 }
___________________________________|
| |
| { ID = 4, time = 4, reply = 3 }
| |
| |
| { ID = 7, time = 7, reply = 4 }
| |
| |
| { ID = 8, time = 8, reply = 7 }
| |
| |
| { ID = 9, time = 9, reply = 8 }
|
|
{ ID = 5, time = 5, reply = 3 }
|
|
{ ID = 10, time = 10, reply = 3 }

well maybe but I think it's over-engineering

Old Perl programmers had something called a Swartzian Sort, named after the guy who wrote the camel book. The same technique is used in Python sometimes but Swartz described his version in a forum somewhere long ago...

If data is inconvenient to sort without auxiliary data, temporarily transform the table to have additional fields that would be useful. Simplify the comparison/sort with the extra labels and transform back into original format afterwards!

It would be handy if a post table had an ancestry list... Whoever had to earliest ancestor would compare before, and if a tie then the 2nd eearliest ancestor, etc. The sort key function would compare the first non-matching member of ancestry list.

Okay, so we create a second array of tables but this one has fields { ID, ancestry[] } and it would be handy to have oldest-first in ancestry list. If that table can be sorted then the original can be rearranged to same order!

So ancestry[] would start as an empty list... Or it should be a one-item list of [ID] (matching self). When constructing these handles just trace backward prepending Great Grandpa before Grandpa before Father before self. Then sort handle list and use result to rearrange original list. ;)

I'm so tired bros

Attached: 1460716268988.png (540x784, 144K)

>bros
We're all anime girls here.

Attached: azu_hug.gif (493x438, 1.86M)

4th year CS here got an e-mail from a professor I think he found a junior deveoper job for me asked if I was interested what the fuck idk what to say.
I mean Im interested in working just thought I'd have to look for a job myself in a couple months after I get a degree. Never worked before and don't even have a CV I wanna work but don't wanna let anyone down.
What do?

Attached: 1553737266447.jpg (700x734, 99K)

rustfags on suicide watch

way-cooler.org/blog/2019/04/29/rewriting-way-cooler-in-c.html

Attached: yablewit.jpg (870x500, 353K)

I suggested and implemented this also in previous thread:

>I wanna work but don't wanna let anyone down
you might want to throw that kind of thinking and attitude into the trash right now as it'll save you a lot of headaches and stress
t. was/am the same way

It's beautiful.

Well it does say someone with 0 experience will be considered so I guess they will train me or expect a phase for me to get things going on and not be a pro right from the start i guess
Still though what the fuck do I write in my CV

Be sure to include your favorite anime.

In practice, how bad is it to go with a thread-per-connection design?

Depends on number on connections. If you do HTTP, you can use nginx, and have your fcgi handler with a small number of threads, and nginx will have its thousands connections served by one nginx thread.

My 10/10s are Ghost in the Shell movies and Haikyuu that volley anime

Oh cool, didn't see that. SQL creates temporary tables as a matter of course.

Is it normal to fantasize about sucking cock when coding?

Yeah, when you are a rustener

apologies to the guy who said !^ for XNOR, i checked the logic and you were right. eXclusive Not OR is equivalent to Not eXclusive OR.

not(xor) == xnor

does something even make sense in opengl?
layout (binding = 4) uniform sampler2D tex;
I mean how can I bind a texture to a certain point? shouldnt I just use the regular binding by uniform name?

Uhm.. sweatie.. the opposite of exclusion is inclusion.

yes
tautology

1
0
0
1
becomes
0
1
1
0

It's easier to set bindings from within the shader rather than query what OpenGL decides.

yes, but how do you set the texture to that binding from client side?

glActiveTexture

If you are learning for profit, is it a good idea to choose a programming language with high demand or low demand?

Can anyone explain OpenGL and the whole shader mess to a brainlet in simple words? are shaders programming languages?

High demand if it's your first language. Low demand if you already know other languages.

Making a slider widget for my operating system. Hooking it up in the terminal app so I can finally change the terminal transparency at runtime.
I also got a new patreon supporter yesterday, so thanks user for joining :)

Attached: Screenshot at 2019-04-29 19-33-48.png (1920x1080, 1.3M)

yes, shaders are programs for your GPU rather than your CPU

good word lad, subbed to you on youtube for more background dev-related stuff.

Based and redpilled

ah finally free of that retarded uniform bullshit.

Thanks user, I'm happy to have you!

Attached: catoffice5.jpg (394x400, 26K)

How's your doom port doing?

Does that mean GPUs have their own instruction set or do they 'just understand shaders? Are they the same as CUDA?

basically both

I'm not working on it at the moment, but I'll get back to it sooner or later.
I recently got GCC ported and working quite well but it's dogshit slow, so I have to do a lot of kernel work to make it go faster. The nice thing of course, is that literally everything benefits from the kernel being faster.

Nowadays, graphics drivers compile vendor-agnostic shading languages like GLSL, D3D shader bytecode, and SPIR-V into vendor-specific machine code.

You'll be fine don't be a bitch

Thanks for the answer =)
And can you make a port of Doom 3 as well then? In future, of course.

I suddenly got 6 interviews I need to prepare for within the next 4 days
WHAT THE FUCK DO I DO I HAVE BEEN A NEET FOR A MONTH
its for an embedded position

Doom 1 and 2 should be straightforward to port. Doom 3 would require OpenGL support which will be harder but nothing is impossible!

Im currently doubting tiled forward shading for higher resolution. if we go with 32x32 workgroups for a 4k resolution it means 8160 frustums need to be culled every frame. that's insane.
I think I will need to cap the light grid at 1080p and just scale it up.

Attached: 1548456684474.jpg (540x540, 39K)

Clustered is better for this reason. Since the frusta end up being compact, you can approximate them with spheres.

why do you need to do frustum culling for every cluster? can't you just use their 2D screen co-ordinates?

I would help you to make some shit you wont to do, but I cannot into OS programming :(
(nothing impossible, but it takes a lot of time)

yeah I read the paper but first I want to have a working forward+ implementation. additionally I want variance shadow mapping and with my lack of experience in opengl it will take some time to get everything running in decent fashion. I still have too many problems with opengl client side

I have a Person object with a gender attribute and I want to use proper pronouns in strings related to that object.
Should I make a class that has methods that return return proper pronoun depending on what object was passed to it as an argument or just several free functions for his/her, him/her, he/she etc?

Just a few more questions. Who implements OpenGL/CL/Vulkan and whatnot? OS or device vendors or is it basically a free library that checks something similar to CPUID? Are there GPUs that don't have OpenGL support?

Typically device vendors, but Intel and AMD document their (recent) hardware well enough for "anyone" to write a driver.

if I'm already a programmer and consider myself pretty good compared to my peers. Is SICP still a good read? Or is it only for beginners?

Attached: 1555139232806.jpg (715x715, 201K)

its for shitposters

Do you want to learn Scheme?
Yes -> yes
No -> Go read CLRS instead.

ok user, I'll trust you

Attached: 1541158092890.jpg (1280x720, 448K)

good lad

why bot have a single function that returns different thing depending on the attribute?

adderall

Have a look at some category theory and read SICP.

me in about 2 hours

Attached: 10.png (816x517, 273K)

Write some embedded systems? Reinvent the wheel?

Writing a program using python to connect to a machine to scan an area and do certain tasks.
I got all of the code to work and it just started erroring for no reason.
So I figured out what the problem was after an hour and the api for the machine hates it when you use certain parts of the api in a function that is not part of the same file the main method is.
So I just moved some stuff to the main file and it just works.

How are you going to decide whether I want 'he' or 'him' or 'his' if the passed attribute is just a binary 'male' or 'female'?

make gender a string?
if you can't change that then make pronoun an attribute of Person, set its default value based on the gender and allow it to be overridden in the constructor.

me right now

Attached: 1552753131406.gif (200x155, 2.91M)

I would say it depends how much code duplication would arise from using separate methods as opposed to a single method with a parameter. Either way, you will be able to express one in terms of the other, i.e.
String get_pronoun_personal() {
if (gender == MALE) return "he";
if (gender == FEMALE) return "she";
}

String get_pronoun_possessive() {
if (gender == MALE) return "his";
if (gender == FEMALE) return "her";
}

String get_pronoun(Pronoun type) {
if (type == PERSONAL) return get_pronoun_personal();
if (type == POSSESSIVE) return get_pronoun_possessive();
}

vs.
String get_pronoun_personal() {
return get_pronoun(PERSONAL);
}

String get_pronoun_possessive() {
return get_pronoun(POSSESSIVE);
}

String get_pronoun(Pronoun type) {
if (gender == MALE) {
if (type == PERSONAL) return "he";
if (type == POSSESSIVE) return "his";
}
if (gender == FEMALE) {
if (type == PERSONAL) return "she";
if (type == POSSESSIVE) return "her";
}
}

Literally just practice.
Find a problem.
Decompose it into smaller parts.
Figure out how to do one part.
Repeat for the other parts.

>modifying the container invalidates the iterators
RREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE DO YOU KNOW HOW MANY HOURS I'VE WASTED TRYING TO DEBUG THIS SHIT GIVE ME MY TIME BACK GIVE MEEEEEEE

Attached: 1458061511179tech.png (900x900, 373K)

Rust doesn't have this problem