/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previously on /dpt/ :

Attached: 1554139259199.jpg (1500x1158, 252K)

Other urls found in this thread:

github.com/Zevv/npeg
letoverlambda.com/index.cl/toc
gist.github.com/nodef0/6bd203ffb549433b78e30de5c5f98731
twitter.com/AnonBabble

>Haskell book
boycotting this lazy thread.

I like C

>haskell
>without frustration
>Bifunctor Profunctor Coprofunctor Contravariant1 Trifunctor

Last for Rust!

nth for haskell tiddy monster

Attached: 1562921169493.png (850x1200, 1.18M)

>frustrated by *Functor
don't use it if you don't need it

that's not the problem hasklet

Attached: 5E3F2079-99B6-4279-AB53-4C367E820241.gif (540x540, 605K)

>ha ha it doesn't matter how bad Haskell can get
>because you'll never use anyone else's code anyway
ooh what an endorsement.

Which language has the best macros? Provide examples and proof plox.

Attached: 1565383103614.jpg (653x767, 44K)

the frustration being that profunctor isn't in base?
Iagree

Rust.

haskell:
-- define a macro for adding the same thing twice
f x = x + x

-- use the macro
example = f 3

Lisp, it quite literally wrote the book on metaprogramming and it's so simple too.

Scheme!

...

>functor functor1 functor2 functor3 functor4
>contravariant contravariant1 contravariant2 contravariant3 contravariant4
>combinations as base classes to make it even worse
Why are Haskell programmers so stupid?

Attached: 1565728965596.gif (615x548, 18K)

nicest parsing DSL I've ever seen: github.com/Zevv/npeg
Zig's printf-style stuff that happens at compile-time and is done entirely in normal Zig is pretty cool as well, although not technically a macro.

simple Lisp macros are simple, but if you want to do stuff like recreate some Clojure features, you'd better read your Let Over Lambda: letoverlambda.com/index.cl/toc

is that you?

The compiler for this little fpl is 350 lines of Python. I'm going to rewrite it in a syslang for fun. How many lines do you think it will end up in that?
not = (\a -> a : 0; 1)

+[5] = (\a, b -> a - (0 - b))

>=[4] = (\a, b -> not(a < b))

>[4] = (\a, b ->
not(a - b) : 0
a >= b
)

*[6] = (\a, b ->
b > 0 : a + a * (b - 1)
0
)

/[6] = (\a, b ->
a >= b : 1 + (a - b) / b
0
)

print(12 * 3 / 4)

C compiler

Haskell type classes are OOP level of bad

>How many lines do you think it will end up in that?
712

I thought it was cp or heavy gore. The imagestorage.c is the source to create your own PNG files. I program only in C++ but it looks safe

Attached: name:godknows.mp3 size:1699872bytes.png (950x1000, 1.55M)

what's wrong with type classes?

I'm finally gonna put time in started to learn programming I will be im sry for saying this java because that's the only course I can take now.
is there anything you guys recommend for me or got a some lists on assignments I could do to improve in programming?
I will be learning C or C++ later probably.

Attached: 1555589496998.png (990x1080, 722K)

have you not been paying attention the entire conversation

nothing

that's more an instance of haskell type system's limits.
it is a very old language afterall

If you're being taught Java just realise that Object Orientated programming isn't the be all end all of programming.
Remember that this is just one way to do things and that Java was built in a time when every programming problem looked like a nail and Java like a hammer.

...

yea ok, I know object orientated is not the end all.
I do like how functional programming works better. idk why it just makes more sense in mu head dont know why. That is why I wanna learn C later.
But I see it could be useful to learn java.

The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant.

you're thinking of procedural programming, not functional programming
functional programming is different

Understand the Functional Programming isn't the be all end all of programming.

are those textbooks made to study for a certification exam good enough to learn and go from absolute beginner to intermediate level in Java?
I will use Core Java volume 1 and Oracle docs as supplement

yea your right sry I mixed the two up .
yea procedural programming just makes more sense for me.
thank you user for correcting me

i just don't get it guys.
weebshit has nothing to do with programming.
why can't they just fuck off back to their cont/a/inment board?

Wrong, FPis the natural next step until we discover the step thereafter

off yourself NEET

