/dpt/ - Daily Programming Thread

What are you working on Jow Forums?

Old thread:

Attached: ndNgicuTsD3sjsPeTqIJfqH4r4UpRl5upd_dWNT7_JA.png (2048x833, 777K)

Other urls found in this thread:

haskellbook.com/
twitter.com/SFWRedditGifs

Why haven't you learned Haskell yet, Jow Forums?

Attached: daily programming club.jpg (1280x720, 166K)

reposting

how do you decide when to use a data structure and when to abstract it as an object? initialising my control class with a big fuckoff list seems lazy to me.

Please use an anime (programming) related picture next time.

i tried to read a haskell book but it was full of cute cartoons of animals so i stopped reading

"""Objects""" are data structures, mongo

Thanks for asking, I actually have! While it's exceptionally expressive, it's too inefficient for my taste - I use C++ at work - so I switched to Rust for my personal projects.

There is no point in learning haskell.

then read the haskell book, not a haskell book. haskellbook.com/

NOT REAL OOP

Attached: yegor.jpg (400x400, 22K)

But I'm an adult, I don't have any.

I have a pdf of this one

good then, the one with the cartoons is learn you a haskell

yeah, but ive essentially got a table im constructing from a binary file, and i dunno if passing that as an init parameter for a control class is what i should be doing. ive only just realised that ive no fucking clue how to properly construct a class like an actual professional programmer and not some coder hack.

ive drawn up some UML, and the basic relation ive got so far is a single control class and a boundary class in the form of a factory class which constructs the actual input for the control class given a file handle.

what im wondering now is if i should scrap the factory and instead make an entity class for the creation and management of this data structure, but then im not seperating IO into a boundary class.

I'm not him, was kinda asking if anyone wants it

Because Idris is much better than that bottom garbage

Young one, thine mind is poisoned by POO.
I request you heal immediately.

Attached: step_one.png (266x42, 4K)

What are the next steps?

sorry, but i want a job. learning endless languages and doing nothing with them does nothing for my employability.

Step Two: Don't use Haskell ever again

There is no next step. You never finish the first one. You might say that you 'know' haskell but there is never an ending.

>UML
not even once

Just tell me the high-level that task you want to accomplish and I'll tell you how to do it in a non-convoluted way.

>UML
People still do it?

Imagine being this big of a slave that you even dedicate your free time in training your corporate dick sucking techniques.

Too lazy.

When I was in HS we did it, albeit on a different set of rules

Attached: 3_z1.png (651x1081, 57K)

i want to detect key combinations from anywhere on the desktop, and trigger a callback to a supplied method or function with the key set that activated it and a data object of unknown type (so the user can add a bit extra info in if they want). to facilitate this i have a control class watching for the key input, and a description of the data structure i need to make it possible. what i need to figure out is the proper assortment of classes to handle the actual creation and storing of that data.

That's not UML tho.

liberty requires leasure, you cant elevate yourself to being anything other than a glorified serf without a means of producing enough wealth to allow yourself to pursue the virtues required of free men.

DzieƄ dobry Antoni.

Attached: 2012-07-16 Professional Photo 5.jpg (2606x3935, 1.39M)

Andrei is a Romanian, not a Pole.

Can't you just create an interface with a method that will be invoked whenever the user presses the specified key combination and let whoever uses your library worry about what additional data they want to store in their implementation of that interface?

I know, I just lacked sufficiently Polish pictures so I made do with what I had.

im the one whos gonna be using that interface, user. besides, in this situation ive got a whole bunch of key combinations i wanna look out for, im looking to make something that could scale to a large application in terms of its flexability so it all looks nice and professional.

