/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

github.com/ForwardCom/manual
lmgtfy.com/?iie=1&q=https://www.google.com/search?q=Can+you+allocate+a+struct+on+the+stack%3F&ie=utf-8&oe=utf-8
lmgtfy.com/?iie=1&q=Can you allocate a struct on the stack?
doc.rust-lang.org/std/io/trait.Write.html#tymethod.flush
youtube.com/watch?v=dSsukh8EdWk
twitter.com/SFWRedditGifs

First for D

Realistically speaking, should I be adding I/O to my language at all?

Realistically speaking you're retarded.

Rust is a fantastic, modern compiled cross-platform programming language :)

turing machines don't use quantum mechanics

What are some good Books/Resources for learning HLSL?

I have literally no experience with it

I already know c++ and c# but would rather use c++ if it relates

This

why is she hitting herself??

Testing my cpu.

Implement this github.com/ForwardCom/manual

Why would you say such a thing?
I think she might be mildly autistic.

I don't know about HLSL but for GLSL the OpenGL superbible is pretty nice

How to get ideas for programming projects?
I am a CS student and I know I should build up a github for employers, but I have no fucking idea what to make.
I usually finish projects in class faster/more efficiently than my peers, but I have no creativity. Guess that means I definitely should not start my own company.

Make a vidya game. It's pretty fun.

I love rust too. Started playing with it yesterday. "The Rust essentials" book is a nice short introduction.

I like that Visual Studio Code has a god tier plugin for Rust too. Although I kinda miss their lack of syntax checking in the plugin.
Overall, it's quite nice.

vs code + Racer is nice and i've seen cool configs for cargo integration

59 MIPS, watch out 68040.

The VS code official plugin works fine though. The Only thing I miss is automatic syntax checking. VIm has it, but project management in Vim is very counter productive.

oh sorry, didn't realize you said vs code, I was talking about the official pluggin

A programming language that can only produce two kinds of programs -- empty programs and infinite loops -- is fairly useless. You should add I/O so that you can generate actual computer programs, rather than just some busy machines that crunch numbers and then throw the result on the floor.

In way in over my head trying to port this html5 everywhere IceCat add-on to webExtensions.

I'm emailing RMS and I don't have the heart to tell him "no"

He asked me to because I made him the McDonald's add-on he asked for on his website

@60089285
>A programming language that can only produce two kinds of programs -- empty programs and infinite loops
I don't recall posting the formal semantics of my language.
>generate actual computer programs
What the hell is an "actual" computer program?
>crunch numbers and then throw the result on the floor
An empty program can't do that, and an infinite loop "throwing results on the floor" would be a self-contradiction.

"programs are proofs" aspie detected

What were you going to mean by this?

> haskell

oh ya I want it on my pu$$y

What makes you think anyone is even going to read your whole post if you can't even reply to others normally?

I have more fun doing low-level programming. Am i autistic?

Literally everyone I know hates it.

i started studying pthreads. this is my first program
#include
#include
#include

void *add_elem(void *line)
{
int *line_pointer = (int *)line;
int accum = 0;
for(int i = 0;i < 3;i++)
accum += *(line_pointer+i);
*line_pointer = accum;
pthread_exit(NULL);
}

int main(void)
{
pthread_t thread;
int matrix[2][3];
matrix[0][0] = 1;
matrix[0][1] = 2;
matrix[0][2] = 3;
matrix[1][0] = 1;
matrix[1][1] = 1;
matrix[1][2] = 1;
int rc;
rc = pthread_create(&thread, NULL, add_elem, &matrix[1]);
if(rc) {
printf("ERROR; return code from pthread_create() is %i\n", rc);
return -1;
}
int *line = matrix[0];
int accum = 0;
for(int i = 0;i < 3;i++)
accum += *(line+i);
*line = accum;
if(pthread_join(thread, NULL)) {
printf("error joining thread\n");
return -1;
}
printf("line 1: %i\nline 2: %i\n\n", matrix[0][0], matrix[1][0]);
pthread_exit(NULL);
return 0;
}

