/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx
msdn.microsoft.com/en-us/library/dd460756.aspx
faydoc.tripod.com/formats/mid.htm
www3.cs.stonybrook.edu/~rezaul/papers/TR-07-54.pdf
doc.rust-lang.org/std/macro.include_bytes.html
rgho.st/6GR22Vd57
twitter.com/SFWRedditImages

First for OOP

every year you live through is cached in memory, so the next year moves faster because you're already familiar with a year. The longer you live, and the more data/years you save in memory, the faster time seems to move.

fpbp

Do you follow the class oriented or prototype (native) oriented style of writing? What is the common agreement on this issue?

Thank you for not using an anime image.

you're looking kind of sexy, Donnie

>Do you follow the class oriented or prototype (native) oriented style of writing?
These aren't well established ideas user. I suspect you're asking if people prefer object oriented programming or procedural/imperative programming?

Or is it less strict so you're asking if people prefer to do their code exploration with the presumption that they will be using a class vs the presumption that they don't want to use a class for things?

class prototypes

Oh God sorry , I meant in javascript. Sorry.

...

Would it be a bad idea to use webp for thumbnails in my chan clone?

/dpt/ doesn't like ECMAScript that much and I doubt they use it.

What is man supposed to use when here's just no good statically typed and compiled language.
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>lisp
too verbose, also static typing not standardized
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters, also uglier than sepples
> any jvm/clr lang
requires huge vm
>go
Rob Pike is faggot, also no macros

Neither

Ada

unless you want to keep old browsers out, no

H
a
s
k e l l

Who said I am using javacript for webdev?

>generating 302598932758937258932759GB/s

C#, friend.

>using javascript outside of webdev

>generates garbage 1GB/s

C++ is unironically the best option and it's not bad to work with once you've learned enough of it

other languages generate 10TB/s

Have you worked on a large team?

What's the Big O of this implementation of Dijkstra? Quadratic or linearithmic?

void dijkstra(const Graph &G,const int &S,vector &d)
{
d.resize(G.size(),INT_MAX);
priority_queue Q;
d[S] = 0;
Q.push(make_pair(S,d[S]));
while(!Q.empty())
{
int u = Q.top().first;
Q.pop();
for(unsigned int i=0; i < G[u].size(); i++)
{
int v = G[u][i].first;
int w = G[u][i].second;
if(d[v] > d[u]+w)
{
d[v] = d[u]+w;
Q.push(make_pair(v,d[v]));
}
}
}
}

Sensory Memory: CPU Cache
Short-Term Memory: RAM
Long-Term Memory: HDD

I'm curious: how would one go about making a simple window manager for windows? Are there APIs that support this?

Anyone have any advice to writing a Java program that outputs MIDI files? I'm aiming for a random music generator side project sort of thing.

>simple window manager
oxymoron

do/can you guys code on drugs, prescriptive or otherwise
and what difference do they make

You have to learn winAPI and work with window handles.
msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx
is probably where you want to start. From there you get all the handles to the windows and you can extract their names or whatever. Using the handles you can set the window position dimension and flags given you have enough permissions. Install msdn.microsoft.com/en-us/library/dd460756.aspx too. It's very helpful for debugging and to gain an understanding of the windows window management.

I've had to do some generic window overlay for someones terrible idea once. It's not a good interface. Don't know anything about windows 8 or 10. Everything might be different.

sorry, program

Haskell is dead

i only drink coffee

i think certain stimulants might be useful but it's very hard to justify using them over the long term (even coffee is of dubious value over the long term imo)

ASM is a pretty specific language, jfc

whoever said it was easy?

SSRIs right now, they seemed to help for a while but I've recently hit a low point again.

Learn how the MIDI file format works.
faydoc.tripod.com/formats/mid.htm

not really
are you one of those idris memesters

Too intelligent to use Haskell.