So what kind of problems are you guys solving? What are you building atm? Or do you guys just edit functional programming book covers on anime girl pictures all day?

Attached: 1565539077999.png (480x480, 332K)

this is 4channel, where anime is a subset of programming, if you newfags aren't happy with that, go back to Jow Forumsprogramming

Attached: 1539235188757.jpg (850x850, 118K)

anime website fag

leave this thread, wageslave

You first NEET.

C string concatenation is cool, but I don't feel I'd prefer it unless I did a game console or an error system (I have a use for it right now, but it wouldn't save anything).

This is fun though:
#define t4_round_nearest_uint(x,n) ((((x) + ((n)/2)) / (n)) * (n))
#define t4_round_up_to_multiple(x,n) \
(((((x) + (n) - 1)) / (n)) * (n))

I did have a macro which took a string and pathed it between a section based on whether or not we were doing a single-executable or multi-executable application. If you want to see how many file descriptors are open in your file-using side of the application, it depends on whether you yourself are the file application or not, to be exact. Looking at your own file descriptors in Linux opens a file descriptor.

see, it's always the wagecucks who ruin these threads

Stop replying to yourself you worthless shit.

Attached: hmm.webm (904x510, 2.87M)

after you stop shitting up every thread

The irony in this post.

yeah those rays that come out are pretty bad.
it's even worse when you realize they're not rays exactly.

For Go programmers: how do you deal with no generics? Do you really have to duplicate code for each type you need? I know there's interface {} but doesn't that undermine the type system? You mind as well use a dynamic typed language at that point.

you cope by repeating to yourself
>it's not that useful in practice
>in practice, it never poses a problem
>it's not as bad as it looks"
>it's the less harmful alternative

generics considered harmful

Why?

Woah man this board is nsfw

sfw*

What do you mean they're not rays?

Attached: volumetric_light2.webm (904x510, 2.61M)

Is that a Twin Peaks reference?

Attached: photo_2019-08-17_19-56-40.jpg (1080x1058, 158K)

It's my test scene, yes it's from twin peaks... obviously.

#include ""

Integrating a low power mode to work alongside FreeRTOS' tickless idle.

>Compiling files... 1%

isn't there like an -fno-code flag to speed up compiling when all you want is typechecking
or are compile times still super long with the flag?

Working on a symbolic circuit simulator, written in C. Currently implementing switches. And you know, having to stop every day for stupid bugs.

Gosto bastante de Twin Peaks

Estas a usar C++?

If you just want to check your code then there is "cargo check". Not sure what commands cargo is passing to rustc under the hood but since it's an option in cargo then there must be some corresponding flags for rustc.

I got the bare minimum working for my Madcow 5x5 Training Program Calculator, so I'll upload it to GitHub. It does what it's supposed to do, hlint reports no errors and its covered by tests.

Any good packages/repo for getting a solid calendar with a bit of a form on it.

trying to do some practice and have the calendar in the middle of a webpage and some api calls about weather/location/flights can be linked to the calendar and form with to and from dates etc..

C

Lisp is the most powerful programming language.

I want an executable that, upon execution, extends the shell's features, so I can call functions of said executable in the CLI environment. The reason I want a single program taking care of all those functions is performance, instead of going the lazy way of compiling lots of small utilities.
Is this possible?
It would look like this:
$ praisekek
bash: praisekek: Command not found
$ ./cmdutils
CMDUTILS running, extra commands added.
$ praisekek
*prints pepe ascii*

I think you can just use aliases to do the same thing, is performance really that much of an issue?
>ASCII art

Not sure I know quite what you mean but take a look at busybox. It uses the argv[0] (program name) to decide what subprogram to run. Then you just create a bunch of aliases for the one binary and have your program match on the name it was run with.

shell aliases
like alias "praisekek" to "cmdutils --praisekek"

Why is her book bound backwards?

Fighting Rust's streams, wrangling lifetimes is easy in comparison.
Made a small example on merging two async streams with different Item/Error types, in this case, incoming socket messages and a periodic timer.
gist.github.com/nodef0/6bd203ffb549433b78e30de5c5f98731

Decided to start building my github profile. I'm starting with a repo that contains a bunch of physics simulations. Right now I'm putting the finishing touches on a program that simulates 3D elastic collisions.

it's a mango inside

Attached: 1564911756462.jpg (600x1000, 147K)

If you make money programming you are pathetic.

dis is great

nice

Depends what you want to happen. If you want it to install the new commands permanently, make a new directory, add the binaries for your commands to it, and append its path to the PATH environment variable. If you want it to be session dependent, then use aliases.
Also,

It would be a good thing, that is it.
Busybox executes itself again, the thing I want to do is just create an utility that brings C functions to bash in the form of commands, but there is overhead when calling an executable, so I thought that a "shell on top of another shell" would be possible.
I am just too lazy to learn regular expressions for that kind of usage.

He's making a database
He's sorting it twice
SELECT *
FROM contacts
WHERE behavior = 'nice'

SQL Clause is coming to town

Hey quick question guys, odds on a fresh out of highscool neet with 0 experience whatsoever becoming proficient at coding in a few months and earning good money off it?

Attached: 15732918302123.png (186x175, 78K)

in java (or any language that has a garbage collector) when you instantiate a object like
dummyObject = new Image(new FileInputStream("dummy.jpg"));

1) what do you call that? specifically when you create an object in an argument list
2) when does the garbage collector pick this up?
bonus: I probably shouldn't FileInputStream like that because I have no way to close the stream, right?

