/dpt/ - Daily Programming Thread

What are you working on Jow Forums?

Previous

Attached: BTS - Spring Day.gif (640x512, 205K)

Other urls found in this thread:

llvm.org/docs/Vectorizers.html
youtube.com/watch?v=Jai5ACq4LR4
lighterra.com/papers/modernmicroprocessors/
dpt-roll.github.io/
better-dpt-roll.github.io/
twitter.com/NSFWRedditImage

First for OCaml.

Second for WebAssembly

JavaScript rocks!

Attached: 1539809511049.png (1000x494, 369K)

I made a script to generate a random Jow Forums filename for when I download an image off google images and don't want people to know.

#!/bin/bash

roll() {
shuf -i $@ -n 1
}

month=$(roll 1-12)
day=$(roll 1-28)
year=$(date +"%Y")
hour=$(roll 0-23)
minute=$(roll 0-59)
second=$(roll 0-59)

code=$(roll 100-999)
timestamp=$(date -d "$month/$day/$year $hour:$minute:$second" +"%s")

printf "%s%s" $timestamp $code | xclip -selection c

Can I learn how to program if I have a confirmed 97 IQ?

Unironically this

Use
#!/usr/bin/env bash
It's more portable

yes you are in good company

javascript

Based

Developing a library for dealing with HDL types in C++, then wrapping it up in pybind so I can also use it in Python.

It's my anniversary btw. Whew.

still looking for help, namely: do I need arm's compiler to use SIMD instructions, or is regular clang able to do it as well?

No, do that yoursef if you want, but I'm not your slave, tard.

>when you take the pair programming while crossdressing meme too far and you both go on a date for some quality peer bonding and you get lost in the moment and kiss him?!? >///

Attached: 154.jpg (1280x1815, 427K)

I will never do such a thing, I use #!/bin/sh, but it looks like you want to use bash.

You make too many assumptions, winfag.

Yes, you need a high O level and to set march.

inline asm or intrinsics, i.e arm_neon.h
Clang will theoretically auto-vectorize too if possible, but the first two are how you make sure it happens.

know this feel all too well

im trying to make graphical display for system information with a picture of funky kong
essentially its conkykong

many thanks
do you know/have resource on which extent clang is able to vectorize by himself?

It should be the same as any other arch.

llvm.org/docs/Vectorizers.html

FUCK MATHFAGS

(sexually)

What's a kernel?

According to the Stallman pasta it's "the program in the system that allocates the machine’s resources to the other programs that you run".
Why does it need to be a separate program, can't it be a hardware abstraction layer as a library? Or could such a library be called a kernel? Can a kernel only exist in the context of a multi-process system? Can kernels only really exist on machines with some form of memory protection?

>can't it be a hardware abstraction layer as a library? Or could such a library be called a kernel?
yeah that's sort of the idea of exokernels

>looked source up
>it's not about pair programming

dropped. I can't fap to this.

Do you guys remember to touch metal before using your PC?

hey last-thread Haskell homework guy, I got a question about your assignment.

namely, it doesn't quite make sense they mention importing Maybe. do they want you to write an evaluator too? because division by zero makes the evaluator partial, but doesn't really change the syntax tree.

also, do they want you to handle arbitrary variables, or just x?

like, if wanted to evaluate with arbitrary named variables, and define division by zero or undefined variable lookup to fail, I'd probably do this:

data Expr
= Lit Double
| Var Char
| Add Expr Expr
| Sub Expr Expr
| Mul Expr Expr
| Div Expr Expr
deriving Show

eval :: [(Char, Double)] -> Expr -> Maybe Double
eval _ (Lit x) = Just x
eval vars (Var x) = lookup x vars
eval vars (Add x y) = (+) eval vars x eval vars y
eval vars (Sub x y) = (-) eval vars x eval vars y
eval vars (Mul x y) = (*) eval vars x eval vars y
eval vars (Div x y) = do
x'

Looking for a 2d graphics library for C. It should be single-header, and operate on raw image data - I can already read and write images with stb_image.
I want to draw lines, possibly draw circles, it would be nice to be able to draw rectangles with opacity too but not needed. Antialiasing would be nice, but not needed either.
So it should have functions with signatures something like this:
void draw_line(unsigned char* image, uint channels, uint x, uint y, uint x0, uint y0, uint x1, uint y1, int thickness, uint32_t color)

I know SDL does it, but it's way too complicated for my needs and requires some bludgeoning to get it to comply.

Lisp is the most powerful programming language.

Math is literally the only thing I'm good at.

Hell I'm not even good at math, it's just that I'm shit at everything else.

