/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

downloads.haskell.org/~ghc/7.6.3/docs/html/users_guide/code-generators.html
github.com/enfiskutensykkel
github.com/syoyo/tinyobjloader/blob/master/tiny_obj_loader.h#L222
en.wikipedia.org/wiki/Danelaw
benchmarksgame.alioth.debian.org/u64q/haskell.html
twitter.com/SFWRedditGifs

Trying to compile Haskell to intermediate C code so I can prove someone on Sup Forums wrong, but I don't know why it isn't working.

Using higher order functions is not functional programming in the same way that using objects is not object-oriented programming.

Tile based image compositor in OpenGL

If you're compiling via LLVM, make sure you actually have LLVM

About to write a library that reads from a kind of simple file format.

Should I have one Foo_Loader that the user gives a filename and a "callback" object that calls functions the user provides whenever it encounters a certain type

Yes, that's a perfectly fine non-FP way to do it.

Just use Parsec.

>Paradigm-mixing OO and FP
Why is this allowed?

I would return a stream. What if the caller wants to parse contextually? That will be very difficult if you make them provide callbacks.

Because it's the only sane way to program.

This.

Thanks for the tip. Is only LLVM supported?

I think so
downloads.haskell.org/~ghc/7.6.3/docs/html/users_guide/code-generators.html

You can compile it to C--

I mean, it's not impossible but what you'd be effectively doing is making the user provide all the base cases and recursive steps corresponding to the data structure you are loading instead of allowing them to do the recursion/iteration themselves.

post your github

github.com/enfiskutensykkel

Structs and pointers?

It's binary data by the way. Not text. And it can potentially be gigabytes large.

>At interview
>So user, we googled your github account and we found someone posting links to it on an archive for that Sup Forums website. Isn't that that anonymous forums where the pedophiles hang out?

>>So user, we googled your github account and we found someone posting links to it on an archive for that Sup Forums website. Isn't that that anonymous forums where the l33t h4xx0rs hang out?
ftfy

If you're implementing objects by using PIMPL and vtables built from the ground up from structs and (function) pointers, then you're still just using objects.

If you orient your program around objects implemented in any manner, that's object-oriented programming.

As long as it's loaded lazily (which is possible with a stream) it's fine.

>IT"S NOT PEDOPHILIA IF THEY ARE ANIME BAE'S

> Isn't that that anonymous forums where the pedophiles hang out?
>...yes?
>Congratulations, welcome to Apple.

>structs are objects
herewego.jpg

And by "orient your program around objects" I mean "model systems as objects sending messages to (calling methods on) each other".

Who are you quoting?

your mom

But he's just using callbacks.
Those aren't objects.

why are Scandinavian people the best programmers?

DID ANYONE SAY CALLBACKS?
fs.readdir(source, function (err, files) {
if (err) {
console.log('Error finding files: ' + err)
} else {
files.forEach(function (filename, fileIndex) {
console.log(filename)
gm(source + filename).size(function (err, values) {
if (err) {
console.log('Error identifying file size: ' + err)
} else {
console.log(filename + ' : ' + values)
aspect = (values.width / values.height)
widths.forEach(function (width, widthIndex) {
height = Math.round(width / aspect)
console.log('resizing ' + filename + 'to ' + height + 'x' + height)
this.resize(width, height).write(dest + 'w' + width + '_' + filename, function(err) {
if (err) {
console.log('Error writing file: ' + err)
}
})
}.bind(this))
}
})
})
}
})

Sharia law instills discipline and mindless obedience.

I mean something like this. Which is essentially passing it an inherited object(using a class rather than a struct, with overloaded virtuals).

github.com/syoyo/tinyobjloader/blob/master/tiny_obj_loader.h#L222

I don't think I'm any better than other people desu. My github is essentially a bunch of unfinished projects and some badly written tools I wanted to keep available for myself.

You can't disprove this. In fact, most C literature refers to any allocation of memory as referring to an 'object'

i was talking about Norway and Finland mostly, not Sweden

Similar semantics and terminology doesn't make it similar concepts.

Just because a programming language has functions, doesn't make it functional.

>Norway and Finland
It's cold and dark in the winter with not much to do besides wrapping a blanket around you, pile up on warm coffee and cocoa and start hacking away.

yeah but.... sh.. shut up!!...

what about girls

If I was attractive enough to be with girls, I wouldn't spend my time on Sup Forums 20 minutes to 1 AM on a thursday.

Whatever it is, it must be something common with Russians

are you virgin?

>The similarity between the operating systems disappears when running in 64-bit mode because the function calling conventions are different. 64-bit Windows allows only four function parameters to be transferred in registers, whereas 64-bit Linux, BSD and Mac allow up to fourteen parameters to be transferred in registers (6 integer and 8 floating point). There are also other details that make function calling more efficient in 64-bit Linux than in 64-bit Windows... An application with many function calls may run slightly faster in 64-bit Linux than in 64-bit Windows. The disadvantage of 64-bit Windows may be mitigated by making critical functions inline or static or by using a compiler that can do whole program optimization.

Why does Windows do this?

No.

See

IDK, their version must be

Drink away depression with vodka and shoot krokodil with frend

lol'd

Because the people who program for Windows have no fucking idea what they're doing.

You need to make more Scandy-threads, bra. I enjoyed the one we had recently.

...

>forgetting the best scandy flag

>st. george
No. The Faroese flag, yes.

