/dpt/ - Daily Programming Thread

Emulator general

Previous

Attached: 1537117071908.webm (640x800, 1.33M)

Other urls found in this thread:

hatebin.com/oqosmutaoz
carlchenet.com/you-think-the-visual-studio-code-binary-you-use-is-a-free-software-think-again/
imagemagick.org/Usage/draw/
cplusplus.com/reference/string/string/getline/?kw=getline
blog.theincredibleholk.org/blog/2013/11/27/continuation-passing-style-interpreters/
pastebin.com/VzFxKwwM
twitter.com/NSFWRedditImage

Everybody go!!!

Attached: 1538751058022[1].jpg (413x550, 26K)

stop posting 3dpd

First for Haskell

D.Va programming thread

/dpt/-chan, daisuki~ (ω )

Ask your much beloved programming literate anything (IAMA).

Please use an anime image next time.

Attached: shot0033.jpg (1920x1080, 310K)

real girls trigger the waifufags. just like irl :)

This is popcount, what does it have to do with my example?
Integer overflow is UB, so that can safely be assumed to never happen.
If you want, you can put in an assert.

>implying you can write an abstract abstract interpreter for abstract interpretation

This! So much THIS!

for me, it's zig

Attached: movezig.png (4824x1527, 118K)

>that can safely
can, not shall.

on x64,
max_if_else_if_eq_avg(INT_MAX, INT_MAX) returns -1
max_if_else_if_eq(INT_MAX, INT_MAX) returns 2147483647

therefore max_if_else_if_eq_avg() ≠ max_if_else_if_eq()

you fail to understand that but the compiler doesn't; THE COMPILER IS TRULY SMARTER THAN YOU.

user btfo by gcc.

Attached: shitgetserious.png (2271x2380, 298K)

Are design patterns a meme?

Attached: 1515086033157.jpg (960x885, 69K)

hatebin.com/oqosmutaoz
JavaScript rocks!

Attached: unknown.png (746x97, 11K)

Dude, It's a meme image, no one actually care.

Daily regex benchmark status

Attached: regexbenchmark.png (504x688, 80K)

Somewhat. Weird mix of "papering over limitations of OO" (strategy), "trivial bullshit" (singleton), and "useful insight" (visitor).

Way overrated by many, a bit underrated by some.

Whats the difference between atom and vscode? they look the exact same and seem to have the same features. Im looking for a cross language cross platform alternative tothe 20 ides and shit im currently using.

It's weird there is a perf diff to even bgin with. You'd assume all language compiler devs just prepackage it with the most hyperoptiized regex or smth

zig is gonna fall into obscurity and get abandoned.
It has absolutely no niche or feature worth picking it up. And to add to the shit, the syntax is engineer-tier ugly.

vs code isn't shit.

what is the best way to learn C? it will be my first programming language
should i read a book, watch one of those 4 hour long youtube videos...? anything specific you can recommend?

Atom is slow as fuck and shite
VS Code is really the top choice. I don't normally think Microshit is quality, but they stepped up the game with this editor

visual studio code spies on you, probably has a keylogger connected to microsoft cloud servers.

carlchenet.com/you-think-the-visual-studio-code-binary-you-use-is-a-free-software-think-again/

CHIP-8 emulator

No joke, I did it in python, turned out to be horrifically slow, so I used it as an opportunity to do it in C

>probably has a keylogger connected to microsoft cloud servers.
>probably
its open source, how can it be 'probably' doing anything?

>C
>first programming language

Why would anyone do that?

Attached: wutface.png (112x112, 17K)

MS have telemetry shit in the binary, but if you compile it yourself like a sane person, you're fine.

read the article, the binaries have stuff that are not in the public source code.

Making useless abstractions

Attached: 1533824787119.png (1920x952, 110K)

Because C is the one language that is simple and beautiful enough to learn first, yet so powerful that it can make a talented programmer (with nothing left to learn) into a literal god.

Stop! C is dangerous! Learn Rust instead, it is the future!

Any guides about how to compile it yourself?

it's what people on here told me i should learn... i initially said i wanted to learn python but i got called a retard for that
what should i learn then? C++? C#?
really?

