/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/torvalds
youtube.com/watch?v=XsFQEUP1MxI
quokkajs.com/
ponylang.org/discover/
github.com/majestrate/XD/commit/c999eb7da2512edaac37805a03d7aca760dc7a4b?diff=unified
twitter.com/NSFWRedditGif

making my first android app according to the android tutorial
I plan on making a DnD character creator

r u s t

is shit

So now that wasm is in every major browser
how should we btfo javascript?

god bless you idio-rust-kun

trait PrintIter
where Self: std::iter::IntoIterator + std::marker::Sized
{
fn print(self, buf: &mut V) -> std::result::Result
where Self::Item: std::fmt::Display, V: std::io::Write
{
self.into_iter()
.enumerate()
.map(|(i, v)| (i + 1, v))
.map(|(i, v)| writeln!(buf, "The {}th item is {}", i, v).map(|_| i))
.fold(Ok(0), |ret, val| ret.and(val))
}
}

impl PrintIter for T
where T: std::iter::IntoIterator { }

fn main() {
vec![1, 35, 64, 36, 26].print(&mut std::io::stdout()).unwrap();
}

wasm is still hacky shit, give it a few more years.

Reminder to ignore Rust false-flaggers. Everyone knows Rust really does tend to look that way the moment you go beyond fizzbuzz and vector iteration.

i sure hope you aren't using shared* in your code, /dpt/.

If they had been using shared_ptr for the purposes it was intended for (shared ownership of memory), they wouldn't have been able to replace it with raw pointers/references easily without a major redesign of the entire system. So I guess the moral of the story is that you shouldn't just mindlessly put everything inside a shared_ptr, because reference counting and locking has some overhead?

>B-but muh z-zero cost obstructions...
What a typical sepplescuck response.

Use the superior intrusive_ptr. weak refs can be kept in ordinary pointers, and convert back to strong refs anytime.

Currently working on a program for my university that allows students to put in a bunch of classes and times that they're available to be at school that will just spit out a few different schedules for them to choose from. Does anyone have an experience doing anything like this?

From my little bit of research it seems like an evolutionary approach is the way to go for this problem, and earlier tonight I implemented a simple evolutionary algorithm that generates pretty damn good schedules, and while I'm happy with it, I want to know if theres a better way.

I figured that I could represent the classes that the student is interested in as nodes in a graph, where the edges of the graph represent the LACK of a conflict between two classes, which means that I would be looking for cyclical groups that for cyclical groups with every other member of their group. Does such an algorithm exist? My genetic implementation actually seems to work really well, but it seems like such a Jerry-rigged way of putting it together.

>implying anyone ever said shared_ptr has no cost
Shoo, retarded Rustlet.

this

But Rust uses recounting, more often than C++ due to borrow checker limitations.
You're talking to a Cnile.

>everyone's too busy talking about rust to discuss anything else
whelp, better learn this fucking meme language so I'll be employable in the future

employable at reddit

>everyone
it's literally the same 3 people, and idiomatic-poster just shitposts with it.

So what are you guys working on?

learning vulkan

What does waits beyond the horizonts of govnocode?

What are you gonna do with it?

Write a wrapper and eventually a modular library focused on games since I'm tired of settling for shitty SFML bindings.

godot 3 is decent tho

I don't want to work with !python and engine-bloat. Plus it's more satisfying and better in the long-run to roll my own everything.

I'm trying to make simple stick figure do jumping jacks.
First I thought to only change location of one arm and it worked but old location and figure of the arm remained on screen. Why? I'm changing location of the line now drawing new one.

public class Guy {
private Circle head;
private Line leftArm, rightArm, leftLeg, rightLeg, torso;
private int _x, _y;

public Guy(int x, int y){
head = new Circle(x,y);
_x = x;
_y = y;
torso = new Line(x +30,y + 60, x+30, y+140);
leftArm = new Line(x +30, y+90, x-10, y+110);
rightArm = new Line(x +30, y+90, x+70, y+110);
leftLeg = new Line(x+30, y+140, x+10, y+180);
rightLeg = new Line(x+30, y+140, x+50, y+180);
}

public void fill(java.awt.Graphics2D aBrush){
head.fill(aBrush);
torso.fill(aBrush);
leftArm.fill(aBrush);
rightArm.fill(aBrush);
leftLeg.fill(aBrush);
rightLeg.fill(aBrush);
}
public void move() {

leftArm.setLocation(_x -10, _y+70);
}
}


And Line
public class Line extends java.awt.geom.Line2D.Double{
private int _x, _y;

public Line(int x, int y, int a, int b){
super();
_x = x;
_y = y;
this.setLine(_x, _y, a, b);
}

public void fill(java.awt.Graphics2D aBrush){
aBrush.setColor(java.awt.Color.black);
aBrush.setStroke(new java.awt.BasicStroke(3));
aBrush.draw(this);
}

public void setLocation(int a, int b) {
this.setLine(_x,_y,a,b);
}
}