Im trying to voxelize a mesh, im clipping the mesh at different distances and render it off and on screens. On screen rendering with the framework provided flip() method works fine.
I have problems with off-screen rendering to texture. Pic related, red slices are the off-screen renders which have some artifacts compared to the green slices that are on-screen renders. The mesh is the voxel representation of the whole off-screen render of the stanfordbunny.

And this is the meat of the code. The on and off screen rendering setups are basically the same, except i change the framebuffer for off screen and generate a target texture. Any opengl gurus willing to point out the problems?

Mook wouldn't let me post code so i put it on pic related

try a higher res depth buffer

How?

I dont think the depth buffer changes anything, on-screen rendering works. Also the shader sets the pixel red if it sees a triangle, no matter how deep it is.

>How?
in generateTexture3D

>the shader sets the pixel red if it sees a triangle, no matter how deep it is
so you don't have a depth buffer

>so you don't have a depth buffer
nvm i'm not sure what you're talking about

you're rendering different slices and you don't want other slices to show?

i think its cubic

free MatLabâ„¢ compiler?

I would want to learn Rust but I'm scared that Rust will die in the coming years

You can't compile matlab. It's impossible. You have to embed a matlab interpretor.

8086 is easy and comfy

>Rust will die in the coming years
Something that's already dead can't die.
Nobody programs in Rust.

linear?

if you don't use exclusively write everything in lisp, then you are worthless.

1: ; AddTwoSum_64.asm - Chapter 3 example. 2: 3: ExitProcess PROTO 4: 5: .data 6: sum DWORD 0 7: 8: .code 9: main PROC 10: mov eax,5 11: add eax,6 12: mov sum,eax 13: 14: mov ecx,0 15: call ExitProcess 16: main ENDP 17: END

how come this results in visual studio lnk2001 error, and when I save and rerun the program after closing it, the error's gone?

...

In what universe

Jesus fuck

reply for DOD

ASM is pretty easy imo just more tedious to write complex code with

Sorry I missed out parts i didnt find noteworthy.
The commented out part in the drawMesh function calls glOrtho where i set the far and near planes, this basically will only show a part of the mesh, like its cut in half. Every slice i change the far and near planes distance to advance in the slices and show only that slice.

This i how i generate the texture:
t = glGenTextures(1)
glBindTexture(GL_TEXTURE_3D, t)
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8UI, w, h, d, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_8_8_8_8, None)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)

If you look at the butt of the bunny it is rendered okay, so the texture should be okay.

>i'm not sure what you're talking about
>you're rendering different slices
Yes.
>you don't want other slices to show
Thats sorted as i described above with glOrtho.
I dont want the artifacts (noise like on-off pixels) that appear on the red slices in my previous post pic. They looks like lines on the mesh representation of the voxels.

I am clueless, never seen this kind of errors before.

I'm programming a telegram bot in python, and it parses icals it gets from a http link using the iCalendar package.

However, I noticed that by downloading from http, it doesn't get the latest ical. How do I get an ical from the webcal:// link as a file or as something to parse in python?

First off, I'm going to assume you add something like:
...
set visited {S};
...
while(!Q.empty()){
int u = Q.top().first;
Q.pop()
if (S.find(u) != s.end()) {
//process node
...
}
}

Then worst case your graph is basically* fully connected, thus you do O(n^2) pops total (first node pushes on n-1 nodes, second node pushes on n-2 nodes, ect), and since PQ pop is just delete(min), we get a total of O(n^2*log(n)) cost for popping all the nodes.
The for loop is only entered n unique times (due to checking the visited set), and does at most n pushes (at a cost of log(n) for insertion), which again gives n * n * log(n) or O(n^2log(n)). Thus total is O(n^2log(n)). Without the set, I'm fairly sure it's O(n^3), since for each n^2 nodes popped you must go through all n* edges each time.
*I put an asterisk here, because generally it's assumed you don't feed dijkstras anything but a DAG.

try glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) in renderOffScreen like in renderOnScreen. now you're only clearing the color buffer in renderOffScreen

Apparently you can implement Dijkstra's with a binary heap without decrease-key and still have it run in O(n logn). I can't for the life of me find an implementation of it.

