/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Attached: remember - no objects.png (1280x720, 1.26M)

Other urls found in this thread:

wiki.nesdev.com/w/index.php/Nesdev_Wiki
cs.rmit.edu.au/online/blackboard/chapter/05/documents/contribute/chapter/05/linear-probing.html
blog.rust-lang.org/2018/03/12/roadmap.html
github.com/Mark-Weston/run
streamable.com/t3rot
doc.rust-lang.org/reference/linkage.html
insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
twitter.com/SFWRedditImages

Something that will get me a job hopefully. I was thinking something like an arduino server with some basic functions. Or II could make a javascript game. On vacation from my job at bank of america for a week and I want to create something so i can get a damn tech job.

Can someone explain logging and verbosity to me? Do you really have to add if-else statements after every block, or even line, of code? 5, 10, 100, 1000 events - how about I'm logging none of them

Third for dependent typing

Attached: 1511639106156.png (410x313, 39K)

the fuck is that?

STRONG static typing.

STRONG static typing.

What language though?

Looks like Agda.

Use monads to have nice, implicit, but controlled logging

Working on a VR sdk for Unity, since VRTK is shut down and all..

>john carmack
>remember - no objects

ok

ok?

>/

Attached: look.jpg (249x250, 7K)

Rate my code. Seriously looking to improve and seeking advice on anything that stands out as dumb or shit (inb4 js is dumb/ shit).

Attached: temp.jpg (1442x916, 156K)

Trying to multiply my transition matrix by a "rank" matrix in C++ and it's busting my brain.

Will Haskell2020 get dependent typing?

What is /DPT/ opinion on Elm?

Every day I think about learning how to romhack or write an OG retro game on NES or GBA
Every day I find no resources other than some guy who uses C and cc65 instead of actually telling me how this shit works

Essence of linalg by 3b1b

Are you an actual retard?

wiki.nesdev.com/w/index.php/Nesdev_Wiki

which vid

The whole series, it's worth it if you've never taken a linalg course.

alright, I'm pretty math-retarded so why not

reviewing offshore developer's code, thinkin bout a zeromq project

Attached: 2018-03-13-160906_1480x1024_scrot.png (1480x1024, 150K)

Your logging function should handle whether to display it or not

I'm having some trouble with fmap in Haskell.

I've got a value that's a Maybe, and a function that takes the value, so I'm using fmap on the function and value, but it's telling me
it's Expecting type Maybe expr, but it's actual type is Maybe (Maybe expr), I'm not sure how that's happening.

item = head exprList --exprList is coming from a function that returns [Maybe expr]

case name of
"foo" -> fmap getFirst item

getFirst :: expr -> (Maybe expr)
getFirst (List (a:more)) = Just a
getFirst _ = Nothing


the function this is in returns a Maybe expr, and just testing what "item" is, the compiler does seem to think that "item" is a Maybe expr, so I'm not sure why when I apply fmap it thinks it's a Maybe Maybe expr. Am I misunderstanding how to use fmap? I'm playing around in the GHCi console and doing it manually seems to work and do what I expect.

What editor is this?

>wiki.nesdev.com/w/index.php/Nesdev_Wiki
That site fucking sucks. Where is my step-by-step edx course by some famous rich asian.

Visual studio code. It's actually sick. Fuck the liars that told me it's a 30GB install.

>jquery
wut

Because getfirst takes typeexpr but you are giving it maybe expr, you need to use the >>= function to pass the value to the function.

visual studio code! it's great.

ikr, but hey at least I don't have to maintain this shit

not necessarily, in c i use:

if (IS_GLOBAL_DEBUG_ENABLED && IS_LOGGING_ON && dWarn < minLogLevel) fprintf(stderr, "[warn] hi this is warn\n");

but I am using fmap in that code.

Also what is expr? All types in Haskell start with a capital case

Its got a longer name so I replaced it just to make it simpler to read here. And I am using fmap in that code

I'm working on my github portfolio right now, what's the best coding style to get hired? I hate allman so i'm planning on just using k&r for everything, is that a bad idea?

People aren't going to hire you based off of your bracing style.
Just write code which isn't shit.

Try (>>= getFirst) as the function argument for fmap

K&R is ultra outdated, and most people won't care what coding style you're using because they companies force you to use their coding style, all they may care about is that your coding style is clear and consistent.