No. A compiler should pretend that UB doesn't happen, or else it is not optimizing well.
Nevertheless, you can add in overflow checks, or clamp the values. It won't change a thing.
And even if that were the case, it doesn't explain the failure to optimize the others. max_bithack_xor never overflows, for instance. And with -Os, these aren't merged into one.

Attached: 1520217793909.png (296x326, 7K)

scheme is simpler, more elegant, and has more abstraction techniques that are fundamental to modern software development.

Attached: sicphave.png (603x702, 494K)

look on the github page.
if you're on an Arch, you can use the AUR to do it for you.

Rock solid.

Attached: 1508953032034.png (792x1023, 104K)

>i initially said i wanted to learn python but i got called a retard for that
that is retarded and C is better, but id recommend C# as a first one, partly because of great documentation and error messages that tell you exactly whats going on. Its also moderately good at everything so a good jack of all trades since you will probably be suing it for a bunch of different things if its your first.

>A compiler should pretend that UB doesn't happen,

but gcc does that since the generated code performs the addition without any check.

add edi, edi
sar edi


is (x + y) >> 1

If it optimized fully, they would all look the same - they all return the exact same results.

Anyone use this? Seems like it takes a long time for the mentors to check your answer

Attached: exercism.jpg (400x400, 7K)

Anyone here have experience with Spring? I'm working on a desktop application for organizing file metadata, is there any reason I shouldn't use something like spring to simplify my application so I can just auto wire all of my variables instead of having to manually instantiate them inside each class?

Dont know spring, but nothing wrong with using things like it, but it seems overkill for something like what you re talking about.

I need to apply a random noise filter on an image dataset.

That "noise" is a bunch of shapes. Text, gradients, halftone patterns, and other unique shapes.
What's the easiest way to generate this dataset?

Imagemagick.

As I understand it, Imagemagick is a set of filtering algorithms for batch processing; it doesn't do any "generation" to speak of. The patterns need to come from somewhere, and at the point when I've done that it's probably easier to use any programming language's built-in pixel 2D library

You can apply filters to empty images. It should be the most efficient way, using a shell script.
imagemagick.org/Usage/draw/

thanks. i think i'll go with C#. do you know any specific books/tutorials that you can recommend before i start looking myself?

the first half of C# in a nutshell is a good reference of all the languages features,

>implying it ever left obscurity
its probably the dev posting it

Looking at the API, this isn't any different from a built-in 2D library, but more difficult because I'd also have to learn bash's idiosyncrasies.

thank you very much

void main(string[] args) {
import gtk.Main : Main;
import gtk.MainWindow : MainWindow;

Main.init(args);
scope (success)
Main.run();

auto mainWindow = new MainWindow("ListBox Demo");
scope (success)
mainWindow.showAll();

import gtk.Box : Box;
import gtkc.gtktypes : GtkOrientation;

auto mainBox = new Box(GtkOrientation.VERTICAL, 0);
scope (success)
mainWindow.add(mainBox);

import gtk.ListBox : ListBox;
import gtk.ListBoxRow : ListBoxRow;
import gtk.Button : Button;
import gtkc.gtktypes : GtkSelectionMode;

auto listBox = new ListBox();
scope (success) {
listBox.showAll();
mainBox.add(listBox);
}
// Make these listBoxRows below unselectable
listBox.setSelectionMode(GtkSelectionMode.NONE);
// ListBoxRows are to be added to the ListBox
auto listBoxRow = new ListBoxRow();

// gtk.ListBox is a vertical container.

import std.array : split;

foreach (buttonName; "This is a listbox container".split())
listBox.add(() {
// this lambda:
// 1. creates a new LixtBoxRow
// 2. attaches a new button with the button name
// 3. returns it
auto currentListRow = new ListBoxRow();
currentListRow.add(new Button(buttonName));
return currentListRow;
}());

listBox.showAll();
}

Attached: 1535758853717.jpg (346x510, 31K)

Design patterns are templates for bad programmers who need guidelines. Good programmers write code without thinking about specific design patterns and their code partly matches design patterns naturally.
You most likely already use common design patterns without thinking about it.

Based komari poster

Is that Vala?

D

