/dpt/ - Daily Programming Thread

/dpt/ - Daily Programming Thread

Prev:

Attached: Miyamizu_Mitsuha_On_Ownership_And_Borrowing.jpg (1920x1080, 331K)

Other urls found in this thread:

stackoverflow.com/a/27110913
en.cppreference.com/w/cpp/utility/functional/ref
paulkernfeld.com/2018/09/16/ownership-explained-with-python.html
youtube.com/watch?v=G5goISKPSH8
doc.rust-lang.org/book/ch06-02-match.html#the-_-placeholder
twitter.com/NSFWRedditVideo

Rust more like butts

post code gentleman's

Attached: __.png (996x981, 718K)

What language do lolicons use?

I'm currently trying to parallelize some raytracing code.

Smal C++ questions about std::thread. I've this function:
void RayTracer::execteRayTracerOnRow(int row, int startCol, int endCol, int maxSamplesPerPixel,
const glm::vec2& currentResolution, ImageWriter& currentImage)
That basically performs a raytrace on a ray for a given range, and I'm trying to parallelize it as follows:

int fourthOfXRes = static_cast(currentResolution.x) / 4;

std::thread firstFourth(&RayTracer::execteRayTracerOnRow, this, r, 0,
fourthOfXRes, maxSamplesPerPixel, currentResolution,
std::ref(imageWriter));
/* repeat three more times... Don't worry, I join everything at the end. */


However, when I compile this, I get hte following error:

/usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/thread:342:5: error: attempt to use a deleted function
__invoke(_VSTD::move(_VSTD::get(__t)), _VSTD::move(_VSTD::get
In file included from
/usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/type_traits:1670:5: note: '~__nat' has been explicitly marked deleted here

Any idea what's causing this?
haha

You should be able to answer that. What's your favorite language?

what language is that sweetie?

rust

>programming
>hard
lmao

Attached: 8122_7e02_689.jpg (689x1024, 169K)

See stackoverflow.com/a/27110913

did you join your thread?

Programming was hard before Stackoverflow

it looks cool

>appeal to authority
heh

What is your sitting position while programming?

Attached: 20181207_142124.jpg (4032x3024, 3.83M)

Attached: fitlopta-7.png (700x525, 486K)

FUCK CODING
FUCK PROGRAMMING
FUCK BUILDING APPLICATIONS
FUCK SCRIPTING
FUCK ASSEMBLING
FUCK COMPILING
FUCK INTERPRETING
FUCK PROGRAMMING LANGUAGES
FUCK DECOMPILING
FUCK IMPERATIVE PARADIGMS
FUCK OOP PARADIGMS
FUCK FUNCTIONAL PARADIGMS
FUCK STRUCTURAL PARADIGMS
FUCK PROCEDURAL PARADIGMS
FUCK ALGORITHMS
AND FUCK DATA STRUCTURES

Me while writing Haskell.

Attached: Vitarka-Mudra.jpg (709x1024, 128K)

I had a class with a guy that worked with Widlar. Apparently he was a pretty interesting guy.

I'm having issues understanding this line:
Pass a pointer to Functor instead of a reference_wrapper
In my case, what would I be passing in as a pointer? What is the reference_wrapper in this case?

Yes. That isn't the issue though. The compiler's telling me that the call to the std::thread initializer is that thing that's causing the issue.

what the absolute fuck I swear to god this is what my brain thought when I saw that image

anyone else saw this?

Attached: tfw_reading_thumbnail.png (446x668, 51K)

>I'm having issues understanding this line:
Retard. en.cppreference.com/w/cpp/utility/functional/ref

Post socks

I'm confused since there's several pointers/references being thrown around in the example.

I fixed all the references to pointers and that didn't fix it. The SO post essentially says to use pointers instead of references, so that's what I did.

Attached: Screen Shot 2018-12-07 at 12.00.24 PM.png (1718x592, 184K)

what is this ugly shit? java? c++?
how can someone unironically look at this and not want to kill themselves? jesus christ

Cpp
Look man, it's my first time multithreading. I genuinely don't know how I can improve this code. I'm open to suggestions.

explain this

Attached: 1544211552762.gif (640x420, 792K)

Still the same error?

>slave
this violates the coc

What happens if you call square multiple times?

>slave
Yikes, pre current year much?

This is a trick. The second 9 is not a real 9, it's a character from the Canadian aboriginal alphabet.

Read this
paulkernfeld.com/2018/09/16/ownership-explained-with-python.html

That's fake and doesn't happen if you cast to list.

If you want more help then post the full error message instead of just a snippit. Like the one on stackoverflow, your error message should trace it back to the line in your code, not just the line in the stdlib.

Attached: .jpg (403x539, 97K)

Can't unsee

>anyone else saw this?
It's all I can see now.

Thank you. The full error message is this:
In file included from /Users/lambda/Desktop/CS148Projects/FinalImage/cs148raytracer-public/common/RayTracer.cpp:12:
/usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/thread:342:5: error: attempt to use a deleted function
__invoke(_VSTD::move(_VSTD::get(__t)), _VSTD::move(_VSTD::get
In file included from ../cs148raytracer-public/common/RayTracer.cpp:1:
In file included from ../cs148raytracer-public/common/RayTracer.h:3:
In file included from ../cs148raytracer-public/common/common.h:3:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/iostream:38:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/ios:216:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/__locale:15:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/string:500:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/string_view:176:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/__string:56:
In file included from /usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/algorithm:641:
/usr/local/Cellar/llvm/7.0.0_1/include/c++/v1/type_traits:1670:5: note: '~__nat' has been explicitly marked deleted here


Basically, the line that the compiler is saying is the error is this:
std::thread firstFourth (&RayTracer::execteRayTracerOnRow, this, r, 0,
fourthOfXRes, maxSamplesPerPixel, resolution,
imagePtr);


The thing that confuses me is that I have four thread lines, but only one or two errors... I'll try and change the parameters I pass in until I see an error.

I'm making a discord bot via JS, if I wanted to make it read a random entry off of list, would just doing a normal txt file do fine? I'd like something that's easy to access to adjust and just have a bot read off a random single line off the list, so I'm wondering if this is a good way of doing it or if there's a better way of doing it.

You can cast in python?

>rust
Opinion discarded

I'll take "fake news for 800”

Attached: croppedImage_1544216736652.png (1440x647, 71K)

Good languages just not your thing huh?

Good taste just not your thing, huh?

what's a blockchain engineer ?

Attached: 1544209148860.jpg (1546x872, 92K)

Unrelated, but does anything else binge on jeopardy on youtube from time to time?

Rust is so empowering. It puts me into a totes comfy headspace for systems programming.

>Good performance
>Comfy syntax
>Helpful compiler
>Encourages good habits
>Forces you to learn

Attached: 341161354.png (478x384, 22K)

The same could be said about C.

nah
how can you write safe rust code if the standard library is full of unsafe code?

How can mirrors be real if your eyes aren't real?

Your eyes and mirrors are real, your perception of reality, however, is an illusion.

Fixed it.
Basically the error was that I wasn't *exactly* passing in the correct parameters to the std::thread constructor (the `resolution` parameter) I used was accidentally passed by value.

Now, I improved my program's runtime by a factor of 3! Woot!

Attached: 1533401848856.jpg (480x480, 34K)

The borrow checker is designed to statically verify the safety of a program according to certain rules. However, the rules as actually implemented are not fine-grained enough to express certain ideas, like disjoint borrows of different parts of an array. At this time, when such finer-grained rules have not yet been implemented, the standard library uses unsafe code in certain places, along with a huge amount of documentation of the way it's being used, to simulate what the borrow checker should do in these situations.

what's the program about?

>However, the rules as actually implemented are not fine-grained enough to express certain ideas, like disjoint borrows of different parts of an array.
split_at_mut

A safe interface implemented under the hood using unsafe code. Which is what my post was describing. Your point?

C doesn't encourage good habits, its lets you do whatever you want.

A shading language and compiler for Vulkan that produces C headers containing embedded SPIR-V binaries, properly laid out struct definitions, named constants for indices, etc.

It's a ray tracer!
Basically, I'm taking a computer graphics course, and the final project involves making a scene.

They recommend you extend the original ray tracer to support things like multithreading and such, but it's not necessary. That said, adding multithreading now allows me to run three times as many operations and basically have it run the same amount of time as the people that didn't do multithreading. Exciting stuff, if you ask me!

Right now, though, I'm hoping to fix the shadows in the top image (transmissive objects are a pain in the butt) and the photon mapping in the bottom image (I have no idea why there are green lines here).

Attached: RayTracer.png (688x977, 175K)

What kind of data structure accurately represents this pattern?

youtube.com/watch?v=G5goISKPSH8

If you care enough to put in the effort, it doesn't matter if the language of your choice forces your or not to be good. One hit one point, thanks for playing along.

nobody cares?

rust is for faggots

do you really need
_ => ()
?

Yes. It fails to compile otherwise.
doc.rust-lang.org/book/ch06-02-match.html#the-_-placeholder

>vulkan
>500 lines triangle program

booka shake

I'm rewriting my shell because I fucked it up too much to support pipes properly

I'm working on a compiler, I'm writing it in Haskell. I have the tokenizer done, works beautifully. I'm doing the AST generator now, and I made a TokenParse monad that works similarly to ReadP, except it operates on tokens instead of Chars, and it can spit out status messages alongside errors. Those are the biggest differences, there's a few others but you get the idea.

How would i go about using parser combinators to parse the list of Vars from a list of tokens that looks like: (Var,Var,Var)? I made an equivalent of the manyTill function, but thar can only do something like (Var,Var,Var,)

The core list-producing parser should match ,Var and then either itself or ). This gives you a [Var] quite easily. Then you just have to tack on matching either ( or (Var on the front, and in the latter case you just cons the variable with the list.

Sorry, I mean the core parser should match:
1. )
OR
2. ,Var then itself
You can see how this mirrors the [], x : xs pattern.

you forgot to put /dpt/ as the subject line

He also didn't ask what we're working on, not sure if I can post it.

get the fuck off my board you monkey gorilla nigger

>doc.rust-lang.org/book/ch06-02-match.html#the-_-placeholder
>-_-
Ayyy

hey /dpt/, why is oopsieism so prevalent? the almost good bits are just crippled fp and the bad bits are unnecessary

Aaaah, i see. I was trying to match (, then either Var, or Var), and it was just a clusterfuck.

That would work if you started with '(' then matched ')', 'Var)', or 'Var,' repeatedly. In fact that might even be simpler than my first idea. There are loads of ways to do this. You could also try matching a comma (or take a delimiter parser as a parameter) delimited list without brackets, using lookahead to know when to stop, then having a bracketed combinator.

god-tier keyboard

libav module for guile. I originally was just going to use libpng because all I needed was an image, but since lav can already deal with almost every format including png it seemed like a better choice.

Now I'm just messing around trying abstract AV files properly.

what high school programming class did you fail?

constrained optimization of numerical methods

hey /dpt/, why is fpism still considered relevant in some narrow circles? the almost good bits are just cripped oop and the bad bits are unnecessary

pfft really??? omg user

lmao are oopsies really this unoriginal?? and easy to set off?

"fp is merely fashion programming! oop is actually practical!" screech tearful oopsies as they write literally the same code over and over and over and over and over and over again, it never occurring to them that a good language would allow them to abstract over it

t. fpfapper

dunno what you do with your oop shit in private, don't really care, but I use fp to produce software

>I use fp to produce software
doubt.jpg

what "software" have you produced?

>the fpfapper thinks his piano arithmetic program is "software"

kek

you're unemployed

>piano arithmetic
funnily enough one of my hobby projects is a tracker written in haskell

shit that earns me a salary, senpai

>shit that earns me a salary
doubt.jpg

c'mon give an example

>program
>"not software"

what's piano arithmetic?

Daily reminder that FP is not Turing-complete.

Explain how. (5 marks)

*scribbles no u*

I feel like the world is running away from me, the older I get. I spent so much time trying to become proficient in c++, and then suddenly everyone hates it.
At work they just want me to do web dev shit in various scripting languages that i've barely or never touched before. Trivial tasks that shouldn't take more than an afternoon has taken me a week.