/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

en.m.wikipedia.org/wiki/Dependency_inversion_principle
clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/
twitter.com/AnonBabble

muslims

>tfw fell for the D meme
>can't be comfortable with any other language in existence because D is so comfy
>peak baby duck syndrome

I have been working on a basic torrent searcher, it scans a few public trackers, and returns results from everyone of them, lets you pick one, and downloads it to the torrent directory.

Can we please talk about programming? Not about anime, religion, or how much you love D

Welcome to the light, friendo.

Nim is the true light, my fello D nigger

Nah, Nim a nice toylang in all but its wildy inferior to D.

thread local GC

D is a myth. Nim is a joke.

C was a mistake

>Keeping track of allocation is HAAAARD :((((

Rust was misguided

>Hard
Tedious*

Java is perfect.

Rust skipped the leg day

That's pretty accurate.
OK pajeet

possible in D.

Name one flaw in Java. You cant.

system.out.print

>Nim is a joke.
I think Nim is going to get its own LLVM compiler
Walter is doing literally nothing, it's like he stopped doing non-boring stuff. I wonder why.

There are some people that want to implement a new GC but that alone will take a heavy rewrite. But that GC is not thread-local

The JVM

ayy, JVM is fucking wonderful

import static java.lang.System.out

Covariant arrays

unsound type system
boxed generics
null references

Who knows, I think theyre currently trying to get the std in order as theyve started deprecating a lot of built-in stuff. D is headed towards optional GC though. Look at all the recent DIPS that are snowballing us there.

arrays are deprecated in favor of collections
all correct which is why I shill haskell

Haskell is also shit.

I wrote a C program that calls printf("%s\n", argv[3]); and then called it with no args and it printed one of my environment variables.

what

liar!

Arrays are the only way to achieve good performance, collections force you to box elements

curly braces

Nice side-effect faggot

On Linux/Posix systems, there is a hidden argument passed to each program: the environment variables, which just happen to live right past the program arguments.
So an acceptable prototype for main is
int main(int argc, char *argv[], char *env[]);
What you're doing is still undefined behaviour, though.

The fact that C will even compile that in the first place is disgusting.

Whycome?

Its UB.

Well yes, but everything in C is UB.

A lot of UB is extremely difficult to detect (possibly undecidable), so the standard does not require compilers to check for it or do anything, really.

and c is shit

It's still the only language usable for FFI.

no

>happily browse programming topics
>find this
en.m.wikipedia.org/wiki/Dependency_inversion_principle
Why do people have to put others down like this?

Suggest an alternative that is usable.

I'm very happy C has UB. It'd be such a headache to work around a complex programming language where most things are clearly defined. In C I can just program where things are defined and be explicit where I have to. UB lets the compiler help me out.

And if I want more safety there's plenty of tools for that like clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
For instance.

> i enjoy not filling arguments where theyre needed
>i enjoy tedious edge-case bugs because my compiler doesnt give a shit and i have shitty habits

nah

I wish C would just segfault on UB

See Also, the C standard has no concept of a "segfault".

At runtime then, w/e

I feel the same way about using Ruby
>tfw most other languages aren't as comfy as Ruby

Well if you're having serious issues writing simple C code then I don't know
UBSan which I posted has that. Not segfault but it gives an error and line where UB occurred and aborts. I'm sure there's some way to make it break in your debugger instead.

Doesn't catch everything obviously.

>criticizing a language means youre projecting your own incompetence and theres nothing actually wrong

alright m8

>At runtime then
The point still stands, whether it's compile time or runtime.
Consider this piece of UB in C:
> The execution of a program contains a data race
How on earth are you supposed to detect that, runtime or compile time?

But you said you had these issues.
These are not general issues among C programmers so clearly you were bemoaning your situation.

Undefined behavior is not intended to be an error. If it were, it would be defined behavior. Furthermore, not all platforms even have a concept of a segmentation fault to begin with. Dereferencing a null pointer is undefined behavior because while on most platforms, that should result in a segmentation fault, on some, it's a physical address that points to something real, like an interrupt vector table.

The big idea here is that rather than placing runtime requirements to enforce specific behavior, we just let the platform decide how that sort of behavior manifests.

No, i was just giving an example when you program in an environment like C

It's not a language problem that someone makes programming errors out of something which they recognize is a bad habit.
>edge cases
They are something you're aware of when you program in C. It's not as mad as something like C++ where you have people who make a living just being experts in the language without programming.
It's in a pretty nice spot with UB as is. Nothing can be assumed ideal before proven but I'm confident it's scoring high.

>Bernstein disputes that this is a practical attack, arguing that no real-world deployment of qmail would be susceptible.

Now that's what I call Judaism, especially over $500

I just like adhering to purity and contractual consistency. I think a language as wildly uncaring as C has no place in software anymore. But we're stuck with it for decades more.

>feels > reals
Someone's got to write the managers for all these managed languages, and with what?

I want to go through K&R and learn C properly. I used C during some classes when I was in school, but I don't really have a complete understanding of it. What's the standard development setup I should be using under Linux to get started with exercises?

>and with what?
Plenty of better languages can use C.
Unfortunately the prime candidate needs to get rid of its GC first before anyone will think about it.

Agda

vim, gcc, glhf

Why is /dpt/ so slow now? Did all the summer fags leave?

vim, gcc, gnumake, gdb, valgrind, and your favorite terminal multiplexer

I recommend using Clang over gcc simply because Clang has much better error messages than gcc.

where's the gate keeper?

Here

You better have read your SICP today or you may not post in this thread

meme


webdev

They're starting to head out it seems. We had a really high quality thread just yesterday (see , it's great save for one troll that showed up towards the very end) for example. Much better than a month ago, at least. Trolls trolling trolls yelling on a daily basis back then.

It's really hard for me to understand what those people even want from their lives. Interesting people rarely respond to trolls because the biggest regulars in /dpt/ know exactly how they work.

Man, package managers sure are great until someone fucks it up and youre stuck unable to do anything.
Guess its toylang night.

learn haskell

Already learning idris, desu.

that's alright but Idris doesn't have great tooling or support desu

I'm working on water for my minecraft clone. Going well.

Thought this glitch was interesting enough to record.

Idris by design is meant to not need a whole debugging suite. And i actually like reinventing the wheel desu.

Is your minecraft clone faster than the original? How is your minecraft an improvement, if at all on the original? Are there any goals you have for your minecraft clone? What language is it written in, C++?

You're about to find out how cool his project is internally. I won't spoil his reveal.

But I'll add that I'm hoping he does some cool user-facing thing with the engine he has once he reaches that stage, like his own version of redstone or something like that. I don't know what his plans are.

>Thought this glitch was interesting enough to record.
You thought wrong

what does this do?

I have a macro that is basically a wrapper around snprintf. However, for reasons, I need to change this so it doesn't use snprintf anymore, probably to something like stringtsream. I need to keep the functionality the same of returning a string without changing the definition.

Is there an easy way to get stringstream to work with a printf style format string, or am I just going to need to parse it and insert all the arguments manually?

I'll tell you what it doesn't do: compile. Forgot that semicolon, senpai.

With the semicolon, it lets you type out.println instead of System.out.println to print to the console. Not sure what that user was trying to accomplish.

cute anime

90 percent of the time /dpt/ posts are
>fizzbuzz
>language wars
>syntax arguments

related.

This will probably be the most interesting post ITT i'm calling it.

Not even /agdg/ would care, desu.
Minecraft clones are a diamond dozen.

Stupid frogposter, get suicided

>diamond dozen
kys brainlet

61450161
>falling for the oldest newfag bait
wew

...

>Is your minecraft clone faster than the original?
I think it will end up being so.

My goal is for the game to be an IDE for writing mods for the game. It's written in C and Scheme

>wew
wew

wew
e
w

>My goal is for the game to be an IDE for writing mods for the game.
u fokn wot
actually that's a pretty cool premise for a game more generally
imagine what if there were a specialized programming language for the mods that also looks kind of like an ancient arcane scroll-language
and like
you must train in-game for higher level ancient scroll magic to write on your scrolls
scrolls = mod packages

>Is your minecraft clone faster than the original?
It's pretty hard to not be. Every minecraft clone is leagues faster than the original.

>Scheme
Okay maybe not.

I've been following: higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/ but I haven't quite gotten it right, there is still issues going on. More in reply.

boolean scantile ( entity_t *ent, int tx, int ty, int h_dir, int v_dir, level_t *map )
{
//tile information
int tile = ( ty * map->Width )+ tx,
til_s = 0,
til_t = map->layer[1].Data[tile];
//tile dimensions
int u = tileset[til_s].tile_w,
v = tileset[til_s].tile_h;
//tile coordinates
int tx1 = tx*u,
tx2 = tx*u + u,
ty1 = ty*v,
ty2 = ty*v + v;
//entity coordinates
int ex1 = (int)ent->hb.x,
ex2 = (int)ent->hb.x + (int)ent->hb.w,
ey1 = (int)ent->hb.y,
ey2 = (int)ent->hb.y + (int)ent->hb.h;
//entity center
int exc = (int)ent->hb.x + (int)(ent->hb.w/2),
eyc = (int)ent->hb.y + (int)(ent->hb.h/2);

int flrL,
flrR;
int celL,
celR;

switch ( til_t )
{
case 1:
flrL = ty1;
flrR = ty1;
celL = ty2;
celR = ty2;
break;
case 2:
flrL = ty2;
flrR = ty1;
celL = ty2;
celR = ty2;
break;
case 3:
flrL = ty1;
flrR = ty2;
celL = ty2;
celR = ty2;
break;
case 4:
flrL = ty1;
flrR = ty1;
celL = ty1;
celR = ty2;
break;
case 5:
flrL = ty1;
flrR = ty1;
celL = ty2;
celR = ty1;
break;
}

float t = (float)(exc-tx1)/ u;
int flrY = lerp(flrL,flrR,t);
int celY = lerp(celL,celR,t);
boolean adjX = false;
boolean adjY = false;

//step x
if ( !adjX && ex2 > tx1 && ex1 < tx1 && flrL < ey2 )
{
ent->pos[0] = tx1 - ent->hb.w;
adjX = true;
}
if ( !adjX && ex1 < tx2 && ex2 > tx2 && flrR < ey2 )
{
ent->pos[0] = tx2;
adjX = true;
}
//step y
if ( !adjY && ey2 > flrY && ey1 < flrY )
{
ent->pos[1] = flrY - ent->hb.h;
adjY = true;
}
if ( !adjY && ey1 < celY && ey2 > celY )
{
ent->pos[1] = celY;
adjY = true;
}
//verify adjustment
if ( adjX || adjY )
{
sethb ( ent );
return true;
}else {
return false;
}
}

I nominate APL.

...

what the fuck is this coding style