it sums line 0 and 1 and puts the result on the first element of each line.
if i wanted to return accum instead of putting in the first element, how would i do that? how can i get the return value?

So I want to create an APP

Do I begin with learning bineary?

My whole post is meant for a single subhuman, nobody else has to read it.

Sup Forums cool kids club checklist

[x] hate OOP
[x] hate IDEs
[x] use only Haskell
[x] never produce actually useful software (this is important)
[x] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)

>[x] hate OOP
>[x] hate IDEs
>[x] use only Haskell
>[x] never produce actually useful software (this is important)
>[] wear knee socks
>[] tiling window manager
>[x] dark-like-my-soul customized colors
>[x] hate popular Linux distributions (because too intelligent for them)

[x] hate OOP
[x] hate IDEs
[ ] use only Haskell
[x] never produce actually useful software (this is important)
[ ] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)

The funny thing is that I'm a CS freshman.

then soon you'll be wearing knee socks like the rest of us

I want to dress like a girl too.

[x] hate OOP
[x] hate IDEs
[] use only Haskell
[x] never produce actually useful software (this is important)
[x] wear knee socks
[x] tiling window manager
[] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)

[] hate OOP
[] hate IDEs
[] use only Haskell
[x] never produce actually useful software (this is important)
[] wear knee socks
[] tiling window manager
[x] dark-like-my-soul customized colors
[] hate popular Linux distributions (because too intelligent for them)
I don't really hate or like anything. I am not cool.

it isn't elegant but make a struct with two elements: one being the address of the segment of the matrix you want to operate on, the other being an int.

Can you allocate a struct on the stack?

lmgtfy.com/?iie=1&q=https://www.google.com/search?q=Can+you+allocate+a+struct+on+the+stack%3F&ie=utf-8&oe=utf-8

Simply impossible

Yes, why couldn't you?

that's a viable option. i can use a global variable for the thread function as well(i think so). i think your solution is more elegant than using a global variable.

[x] hate IDEs

im a C++17 dev who uses macOS, vim, and YCM

im pretty boring

Enlightening stuff

Apologies
lmgtfy.com/?iie=1&q=Can you allocate a struct on the stack?

Of course not.

def makingChange(denoms, amount):
optimums = {}
optimums[0] = 0
optimums[1] = 1 # to make change for 1 cent, use a single 1 cent coin
coinCounts = {}
coinCounts[0] = []
coinCounts[1] = [1]
for i in range(2, amount+1):
next = [i-x for x in denoms if i-x >= 0]
bnext = next[0]
for j in next:
if optimums[j] < optimums[bnext]: bnext = j
optimums[i] = optimums[bnext]+1
oldList = list(coinCounts[bnext])
oldList.append(i-bnext)
coinCounts[i] = oldList

return coinCounts[amount]

for i in range(1, 101):
print(i, " : ", makingChange([1,5,10,25], i))


i felt productive today. i think i may try to implement the solution to one dynamic programming challenge every day until i feel comfortable with it, and then i'll switch to learning about stuff like red black trees and other data structures i don't know enough about.

what do you guys thi nk about that idea?

[ ] hate OOP
[x] hate IDEs
[ ] use only Haskell
[x] never produce actually useful software (this is important)
[ ] wear knee socks
[ ] tiling window manager
[x] dark-like-my-soul customized colors
[ ] hate popular Linux distributions (because too intelligent for them)

I use C++ and Ruby for the most part, wear crew socks, and use Ubuntu.

lul

>[_] hate OOP
>[x] hate IDEs
>[_] use only Haskell
>[made a website for a guy once] never produce actually useful software (this is important)
>[x] wear knee socks
>[_] tiling window manager
>[x] dark-like-my-soul customized colors
>[_] hate popular Linux distributions (because too intelligent for them)

[] hate OOP
[] hate IDEs
[] use only Haskell
[] never produce actually useful software (this is important)
[] wear knee socks
[] tiling window manager
[x] dark-like-my-soul customized colors
[] hate popular Linux distributions (because too intelligent for them)

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

