/dpt/ - Daily Programming Thread

What are you working on Jow Forums?

Old thread:

Attached: karen haskell.png (1280x719, 818K)

Other urls found in this thread:

netrunner.cc/
gnu.org/software/libc/manual/html_node/Basic-Allocation.html#Basic-Allocation
thebookofshaders.com/03/
scs.hosted.panopto.com/Panopto/Podcast/Podcast.ashx?courseid=b96d90ae-9871-4fae-91e2-b1627b43e25e&type=mp4
github.com/clasp-developers/clasp
github.com/cmu-db/ottertune
greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf
twitter.com/SFWRedditGifs

should i add parallelism to my language
it doesn't have side effects, but the memory backend currently has side effects, which i have to isolate and it's really doable since malloc is apparently thread safe

should i add parallelism to it, would anyone care

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

GIL

it's not interpreted
each thread will have it's own gc going on

i might just do it, i am curios if i could get a speedup

We should make a custom browser.

>she doesn't know about netruuner

>the programming language math and science uses

no wonder we can't even get to the moon.

Attached: ReverseDigits.png (761x380, 10K)

The card game?

You should be able to solve this
Test case:
./a.out ß
SS

Attached: Screenshot from 2018-12-22 10-30-02.png (950x188, 26K)

I don't think they program rockets and stuff in mathematica.

That's not FORTRAN. Also stop being a retarded fizzbuzz poster that is doing things scientists would never bother with in mathematica.

no the Jow Forums """browser"""
netrunner.cc/

This is actually pretty efficient.

Try programming that in C or Java. You'll see Mathematica's is pretty fast.

are you fucking retarded there's already another thread up

CURRENT THREAD

Attached: AngerComparedToUniverse.png (842x591, 653K)

>can't think of a good github username
help pls

Attached: Screenshot from 2018-12-22 10-34-39.png (642x380, 46K)

You made a thread 2 hours early to shill your shitty discord?

No, fuck off.

what is the best C programming book? no K&R posting bls

use help_pls

People will be nice to you.

>The Perfect Browser
>Written in C++
>lead dev is a macfag
>clearly can't even parse CSS let alone render properly

That's an extremely bloated Lynx.

i have a question about threads
let's say i have this function here, which is computationally inefficient in many ways, but just as an example

fibs(x)
if(x

And then what? Where to share it?
Sounds great, cheers

oh and also
let's say two functions are running concurrently each in a different thread, and at the same time both of them allocate a variable, on the stack

is the stack safe from the two functions messing with each other, it should be right?

what if the two functions are the same function though

let's say instance of function number one does
int x = 2
and instance of function number two does
int x = 3

clearly to do x = 2, the function needs write 2 to esp and then do esp + 4
but the other one needs to do x = 3 and then esp + 4

that's not atomic or whatever you call it, they can clearly mess with eachother

what am i missing

>unicode
faggot

I'm not sure what you question even is. You don't want to make new threads over and over.

>the function is defined in such a way that thread1 will be called again for fibs(x-1-1)
Are you spawning a new thread or reusing thread1? I don't really understand your question.

Threads don't share a stack.

>is the stack safe from the two functions messing with each other, it should be right?
yes
each thread probably has its own stack

i wanna spawn, but maybe it's actually smarter to reuse somehow, though idk how right now, will have to think a bit
thx, so the stack is ok
what about malloc and realloc and memcpy etc. c library functions

they should be thread safe right in the sense that they have some syncronization that means they won't return overlapping memory segments and it's up to me to make sure the threads only access their own memory given

Use the glibc manual, it's all in there. Here's malloc:

gnu.org/software/libc/manual/html_node/Basic-Allocation.html#Basic-Allocation
>Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem | See POSIX Safety Concepts.

Click that POSIX Safety Concepts link and read it.

btw im using gcc
also where can i find this sort of info on the c library functions and their thread safety, im talking pthreads

i just want to make sure i am able to use C and it's library reliably with threads and only modify my own code to make that thread safe

>also where can i find this sort of info on the c library functions and their thread safety, im talking pthreads
man pages
$ man malloc

Attached: 1545437317.png (1031x219, 24K)

this is tree reading
meaning i start at the root, find a word i don't know exactly and have to read about that too

but thx anyway, it's a useful link
>No manual entry for malloc

ok
>To avoid corruption in multithreaded applications, mutexes are used internally to protect the memory-management data structures employed by these functions.
for both malloc and realloc
this is good

thx guys

welcome to 20 years ago

>this is tree reading
>meaning i start at the root, find a word i don't know exactly and have to read about that too
How is that a bad thing? You learn thing but also learn more.

well i do have to check just in case
i just learn from my mistakes

Are you trying to recreate BEAM?

so this is a feature of scala
def implicitFoo(implicit i:Int) = print(i)
implicit val v = 2;
// (... code ...)
implicitFoo
// somehow prints 2


why
just why

give me one reason why this feature makes any sense at all

Fucking guile-snarf macros don't work if I want to make a module instead of just top-level primitives. I have to go back to:

scm_c_define_module(...);

scm_c_define_gsubr("some-function", ..., actual_c_function);
scm_c_export("some-function", NULL);
/* 100 of these */

I think I'll have to do my best at C pre-processor hacking.

Attached: fuck this shit.jpg (681x635, 105K)

it just takes things off the stack, and the upmost element is v=2

Never seen it, but I think their documentation and it looks like it's just scope-level default parameters, really. I think it's a bit much as far as features go, but I could see using it if I were the only one writing the code.

I guess that's what you come up with when you want dynamic scope, but your brain has been atrophied by the functional programming meme.

it makes code unreasonably hard to reason about and probably leads to bugs. it's a feature for the sake of having more features. it doesn't do anything good on the contrary it's clearly a bad thing to use

I agree and never claimed otherwise

that's why i'm asking, what leads the design team to include things like these? is there any niche use case where this is actually a good thing?

It's just feature creep I guess. C++ suffers from that a lot

what is go useful for?

>has a GC
shell scripting?

//cast to bytes
//iterate
byte > 32 ? byte -=32 : byte +=32
//recast to str

programming

Go seems like a library that pretends it is a language

austrian user here and the generally accepted capitalization of ß is SZ. In some fonts it's more apparent that it's a fusion of s (old fonts often write s similar to f) and z

Attached: Screenshot_20181222_020404.png (205x318, 35K)

K&R

>tfw so smart I solve coding problems while I'm in bed about to fall asleep but not when I'm at my desktop

Attached: ayo.jpg (680x598, 54K)

>solve coding problems while away from computer
It always seems so simple.

Lisp is the most powerful programming language.

Why is there 2 threads?

The other thread was made at like ~150 post away from bump limit into the previous /dpt/ to push his discord thing. He didn't even link to it in the previous /dpt/.

What a faggot

Redpill me on aliasing mutable data

recipe for disaster

Suggestion on a book for "purity" validations? Say I had a function which took an array pointer and a length, and only did a single function (say increment) over the array, and returned nothing. Just analyzing the function could tell me that say, I didn't check if the pointer is null before using it (let's say I define that to be a rule, and it is a basic precaution), and could warn me over overflows (a pure increment could be dangerous).