I thought they added ==python.

I don't want to work with script shit.
I'd rather have the choice to easily embed any language i want like an Idris. But that's getting way ahead.

a group of nodes that share an edge with every other node in the group is called a clique. finding whether a clique of a given size exists and finding the largest clique(s) are all np-hard problems, but there are decent heuristics available.

Cause you're drawing to the same framebuffer as the previous frame. It's like taking a piece of paper, drawing a picture, and then drawing a new picture right on top of it. I'm not familiar with that particular graphics library but their should be some function like "clearscreen" somewhere. I've only used openGL to do graphics but it's GLclearcolor in that world, I reckon it's something similar in yours.

Just to preempt your next question, there is something called double buffering where you fully render to the framebuffer and then swap with the active one that is rendered to the screen to prevent screen tearing

Yeah there is, "repaint". I'll fiddle with it more, thanks

>You're talking to a Cnile.
But Cniles use refcounting a lot too.
In mpv, in linux, etc.

Talking more about fizzbuzzers than actual developers here

Rust is truly the nicest language to do pointer arithmetic in. It's very capable of it, does not have nearly as many gotchas while doing it as C++ and makes it easy to write custom allocators or convenience pointer wrappers.

Also, you get to trigger some people with unsafe blocks. It's perfect.

Oh yeah, I'm not really sure you understand what your "line" object and your "fill" function really represent.

Your line is just a set of numbers that represents relative position in coordinate space. When you call fill on that line it translates that coordinate space to the actual pixels in your framebuffer and fills them in so to speak via a process known as rasterization. Same deal if you were projecting 3d coordinates onto the framebuffer but the math would be slightly more complicated (not much more complicated than you would expect though).

So, when you draw and then move your line, the rasterization has already happened and you are merely moving the representation of your line in coordinate space again, the rasterization remains. You probably figured this out but it's good to know it explicitly and to know some of the terms in case you have to look something up in the future.

Let's peep what kind of people are downloading my app...


Most of them are burgers as expected, but i have some pajeet users too and holy shit a nigerian prince has installed my shit as well, breddy cool

And how many niggerians are using YOUR code anonchans? .. Yeah i thought so.

>Rust is truly the nicest language to do pointer arithmetic in.
false. give me your example of "nice" looking PA.

>Rust is truly the nicest language to do pointer arithmetic in
>unsafe {
*ptr.offset(n) = x;
}
>compared to
>ptr[n] = x;

LMAO

You the annoying kid with brown hair in seng265

get ye gone ESL

My software is used by millions of people all over the world.
My github: github.com/torvalds

Don't be silly, about 0.0001% of Linux users compile their kernel from the git.

youtube.com/watch?v=XsFQEUP1MxI

What editor does Fun Fun Function use?

And about 100% of linux users had their kernel originate from the git, which is written by me.

How many smartphone users compile their own programs again?

I wish linus would come here and talk about programming with us

>jump cut almost every 5 seconds
how the fuck do people actually watch these types of videos

Sepplefags and rustfags beware, Linus is gonna rustle your jummies.

His WHAAAATS UP EVERYBODY voice was more grating, desu. Will never understand how people can """""learn""""" things from these people.

Why are the Rust devs so schizophrenic? On the one hand, its devs tout "explicitness", on the other hand, it is full of bizarre implicit conversions:

type Crappy = Fn();

fn foo() {
}

fn main() {
let ch: u8 = 0;
let int: u32 = ch; // error: expected u32, found u8

let bar = || println!("i am useless");

let tmp1: Box = Box::new(foo); // this is perfectly fine, for some reason
let tmp2: Box = Box::new(bar);

foo(); // this is also perfectly fine. foo doesn't get moved into the box.
bar(); // this is not fine. bar got moved into the box.
}

Has Linus talked about the rust menace anywhere? I'm curious what he thinks of it.

Linus' opinion on C++ is outdated as evidenced by that rant. He'll just embarrass himself as he gets BTFO'd.

Part of it is a character bit from the previous episode.

He did a really good functional programming series, kind of just stuck with him after. But yeah, it's obviously hit and miss peppered with youtube cringe antics.

>libraries which define NDEBUG in their headers and fuck with my debugging

Just C things

>headers
Laughing_modern_langs.webm

read the video description
> Inline evaluation plugin quokkajs.com/
so judging from the layout either VS code or Atom

I tried playing with wasm and.. fuck

Getting a string from C into a Javascript variable (ie, doing anything with it) is a horrible fucking drama.

So when i'm making dlls i am always confused on how do i call the namespace.
Like if i have a class called poopmaker and the neamespace is also poopmaker then it's retarded because invoking it in projects as
new poopmaker.poopmaker();
looks like shit

If interpreted program means just in time compilation,
so that means the interpreter will pause waiting for the compiler to run mid-program,
and also the compiler pause waiting for the parser to run mid-program.

then isn't that means code golfing is really good for interpreted language??