looks like success really does breed jealousy, achmed :^)

what

I would totally live in Scandy-land if I spoke a Scandy-lang.

>Icelandic one has slitty eyes
It's funny because it's true.

>icelandic

English people are trying to redefine themselves as Scandinavians because of Brexit now and fear of being alone outside EU without any alliances.

Icelandic girls will break your heart

en.wikipedia.org/wiki/Danelaw

>Icelandic
It's clearly the finno-ugric one.

Would totally hatefuck Björk

We are taught this in high school, user. You clearly don't remember that the vikings were driven away after losing the battle of Stamford bridge.

I live in a village with a -by suffix

I wouldn't bother. Haskell won't beat Java
Java is faster than Haskell.

benchmarksgame.alioth.debian.org/u64q/haskell.html

How many compilers have you written in Assembly language?

It's easier to write idiomatic, safe, fast code in Haskell than it is in Java.

worth pointing out that a lot of those are out of date for a lot of languages

Explain to me what you think I'm trying to accomplish user?

Protip: Running fast isn't the correct answer.

how the FUCK do I move a file safely to a folder in C with linux

In assembly? None.

In Java: one.
In C: two.

>In assembly? None.
lmao

So there are effect systems for determining what has to be done at run time vs. what can be done at compile time. Is there anything similar for ensuring certain things are done only at compile time?

...what? Anything you need done at compile time hard-code or use something like template metaprogramming if you language supports it.

It's not about what I want to be done at compile time, it's about separating out what MUST be done at compile time through inlining, constant folding, etc. This is in the context of language design, not using an existing one.

lmao

ayyy

idris has type providers

>tfw to smart for OOP
>tfw have to use Haskell
>tfw my iQ can't be measured on a human scale

he's floating away on his head because he's an airhead, and really dumb, and all the anons below him are unimpressed with his ego

Man, these >to smart memes have become strange.

You copy the original file to the new folder, then delete the original file. If you're asking about implementation, you should read up on the C docs.

Why is there a tennis ball pooping into a see of pee, poop and wojaks with microcephaly and anencephaly ?

I haven't actually read any docs yet because all of the implementations I've been looking at somebody goes "oh that way isn't safe, because the system can potentially overwrite it and you can't use stat() here because" etc

Lena, except every R/G/B value is within 1 standard deviation of the average.

I take it this wasn't written in C then

When should I use A, B, or C?

/* Option A (stack) */
DataStructure foo;
init_data_structure(&foo);
/* ... */
destroy_data_structure(&foo);

/* Option A (heap) - allocate and free manually */
DataStructure *foo = malloc(sizeof(DataStructure));
init_data_structure(foo);
/* ... */
destroy_data_structure(foo);
free(foo);

/* Option B - pass pointer to pointer, allocate and deallocate in init/destroy functions */
DataStructure *foo;
malloc_and_init_data_structure(&foo);
/* ... */
destroy_and_free_data_structure(foo);

/* Option C - return pointer, allocate and deallocate in init/destroy functions */
DataStructure *foo = malloc_and_init_data_structure();
/* ... */
destroy_and_free_data_structure(foo);

Because averaging in C is impossible?

Yes, you're right.

That's not really what I'm looking for.

For example, something that MUST happen at run time is I/O. Something that MUST happen at compile time is using something that doesn't have a run time representation at all.

You can make a run time representation of anything, of course, but I'd rather be able to say that something must be done at compile time so that you know it will be 100%.

>using CuckSharp

lel

I understand your concern for safeness, but if you were truly that concerned you wouldn't be using C. You also have to keep in mind your use case and exactly what your code does that might be considered unsafe. If your code doesn't use threads then you don't have to worry too much about race conditions and building protections against that would be meaningless. Just write the code first and worry about safety later or - as many C programmers are wont to do - even never.

Oh I personally am not overly worried, it's a very simple application, I just don't understand enough about this kind of thing to get a sort of metric sense for how safe my program should and should not be.

Whats a good IDE for beginners with language C on Linux?

Genuinely in the most non-meme sense, none. Get a good text editor and learn bash and Makefile, and all your compiler flags. Then once you're very comfortable but feel the need for an IDE, it'll make so much more sense and you'll be able to unlock the true power of IDEs.

Genuinely in the most non-meme sense, none. Get a good text editor and learn bash and Makefile, and all your compiler flags. Then once you're very comfortable but feel the need for an IDE, it'll make so much more sense and you'll be able to unlock the true power of IDEs.

Genuinely in the most non-meme sense, none. Get a good text editor and learn bash and Makefile, and all your compiler flags. Then once you're very comfortable but feel the need for an IDE, it'll make so much more sense and you'll be able to unlock the true power of IDEs.

A for simple reusable data structures which you will manipulate directly.

B for complex objects which you will only pass to their own public interface functions. Return integer error codes or 0 for success.

C never.

What would you guess this was

Linux basically is an IDE. Windows would be too if it wasn't so shitty that you need 3rd-party programs to get similar functionality with the terminal, file system, etc.

Its called gedit and a terminal

A whenever possible, B if not but you should allow the caller to specify the allocation/deallocation routines instead of forcing malloc/free on them. Naively using B can be quite detrimental to performance.

Perhaps I should say that most Linux distros are IDEs, not Linux itself.

Looks like it had something to do with fixed size regions.

Do the arrows point to the highest intensity in a given region?