/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: Χριστὸς_ἀνέστη.jpg (800x535, 76K)

Other urls found in this thread:

axisorder.com/join/
man7.org/linux/man-pages/man2/execve.2.html
linux.die.net/man/3/execl
developers.google.com/apps-script/reference/spreadsheet/
twitter.com/NSFWRedditGif

Thank you for using an Easter image.

Second for chocolate.

Attached: 1439648511159.jpg (469x469, 116K)

Mini master race

hello senpai,

if you copy and paste random bits of code, can it fuck up your program, even though the snytax of the code itself is free of errors?

Want proper parametric polymorphism and multiple dispatch in your dynamic language? Use Julia.

Attached: Julialogo.png (320x216, 11K)

Yes when you need to change every appearance of it and you forget a spot.

Working on my 80386 pc emulator, trying to figure out why windows 3.1 won’t boot in enhanced mode.

Attached: F0C59FBC-11BC-41E4-8C78-A643458DEFA0.jpg (750x770, 388K)

Ugh, Kivy's DSL really shows Python's limitations. It has the exact same syntax as Python but with different control statements.

If Python had macros or something similar, it could have been plain Python code, instead of separate files that have to be parsed and which can't include Python subexpressions. Python is honestly really terrible at edsl's.

Wanted to make Rusty:Eyes more lightweight by dropping any unnecessary dependencies.

Went from using an entire Game Development library for its 2D Graphics Library to just a 2D Graphics Library because I was pulling in an entire house when I only needed the kitchen sink. Then got rid of GTK to use the Windows API directly instead because all I want is some running water.

Footprint of the compiled program dropped from 2.3mb~ to just under 250kb but now I don't really have a program anymore. All it does is let you select a file to open and that's it.

Hope to get it painting tonight so I can start implementing some of the basic functionality again.

>Use julia
axisorder.com/join/

It's gimped by design. Guido von Python hates macros, lambda functions, basically anything lispy or FP. He even tried to remove lambda functions from the language.
It's one reason why I go to R, Julia, or Ruby if I can help it.

Continuing work on my _start function. Now I'm trying to minimize the number of inline assembly calls needed to get all the data I need. I thought about taking the stack pointer and putting it in a unsigned long pointer, then setting argc and argv through that pointer.

It's not working though. I'm guessing all the local variables are making the compiler fuck with the stack. Let me check the disassembly.

If it is mostly inline asm (my wild guess), store the variables in registers and turn on optimization to directly use the args from the stack without moving the stack pointer or copying anything.
GCC, Clang or MSVC btw?

dummy here
the heck is the difference between uml and that other one we use in databases er model or whatever its called
and where can i learn uml online for free
taking software engineering 1 course and this professor cant explain for shit

I wrote a program in c# with selenium that searches for random URLs on Tor, if it finds a connection it will save the header, footer and URL into a text document then continue its search.

Attached: 1517265449450.png (1360x768, 1.56M)

UML is for object instances and classes and OO relations. Databases ER model isn't and maps relational tables to each other.

Careful with the browser settings
>win32
lol pic related rip user

Attached: 1o5dl8.jpg (600x369, 46K)

unsigned long *rsp; // sizeof long == sizeof void * == 8 == register size
long argc;
char **argv;
char **envp;

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

argc = *rsp++; // when process starts, rsp points to argc
argv = rsp; // rsp + 8 points to argv
envp = argv + argc + 1; // envp is after argv

sub $0x8,%rsp
lea (%rsp),%rax
mov (%rax),%rdi
lea 0x8(%rax),%rsi
lea 0x8(%rsi,%rdi,8),%rdx
callq 420


Aw come on. Why does it sub 8 from rsp? WHY? It doesn't even use the stack space for anything! It's like it wants me to go back to glibc.

I'm using GCC and compiling with -Os, which enables most stuff from -O2 and also reduces code size.

It uses the stack space to allocate the return value of a call to fork(). You've obviously encountered undefined behavior.

