/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?
Old thread:

Other urls found in this thread:

benchmarksgame.alioth.debian.org/u64q/program.php?test=fannkuchredux&lang=lua&id=1
docs.unrealengine.com/latest/INT/GettingStarted/index.html
kernel.org/doc/gorman/html/understand/understand007.html
twitter.com/SFWRedditImages

Thanks for using an anime image

>smug_anime_girl_321.jpg

I'm just kinda curious if anyone's actually going to start hosting on another platform. Like .NET Core on linux/mac was make or break for their product meeting demand (like hosting on AWS vs. Azure)

I want to work from home. How fucked am I?

Anime posters are usually polite, pleasant and knowledgeable

-- K. Powers, 43.

If you want to do freelance, not at all. If you want to work in the industry, unless you have a nice resume, you probably won't get anything.

Thank you for using an anime image!

Day 6: Still learning Haskell. This the most I've dedicated to any language to get to a point to actually use the language. And I know Prolog and Functional Programming(Mostly). This is harder than I thought

Only to learn that, in the end, you won't even use it

>And I know Prolog
Did you do anything useful with it?

Yeah, I ran this:

benchmarksgame.alioth.debian.org/u64q/program.php?test=fannkuchredux&lang=lua&id=1

And it only took 95 seconds on my FX-6300 vs 1600 on regular Lua compiler on a superior(I assume) CPU than mine.

ask if you need help

Not really. I learned a new way of thinking, and recursion is very easy now, thanks to Prolog.

I'm trying to learn Scheme as a programming noob (just a little C++ experience), and I'm having trouble with this simple Fibonacci sequence code. Here's my attempt to produce the nth Fibonacci number:

(define (fib num) (if (< num 0) 0)
(if (= num 1) 1)
(if (= num 2) 1)
(if (> num 2) (+ (fib (- num 1)) (fib (- num 2)))
)

But this produces the error "The object #!unspecific, passed as the argument to integer-add, is not the correct type." Surely my code is not efficient, but why doesn't it at least run? It seems there's some data type issue, which seems weird for Scheme.

So basically if I'm allowed to cheat and import a threading library then I could get it down barely below the Java times on shittier hardware.

I'm being lazy when it comes to multithreading some old code and making it so that I stick every single global variable I'm using in a giant struct, writing my function signatures and then using OpenMP to parallelize.

Good enough, in my books. Not sure how else I can more efficiently multithread without expending more effort with a concentrated rewrite.

*rewriting my function signatures.

(define (fib num)
(if (< num 0) 0
(if (= num 1) 1
(if (= num 2) 1
(if (> num 2) (+ (fib (- num 1)) (fib (- num 2))))
))))

clang's address sanitizer is pretty cool. The next three hours of debugging should be a blast...

PSA: Crossdressing is unsafe, /dpt/. Stay safe.

use std::mem::transmute as crossdress;

struct Boy;
struct Girl;

fn main() {
let hime: Girl = unsafe { crossdress(Boy) };
}

Ok that's pretty funny user

I want to write a game mod. Nothing really complex. I primarily want to read data
about what's happening behind the scenes but may not be part of the games interface.
Damage done, movement speeds and the like. Which libraries should I study to get an understanding
of what I need to do?

Did you not catch this happening under Valgrind?

Valgrind gives better diagnostics with line numbers and such.

what game and engine?

Depends on the game, as well as how you interact with the data. Is there an API? A memory location?

Unreal engine games.

#define BOY 1.0
#define GIRL 0
float gender = BOY; // Hormonal ratio
gender = GIRL;

Valgrind doesn't complain.

Thanks! I would've never spotted the flow-control syntax error, since I haven't formally studied that in Scheme yet. I was just mimicking someone else's code which was much simpler to try to get it myself.

Also, I'm using Emacs for an interpreter right now. It seems like it might be useful, but do you recommend any others for any reason? I'm not really familiar with Emacs so I'll have to learn that too unless you think that might be a waste of time.

>STD
>FN
>Transmute

>lazy
who cares, as long as it works.

getting all the locks/spin waits set up right is the tricky part.

was the original bit torrent client written in haskell?

>who cares, as long as it works.

I assume people who actually want faster code. Why fuck with threads if you don't care about speed? Why be lazy if you do?

No, it was written in Python.

Which version of Unreal? 3 or 4?
With 4, they have a great amount of extensive tutorials on how to use the engine
docs.unrealengine.com/latest/INT/GettingStarted/index.html
Otherwise, you can start with downloading the Unreal 3 SDK.
Also, do you know C++? Also, they use UnrealScript, which is shit.

point is, do whatever works.
don't fret about it being proper or someshit. if it makes an improvement, then it's a win.

Maybe I should be more specific. I am calling all this code inside a loop so...

I need to do this because parallel calls to the code with a bash script didn't yield enough speedup.

...

why is "s" greater than "t" ?

How many years do you think your code will stick around for and actually be useful?

Because rock is after climbing alphabetically.

print("Hello World!")
Forever.

oh I had no idea it counted strings as values.

thanks lad

Linux source is too much of a clusterfuck to read.

When you allocate a virtual page, wouldn't that be mapped into the current process's address space? so when you do a context switch and a Linux subsystem tries to access that portion of memory it should page fault right? because it was only mapped into that other process's address space because each process has it's own version of the kernel page tables.

Except this doesn't happen in practice. So does anyone know what Linux does to solve this? how does it somehow make kernel mapping available in every process?

>Linux source is too much of a clusterfuck to read.
That's true of every optimized real world app.

>real world

book examples and college projects are not the real world

Do I really need to read SICP to learn functional programming or is that just a meme?

Thanks. It's UE4/C++

Like everything on Sup Forums it's just a meme. You just need to learn quantum mechanics if you want to stay relevant for the next 10 years.

>when your page faults are in the millions
>but it doesn't really matter, right?

Page faults don't exist in the C standard

Reported to Github though police.

>When you allocate a virtual page, wouldn't that be mapped into the current process's address space?

When you allocate it nothing happens until you do something with it. Paging is "lazy" afaik. So yes, it should page fault but only when you try to access it. This is needed because linux can over commit.

I'm not talking about userspace though, I'm talking about the kernel.
When the kernel allocates a page for itself, how does it make that mapping available in every process's address space?

I'm having a hard time finding the right info (and I'm not about to dive into source to find it) but I'm guessing it has to do some hand-waving with the page tables for all processes involved. But I think it only updates the tables for each process if they each fault.