Further progress in the analyzer could reach up or down. If I replaced the increment with a "increment if the value is not the highest positive", then it could hold the overflow rule, until it recognizes that the second increment operation prevents overflow (it would have knowledge of max size, and compare a literal or symbol in the program to it's "knowledge"). Conversely, if I went up, if I passed a fixed array of explicitly stated size, it could verify that the length I am modifying is equal to or less than the maximum size. A "smarter" analyzer could verify that if my compiler rules agree with the analyzer rules, then I could even pass in a reference to any element of the array, and it could determine if my length goes out of bounds.

I assume this may be covered in a book on static analyzers or something, but I don't know any off hand.

just use std::shared_ptr and forget the whole thing

been working in circles the last few days and everything's working now and i have no idea why and i just feel peeved i'm too hired to be happy but too relieved to be properly angry

this is a wise observation
>in interview
>explain the theoretical answer in a minute
>sketch out the pseudocode in a few more
>spend the rest of the hour trying to hamfistedly pajeet it into working
:(
next time i'll practice more and study less

are you feeling ok user?

glsl is blowing my mind. even the simplest example is hard to wrap around.

void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
gl_FragColor = vec4(st.x,st.y,0.0,1.0);
}

The value of st.x is a uniformly distributed normalized variable based on its x pixel location. so instead of iterating to create an array, I'm just writing math equations that describe what I want.

I do not like what you're doing. Is there a demo I can examine?

thebookofshaders.com/03/

It's almost as if GPUs do everything in parallel and make you write your code in that way.

Generating something dynamically, like static html or resizing pics. Because it's compiler is fast. That's about it.

Speaking of generating html, anybody do this for a very large site? I mean dynamically generating html. Apparently Netflix was going to do this at one point.
This site, 4chinz apparently does this, keeping metadata in a dbms and then regenerating the html page with each post.
Just wondering what the high level architecture of such a process would look like, I wish to do this in OCaml and have my own idea, curious about others.

Get CS:App and K&R.
There's lectures for it: scs.hosted.panopto.com/Panopto/Podcast/Podcast.ashx?courseid=b96d90ae-9871-4fae-91e2-b1627b43e25e&type=mp4

...

K&R is nice but it's really outdated. K&R isn't even a valid C standard anymore. I would sooner look for a book that has been updated to let you know about the features of C11. K&R should only be used for extremely basic stuff at this point.

At work one of my applications is a dynamically generated webpage that is really just pulling from the database and sending over the html to be displayed if that's what you mean. Most new wave shit is apis to return json and let JS handle everything, but it's nice to do that lifting on the backend too.

No No no.
Yes it's outdated, except it's description of how crazy you can write declarations. Plus it's clear and concise, can be read in a weekend. Same with 'Unix Programming Environment'. Unironcally the only book you will ever need to program any OS you want, using their manpages after you get a crash course in signals, filters, shells ect. That's why you still read it, just be aware that you'll also need to go and read CERT Secure Coding in C and things like Cs:App as well, to understand C on an assembly level and how Return-Oriented-Programming works, how cache works, ect.

Another great C reference is reading through Andrew Appel's Verified-C compiler docs. Not that you'd ever use it, because it's slow as shit and more mission critical/NASA things, but it help you write you own C programs knowing what things are important to take special precautions with.

Thank you.

It's a very simple process, especially for Jow Forums. Two ways of doing it: Keep an active 2d array/hash of all threads and their replies, and if one has been replied to earlier, it gets updated, and then a caller could check every thread, and pull the most recent threads and compose them (the presentation for Jow Forums is simple, so really it's just mapping input to output). The other style would be to sort the threads every time they're updated. There's probably a mix of behavior: thread times are fixed because quantity is limited, but their content isn't (images, text). With a bit of preemptive memory allocation (you could reserve say, the 80th percentile of memory used in each thread on average), you could reduce dynamic memory calls.