>I'm using GCC
Are you stuck in the last decade? Upgrade to clang already, user.

How do I implement a binary tree if I'm going in blind? I don't even have am example of someone else doing it.
How do I break down an alien concept into logic and then into instructions in the language of my machine?

Attached: 1480477348879.jpg (692x494, 100K)

Actually, I plan on supporting clang in the future. My makefile is written so as to enable me to switch compilers.

Some of my code relies on GCC specs files though, just like musl and its musl-gcc wrapper. Clang doesn't seem to have that feature.

W-What?

How do you research?

Any answers?

Is that actually practical? I have trouble imagining that's an effective way to index. How many URLs per second are you doing on what sized sample space?

What language are you using? The two most common ways to do it is with tagged unions (and pointers in languages where the former are value types) or classes.

GCC is perfectly fine. In fact they got their act together and improved after clang smoked them initially.

Why not both? Clang for debugging and good error messages, and whichever performs better on benchmarks for release.

>whichever performs better on benchmarks for release
So i2c always?

How do the teams work, and why is chocolate superior?

the teams are definitely IP based, t. shitty ISP that always changes way too fucking often. creme->mini->nigger team so far.

I only really care for code correctness. These compiler developers took the standard and made it out to be some letter of the law thing.

What undefined behavior, specifically? I am compiling with -fno-strict-aliasing.

Hiroshimoot is a BBC/cuckoldry fetishist
That's why team black and team cum are #1 and 2, and team mini white dicks is team #5

>How do the teams work
(3rd octal of your IP + 4th octal of your IP) % 5 example: 112.112.133.133 -> (133+133) % 5 = 266 % 5 = 1
0 = peep
1 = choc
2 = cream
3 = peanut
4 = mini
>and why is chocolate superior?
They are not.
Heil Mini

And I messed up my code ending block

jesus christ @ racket's MATCH
can haskell even compete?

lisp and haskell are both shit

What does that even do?

YOU TAKE THAT BACK

Attached: hask.png (1000x1000, 32K)

You need gonads to compose monads, buddy. And lisp is p/ based too.

Can someone explain what stream in seppels is?
if I have a fstream open a file, will the disk read happened during the fstream::open() or during the character / array extraction?

>He even tried to remove lambda functions from the language.

God damn so that's why Python has that castrated piss poor excuse of a lambda, it's basically a return statement.

It can match against anything value ever, of course, given the values can be represented with text.

Kind of interested in writing a DAW to be just how I need. I have a pretty specific workflow that is clunky in everything I've tried.

register unsigned long *rsp;
__asm__("movq 0(%%rsp),%0": "=r"(rsp));
exit(main(*rsp, rsp + 1, (rsp + 1) + *rsp + 1));

sub $0x8,%rsp
mov (%rsp),%rsi
mov (%rsi),%rdi
lea 0x10(%rsi,%rdi,8),%rdx
add $0x8,%rsi
callq 420

Wish there was a way to make GCC explain to me why it's generating certain code... I don't know what else to try.

Also modelling e.g. tube amps seems pretty interesting.

Should I use libvorbis or stb_vorbis.c?

>Kind of interested in writing a DAW
god-speed,god-sanity,-god-patience lad. Audio work is fucking tedious.

Trying out atomics in C11.

Why does this NOT work:

static _Atomic size_t lock;
static int global;

static void increment_lock()
{
size_t unlocked = 0;

while (!atomic_compare_exchange_weak(&lock, &unlocked, 1));
global++;
atomic_store(&lock, 0);
}


When this does?

static _Atomic size_t lock;
static int global;

static void increment_lock()
{
while (atomic_exchange(&lock, 1));
global++;
atomic_store(&lock, 0);
}


This is run inside a bigger function that just calls it 1 million times in each thread.

Is there a way to use other programs inside of a program? I've heard that you can use the system command in C but it's considered bad practice. What's the proper way to do it, if at all.

syscalls

Anything in particular?

what team am i