I miss spoke here. I think it's only a "fault" if no mapping exists. I'm having a hard time remembering the correct wording.

>But I think it only updates the tables for each process if they each fault.
I think it does too. It is what kernel.org/doc/gorman/html/understand/understand007.html seems to be hinting at.

Technically you are right because no mapping exists in that address space.

Okay, found it finally. It IS a fault, but not a page fault. Referred to as a "minor fault" when the OS has a page but it's not mapped in the current process.

I'm tempted to switch to loonix full time and run a VM for the shit on Windows I need, I installed it first to compile some project off github and it's been edging out windows in how everything just werks.

Anyone good with shaders here?

I'm thinking about making a paint program that makes heavy use of OpenGL.

I'm wondering are there good potential ways of doing a flood fill using a shader?

What about expanding the edges of something.. like if a sent a b&w texture with a black blob in it to the GPU, could i make it expand the edges by 20px or so pretty efficiently?

#include

Should I learn Rust or is it just the meme version of C?

>there's no #uninclude
huge mistake

Yes to both

Yes but what about those fun enjoyable video games that you need to get through the day you BITCH

This is a hypothetical but maybe he's not a man child?

It's not C. It's basically a ML inspired version of C++ done more sanely. That being said, it is usable but I personally will not switch to it until it hits 2.0.

I only play Dotes these days.

It's a feature rich language with excellent resource management controls and LLVM on back end.
To the rest of /dpt/, what are the downsides of Rust at present?

>C++ done more sanely
it would be nice to have a language like that but I don't think it'll be Rust

1. You do not have a case for num = 0.
2. Please use cond, rather than a bunch of if statements.
3. Please do not ever write a O(2^n) Fibonacci except as an example of how to not do recursion.

It's ownership system just gets in the way most of the time.
The syntax is pretty fucking ugly, but is still better that C++'s.

>this is how you check if one string begins with another in haskell
zipWith const >=> (==)

The insanity inherent in C++ becomes apparent when you exercise the elements of the language which are no longer idiomatic. C++11/14/17 was a series of therapy sessions to massage away the spikes of insanity, but they still linger beneath the surface.

Consider the fact that any non-trivial project you'll undertake will last at least 5 years. Do you want your program to live in the asylum of C++, or the sex dungeon of Rust?

>highly efficient code restricted to one platform
or
>horrible in terms of efficiency code, but works everywhere
Choose your poison

That's crazy. How can ANY other language compete?

that's very ____ intuitive

Not my criteria. Reliability Uber Alles.