github.com/clasp-developers/clasp

>Building on most systems will take around 8-12GB of memory and ~1-2 hours with a relatively modern processor, so be prepared to watch a movie or do some other useful work until Clasp is all done. You may also want to activate a large enough swap file if your system does not have enough DRAM.

SEPPLES, not even once.

Attached: 1543016946969.jpg (500x496, 76K)

that's what I thought, even with in-memory dbms this is slower than I want, though after auto-tuning with CMU's experimental tuner it did definitely make it acceptable was wondering if there's some other careless abstraction I could dick around with to regenerate more parallel. This is their tuner: github.com/cmu-db/ottertune

btw anybody wants to make money, advertise yourself as a mid-level dbms tuning on some freelancer site, just use Ottertune, collect your fee. Could probably even automate this, it works quite well (obv cannot replace real tuning skill, but better than default)

Last I knew, Chrome generated like 21GB of files on compile because they didn't easily separate compiling for specific architectures/systems.

Earlier in this thread I asked if there was a book which approached validation from applying a rule set to a function and in theory working your scope bigger from there. This seems like a good book for ideas. Thank you.

Patience, combining common lisp with C++ is difficult.

interesting,
thank user

>actual program
>10s of megabytes on compile
>compiler
>"Please download more ram"
Common Lisp, (at-least-once? nil)

HOW DOES LISP KEEP GETTING AWAY WITH THIS?

Attached: file.png (1120x452, 313K)

many languages can do math vectors

Did you even test the fucking garbage you came up with, you dumb nigger

what verb do you use in a commit that deals with organization or simplicity?
would that be "refactor foo" or is that too broad?

Based rust

What was the demo? I'd be interested in the demo they used, because I wouldn't imagine C would allocate too much extra memory (null-terminated strings could be an example of C allocating "useless" memory, if the demo can be verified by the compiler so they are not needed - which is bad programming for a demo, unless an optimization is guaranteed by the language. There could be some other things, like how a C compiler defines minimum values to be of a certain capacity.

This picture is an overview. Here is the paper:
greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf

>2d array
linear algebra optimization opportunities here, multiply matrix in a pattern matching case statement loop like genserver/OTP that can look up the dbms faster, no search function instead go directly to record X

Help a C# noob out pls.

I don't see any mistakes but when I run the code I have to press enter before the console reacts to my response. So In this case if I input A nothing happens unless I press enter and then input A again and only then it works. Wtf.

Attached: Console.WriteLine.png (640x340, 13K)

You can just say "organized x" if it's moving things. Refactoring is explicitly re-implementing the previous behavior in a new way, hopefully for the purpose of improving some attribute (you could refactor something worse?). Simplifying is good only if you did actually simplify. Removing a few functions for example, if the application doesn't need to re-use them (and an inline, C, wasn't really useful).

>doesn't know what Mathematica is used for or capable of
>HUURRRR B-BAD!!
Fucking retard.

Attached: smug_ran2.png (1000x1000, 495K)

>using scheme style in common lisp

Not sure, most console input needs a terminating value: return carriage/newline, or EOF.

Uh, Idk what you're saying. I just meant in worst-case scenario, you pre-allocate a limit of size for each post and content. Look-ups would be cost (1), though you'd have to look through all records for "most recent" posts.

Don't bully the lisplets. They don't know any better.

lol you got me. I've only learned bits of SICP/Scheme style.

Attached: 81nKJ8qvcYL._SL1500_.jpg (1500x1500, 157K)