/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

github.com/rubykube/peatio/
sscce.org/
youtube.com/watch?v=kIA_UtdVabQ
stackoverflow.com/questions/23986825/opencl-for-loop-execution-model
doc.rust-lang.org/std/thread/
github.com/dailyprog/dailyprog.github.io/blob/master/test-image.html
visualgo.net/en
amazon.com/Grokking-Algorithms-illustrated-programmers-curious/dp/1617292230
twitter.com/AnonBabble

ohaio gozaimas~

learning SDL to make a Doom clone, why the hell SDL defines its own fixed-width integers???

This thread is already shit.

>release first project
>100 stars on github in the first day

i've made it mom,
living the dream

quick question: how do i convert github stars into hard cash?
and where do i get my rockstar programmer club membership card?

For the same reason Qt has qint's -- for better cross-platform compatibility. You're free to ignore them.

Post it so I can bully you

C++ friends unite!

what project?

now I'm interested

i wanna put a star too

おはよう ごさいます user君

konbanwa

Starting to contribute to this opensource cryptoexchange project:
github.com/rubykube/peatio/

Share it with us

Reposting.

Duh

I don't quite follow.
I said that he should use char *p instead of int *p.
I understand that his code isn't bulletproof, especially when using a fixed character array to place input into.

so, from >friendly feedback
1.
void Tournament :: genMatches()
{
vector ::iterator itB;
vector ::iterator itE;

for (int i = 0; i < players.size() - 1; i++)
{

tf is going on with the indentation of everything after itE?

2. Matches.push_back(currentMatch);
what is Matches, where is it defined
does this code even compile?
I mean it doesn't even include a main method, do anything with the result (assert, print), or do debug prints as you're building the rounds up
ffs post a *self-contained* example
do you know what it means?
hint: I should be able to copy-paste it into a file, compile and run it, and see the issue during runtime (be it printing, assert failures or other errors)

>on-topic feedback
$ cat shite.scala
def genRounds(playerCnt: Int) = {
require(playerCnt % 2 == 0)
var ps = (1 to playerCnt).toVector

for (round constructive feedback

>so, from
>so, from
ftfm

also wrt
>self-contained
sscce.org/
>The SSCCE
>Short, Self Contained, Correct (Compilable), Example
>If you are having a problem with some code and seeking help, preparing a Short, Self Contained, Correct Example (SSCCE) is very useful. But what is an SSCCE?
>It is all in the name, really. Take a look at each part. The version prepared for others to see should be:
>- Short (Small) - Minimise bandwidth for the example, do not bore the audience.
>- Self Contained - Ensure everything is included, ready to go.
>- Correct - Copy, paste, (compile,) see is the aim.
>- Example - Displays the problem we are trying to solve.

Learning unix sockets to make a program in Haskell (for parsing) and C (openGL).

why not use python?

Anyone here knows OpenCL? I have a C++ program that I want to run in my CPU and GPU at the same time, can I just use OpenCL to concurrently execute the for loop that is in use 99% of the time? It's just number crunching with some random number generation, so it's just pretty much C code anyway, I can just use it as the OpenCL kernel right?

>no sense in wasting my time getting your code to compile, frankly
>people are less likely to want to help you, the more of an unnecessary hassle you make it for them to help you
not to mention that the issue may be highlighted (and much easier to spot) in the code that you chose not to post
so, again, you're making things more difficult than they need to be

Use cuda

NOT PORTABLE YOU FUCKING TOOL

Idk but maybe give this video a watch: youtube.com/watch?v=kIA_UtdVabQ
He makes an overview of CPU+GPU computing. You may find interest in openACC.

Why use python?
I'm pretty comfortable with Haskell, parsec and C, but not python and its parsing libraries.

>I'm pretty comfortable with Haskell, parsec and C, but not python and its parsing libraries.
excellent reason NOT to use python imo
he prolly thought you're using haskal due to memes

SDL threads or POSIX threads?
POSIX threads should work on windows right?

stackoverflow.com/questions/23986825/opencl-for-loop-execution-model

>POSIX threads should work on windows right?
wont compile, you'll need to do a few #ifdef's

they work on windows if you link to winpthread from mingw64

std::thread

Fuck off Bjarne.

>windows
>mingw
if yer a masochist

More portable c:

>Bjarne
>Implying
doc.rust-lang.org/std/thread/

Fuck off Steve, you are even worse than Bjarne.

>C
>portable
thanks to dynamic linking it's not even portable across lincucks distros

yes but it has the better compilers
dynamic linking respects the user's freedoms

>dynamic linking respects the user's freedoms

This is some next level rust shitposting? Dynamic linking is the only acceptable form of linking.

but LD_PRELOAD is broken

>terrorist might blow up plane so you should never fly anywhere

>dynamic linking is the only acceptable form of linking
from 2 options you chose the wrong one

In Rust, suppose I have a crate with two binaries in it and some code I'd like to use in both, so it looks like
src/foo/main.rs
src/bar/main.rs
src/stuff.rs

and in Cago.toml I have
[[bin]]
name = "foo"
path = "src/foo/main.rs"

[[bin]
name = "bar"
path = "src/bar/main.rs"

How do include `stuff` in both `main.rs`s? As far as I understand, mod works only from the current dir inward, and there's no way to 'mod' a file from the parent directory. Then how am I supposed to reuse code in a single crate?

Playing with Sup Forums's json api in node.js.

I just finish the making of an html page containing all images in /g.

github.com/dailyprog/dailyprog.github.io/blob/master/test-image.html

It doesn't work yet - Sup Forums's cdn seems to dislike we link to images from elsewhere (or I'm asking for too much images).

Is there any good guides for making GUI for your java program?

I made program where you input speed and gravity. Then it prints out second/height/speed and stops when the object is down again. After that it prints highest point where that object was.

sounds like a shite building system
guess you could kludge it up with symlinks?
so much for "modern language"

Protip: Unlearn rust

Learn a language that works

im trying to make a parser that parses a custom language based on this pic into lua and then runs it.

When I have a directory structure like
src/foo/main.rs
src/bar/main.rs
src/lib.rs
then
extern crate
in both main.rs is enough to work.

Rude

Pic related

>Two main functions
lol, wut?

Invoking cargo build creates two binaries

please don't import me unless you are in japan

...

It actually worked, thanks.
Two executables - two main functions.

Good to know

A Rust crate with binaries may still have a library component (i.e. lib.rs and submodules). Then in the binaries you just `extern crate dpt`.

People got so used to free shit they just take it for granted now ungrateful cunts.
I have a cool little app on the app store and 100 people installed it (and kept it), and not even one single of them bothered to rate it
This sucks dick.
I will have to create fake accounts and rate it myself

>tfw reading the whole thread

You have no face?

>feel

Whoops, am dum

I'll forgive you if you post feet

...

...

How would I go about visualizing algorithms? I want to learn sorting algorithms and visualize them.

Just learn how to do 2D graphics first and then make array length amount of different height vertical lines and apply the sort to them?

haven't used it but there's this
visualgo.net/en

>this tool looks better on larger screen :)

>I want to learn sorting algorithms and visualize them.
the wikipedia page on almost all them has a gif showing the sort.

Yes, I am aware that the internet is full of gifs and videos and fancy html5 sites which show all the possible sorting algorithms.

But the idea was to read about the algorithm, then try to implement it myself. And also learn the visualization part on the side.

I think you could also do that by reading the wikipedia page for the algorithm or just read an algorithms book.

i don't see how the answer to your last question could be anything other than "yes"
pick your favorite language. there is some way to draw shapes in a window with it

find the pdf or something
amazon.com/Grokking-Algorithms-illustrated-programmers-curious/dp/1617292230

Question:

How do I add/remove objects of a JPanel that's on BorderLayout.CENTER from a JPanel that's on BorderLayout.START_PAGE ?

I made a function inside the JPanel that's on the center with
public void resetGameSize(){
this.remove(mtrx);
mtrx.newSize(2, 2);
this.add(mtrx);
}

and now on the JPanel that's on the start_page part I made a combobox where I want one of the options of the combobox to do
Main.resetGameSize();

but it turns out the resetGameSize() should be static for me to do that, but I can't make it static because remove(mtrx) and add(mtrx) wouldn't work then.

I'm a shitty coder I know. Any ideas for a workaround?

Oh I forgot to mention, the two different panels are on two separate classes.

What can affine types do for MY projects?

How the fuck am I supposed to free resources on exception in memory managed language?
This is fucking bullshit.

Affine types are deprecated, use linear types
What language

>What language
C

nothing, because they're wasteful.

C doesn't have exceptions tho

Just log an error and exit gracefully

>read up on RAII, smart pointers, etc
>confident and pumped to code
>mfw i actually try to create something
>clusterfuck of leaks and cyclic shared_ptrs

Like the Idea is that I give allocator to plugin and if there's exception on plugin function I unplug it and free everything in allocator but what to do if the plugin has shit running in different thread?

>what is longjmp

Bullshit you shouldn't be using.

But if you do wanna steam ahead with this - you need to put a setjmp everywhere you would put a "try" block otherwise in a language with built in exception handling.

>constant time method to jump arbitrarily far up the stack
>bullshit you shouldn't be using

Don't allocate anything manually, ever
If you want to create something, push it onto a vector or add it to a map
Then you never even have to think about memory management

What is the best area of computer science and why is it math?

It's only constant time if you don't need to call any cleanup routines along the way.

...

math isn't CS, math can just be applied to many areas in CS.

>Then you never even have to think about memory management
brainlets

How can I average two numbers in C?
Wtf, I thought C was just as powerful as any other language

>math
>area of computer science

C doesn't even have strings. Why would you think it's powerful?

>Read up on Ada and secondary stack
>Confident and pumped to code
>Mfw I actually try to create something
>Clean strongly typed code and living on the stack

Shit, I meant ints