or try glDisable(GL_DEPTH_TEST)

In VHDL, I'm working on getting a set of up / down counters for real time demodulation of a signal to communicate with a bus interface properly.

I've learned a lot about finite state machines in the past few days. Opinions on single process FSMs vs two process FSMs?

For being a subreddit on Sup Forums /dpt/ sure hates any language that isn't mainstream and enterprise ready.

*clears throat*

>tfw retards are slowing down Rust development by conflating HKTs with type level lambdas

>muh higher kinded types
>muh lambdas

Make fmap map again.

>it's another episode of user being mad at what he doesn't understand

Well I went and looked it up, and found this paper (which, interestingly enough, says always use NoDec algorithms for cache/IO reasons): www3.cs.stonybrook.edu/~rezaul/papers/TR-07-54.pdf
Gist of it is on page 17 figure 6 function B.2. Basically you maintain an array of current min distances for each node, and push on tuples containing (node #, distance) which it looks like you were trying in your original post. Then when you pop a node, you only do anything with it if the distance it was pushed on with is smaller than any you have seen so far. They go over the complexity on the same page, where m == E.

doc.rust-lang.org/std/macro.include_bytes.html
>Rust actually has a standard and simple as fuck way to embed any arbitrary file into the program at compile time.

fn main() {
let foo = include_bytes!("foo.bin");
println!("foo = {:?}", foo as &[u8]);
}

foo = [192, 193, 194, 195]


C and C++ BTFO.
I don't know why other languages fail to support something as simple as this, forcing you to resort to stupid platform-dependent linker fuckery.
This is a big win for me.

HKT's are fucking useless but don't shit-talk lambdas m8.

I see they use a weight function in their implementation. Any idea what that is doing exactly?

So I've found the Idris book, it's a 10Mb pdf with awful text quality(because it's an OCR of the printed version and not the PDF edition), but it's quite readable. If anyone wants it, see rgho.st/6GR22Vd57 . I can upload it somewhere else.

Why did the equal signs turn into asterisks?

>HKTs are fucking useless
I think you mean "quantifying over HKTs is fucking useless", which is still pretty dumb. "HKTs are fucking useless" means you think every generic type is useless.

running this in R studio after changing the seed to 1234 made me get a very weird graph in question 8 part C. any idea what's causing this?

I don't see a weight function (at least what I think of as a weight function). Are you looking at Figure 6, function B.2 (i.e. upper right corner of page 16?)

Interesting.

No, I mean higher kinded types are useless.
Everyday generic types aren't higher kinded.

Functor is an everyday generic type

If F is a type then F is a higher kinded type.

Personally I don't really like the term "higher kinded type" because they aren't actually types. "Type constructor" or "type family" is better.

Functors aren't higher kinded.

Yeah, check the for each loop. There are calls to w(), which they say is a weight function

In that case, Rust has HKT's then.
Why do people say that Rust doesn't have HKT's?

F is just a function.

FunctoR is.

It's a type term of a higher kind.
Type functions and type constructors are not the same.

Rust doesn't have the ability to quantify over HKTs, which is what people typically mean when they say a language has HKTs.

Functions to types are also known as type families or "higher kinded types".

Django. Want to make a blog with it for full control of customization. And once that done, rent a webserver and make a domain name.

Fuck Wordpress.

>Type functions and type constructors are not the same.
That's not what coq say.

What does "quantity over hkt" mean?

And what does "quantifying over HKT's" even mean? give example that ISN'T in Haskell please.

> give example that ISN'T in Haskell please.
template< template > in C++.

The exact same as quantifying over types (what most languages' generics can do), just with HKTs instead.

// Foo is defined FOR ALL type families of kind * -> *
template
struct Foo {
F bar;
F baz;
}

Tried both in every way, no change.

I also tried using GL_UNSIGNED_BYTE type texture, no change, but ill stick with this so im not wasting 4 more bytes on nothing.

It depends on the system, but to consider all systems you would refer to them differently.

I would use them differently anyway.

pic