man7.org/linux/man-pages/man2/execve.2.html

linux.die.net/man/3/execl

These resource helped me in my systems programming class

Discrete structures brah. learn a little bit of elementary cs math, it goes a long way

Is it me or is DirectX 12 just an awful API

DirectX and OpenGL have always been awful. Always.

Hey Jow Forums, give me some advice here. I want to code something that can do things to youtube's player while also talking to a python script on the computer doing something else dependent on what the youtube player is doing. I'm not experienced with this kind of thing, so I'm wondering what the best way to go about it is - what seems most obvious to me is making a JS extension that can mess with the youtube player and then talk to the python script, but is there anything else I could do that might be less convoluted?

Jesus christ. I see a bunch of resumes applying to my company and a lot of pajeets have experience at Intel. How shit is it to work there? I can't even imagine.

Attached: file.png (1200x796, 64K)

>based christos OP.

Happy easter /dpt/, please rate my matrix-multiplier (done in python because its easy and direct)
for i in range(len(L1)**2):
print(L1[i%len(L1)]*L2[i//4])

read the docs, dumb nigger.

Why did Python get so hyped compared to Ruby? Not saying that Ruby is perfect by any means, but it's definitely much more elegantly designed than Python. Was it because of Rails hijacking it?

Python has like a decade headstart. People were already using it in the 90s and early 2000s, while Ruby only showed up on people's radars after Rails in 2006.

ive been learning C for the last few months, I'm fairly comfy now. but I need a project, what do you goyim recommend?

rewrite linux kernel in c

I asked this in the stupid questions thread already but is python a good place to start learning languages?

MIDI stuff combined with a GUI in Java to be brief.

I hate using Java but seriously, use this programming language if you ever want to work with MIDI output and retain cross-platform functionality, unlike C++ where your best bet is importing a library made by some Japanese dude, this programming language can do MIDI natively and it's so damn easy too.

On that note, any other programming languages out there that have it easy for working with MIDI output? Such as playing a file and working with current MIDI events.

How is portable C++ MIDI difficult to do at all? use rtmidi.

Hex dump and byte-wise editor to write do some cooleo RAM-Modding.

Yes. Almost any language is, desu.

Well actually I was using OpenMidiProject which was actually the thing I needed, but honestly both libraries are a total pain to use.

Thanks user

If working with raw message bytes is an inconvenience for you maybe. It was never a problem for me and I have no issue with rtmidi.
I have worked with MIDI for so long, I speak it almost fluently at this point.

Playing around with C's goes-towards/tends-towards operator.

For example. as i tends towards 0, print i:

#include

int main() {
int i = 10;
while (i --> 0) {
printf("%d\n", i);
}

return 0;
}

>Playing around with C's goes-towards/tends-towards operator.
It's April 2, stop that

But user, try it. It works.

what the fuck lol. thats two separate operations.. what exactly are you trying to learn here?

>what exactly are you trying to learn here?

I'm not trying to learn anything. I'm demonstrating my knowledge of the hidden features of C.

while (i-- > 0) is not a hidden feature

while (i --> 0)

the real tragedy is python detracting from perl (5 and 6)

while (i

>#include

Attached: vomit.jpg (650x650, 90K)

pure autism, cin and cout in pure C macro

#define FORMAT(x) _Generic((x), \
char: "%c", \
signed char: "%hhd", \
unsigned char: "%hhu", \
signed short: "%hd", \
unsigned short: "%hu", \
signed int: "%d", \
unsigned int: "%u", \
long int: "%ld", \
unsigned long int: "%lu", \
long long int: "%lld", \
unsigned long long int: "%llu", \
float: "%f", \
double: "%f", \
char *: "%s", \
void *: "%p")

#define SCANF_PTR(x) _Generic((x), \
char *: (x), \
default: &(x))

#define PRINT_1(x) printf(FORMAT(x), x), printf("\n")
#define PRINTL_1(x) printf(FORMAT(x), x)
#define SCAN_1(x) scanf(FORMAT(x), SCANF_PTR(x))

#define CAT(x, ...) PRIMITIVE_CAT(x, __VA_ARGS__)
#define PRIMITIVE_CAT(x, ...) x ## __VA_ARGS__

#define NUM_PRIV(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, n, ...) n
#define NUM(...) NUM_PRIV(-1, ##__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway)
#define FIRST_HELPER(first, ...) first
#define REST(...) REST_HELPER(__VA_ARGS__)
#define REST_HELPER(first, ...) __VA_ARGS__

#define DO_1(macro, ...) macro(FIRST(__VA_ARGS__))
#define DO_2(macro, ...) macro(FIRST(__VA_ARGS__)); CAT(DO_, NUM(REST(__VA_ARGS__)))(macro, REST(__VA_ARGS__))
#define DO_3(macro, ...) macro(FIRST(__VA_ARGS__)); CAT(DO_, NUM(REST(__VA_ARGS__)))(macro, REST(__VA_ARGS__))
//...
#define DO_9(macro, ...) macro(FIRST(__VA_ARGS__)); CAT(DO_, NUM(REST(__VA_ARGS__)))(macro, REST(__VA_ARGS__))
#define DO(macro, ...) CAT(DO_, NUM(__VA_ARGS__))(macro, __VA_ARGS__)

#define PRINT_SEP " "
#define PRINT_HELPER(x) PRINTL_1(x), PRINTL_1(PRINT_SEP)
#define PRINT(...) DO(PRINT_HELPER, __VA_ARGS__); PRINT_1("")
#define SCAN(...) DO(SCAN_1, __VA_ARGS__)

#define cout(...) PRINT(__VA_ARGS__)
#define cin(...) SCAN(__VA_ARGS__)

don't forget to define WIN32_LEAN_AND_MEAN

for what purpose though

Trying to make a simple spreadsheet program - record some answers from a Google survey and put that into a spreadsheet with custom timestamps, fonts and spacing between each entry. Problem is my only experience with programming is an introductory Java class and it didn't teach any applications, just syntax and logic. Figured that I would need to use developers.google.com/apps-script/reference/spreadsheet/ somehow, but don't know where to start. Any help?

Attached: google-docs-and-spreadsheets.jpg (1024x640, 101K)

Where the cute femboys with programming socks at?

Working on a simple text user interface in Fortran. Yesterday finished code for creating frames with text headers, pic related.

Attached: frame.png (644x413, 20K)

Dump the data into a CSV first. Then you can import it into any spreadsheet easily.

All the other fancy shit can come after that.

>Aw come on. Why does it sub 8 from rsp? WHY? It doesn't even use the stack space for anything! It's like it wants me to go back to glibc.
It's aligning the stack pointer (16 byte alignment) as required by the ABI.
Since you're attempting to write _start in C it's assuming it's a normal C function which if called would have pushed the return address and thus misaligned rsp by 8, so the compiler has to always generate a sub rsp, (n mod 16) + 8 in any non-leaf function.

>m-m-muh type safety
Threadly reminder that runtime type errors are impossible in JavaScript because every expression has the static type Any. It's literally as type-safe as Hasklel. inb4 tags are types.

You're missing the point of types.

>You're missing the point of types.
The retards who use buzzwords like "type-safety" clearly are, because JS is literally type-safe.

>because JS is literally type-safe.
I'd love to know the secrets how you make null & undefined-based programming work.

>all those solid counter-arguments
I would love to hear your definition of "type-safe" which somehow excludes JS.

Well my argument would be to make a compile time, type checked X, but JS can't even guarantee compile-time stuff unless you compile from another language.

From the wiki:
> In computer science, type safety is the extent to which a programming language discourages or prevents type errors.

var a = 10;
> undefined
a();
> TypeError: a is not a function [Learn More]

>Well my argument would be to make a compile time, type checked X
What the fuck does that even mean? Do you know what a definition is? That's not a definition. What makes a language "type-safe"?