I just finished coding up my website. (Plain HTML+CSS+JavaScript). Setting up CRON to autodeploy it from GitHub. Brogramming is fun!

grats user!

Because Japan normally reads books from right to left.

Anyone familiar with CMake and Qt here?
I'm trying to add resource file so I appended my .qrc file to the source list that's passed to the add_executable call and added CMAKE_AUTORCC ON flag but I get errors like:
No rule to make target required by autogen/qrc_res.cpp.

Nevermind, you cannot apparently have the .qrc file and the actual resources in two different parent directories, even if you provide correct paths.

Trying to write a 2d sprite game in c++, no problem managing user input, drawing etc, but what I am wondering is how would one go about making the game polymorphic?
I'm looking at making the drawn objects polymorphic in the following way:
// Pseudocode
struct drawable{

int x, y; // starting coords
int curr_x, curr_y; // current coords
string filepath; // location of filetodraw
bool draw; //do we draw this

virtual void update(){} // change x,y coords, and anim data

virtual void drawSelf() = 0;
virtual void changeFrame() = 0;

}

struct background : public drawable{

vector *images;

void background(int level, int scene, vector &images) override{ // get background for level+scene, store in vector of images
}
void update() override{}

void drawSelf(drawLibrary &ptr, vector &images) override{ // send image list to be drawn
}
}

struct sprite : public drawable{

sprite *a;
int[4] *sectionToDraw
void sprite(&a, §ionToDraw) override{ //get character sprite texture and rectangle of texture to draw for sprite
}

void update(){} //Dont know what this accepts yet but should update section to draw and the x,y coords, or the draw flag

void drawSelf(drawLibrary &ptr, sprite &a) override {} //draw

}


Is this a reasonable implementation?

>few months
Zero. Minimum of 1-2 years before you'll start getting anywhere remotely close to earning decent money.

>1)
I don't think there is any special name for it. If you say something like "Nested constructor calls" most people will know what you mean.
>2)
When it isn't referenced anymore (& the GC is doing a scan), so pretty quickly.
>bonus: I probably shouldn't FileInputStream like that because I have no way to close the stream, right?
Yes, use it with try-with-reesource so it gets automatically closed.

Java doesn't have destructors, but "finalizers" instead. They have very weak guarantees though, so you generally want to close it manually.

have a look at SFML's source

use composition over inheritance. If you want an object to have some behaviour like being drawn, give it a drawable component which receives the necessary parameters (e.g. z-coordinate so you can have a background).
If you attach some component to an object, register it in a list for your scene. Then in your global update you can just iterate over the different lists of components.

Someone said I could make a game in Javascript. How true is this? It's really the only thing I'd be intersting is in remaking dope wars/drug wars. Like the list of this stuff in pic related, how possible ius it to a lot of that in javascript? Obviously more advanced things will be not possible for me but I'm just curious since I really have no ideas on what to make other than games

Attached: 1497930603349.jpg (1261x1000, 314K)