>look up quadratic interpolation
>it's hopeless
>look up cubic interpolation
>it's hopeless
why does life have to be so hard?

what's hopeless?

>it can't be that hard
>look it up
Oh shit

linear interpolation - you interpolate between a and b
cubic interpolation - you do linear interpolation between a' and b', then integrate
(do this analytically so you just get an expression to apply)
quadratic interpolation - you do cubic interpolation between a' and b', then integrate

>studying for java exam
OOP is so boring to me bros
whenever i see something like "super", "private", "this" or "self" my brain just turns off
are all OOP languages this depressing to learn?

Attached: cryign.png (150x112, 15K)

Dumb frogposter

yes

How long did it take you guys to get decent at your first programming language? I started a couple of months ago with the hopes of becoming good at C++ and Java in say, 3-4 years. Is that an achievable goal? I'm honestly not sure anymore. Even the books are very hard to follow for me and I'm not sure what half the stuff even means until I do some extra research on it.

What the fuck does interpolation even mean

dumb frogposter

You have a value at 2, and you have a value at 4.
If you want to get the value at 3, you interpolate. Not a hard concept to understand.

Absolutely based and redpilled.

Ah

>dumb
that was kind of implied in the post bros

It depends on what you mean by "good"

>learning programming from books
Don't do this. Use programming to solve problems, that's what it's there for.

>how long
No one really masters programming in the purest sense, they master whatever section of it is relevant for their job or studies.

That being said, C/C++ require you to learn memory and low level stuff in addition to OOP. Whereas Java just requires learning OOP, so C languages take a lot longer.

In my opinion, you need to just get a job doing programming. You can be a master but unless you have some work experience or some contribution to an open source project, no one will believe you.

Yeah it's the most dull paradigm tbhh

>linear interpolation: take 2 points, find a and b such that ax+b intersects those 2 points, then plug in the x you want.
>quadratic interpolation: take 3 points, find a,b and c such that ax^2+bx+c crosses all 3 points, then plug in the x you want
>cubic interpolation: take 4 points, find a,b,c and d such that ax^3+bx^2+cx+d crosses all 4 points, then plug in the x you want
It's 'harder' because the quadratic and cubic formulas are more complicated than the linear one, but you only have to use them, not invent them.

Define decent.
After 4 years I feel like I’m familiar enough in C++ to do my job without fighting with the language. As far as really mastering the language there’s still a long way for me to go. Some of the senior engineers are literal wizards
Mainly the thing that matters is your persistence and dedication. Keep learning keep working and you will become good enough in a year or two.

yeah it was implied by the image you posted

Don’t listen to this retard, read the fucking books. Don’t be a fucking Cowboy Coder, think about what you do and know what you’re doing

i started with C and was very comfortable with it within a week. sometimes, 10 years later, i discover some surprising standard library function i never knew existed, but that's about it.

becoming proficient with PROGRAMMING was a different matter entirely. it was a few years until i actually read a book about general programming practice and it all finally clicked - you learn that programming is just problem solving with workhorse data structures and algorithms, not magic. when using any program you immediately start thinking of how you would write such a thing, building a model of it in your head.

Decent as in, employable I guess, that is my end game in my goal

thanks

Books aren't bad, you can't rely on them forever but it's a good way to learn before you start doing sutff yourself.

>think about what you do and know what you’re doing
This appreciation comes by doing something for a living, rather than pontificating on the internet with hobbyist programmers who know nothing on the whole.

Books are great when you are ready for them. Beginners need to just start programming because nothing in the books will make sense to them unless they have tried to work with these concepts by fighting the compiler first.

There are books specifically made for beginners.

>find a and b such that ax+b intersects those 2 points
deceptively complex wording because a and b are just 1D samples in a data set; when you go beyond linear interpolation you no longer have that luxury

>find a,b and c such that ax^2+bx+c crosses all 3 points
this is the part where i throw up my hands because i read stuff like "solve the equation such that the derivative blah blah blah blah"

Or you could use 4chanX's inbuilt functionality for this.

Oh, don't be scared about it
Don't forget it was real
Do you remember the way it made you feel?
Do you remember the things it let you feel?~~
extern crate gio;
extern crate gtk;
extern crate chrono;

use gio::prelude::*;
use gtk::prelude::*;
use std::env::args;
use chrono::Local;


fn current_time() -> String {
return format!("{}", Local::now().format("%Y-%m-%d %H:%M:%S"));
}