powerball.lisp
(defparameter *prize*
'(((5 . t) . grand)
((5) . 1e6)
((4 . t) . 5e4)
((4) . 100)
((3 . t) . 100)
((3) . 7)
((2 . t) . 7)
((1 . t) . 4)
((0 . t) . 4)))

; ((1 23 9 11 3 44) . 15)

(defun win (yours winner)
(let ((ix (car yours)) (j (cdr yours))
(kx (car winner)) (m (cdr winner)))
(labels ((foo (acc x)
(if (member x kx)
(1+ acc) acc)))
(cdr (assoc (cons (reduce #'foo ix
:initial-value 0)
(eql j m))
*prize* :test #'equalp)))))


>impying your lang can beat this

you're looking for java

efficient but works everywhere

'Normal Day at the British Exam commision':
>Reginald: Spiffing Morning to day James. Have you got the new exams for the computing courses ready.
>James: Why, yes indeed my good fellow, I already submitted it to the Dean and he approved.
>Reginald: Wonderful, What have you changed?
>James: Well, you know how all these computing students spent a lot of time in front of their computers coding and stuff, I thought it must be bad for their eyes and brain; So I'm having write code, but not on a computer, no no, dear fellow, but on paper, just like God almighty Intended, but it still has to be syntactically correct.
>Reginald: Marvellous idea, my good man, you will be eternally remembered.

but paper doesn't typecheck your code???
how would you write haskell in it?

>implying students do anything other than java and assembly in here

Currently trying to learn web shit for a project idea I have. I've spent the last two weeks playing with Javascript, React, ClojureScript etc, and I think I'm ready to build something.

Any ideas for a relatively simple single page application that should have login/users, simple data entry stored in db?

Don't care about how it looks. Just some simple functionlity to learn the architecture of this shit. I don't want to start my main project without having used any of this.

Also, r8 my stack:

>Clojurescript/React front end
>Reagent
>Re-frame
>Re-com
>Secretary

>Clojure backend
>Compojure
>HugSQL
>PostgreSQL

>It's ownership system just gets in the way most of the time.
I can agree with you that the ownership system is at times cumbersome, but it's a constant time write cost that objectively improves the quality of code. As we know from several studies, high quality code upfront is always cheaper than low quality code which then gets reworked over and over in production. It's a pain point, but it is a good pain.

>The syntax is pretty fucking ugly, but is still better that C++'s.
I have to 100% agree on this. It's a shame that a language so inspired by ML doesn't have the clean readability that so many ML variants have.

scratch

I love watching the syntax highlighter fuck up faggy lisp code. Get bent pole smoker.

This. I wish more people would understand the magnificent efficiency of JIT. Idiotic deluded Haskellfags.

I assembled and ran my first byte code program for my interpreter today. Currently it's register based but I'm considering moving it to stack based.
.types
void
u8
u16
u32
u64
string

.signatures
run = void(string)
m = void()

.u64
number_1 = 214
number_2 = 34

.native_code
runuvm_print_number : run

.code
main : m {
load r0 number_1
load r1 number_2
call r0 add_and_print
return r0
}
add_and_print : m {
add_64 r1
call r0 runuvm_print_number
return r0
}

.exports
main

My Aussie exams had this too. It's a laugh and a half having to fill out an unlined page with handwritten Java code that may or may not compile.

Say I have a small Java program which I have deployed in a UNIX-like environment, and as part of some process I invoke that program 100 times or so. Do I have to pay the warm-up cost every time?

>Clojure
That's a lot better than I thought it would be when you started your post mentioning web shit.

Who /listened to every Rich Hickey lecture but never once even tried Clojure and never will/ here?

A personal notes app?

>login/users
You know any web framwork implements this right?

>Clojurescript/React front end
Tolerable.

>Clojure backend
Pretty good.

>PostgreSQL
Pretty good.

>Reagent
>Re-frame
>Re-com
>Secretary
>Compojure
>HugSQL
I don't know any of these memes.

Started to learn C as my first language.

How is my first program?

#include
#include

/* Nigger Nigger Nigger Nigger Nigger Nigger Nigger */
int main()
{

printf("Hello Nigger.\n");
printf("Nigger Nigger Nigger.");


return 0;
}

Yep, I fucking hate the web, but it's the only game in town for what I need it for.

Seems like Clojurescript gets me away from dirty Javascript enough. And React seems genuinely good.

3/10, need a CIA nigger.

You missed a newline.

I'm writing a C library for storing and retrieving ordered strings using order-preserving minimal perfect hash functions for muh constant-time random access AND ordered sequential access.