hey quick question, in c++ how would I get rid of \n characters from being read into a string from a cin stream?

Maybe with
cplusplus.com/reference/string/string/getline/?kw=getline

yeah getline isn't working, the stream input is spilling over into another object which can only accept integers not chars, which is causing it to fuck up.

what the fuck is this gay shit?

Attached: 1528441509188.gif (575x420, 507K)

Is Rust stable yet?

Its some retarded shit youll never see outside pics on here anyway, its called a 'woman',

I want to learn to code as a hobby, what are some good projects you can do?

do you need the string to be accessed live and therefore you need to catch the newline/return carriage or can you just .find and .remove them before serving it?

emulator

yes, I'm not sure what "accessed live" means, but what you're saying is true in general, how would I go about doing this?

cin is all kinds of busted, never use it.

video games

If you need raw characters, you will need to catch it during the read loop, or when it is appended, if you're using formatted read that shouldn't ever happen

I want to make a general "set algebra" evaluator in lisp (can do set union, intersection, difference, etc..). The sets can contain anything from numbers to strings to other objects.

However, I am running into a problem. How do I handle the case where I need to compare a string and an integer (or more generally, mismatched types)? Would I use the standard "eq" predicate? The only problem with that is that (eq "a" "a") returns false.

Would I have to write a sort of function that maps from types to comparisons?

you might AS WELL run HASKELL on your HASWELL cpu

run it on your uwu instead

Attached: DoiSom7XUAAgHpF.jpg (680x383, 29K)

>no being0
>'() isn't false
>'() isn't its own car and cdr
>define-syntax
lmao

baby duck af

equal?

>continuations
>no standard library
>no namepsaces
>not portable

continuations are powerful and useful.
make your own, this is lisp.
who cares
there exist many more scheme implementations for far more diverse platforms than c++ommon lisp

Lol yeah Just realized that two minutes after I posted.
I'm not terribly smart.

Attached: SPOOK.gif (600x450, 1.66M)

I wrote a regular expression compiler that generates C code.

it's pretty cool

> scheme
> more abstraction techniques that are fundamental to modern software development

scheme has hygenic macros and what, continuations?
guaranteed tail calls i suppose

but these are mostly toys for scheme fanboys, not fundamental to modern software development

Can you share the code?

are there any pathological backtracking cases tested?
most of the regex vms listed die on those

it's just a toy so it's probably kinda shitty but sure, give me a bit to clean it up and post it somewhere

>give me a bit to clean it up
It's anonymous, share the dirty code.

nah it had some old bits from before i got rid of the bytecode interpreter, gonna delete that stuff at least

lambda expression

you know what, i'm retarded. i thought the post was comparing scheme and common lisp

The cases for that benchmark are as shown, email, uri, and ip. You can google regex benchmark, should be the first thing you see. There are loads of issues on how other language devs want their language represented, and so the benchmark changes as the 'right' regex compilation is chosen. The github has the patterns iirc

>continuations are powerful and useful
powerful sure, but useful, no
Nobody understands continuations, they're like the monads of Scheme.

Should I get into Haskell again?
Show me a Haskell program to make me horny for it.

Attached: 1533778883777.gif (388x218, 2.19M)

continuations are the mother of all monads

Please I just want to understand it, give me the proper resource.

You want to understand monads?

continuations might be easier to understand if you implement a continuation passing interpreter.

this might help

blog.theincredibleholk.org/blog/2013/11/27/continuation-passing-style-interpreters/

pastebin.com/VzFxKwwM

Both, but mostly continuations.

its just a method followed by a goto

>this isn't any different from a built-in 2D library
Well, no, there's a big difference in imagemagick's favor:
>when you say imagemagick everyone knows you're talking about imagemagick
>when you say "a built in 2D library" no one knows what the fuck you're talking about because you forgot to tell us what language and/or platform you're using
pic related yfw rn

Attached: 1535362346239.gif (297x268, 600K)

if you understand how return addresses on the stack work
a continuation can be understood as popping a return address off the stack, and wrapping it up in a function that jumps to that address

it's not literally that, and undelimited continuations aren't bounded to a stack principle, but in general continuations are just the `address of the rest of the code`