How can a bracing style be outdated?
It also the "base" for the Linux Kernel Coding Style, which is used extensively in open source C stuff.

Attached: mrdoob.jpg (498x353, 26K)

No idea what the fuck is going on now

fmap (>>=getFirst) item

gives the error:

Expected type: Maybe (Maybe Expression)
Actual type: Maybe Expression

fmap getFirst item

then the error is reversed on what it's expecting

Expected type: Maybe Expression
Actual type: Maybe (Maybe Expression)

What fresh hell is this

programming socks
>check
skirt
>check
cute t-shirt
>check
pink panties
>check
astolfo wig
>check
programmers plug with pink tail
>check
SICP
>check
All systems ready. Now I just have to write a project in c# that can send/receive data without losses that uses an array, multithreading, inheritence, async/await, exception handling and reflection.

Seems easy enough I'm just going to write a UDP chatroom.

Attached: images (99).jpg (225x225, 11K)

You're missing the noose and stool.

pls, no bully.

What features do you like that aren't features in every editor?

Your types arent what you think they are. You needto postthe whole error message to see what is wrong.

>VS Code
>Emacs, vim, spacemacs, etc. exist and don't require 4gb of ram to run
>proprietary
baka desu senpai

Attached: 1490515054961.gif (400x400, 1.47M)

pics?

Attached: Tomoko.jpg (442x351, 82K)

I don't see much reason for the Master class to keep state for the window width and height aside from the Renderer. Its pattern of handling resize events and initializing the renderer with window dimensions seems fine enough.

>plug
everything but that desu sensation is too distracting uwu

Attached: dpt.png (581x1133, 616K)

I write a macro that takes the error code, checks it and contains a printf which gives line, file and error message (through something like geterror usually).
For logging a vast variety of (non error) events you have to define you should probably do something clever.
Seems like a good idea to put the logging code with the functions passing events.

>What are you working on, Sup Forums?
Working on a python script to glitch images

Attached: test.jpg (850x1015, 124K)

pretty excited that this works

not fully featured yet, but it's got a tokenizer, parser, codegen and bytecode vm in 1100 lines of C.

Attached: compiler.png (466x940, 76K)

>user accidentally glitches his manga collection

I need to learn Haskell in a week. Is learn you a haskell for great good the way to go?

That book has a lot of fluff, you can read it in a day. It's an ok first book but you need to read other books as well.

how do i make a hash table with linear probing in java?

O god I once made a python script to automate some pre build shit like converting and moving around textures and other resources from my art folders, something went wrong and I deleted half of my code, half of my art, the python script itself, and corrupted my git suppository. I had to go back to a very old remote git.

gotcha, thanks. is real world haskell a good follow-up?

cs.rmit.edu.au/online/blackboard/chapter/05/documents/contribute/chapter/05/linear-probing.html

>corrupted my git suppository
uh user that's not where the code is supposed to be stored

how does one calculate what the hash code for each key should be?

Attached: hash.png (634x398, 215K)

it literally says right there. h(x) is the hash code

h(x) = x%M (the remainder after dividing x by M)

>Not keeping your code with you at all times

Attached: image-10.jpg (856x1089, 92K)

He's into functional programming nowadays.

right, I'm dumb.
so when I add a key to an element in the array it should be according to the value given by h(x), which would be the array index.
and because its linear probing, id linearly move to the next array element if its full

I'm making a function to make queries on a cmis repo, basically it can search for a file/folder, inside a folder and/or its subfolders, for a file contents, etc.

Now I can't decide for the best course of action. Should I make one big fat function that handles all possible queries, and then smaller ones who just call the fatass with default parameters for ease of use or even just handle the rest on front-end ?
Or make the different possible queries (search_by_name_in_folder, search_by_date_in_tree) and handle on the front-end which one to call ?

Attached: __iwakura_lain_serial_experiments_lain_drawn_by_haraguro_panda__d95b58a529e2e0f13fd55234cb3b4d4d.jpg (800x1200, 855K)

I am trying to get into javascript.
Can anybody please explain this 'return () => local;' line?
The book I am reading introduced it out of nowhere and I can't find useful information online.

function wrapValue(n) {
let local = n;
return () => local;
}

let wrap1 = wrapValue(1);
let wrap2 = wrapValue(2);
console.log(wrap1());
// → 1
console.log(wrap2());
// → 2

Google the syntax.

