/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

facebook.github.io/reason/
google.com/search?q=print one line python
google.com/patents/US6007232?dq=6007232
open.gl
github.com/torch/torch7/blob/master/TensorMath.lua
fsharp.org/
youtube.com/watch?v=TH9VCN6UkyQ&list=PLmV5I2fxaiCKfxMBrNsU1kgKJXD3PkyxO
learnopengl.com/
twitter.com/NSFWRedditGif

you suck at life

>C programmers will never admit that other languages have SOME good features

I do
javascript has closures
PHP has traits
C++ has lambdas
java and python suck though

C is PERFECT there is literally NOTHING wrong with C. C++ and Go are literally just bloat, I don't see why anyone would in their right mind program in slow as fuck languages like Python or Lisp. The unix way is the right way. C is the best language.

I don't think that's the case usually. It's about tradeoff.

There's rarely good tradeoffs.

If these are the most important features of C++ to you then I suggest using Rust.

oh shit i can actually make dynamic web pages in C

Is there anything C can't do?

java has lambdas
python has lambdas

Probably the wrong post to reply to:

I have a file and a compressed version of it (some flavor of gzip without encryption that i cannot replicate with gzip) how can i determine what the encryption is and how to replicate it with other files?

Anyone have experience with this kind of stuff?

>C is PERFECT there is literally NOTHING wrong with C.

i like ur bait

depends on what you're using it for

C is really bad for a lot of purposes

Run file on it:

$ file kek
kek: gzip compressed data, from FAT filesystem (MS-DOS, OS/2, NT)

$ file rofl
rofl: compress'd data 16 bits

I would argue that using C is a negative trade off for most applications.

I used to think so, but the compiler is restrictive to a point in Rust where you are forced to program around the compiler instead of being able to focus on the actual problem at hand. I don't think it could be any other way and I greatly appreciate Rust but it can be a pain in the ass for writing a lot of things you'd need a "systems programming language" for.

> java has lambdas

functional interfaces. you need to declare an interface to use a lambda. it beats the purpose.

> python has lambdas
but it needed closures. ruby and lua have them.

If you're having to "program around the compiler" you're probably doing something wrong. What do you mean exactly?

I want to print my str and mpg all on one line...
how do?

>the unix way is the right way
>C
Nigga the Unix way is flat files and scripting together small utilties. Ergo Bash and Lisp.

>how do?
Use C++

>C is really bad for a lot of purposes
What's C bad for? Seems like that's worth metioning.
>I would argue
Please, go ahead and argue. Aside from functional programming I don't know of any programming paradigms (in isolation, ignoring where they're contained currently) which really help you in development to a significant extent.

any reason to use REASON? facebook.github.io/reason/

but were using python

plz no bully.... :__:

carlos!

>you need to declare an interface to use a lambda.
No you don't

>it beats the purpose.
And here I thought the purpose was higher order programming

>but it needed closures
It has fucking closures

Average 2 ints

Playing around with Electron.js and Three.js. Currently making a key input controller.

google.com/search?q=print one line python

>kek
Explain.

If you think there's something in your brain worth having, I will take it.

what is this show called XD?

return ((float) (a / 2.0) + (b / 2.0))

> Is there anything C can't do?
Make its users to shut the fuck up about it

Why not (a + b) / 2.0

overflow

So use a different variable type.

>What's C bad for?

It'd probably be more appropriate to talk about what C is good for, which is systems programming.

a trailing comma! Thanks!

google.com/patents/US6007232?dq=6007232

There's no point you will never understand. Language games and all.

It would be pointless anyway.

Remember to poo in gnoo kids

Congrats on getting set up with CGI, by the way.

Overflow and it rounds down when it shouldn't, i.e. The average of 6 and 15 is 10.5, correctly rounded 11. Calculating ( 6 + 15 ) / 2 in C returns 10 though.

I haven't seen a good solution to this posted yet.

that really helped
what was i even thinking...

Often it is easier to implement a small lisp or basic in C and write your application in it than write it directly in C, lol.
C is a 1970s relic designed to run in 128kb of RAM, truly a "worse is better" of programming languages.

The integer average is usually defined with truncation, not rounding.