I am trying to serialize a class I made from rows in a datagridview (each row is it's own object), but when I put the XML serializer into the loop, instead of making the whole thing into an XML file, it just serializes each row separately, so I'm having each object be it's own XML file.
What can I do to fix it?
Pseudocode:
for(each row in datagridview)
{
class a = new class (current row column 1, 2 and 3)
xmlSerialize(a)
}

I'll make a design for you: first, you have a single non-member function (or a static method, whatever you call that in Java) that accepts a key combination and an interface that I'll describe later. I'll call that function RegisterCombination. Why a single non-member function? Because it doesn't make sense to make multiple instances when you want to register keystrokes system-wide. That function will simply assign that interface to the key combination in a global hashmap (or a similar data structure, you just need efficient key-value retrieval) that I'll call CombinationMap. The interface needs to have a single method called Do or something like that. That method will accept a key combination so that one interface can be passed to RegisterCombination multiple times and act differently in response to each one if a need like that arises. When your listener detects what a particular combination of keys has been pressed it searches for that combination in CombinationMap and if it's present there, it invokes the Do method of the interface assigned to that combination WITH that key combination. That's as simple as you can make it. Why do you want to bother with factories and god-knows-what?

Why is haskell falling so consistently?

Attached: redmonk.png (1044x762, 171K)

>We query languages by pull request in a manner similar to the one GitHub used to assemble the 2016 State of the Octoverse
shit tier metric

>Any ranting with JS at the top and CSS in it
Shit.

What anime?

suicidal shitlang users artificially lowering its ranking out of desparation

muh appeal to popularity

The hype has ended, people realized that purely functional languages are too bothersome to use in real projects and mainstream languages started adding FP features like lambdas. People who learned Haskell used that experience to make themselves better programmers in more mainstream language instead of actually writing it. Haskell in the Lisp 2.0, it'll never die and always linger with a community of enthusiasts, but will hardly ever flourish beyond that.

clean and simple, however theres a couple of problems. my key combinations are going to be composed of a set object containing objects from another library, therefore either the user has to import that library to construct their macros, or i need a factory to do it for them. second problem, suppose i have 50 key combinations, what then? is the user going to write their own code for handling that each and every time, or should i provide a means of handling that neatly and have the data structure managed by some entity class with its own boundary class for file IO and a factory class for making its components?

Because Rust exists.
t. switched from Haskell to Rust

>my key combinations are going to be composed of a set object containing objects from another library, therefore either the user has to import that library to construct their macros, or i need a factory to do it for them
You don't need a (((factory))). You need a single function that takes a key combination as a vector of enums and translates it to the format of that library. Have RegisterCombination take that vector and invoke that function, so that it can be private.
>suppose i have 50 key combinations, what then?
If the behavior has to be the same, the user has to add the same interface under 50 different key combinations through RegisterCombination. If it's a family of keys like Ctrl + any numerical key, that could be achieved by user writing a simple for loop to handle all cases. You could come up with a custom format like Ctrl + 1-10 and a function that does it for them automatically. If it's not the same behavior, they just call it 50 times with different arguments or write a for loop that iterates over an array of key combination and an array of interfaces and invokes RegisterCombination with them. And stop with all those buzzwords because I start to think you this is bait.

do you know of any projects that do error handling well?

>You need a single function that takes a key combination as a vector of enums and translates it to the format of that library.
so a factory, only one for parsing input. how am i going to represent a shift key press? am i going to need to write my own enum for every possible pressable keyboard button the OS could possibly support?

see, why would i do any of that fuckabout, when i can delegate the understanding of the actual keypresses to the library that will be handling them, and batch load in key combinations from a file? i should mention that this software im writing is going to be working in the context of a system that will be loading in another file which will be a list of code snippets to execute based on which is selected by the GUI, or alternatively triggered by an associated key combination. hence im thinking in terms of scalability of solution here.

>buzzwords
im describing it as im thinking of it, using the UML stereotypes given in what ive read on it.

All of these.

im liking the new Qt for Python wheels, but I don't like their size. All of Qt is included, and I only need basic GUI stuff, no webkit or filesystem or embedded shizzle. it there a more minimal wheel somewhere thats not a 100MB+?

What language ?

>python
>complains about bloat
>python
u wot m8

I give up, enjoy your POO.

Attached: 1529066265103.png (571x618, 29K)

ive pointed out several problems with your solution m8, mine isnt a simple however when you add in the shit you would need to write to use it then it becomes a lot simpler.

python question
Can I read the filename of a file with Open()?
Let's say I have 10 image files in a folder named 1-10, and I want it to choose a file randomly to use. I could give out a random number, but what if one file is a jpg or png? The filename should be stored (with path) and then used elsewhere in the program.

>get a random number from 1-10, let's say 4
>4 filename gets stored
>can print the image location + complete filename afterwards as example
Hope I explained it well enough, trying to learn python on my own.

I like posts like these that jump straight to the point from the first line. That way I don't have to bother reading the rest of the retarded post

get all the files in a directory
get a list of the files in the files in directory list that meet your spec
pick a random number from index to end and use it

NO era penal

>tfw scared of learning C++ because it might die soon.

Stop ingesting Jow Forums memes.

It's not dying soon.

Thank you, i'll give it a try!

There's not point in learning C++ any more, learn Rust instead.

I am learning Godot. It's pretty neat.

Attached: meem.png (2500x1250, 906K)

Whats the actual chance Rust becomes the next C++

Rust syntax is even worse than C++.

Here, have this

Attached: 1504159769135m.jpg (568x1024, 90K)

Reminder Godot hasn't had a single decent game yet.

At least other countries' ministers of defense aren't insane nutjobs who come up with a new conspiracy theory every month.

This is an advanced shitpost. The esl-ism combined with promoting another language over a "pajeet" one really jogs the noggin.

you should be scared to learn C++ because you might die soon.

>new conspiracy theory
Seems tasty. Have some details?

50%, it either will or won't.
That's because you haven't spent a minute actually learning the language, of course the syntax looks weird to you.

I know the language, that's why I know it's ugly.
The density of special tokens and keywords is just too great.

give this a go next time, read the class reference page online

it is until you spend a week debugging your fancy component only to realise that some bright spark added some shit under the hood you woulnt have thought of and the fancy calculations it was doing to try and do the thing you want is broken.

It's mostly about the Smolensk catastrophe:
>there was an explosion on board before the plane crashed
>the Russians who serviced it a few months prior had sabotaged it
>the crew was poisoned
>the plane crashed because Russians created artificial fog using helium
>three people survived the crash and were then gunned down by Russians while trying to escape the plane

haskell

Good old times.

Attached: vs6pJpv.png (1000x1516, 407K)

newsflash: Macierewicz isn't Poland's minister of defense, it's this young lad now.

To stay on the thread topic: What do you think about Nim and Crystal? Anyone using it?

Attached: mariusz-blaszczak[1].jpg (773x515, 24K)

I had to make my own vim colour scheme for rust that only highlighted numbers, strings, and comments because it was too colourful otherwise

what language should i learn next Jow Forums?
purely for usefullness.
go, c++, rust or lisp?

>Nim and Crystal
Crystal is nicer imo, Nim is just weird with aLongName and a_long_name being the same identifier and operator precedence based on spaces. Both are waste of time tho now we have Rust.

>lisp
>purely for usefullness
definetly not

C++
Go
Rust
.. everything else ..
Lisp

Godot vs Unreal
which one?

Is there any game engine with haskell-like scripting code?

I'd say Rust > C++ here since you'll be able to do evarything you'd be able to in C++ but better

Usefullness wise its probably go. But it's awful, learn rust or c++

is rust the future?

Yes, but a distant one.

Usefulness for what?

If you are a complete newbie, learn Go. If you already know several languages, C++ .

If it keeps up at the pace it's been going at, I'd say yes, it is. It won't replace C/C++ in your lifetime but who knows

No but it's pretty damn nice.

This immediately sets i to 0 after initial 32, then decrements into negative values. Am I missing something vital?
for (i = 32; i != 0; i--)

forgot to mention it's in C. This happens if i is declared as a size_t. When declared as an int, it stays at 32.

No, there must be something in the body.

Post full code, you're probably doing something in the loop itself

because I'm currently learning erlang