I'm no JS-fag, but I believe it's equivalent to
function () { return local; }

blog.rust-lang.org/2018/03/12/roadmap.html
> Ownership system improvements, including making borrowing more flexible via “non-lexical lifetimes”, improved pattern matching integration, and more.
> Trait system improvements, including the long-awaited impl Trait syntax for dealing with types abstractly.
> Module system improvements, focused on increasing clarity and reducing complexity.
> Generators/async/await: work is rapidly progressing on first-class async programming support.
> In addition, we anticipate a few more major features to stabilize prior to the Rust 2018 release, including SIMD, custom allocators, and macros 2.0.
Noice.

A little 3D game in C without using an engine/framework
github.com/Mark-Weston/run
streamable.com/t3rot

Attached: 2018-03-13-110035_1366x768_scrot.png (1366x768, 60K)

>Still no stable ABI
There is still no reason to take that shit seriously.

Rust has stable ABI, it's called the system ABI of the platform, some people call it the C ABI for historical reasons.

>Can't even dynamically link libraries written in the same language without writing a C FFI
Are you fucking serious?

Attached: 1390404444101.gif (480x480, 1.02M)

>C ABI for historical reasons
It's because the fucking ELF file format is defined with ANSI C language you retarded rustcuck

You're moving the goalposts, you can dynamically link libraries, but the Rust-specific ABI isn't stable.

>but the Rust-specific ABI isn't stable
>>libraries written in the same language
That's what I said.
Go dynamically link a Rust library from a Rust program using its Rust interface.
The fact that you can't is a fucking joke.

yeah, I was able to figure it out.

() => local represents a function and this function will be returned and not called yet.

You can produce and link Rust-specific dynamic libraries, m8: doc.rust-lang.org/reference/linkage.html , see dynlib.

insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
Rust is the most loved language according to the Stack Overflow survey 2018, the third year in a row. I mean, seriously, if you still haven't felt for it, there's something wrong with you.

Does _anybody_ use that? Why do I need to re-compile literally everything when I use libraries in Rust?

>Rust doesn't have a stable ABI!
>Yes, it has.
>But you can't dynamically link Rust libraries!
>Yes, you can.
>B-but no-one uses it!
C-tards are pathetic.

How do I correctly initialize a 2D array of const chars in a C++ constructor?
Normally I just use
const char list[2][4] = {"foo", "bar"};

But I can't use something like
Class::Class() : list({"foo", "bar"})

to initialize it if it were a member of the class.

Attached: 129643499378.gif (125x94, 461K)

>>Rust doesn't have a stable ABI!
>>Yes, it has.
No, it doesn't. You still can't have plugins and shit like that, and I'm going to assume that all of those libraries have an extremely high possibility of breaking when you upgrade your compiler.
>>But you can't dynamically link Rust libraries!
>>Yes, you can.
I was proven wrong with that one, but I didn't know about it, because it seems that literally nobody is using it.
Everything Rust uses Cargo, which seems to only be capable of downloading/recompiling all of the dependencies.

>caring what soyboys think

Attached: smug_laugh.png (782x1021, 330K)

The only reason Rust has a stable ABI is because there's exactly one implementation of it, lmao.

struct Foo
{
const char list[2][4];

Foo(): list{"foo", "bar"} {}
};

Its cool and all, but I can see you really don't like error checking, because there is none in that application.

I should have mentioned that I'm not using C++11, which means that that initialization method is invalid.

Then you're fukt. Initialise it manually in the constructor body.

Reposting for answers and advice

I know. There are two excuses why I didn't do that.
1) OpenGL sabotages any kind of sensible error-checking. Any OpenGL function call can fail with GL_OUT_OF_MEMORY and leave undefined state behind it, so the only reasonable behaviour is to abort.
This means I would have to check for errors almost after every line in renderer.c and that would double the size of the file with no gain.
2) This is a game. This means that both the production speed (even with C) is important (I don't want to spend half a year on this) and it's not security-critical.
So I could have done SOME error checking, but in my opinion is better to aim at completely robust application with all error codes checked, or no error checks at all, which is what I chose. Checking for errors selectively (let's make a robust primitive generator, but completely ignore the renderer, and check a few corner cases in window maker) seems wrong to me, although I might be wrong.

Which means that the array has already been initiated and I'll have to use strcpy on each index.
Fuck this shit.