>1 dll per class
Wintards everybody

ahead of time is the future.
ponylang.org/discover/

time doesn't matter in code golf

>interpreted program means just in time compilation
no

What lang? C# (the absolute state of)?

First of all: "looks weird to me" is the weakest argument you can have against a programming construct. "It does what it's supposed to do so deal with it" is a more-than-sufficient counterargument.

Second, in my eyes, namespacing should be orthogonal to linking. How you write down symbols shouldn't depend on how they are resolved down the line, otherwise you'd have to change all your code to switch from DL to SL, which is proof of lack of abstraction. So something is wrong either with your toolchain or with the way you've set it up. In any case you should fix this. Java doesn't have this issue, GNU/Linux C doesn't have this issue, even Python arguably doesn't have it, so wtf?

Third, don't you have some kind of let-notation or import or idk in your shitland? Stuff like let poopmaker = the "poopmaker" class in the dynamically loaded library "poopmaker"? That would alleviate the problem in point 2. Or just import poopmaker.*?

imagine earning money programming

>vector iteration.
It's called range manipulation, you smelly cnile

his two main arguments are still valid.

This little gem :)

No they aren't, and haven't been for a while.

What are the odds of my programming professor browsing these threads? I've gotten very specific advice here before at very specific times, and he also shares a lot of specific tinfoil hat type opinions I've seen here.

I'm scared.

What two arguments? Which rant? He made several, let's just make sure we're talking about the same document.

c++ still does a lot more in your back than c
c++'s social software engineering cost is still higher than c.

like what?

>c++'s social software engineering cost is still higher than c.
>Implying
C programmers are fucking retarded.

I can't say in case he's lurking and finds out it's me.

>you are the only person in your class who looks like a Sup Forums stereotype
nah lad

Hi, professor!

BOOOOH, Brandon. Yes I know you browse Sup Forums you fucking white supremacist, and you're going DOWN! I was only pretending, but you scum you truly feel home on paleoconservative troll websites, so now you're going to fling out of college if you don't amend your ways. THINK FAST, I've already written an e-mail for the dean!

>C programmers are fucking retarded.
most programmers

>I can't say in case he's lurking and finds out it's me.
How come he will identify you?

>you fucking white supremacist

That's something he would unironically say, yes.

Other one is the fat indian manlet with a pepe folder and custom weeb loli waterfox background.

Because I asked for homework advice in here, and the next day he randomly mentioned the exact same thing in the exact same specific way.

>What lang?
As if anyone serious about programming use anything else than C#

I'm not a pajeet.

12 rupees have been deposited to your online microsoft evangelism campaign, rakeesh. Please keep doing the needful.

>stack overflow
>interesting and useful discussion about the ups and downs of different techniques used to achieve the same goal
>"closed as not constructive"
>ask question
>"hey, how do i do X without an external library"
>"i recommend library Y its really great, you can find it here. written by me btw"
>"+1 for recommending library Y!"

I had many more problems with
>ask question on SO
>locked as duplicated question LINK HERE
>click link
>the question is not duplicate at all, only similar but completely useless to me

Me too!
I also had
>ask a question about whether it's okay to glue 2 pages of my passport together to hide parts of my past to my employer
>Rajeesh, based on details in your message, you seem to be a Pajeet working in the middle-east. Do not, I repeat, do not, under any circumstances, hand your passport to your boss. They have no grounds to make that request and in this particular country they have a documented habit of effectively holding your passport hostage, striping you of your legal existence and forcing you into slavery under them. Report this to the police and remember to keep your passport safe.
True story.
America remotely saved my ass in the middle east without any military involvement.

This is why I shill for Microsoft.

Ssssh ;^)

are you memeing or do we actually have pajeets in this thread?

ranjevs and rajeets lurk around and even post here.
You can tell by the various ESL posts. Every region has their own distinct style of broken english.

my gripe is that I don't ask obvious questions that could be answered by taking a look at the docs.
I tend to look at pretty obscure problems. And the thing is that whenever I find a SO entry relevant to the problem it's most likely closed because no one had a definitive answer but in the comments there was a discussion that could have given some hints. But those fuckers close that down as inactive or whatever.
SO is only good for pajeet/normie tier questions. For anything else it's useless.

I am meming indeed, but I am actually an Indian computer engineer with a sense of humour. I do find these memes funny especially given that I have personally experienced them. And inb4 no I do poo in the loo and I meet the western standards for personal hygiene, or at least I try.

It was a pleasure fighting the meme war with you :v)

What are some good tutorials on cmake? I need to convert a complete project from a monster Makefile I wrote.

github.com/majestrate/XD/commit/c999eb7da2512edaac37805a03d7aca760dc7a4b?diff=unified


r8 my commit

That looks horrendous.

I'm trying to implement the unix pipe, but the code is a mess. I'm not even sure if regex is the right way to parse it

>claims C is the best language
>always extremely hostile for no reason
He would fit right in