fn build_ui(application: >k::Application) {
let window = gtk::ApplicationWindow::new(application);

window.set_title("First GTK+ Clock");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_default_size(260, 40);

window.connect_delete_event(move |win, _| {
win.destroy();
Inhibit(false)
});

let time = current_time();
let label = gtk::Label::new(None);
label.set_text(&time);

window.add(&label);

window.show_all();

let tick = move || {
let time = current_time();
label.set_text(&time);
gtk::Continue(true)
};

gtk::timeout_add_seconds(1, tick);
}

fn main() {
let application = gtk::Application::new("com.github.clock",
gio::ApplicationFlags::empty())
.expect("Initialization failed...");

application.connect_startup(|app| {
build_ui(app);
});
application.connect_activate(|_| {});

application.run(&args().collect::());
}

Attached: 44187203.jpg (600x439, 38K)

Fair point. There are very good books for beginners but a lot of people learn better by just doing something they want to do with programming and figuring it out as they go.

However, when most people go the book route they aren't talking about beginner books they are talking about shit like C book or SICP which aren't intended for beginners at all.

does it bother you that people hundreds, even thousands of years ago would look down at you with pity and disgust, for your piggish lack of mathematical understanding?

Attached: gauss.jpg (932x466, 36K)

>meanwhile 99.999% of humanity wouldn't even be able to grasp the concept of multiplication and division

hahahahaha
enjoy your life of QA

PS scripting that backs up entirety of a user’s local profile so that I can replace or upgrade the PC and restore the profile without them logging back in to create the profile first. You would think Microsoft would have something built in like this but they screw up some really strange things (eg you can change Computername and domain with one restart using the GUI but you need two restarts if using CLI)

>i throw up my hands because i read stuff like "solve the equation such that the derivative blah blah blah blah"
americans do not understand that this counts as math illiteracy in 2018
they act proud of this, they wear it like a badge, I will never understand it

>99.999%
what's that?

where the fuck do x1 and x2 suddenly come from?

Attached: cub.png (535x139, 9K)

If that's the kind of book you're speaking of then yeah you're right, a complete beginner can't just pick up SICP and start reading it, he'd get nothing out of it.

i'm english, i can't solve a system of linear equations

(x1,y1) and (x2,y2) are the points you're interpolating between

t(x) is an expression involving x1 and x2 of those points.

that's embarrassing
well you do know how to turn it into a matrix problem at least so you can easily enter it into a computer? that's more important

I'm english and I can

Attached: 1523483823286.jpg (580x326, 19K)

youtube.com/watch?v=Jai5ACq4LR4

How do I skip the current iteration of a loop in C? Is it proper form just to goto the end of it?

Must feel bad when you need to be spoonfed

Attached: stupid.png (962x275, 21K)

continue;

Please do not help lazy people. They aren't worth it.

That's bad, it can be a timestamp in the future.
#!/bin/sh
echo $(($(date +%s)-$(tr -dc 0-9 < /dev/urandom | head -c 7)))$(tr -dc 0-9 < /dev/urandom | head -c 3) | xclip -selection c

Random timestamp within last 4 months.
Also, don't use bash, it's less portable.

at least i truly see

Fuck, I never realized there was a statement for it. That's neat.

y'all a bunch of amateurs

>would look down at you with pity and disgust,
did you take a look at your idol? i would probably kill him with a single punch. where's your math, now?

It's basic C loops 101

How much do modern CPUs have in common with ye olde microprocessors from the 80s in terms of design? Are they still fundamentally the same, just more compact?

They're quite different on a microarchitectural level, ISAwise they try to look the same but the abstraction's pretty leaky.

>would kill gauss I single punch
Gauss was a 5th degree black belt in both BJJ and Akido and was 2x Navy Golden Gloves

not much

lighterra.com/papers/modernmicroprocessors/

Attached: 14af149147bc01237dec43262817364884f97d735da698d8d5abcf6b7a7ba684.png (3840x2160, 1.61M)

>inb4 thread flooded with retards rolling
fuck off and make a random number generator

>How long did it take you guys to get decent at your first programming language?
8 years and counting

dpt-roll.github.io/ and better-dpt-roll.github.io/ were made exactly for that

amateur hour again I see

roll

Since I know nothing about graphics I will simulate a single frame using my programming skills using paint

Attached: double-pendulum.png (559x482, 8K)

Bump.

In stb_image, why is int used for something that can only be 0-4?
Why not either an enum or a uint?

I'm spanish and I can but I find it a bit hard.

Im working on this web based OS thing. Its just for fun and isnt fully featured, but it looks like a OS and I can visit websites in it. I am posting this post from the "web browser" in the web based OS itself (pic related)

Attached: DANK MEME 2018-10-20 at 19.08.16.png (839x852, 138K)

>writing hard stuff
>not just making video games

Attached: 1533028012711.jpg (142x250, 14K)