>[ ] wear knee socks
No lying.

great idea. i'm also doing programming challenges everyday. the cormen book "introduction to algorithms" gives a nice view about RB trees, dynamic programming and complexity. i suggest you take a look! good luck and keep practicing!

BROTHER

Reminder that OOP has literally zero mathematical theory or rationale behind it.

Does this look like a good answer?
f: addi $sp, $sp, -4
sw Sra, 0($sp)
jal func
add $aO, $vO
add $al, $at, $a3
jal func
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra

Reminder that by making this post you have guaranteed some absolute fucking retard, who survives his day to day life by pretending the people who come up with the algorithms they use, the languages they write, and the computers they use, aren't academics and don't have masters; or at least dropped out which somehow discounts them from that, will reply with

>muh useless academia

New to rust here. Why is it not printing stuff before read_line? What am I doing wrong?
use std::io;

fn main() {
print!("What's your name?");
let mut string_input = String::new();
io::stdin()
.read_line(&mut string_input)
.expect("Invalid input");
let user_name: &str = string_input.trim();

print!("Great, what's your age?");
let mut string_input_2 = String::new();
io::stdin()
.read_line(&mut string_input_2)
.expect("Invalid input");
let user_age: i8 = string_input_2.trim().parse().expect("Can't parse age");

println!("Hello, {}({}).", user_name, user_age);
}

What's a cute anime girl like you doing in a place like this?

pls halp

Sup Forums is fucking terrible with image formats, not supporting apng, or vp9.

how the fuck does this work

doc.rust-lang.org/std/io/trait.Write.html#tymethod.flush

Because buffering.

layers

Can you guys give me a quick rundown of buffer and flush etc? How are they related to I/O streams?

>[] hate OOP
>[] hate IDEs
>[] use only Haskell
>[] never produce actually useful software (this is important)
>[] wear knee socks
>[x] tiling window manager
>[x] dark-like-my-soul customized colors
>[] hate popular Linux distributions (because too intelligent for them)

I'm practicing Java or Jawa as pajeet would call it.

What program should I write to test my profiency?

apng is a meme, and the the VP9 ABI isn't stable (1.5 broke back compatibility with all previous generations).

p
a
j
e
e
t

make a game

Make a lisp and ditch java

still shit that it doesn't support either

Like a text-based game?

No i wanna make fart apps so i can make big money

Don't get me wrong, I'd love VP9 support, but you'd then be stuck in a hell of broken support or enforcing a specific library version (which is too much for most people). In any case it's too much work and worry for the site ops.

Writing single characters or whatever at a time to a file is extremely inefficient, so they are buffered and only get written to the file when the buffer is full, or you explicitly flush it.
stdout is typically line-buffered, which means that it will write to the buffer when it encounters a newline character. You didn't write a newline, so it didn't get flushed.
If you're ever going to write something that you want to be displayed immediately and you haven't printed a newline character, you have to explicitly flush it.
None of this is Rust specific. Basically every language does it like this.

>write to the buffer when it encounters a newline character
flush the buffer when it encounters a newline character*

see see youtube.com/watch?v=dSsukh8EdWk
Note that the print!() macro doesn't flush input, println!() does

>not flush()ng
Have you ever used Ioo before, pajeet?

>>>/global/rules/6

I unironically want to be a little girl.
With programming socks, and be a LISP and C master.

It was a double pun of the highest quality

>fflush(stdin);
Non-portable microsoft-only shit.

I don't know i got it from Chegg because i couldn't understand it.

>C is a "portable" assembly guise

>programming socks
What did she mean by this?

You are a fucking idiot.

And I want to make you sit on my lap while we program together. What do you say?

kek

>meme

I read that as "Realistically spanking..."

>he calls hashes dicts

It should be able to write to memory

muh proofs!111!!1 1 1 one

no one calls hashes dicts. some people call hash tables dicts.
>calling hash tables hashes

S-Sure.