Where do I go to learn OpenGL. I just don't get it. I try to set up my VBO's (which I don't understand) and my VBA's (which I also don't understand) and call my glUseProgram(); anywhere it wouldn't matter (like just after I've swapped the buffer) and shit just stops drawing.

I don't know about C, but in C++ define the variables a and b as double

int main()
{
double a, b, avg;
a = 6;
b = 15;

avg = (6 + 15) / 2.0;
cout > a;
}

Not sure if sarcasm

Okay.

>Recently DeepMind said that they switched from Torch to Tensorflow
>That means they still used Torch before, for AlphaGo vs Lee Sedol match
>Torch is built on Lua, to be specific - on LuaJit

The Human vs AI match of the century has been using Lua at its core. How does that make you feel?

thanks

What's the best way to make a dynamic webpage?
I've never done this before, but I'm thinking I should be printing out premade headers and footers and then my dynamic data in between?

Actually when rounding .5 the "correct" way is to round even. Still, integer average on a computer is accepted to be truncated.

open.gl

Be a cool kid and implement the whole webserver in C.

Got some more features done and renamed the project to something less serious. Im so proud of it so far :)
JSON Level Editor > JSON LeE > Jason Lee

getting lazier

JSON is overkill and wasteful for this.

LuaJIT is some of the fastest shit there is around, even faster than V8.

Title commands don't need an "=".

What are you using? I've been interesting in doing web-backend stuff but all those ugly scripting languages just scares me.

lel one of my old programming professors was named jason lee

...

Yes. Read about the HTTP protocol particularly gets and posts and session cookies.

Actually torch offloads the real computation to CUDA, but all the high level stuff is still luajit.

Also note that @ 2016 v8 is already faster.

>session cookies
don't forget the annoying as shit EjUw-mandated disclaimer

Its made and intended to be used with GameMaker:Studio which only has (albeit shitty) support for JSON. Didnt feel like making my own parser for something else. The level file will store a list of all the instances and their properties as well as any other data for the level like music etc.
Im thinking about also storing all of the levels in a single file so that people could make a bunch of extra levels and you just have to send 1 file.

Its far too late but Im just curious, what would you prefer instead of JSON?

Well it seems to me like everything has the same properties, so a simple binary format would be enough. JSON (and co.) is useful when you need to encode the structure alongside the data.

>eu mandated disclaimer?
What is the EU making y'all do?

C

Really, all i'm doing is printing shit.
char *header = create_buffer("assets/header.html");
char *footer = create_buffer("assets/footer.html");
printf("Content-type: text/html\n\n");
/* header */
printf("%s", header);
/* body */
printf("current time: %zu, %s\n", t, messages[rand() % 3]);
/* footer */
printf("%s", footer);

When will a non-bloat modern direct replacement of C come?

>using Lua at its core

>LuaJIT is some of the fastest shit there is around

I looked at the source code and have determined you are both full of shit. Lua is delegated to a glue language, all the relevant parts are implemented in C:

github.com/torch/torch7/blob/master/TensorMath.lua

Claiming Torch is Lua is like claiming Tensorflow is Python.

it already has.
fsharp.org/

youtube.com/watch?v=TH9VCN6UkyQ&list=PLmV5I2fxaiCKfxMBrNsU1kgKJXD3PkyxO

This editor is built in GM?

int avg ( const int a, const int b )
{
return a / 2 + b / 2 + ( ( ( a < 0 ) ^ ( b > 0 ) ) & ( ( a % 2 ) | ( b % 2 ) ) );
}

They do all have the same properties but their values are all different. Pic related is a simplified version of the save structure (older save format is missing a few variables but overall structure is the same).

To elaborate: I think learnopengl.com/ is like an updated version of this. I started with open.gl and was still pretty confused when I finished, mostly because it has a very "Just copy paste this code and look at the result!" kind of approach. I'd recommend once you finish that you just throw all the code out, start over and try to think yourself about how you want to abstract the stuff in it. You obviously don't want your main event loop to be a bunch of glDraw this, glBind that, etc. so find a way to break it all out into smaller chunks and it'll become much easier to think about.

The way I think about it (admittedly I'm still very much a beginner) VBOs are basically arrays and VAOs (what I'm guessing you mean by VBAs) are collections of glVertexAttrib calls (but not glBindBuffer calls, which I used to forget a lot). Depending on how many shader programs you have you shouldn't need to call glUseProgram much. If you only have one shader program you should only need to call it once.

Exactly. JSON is completely overkill for this kind of scenario.

You don't need to encode any structure in your level file, so you can literally just have a binary stream of integers where each 8 in a row (IDs are just integers) will produce an object.

Sure is! Been working on it for about a week. It also can save and load the level files both in the editor and in game.
Its my pride and joy right now

what does /dpt/ think of dat boi?

If your website has cookies you need to put a popup about it on the page. I've seen it on a lot of pages but it's also missing on a lot of pages so I doubt you're gonna get taken to court over it.

Breddy neat. I've used GM to build a few small platformers before, but nothing serious.

Not into gamedev, desu.

Slick editor, though. Looks gud.

Why is avg an int, why would you define them as int.

o shit waddup

Thanks for elaborating. I'l go through both.

Basically right now I have one program that renders an entire scene through a fragment shader (raymarcher, signed distance field). I just wanted to see how I could start using that scene in interesting ways. I've been guessing I'd manage that by using a depth buffer (because that's something I can use to decide on a pixel by pixel basis what's infront or not).

But I can't get the point I was gonna test with to render for what I don't see as any real reason. But I'm gonna have to sleep now. It's clear I need open.gl or learnopengl.com.

Who is better Kanye or Drake?

>Unix way
>Lisp
>I don't know what the fuck I'm talking about

both shit but kanye

That would be a good idea but the object names are unpredictable because the game I am making it for isnt complete yet. Also I plan on making it compatible with anyone's projects and selling it on the marketplace. Ill be supplying the source scripts to save and load but the compiled version of the editor. It will soon have the ability to add custom variables to objects then the dev would just have to modify the save and load scripts in their game to make use of them.

Thanks :) Its been a pain in the ass so far but Im happy with it. I want it to outperform the built in one with features.

Kanye for sure. His newer music is a joke but the old shit is dope.
Drake is too much of a cry baby.

Because that was the original problem: How do you mathematically average two integers (meaning without truncation and overflow). This is how you do it (or at least I hope it is).

> Lua is delegated to a glue language, all the relevant parts are implemented in C:

The actual architecture of the neural network and training algorithms are specified in Lua, while low level vector algebra ops are implemented in C and CUDA. Without lua code the AlphaGO wouldn't be AlphaGO.

>C
>designed to run in 128kb of RAM
sounds efficient

>object names are unpredictable
Doesn't matter, you should save them as IDs and not names.

GM:S determines and hides asset ids from the user. I only see them as names and can only control the ids with object_get_name(index) and asset_get_index("name"). The ids of the game and the editor are unpredictable. What one calls 15 the other could call 34. The name is the only way I could think to transfer them.

I'm pretty sure they're fixed when you create the thing in question in practice.

trying to come up with ideas of how to showcase my telegram lib/use for a tutorial
why is it so hard to come up with things once i do have time for them?

Which programming language is most likely to get me laid when I tell her?

It's called the Blub Paradox, you should look it up.

>C2 uses garbage collection as an example

Coq