/dpt/ - Daily Programming Thread

Old Thread: What are you working on, Jow Forums?

Attached: dpt.png (1550x1123, 890K)

Other urls found in this thread:

github.com/jonschlinkert/is-true
dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html
archive.is/dAZWO
lmgtfy.com/?q=java stream scanleft
stackoverflow.com/questions/34197567/what-is-the-equivalent-of-haskells-scanl-in-javas-streams
lmgtfy.com/?q=java parallelprefix
dynasty-scans.com/chapters/hatsu_kokuhaku_ch04
archive.org/stream/fortraninteracti00cuccpdf/fortraninteracti00cucc#page/n47/mode/2up
pastebin.com/srp30ws4
hackerrank.com/challenges/encryption/problem
twitter.com/SFWRedditImages

Looking for entry-level positions in the area, and trying to come up with a fun project for in the meantime.

This gets gayer every thread

post your problems fagit, quit avoiding the inevitable

Anime losers are the worst programmers

trying to define neural networks as a traced symmetrical category and then use that as a semantics for linear logic in Haskell. I'm hoping it will lead to a very intuitive DSL for defining learning algorithms

I'll repeat my question. I love repeating questions.

Best language for developing a websocket server today is ...?

Attached: websocket_logo_white.png (512x512, 11K)

In C++ is it a bad idea to pass nullptrs willingly?
I have a piece of UI that I want to update with information if a pointer is valid, but I want to hide it if there's nothing selected. So instead of having a
void ShowFrame(ptr* InPtr)
void HideFrame()

I would have the ShowFrame method and if it's a nullpointer just hide it. Is there any reason why this is bad? It feels more natural to do it this way

Is this the power of javscript?
github.com/jonschlinkert/is-true

Depends on your use case. Node.js used to be one of the only ways but now there's a bunch of integration with other technologies.

Pretty pointless, yeah, but if you read the code it's at least not ===true or something. It has logic for negation that's probably meant for CLIs or something.

kotlin
you can call any java libraries you want

Just in case anyone else wants to play with freestanding programs. Consider my argv+env program to be in the public domain.

/* gcc -nostdlib -ffreestanding -Os -o s s.c && objdump --disassemble s && ./s argv1 argv2 argv3
* argv:
* ./s
* argv1
* argv2
* argv3
* envp:
* LANG=en_US.UTF-8
* DISPLAY=:0
* [...]
*/

long sys();
int main(int, char **, char **);

void _start(void)
{
register long argc;
register char **argv;
register char **envp;
register int r = 0;

__asm__
("movq 0(%%rsp),%0" : "=r" (argc));

__asm__
("leaq 8(%%rsp),%0" : "=r" (argv));

envp = argv + argc + 1;

r = main(argc, argv, envp);
sys(60, r);
}

long len(const char * str)
{
const char *s = str;
for (s = str; *s; ++s);
return (s - str);
}

void wstr(char * s)
{
sys(1, 1, (long) s, len(s));
sys(1, 1, (long) "\n", 1);
}

void wtstr(char * s) {
sys(1, 1, (long) "\t", 1);
wstr(s);
}

int main(int argc, char **argv, char **envp)
{
char **p = argv;
wstr("argv:");
while (*p) { wtstr(*p); ++p; }

p = envp;
wstr("envp:");
while (*p) { wtstr(*p); ++p; }
return 0;
}

long sys(long n, long _1, long _2, long _3, long _4, long _5, long _6)
{
register long r10 __asm__("r10") = _4;
register long r8 __asm__("r8") = _5;
register long r9 __asm__("r9") = _6;

__asm__ volatile
("syscall"

: "=a" (n)
: "a" (n),
"D" (_1), "S" (_2), "d" (_3),
"r" (r10), "r" (r8), "r" (r9)
: "rcx", "r11", "cc", "memory");

return n;
}


dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html
archive.is/dAZWO

Thanks for being here for me guys. I was getting so frustrated with this assembly function I was almost giving up on the thing, but it works now!


Next step is the rest of the SysV AMD64 ABI. I should probably zero the base pointer as suggested by the document, to mark the bottom of the stack. Then I guess it's time to explore all that auxiliary vector stuff. I'm not sure if that init/fini stuff is so useful though, never used it.

>What are you working on, Jow Forums?
Some audio shit for windows

It's fine, but there are other options, such as:

std::optional
std::unique_ptr if you're passing ownership you may as well do this
std::shared_ptr if you can have multiple owners
std::weak_ptr if you have multiple owners and know that you may have a dangling pointer situation, and only need to read/store reference to and not own (thus check if it's gone at some point).

Attached: write-it-in-rust.jpg (480x800, 107K)

Could someone link the discord server for me?

Depends on your style of C++. "modern" C++ more or less does away with pointers entirely, but if libraries you use don't play ball you're back to using pointers in your code again

Explain.

I know what a symmetric category is.

>Best language for developing a websocket server today is ...?
I honestly would use Go.

lmgtfy.com/?q=java stream scanleft
top result:
stackoverflow.com/questions/34197567/what-is-the-equivalent-of-haskells-scanl-in-javas-streams
>Arrays.parallelPrefix(arr, Integer::sum);

What do you mean developing a websocket server? Like from scratch, or using a lower level library?

Because it probably makes the most sense to use uws, and see if there are bindings for your favorite server/language. The creator got upset a few weeks ago and deleted the git repository for the Node.js bindings, but the NPM package is still up, and he said he may still publish updates in the future. Plus there are still existing forks of the bindings, and the docs are basically the same as ws with a few caveats. So Node.js with uws is still probably one of the most viable options imo.

But if you find a well maintained uws binding library for your favorite backend lang, then I'd say go for that. Or if you know how, and you're motivated, write your own bindings. Probably not easy, but might be worth the effort, since the stats uws seem impressive.

I'm implementing a paper that defines a category Learn where the objects are euclidean spaces and the morphisms are learning algorithms (for example a network and backprop). The authors postulate that this category might have a trace, which if you think of a monoidal string diagram is just taking the input of a morphism back into the morphism itself. The trace is a way of defining "loops" or feedback. Coincidentally any symmetric monoidal category with a trace is a semantic model of linear logic.

Null object pattern
Tagged union (with std::variant)

I'm just here to say that I'm writing my masters thesis in my underpants and there is nothing you can do to stop me.

>taking the input of a morphism
sorry, output of a morphism*

what manga oniisan?

underpants master race

>);
Isnt that a 3rd-party Library method?

lmgtfy.com/?q=java parallelprefix
gee, I wonder if it is

.NET Core runs on all platforms and it's fast, well-maintained, and easy to use.

Just use C#, the ease of writing it (supports relevant programming paradigms at this point) in combination with the performance you get is really hard to surpass.

左のページを見て

this is a christian board, no swearing pls

HIDARI NO PEJI WO MITE

>HIDARI NO PEJI WO MITE
Did you mean 左 の ぺじ を みて?

C#'s async is neat. But that's about it desu.

u will regret this

>Look at the front of the left

no bully plz

Attached: SAM_7910.jpg (1066x1600, 272K)

christ, I've used a fair amount of haskell and do hobby ML but I don't have a goddamn clue what you're talking about

not sure where you get "front" from but ぺじ isn't the same as ページ and doesn't make sense. Probably switched inputs on the keyboard at the wrong time or something. It's really "look at the left page"

Attached: 63b.jpg (1000x1000, 314K)

Go, Scala, Clojure depending on your autism.

nah m8 I just let jewgle fuck it up 4 me

>Scala
>pragmatic technology
what year is this?

Java/Kotlin + vert.x

unleash your inner neet weeb and learn japanese user

you can even hold a job and program, you just gotta come home at the end of the day and sit down in your underpants with a pocky in hand

like this guy

I loved my college computer architecture course, and I know a fair amount of C++ and Python. What are some projects for me?

ERP with a web front end.
In python.

What aspects of it did you like?

>neet weeb
>hold a job and program
seemed more like a negative for a coworker of mine, desu

Learning about different models of CPU pipelining, and writing MIPS assembly. I guess I could do stuff with memory, I know it's common to write a memory scanner

Do you guys put your projects on your resume and what site do you use to upload your projects? I want to put my projects on my resume but dont' know which site to upload them to.

Attached: 1512423552703.jpg (250x248, 5K)

github

I can imagien it looks like that from the outside, it's just a lot of technical jargon, it's really quite intuitive if you've familiar with the concepts.

noob here, what does this do?

Literally me

One idea is you could write code generation for a really simple compiler. Three address code looks pretty much like MIPS assembly. Make even just a visualizer for expressions to start simple, it could be like x==1+2*y turns into
mult t1, 2, y
add t2, 1, t1
subu t3, x, t2
sltu t4, 0, t3


It's hard to make a project around CPU pipelining but you could learn Verilog or VHDL and make some kind of simulated hardware project.

okay link to the paper at least? is it on arxiv?

I don't have a single project online on shithub and work for one of the largest companies in the world.

Don't feed the shithub machine.

Agreed ( as the guy who asked for the explanation).

It's fairly natural to me as someone who has worked with categorical quantum mechanics. The category of vector spaces is dagger symmetric which implies that it is trace symmetric. Neural networks are basically generalizations of linear maps with some extra nonlinear stuff happening, so them having a trace is reasonable.

That is a really cool idea, thanks user. Would it be feasible to write something that compiles to MIPS, or do you think Verilog or VHDL is better?

no one said it's necessary but in today's world it sure does help a lot. similar employment situation for me and I'm pretty sure github was a big factor

>Would it be feasible to write something that compiles to MIPS
That's basically the easiest still used architecture around, and I would call amd64 feasible too so go for it.

dynasty-scans.com/chapters/hatsu_kokuhaku_ch04

Although, in categorical quantum mechanics, the monoidal product is the tensor product, and the trace means taking the partial trace over one factor. The natural product of two neural network is the cartesian product.

One possible way to circumvent this might be to use something like tensor networks for "neurons" instead of regular NN's, but that's pretty different from mainstream algorithms.

But how would you show your past projects to your employers?

Great, thanks! I'll definitely try it out

>the trace means taking the partial trace over one factor
Totally different poster here. I don't know much about traces. Related to partial differentiation?
∂(A⊗B) = (∂A⊗B)⊕(A⊗∂B)

I have this excersise Jow Forums:

One classic method for composing secret messages is called a square code.The spaces are removed
from the english text
and the characters are written into a square (or rectangle). For example, the sentence "If man was
meant to stay on the
ground god would have given us roots" is 54 characters long, so it is written into a rectangle with 7 rows
and 8 columns.
ifmanwas
meanttos
tayonthe
groundgo
dwouldha
vegivenu
sroots
The coded message is obtained by reading down the columns going left to right. For example, the
message above is coded as:
imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau.

How would i go about implementing this in C?

Why can't I be a hacker in common lisp? Isn't lain a hacker???

Attached: sigh.jpg (676x676, 37K)

nigga who is lain anyways

you can't reverse engineer anything meaningful with it.

hello newfriend&/normie.

dumb frog poster

fuck off retard

Yeah, it's very feasible, especially compared to x86 due to how similar it is to three address code. Most guides will teach you how to generate what's basically MIPS.

There are a lot of different learning resources out there -- one good one is the Dragon Book, but for any given use case only a subset of the chapters are worth reading. For code generation it's got its own section which teaches you how to make 3 address code.

Attached: codegen.png (444x345, 35K)

hey senpai, what does it mean when your program compiles but when you execute the window crashes immediately?

you fucked up big time

*inlines ASM*
Ah yes, another job well done by Lisp!

>what site
cockhub, obviously

>ifmanwas
> meanttos
> tayonthe
> groundgo
> dwouldha
> vegivenu
> sroots
use code tags for fucks sake

> (You)
>you can't reverse engineer anything meaningful with it.

How do I learn to hack in lisp

Tab is 8 characters wide.
Intend and align only with tabs.
If you do anything else you are literally soycuck.

>What are you working on

Working on my little battalion management program. So far I've managed to create a main menu and one sub-menu for managing people information. Still a long way to go.

I got the project idea from here:
archive.org/stream/fortraninteracti00cuccpdf/fortraninteracti00cucc#page/n47/mode/2up

Attached: Kazam_screencast_00000.webm (659x413, 197K)

What do you mean by "hacker"? Like in the original sense of the word, like an expert? Or in the newer sense of the world, like someone who penetrates systems?

FORTRAN

>54 characters long, so it is written into a rectangle with 7 rows
>and 8 columns.
what's the algo for deciding how many rows and cols? If that's not sufficiently well specified, your algo won't produce correct results.

>i [...] like someone who penetrates
bottom bitches pls go
this is a masc only thrad

yup that's what I'm having trouble with, the author of the excersise doesn't specify that.

>What are you working on, Jow Forums?

Exploring the deepest, darkest corners of Racket.

Attached: s.png (1680x1050, 34K)

post text, so we can find a less shit source for the problem

Rate my fizzbuzz. It doesn't require conditional statements :3

check :: Int -> Int -> Int -> String
check 0 0 _ = "FizzBuzz"
check 0 _ _ = "Fizz"
check _ 0 _ = "Buzz"
check _ _ a = show a

makeFizz :: Int -> String
makeFizz x = check (x `mod` 3) (x `mod` 5) x

fizzbuzz = map makeFizz [1..100]

main = mapM_ putStrLn fizzbuzz

>patmat
>not conditional
have you considered a career in law?

pattern matching is conditional statement

It's basically asking you to do two things:

1) write code to construct/deconstruct a matrix out of a string
2) transpose a matrix of characters

Then your program constructs the matrix, transposes, and deconstructs, in that order. Not that it's any help but I wrote it in Haskell for fun:

import Data.List
chunksOf n xs = takeWhile (not . null) $ map (take n) $ iterate (drop n) xs
block s = concat . transpose $ chunksOf w s
where w = ceiling . sqrt . fromIntegral $ length s

Pattern matching isn't a conditional statement though.

Here's the full explained excersise: pastebin.com/srp30ws4

It's not a conditional *statement*, but it's a conditional structure. It does the same thing as case.

How do I iterate over a key-value pair array in Javascript, such that I have access to both the key and the value?

>no gui
GUIs are what separate professional programmers from amateurs.

I see. In that case, let me suggest
>have you considered a career in law?

What's the structure?

Like [['key',1], ['key2', 2]]?

>GUIs are what separate professional programmers from amateurs.
How so?

No, it's an associative array.

>jewgle "the characters are written into a square"
have a look at
hackerrank.com/challenges/encryption/problem
seems like a more precise statement