/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

ghostbin.com/paste/a36kt
file.io/jcK3ok
expirebox.com/download/6dcdb6349818fbb0dd7215a98ee07adb.html
github.com/golang/go/blob/663226d8e130470c1a627c64cf489261ebb6da08/src/runtime/malloc.go#L258-L286
twitter.com/NSFWRedditGif

trying to convert my xna project monogame

bow before your new god /dpt/

link to talk?

I have a small desktop application and want to share it with a limited number of people(

Also not real-time or anything fancy, just a couple KiB at a time at most

>A part of it would be sharing (and storing) the data generated by these people between them, but I don't have any experience with network/cloud/internet/whatever stuff.
you're going to need networking knowledge to do that. read about socket API. you don't need to know anything more than the API really
you can buy a server like with amazon web services or you can use your own computer as the server

Just for storage? Have it on your hard drive.

I'm trying to redirect my rendering output to a framebuffer texture so I can do post-processing effects on it, but no combination of framebuffer format options seems to work.
My graphics driver says I have framebuffer and renderbuffers enabled as extensions, but they don't work.

Nice font choice he has there.

How do you cleanup after CreateProcess(..., &processInfo) in winapi? Is CloseHandle(processInfo.hProcess) enough?

you must close both hProcess and hThread

Will ASM + C get me laid?

Thoughts on xoroshiro128+?

laid off maybe

i've been slacking way too much and haven't done much of anything between my break in school. supposed to be doing an internship this spring but have forgotten most everything i've learned. need some motivation to make something worthwhile to get back into the groove.

any ideas?

learn javascript

Been doing some simple examples yet my functioning code keeps coming out a lot different than the answer's. Besides some printed text is there any reason to use the example's code over mine?

Example (Write a C# Sharp program to check whether a given number is even or odd.)
{
public static void Main()
{
int num1, rem1;
Console.Write("\n\n");
Console.Write("Check whether a number is even or odd :\n");
Console.Write("---------------------------------------");
Console.Write("\n\n");
Console.Write("Input an integer : ");
num1= Convert.ToInt32(Console.ReadLine());
rem1 = num1 % 2;
if (rem1 == 0)
Console.WriteLine("{0} is an even integer.\n",num1);
else
Console.WriteLine("{0} is an odd integer.\n",num1);
}
}

Mine
{
static void Main(string[] args)
{
int number;

Console.WriteLine("Input an integer.");
number = int.Parse(Console.ReadLine());

if
(number % 2 == 0)
Console.WriteLine(number + " is an even number.");
else
Console.WriteLine(number + " is an odd number.");

Console.ReadKey();
}
}

try to write a basic compiler

>Been doing some simple examples
Exercises* to test my knowledge

write a toy 64bit OS

>if statements without curly braces
are you sure this isnt python?

kill yourself

Is kotlin good

One-line function blocks don't need braces

python isn't the only one that can do that

no

all good suggestions -- thanks! i really need a kick in the pants to get myself moving and motivated. i'll post here once i've got something going. cheers.

reddit told me it was

We all know you are just going to sit there and not do any work, dont kid yourself or us

this
unless you get out your pro programming gear

where can i get a g(b)f like this?

on dpt of course

damn, nene BASED af

I honestly can't recall a single time I've ever successfully compiled a Rust program with no errors and then it didn't work.
I can recall ~3000 times I've compiled a C program with no errors and then it shits the bed.

are you retarded? haven't you learned by now that most of /dpt/ hates anything but C and Lisp? these people are NEETs, a practical, modern language for android development like Kotlin is disgusting to them.

Is python a viable language to learn? Looking to learn a language and heard good things about python

>Learning rust several months ago
>Spend a week writing a somewhat non-trivial program to learn it (automating some shit)
>Try use the program again recently
>It doesn't work now for whatever reason (probably because I'm a white male and haven't flogged myself for it recently)
>Try to read the code, and it's a complete mess making use of idiomatic rust
>Can't be fucked trying to fix that shit
>Spend a few hours rewriting the whole thing from scratch as a series of shell scripts
>It's way shorter and works way fucking better
Rust really is a horrible SJW meme, which leads to terrible code.

>have to use inform 7 (a domain-specific macro language for z-machine text adventures) for a class
>world model is object oriented
>not even the good kind of object oriented with traits, instead it's the shitty class hierarchy model
>inb4 "hurrrrrr no such thing as good object oriented model"
>at least it has multimethods
>can't override check rules (a "rule" is pretty much a multimethod, and "check rules" are rules for deciding if particular actions succeed before carrying them out)
>instead, if you try to write an alternative check rule for a more specific case, inform 7 just runs every check rule including the one you wrote and your shit still fails
>can't even override this behavior with "rule succeeds" (inform 7's version of "return true") because then it just fucking shits the bed and doesn't do anything at all
>can't write singular descriptions like "the cat in the hat," only plural descriptions like "all cats in the hat" (a "description" is inform 7's version of a list comprehension)
>can't get around this issue by writing rules that accept descriptions as parameters, because descriptions can't be passed as parameters unless they don't refer to any local variables
>can't even get around it by writing rules for finding individual objects on either end of a relation (a "relation" is like a named link node between two objects, whose name is a verb reflecting a physical relationship, e.g. "source is wearing dest," "source contains dest," etc)
>it compiles but just doesn't work
>wrote an entire extension (inform 7's equivalent to a "library") for specifically this purpose
>it compiled fine
>tried to use it
>game fucking segfaults at runtime
>32 bit version of the compiler doesn't work at all
reeeeeee why is inform 7 such a shitlang
can't even do fucking metaprogramming ?! ? !? ? !??

reeeeeeeeeeeeeeeeeeeeeeeeee

I CAN'T EVEN FUCKING UNINSTALL IT OR STIOP USING IT BECAUSE I NEED IT FOR MY CLASS REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

>lying on the internet
Post the code fagweed

>Visual Studio throwing a shitfit over "&&"
>Took me 10+ minutes to realize I wrote "%%" and not "&&"
Who /smart/

sounds like you are just a shit programmer, honestly
>try to read the code
If Rust is too cryptic for you, maybe a language such as Java or Python is more your speed. Are you a web developer?

>complaining about an open source programming language
>simultaneously being too much of a brainlet to be mentally capable of doing anything about it
scum of the earth right here boyos

>complains about Rust
>doesn't want to write a macro language for Rust

>complains about C
>doesn't want to write the language C++ should have been

>complains about Java
>oh wait I actually completely respect that

Rate my 4x4 matrix multiplication function.
ghostbin.com/paste/a36kt

Think hard on what you need or what you're currently interested in building. Tips from Sup Forums tards won't motivate you.

Ok then, here they are. The shell script isn't quite feature equivalent, but it's close enough.
file.io/jcK3ok

If by good you mean that a lot of jobs are requiring in, then yes.

>404
Thanks for confirming

Oh, I didn't realise that website was one of those single-download ones.
Here's another one, then: expirebox.com/download/6dcdb6349818fbb0dd7215a98ee07adb.html

Need examples of coding for portfolio to enter shitting game design course which is the only financial aid approved course offering fundimentals in not just java

Real shit at C# inb4 object oriented sucks but honestly I just started teaching myself that and don't know enough about coding to understand the downsides written basic maths thing take 3 numbers from readline then do math and output with write line wrote a change stored xyz positions its games orientated maybe they will like it plan to write up a version of anons is it odd or even but easier wondering what /dpt/ thinks some game dev flocks would expect from zero experience basement dwellers trying to exploit their financial aid assistance to pay for education

maybe you should learn how to use commas first

,,,,,,,,,,, bit late

Unfucking a project at work. We have a batch processing application at work and it has a web based admin interface for managing it. Originally, I was the only developer who worked on it. However, a new version of the underlying batch program that it controls was being developed so they decided to fork the admin tool. I would keep maintaining the existing one and some other developer would work on the fork to make sure it would be compatible when the new batch process rolls out.

The problem is that the other developer who worked on the fork thinks of themselves as the next Linus Torvalds and has an ego large enough to make Dijkstra blush. They decided (without asking anyone) to make vastly more changes to the tool than just upgrading the compatibility. What I got back was a tool where half the functionality was missing and performance was so fucking terrible that it would take 30+ seconds just to pull up the page with the currently running jobs. Additionally, all of the ajax calls were removed so that every single action was a full page reload. So having full page reloads for every single click on a page with 30 second load times makes it horribly painful.

So I've been spending the last couple weeks adding back all of the features that were stripped out and making the performance not complete shit. The developer who messed all this crap up has been patting themselves on the back about what a great job they did. Meanwhile, the users have been pulling me aside and telling me "thank fucking god you're back" upon hearing the news that I would resume work on the mainline project again.

>Need examples of coding for portfolio to enter shitting game design course
> to enter shitting game design course
Huh?

Why is the egoist who is developing their own fork working on your code if you are working on the original?

ProcessStartInfo p = new ProcessStartInfo();
p.UseShellExecute = true;
p.Verb = "runas";

try { Process.Start(p); }
catch (exception e) { }

RegistryKey rkApp = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.SetValue("Infekt.exe", Application.ExecuteablePath.ToString());

Throws a registry access exception on Resistry.Local idk why

I had some shit break due to some random changes they made between versions.
The performance of the optimized code was pretty good though.
Maybe the terrible code is mostly your fault.

Sorry. I wasn't as clear in my explanation. The egotist developer forked the project to make the necessary changes to upgrade it for the new batch process that it administrates. Once that new process went into production, the fork was merged back into trunk. Thus it was one project again. What was merged back though was more than just upgrades for the new process. Half the fucking functionality was missing and the code was "refactored" in a way that made performance fucking terrible.

This is an ongoing problem with this particular developer though. Everything she touches comes back with missing features and horrible performance. She had also done some work on that underlying batch process I talked about and it needs to complete within 24 hours so that the next days processing can happen. At one point it was taking 72 hours to complete (meaning it would never catch up) and other people had to come in and undo her damage. Yet she still acts like she's god's gift to the earth and everyone around her is incompetent.

>Yet she still acts like she's god's gift to the earth and everyone around her is incompetent.
I think this is common for programmers. I know it is common for artists to think. This is why, of course, artists hate each other. I imagine it is the same for programmers.

Agreed. I will admit that I can be that way sometimes. The difference is that I recognize my limitations. I ask for help when I need it. I don't just remove a bunch of features at random. I also don't have a history of needing other developers to come in and do damage control on projects I've touched. Good developers can deploy something to production and have it just work for years and years with barely anyone noticing. Bad developers need entire fucking teams to be brought in to do damage control on projects they ruined. I've talked to this developer before about this (not phrasing it that way of course) and the response is that her projects are just "that important" to need maintenance teams. It's not that she leaves everything in ruins wherever she goes, it's that she is so amazing that she works on all the important stuff that needs that kind of attention.

The thing with art is that it is pretty fucking subjective. When you're talking about performance metrics, not so much.

Good code is still reasonably subjective as well, though, and design decisions even more so.

They're based on technical reasoning, but humans are so far below the level of perfect programmers that, all the time, we make heuristic decisions and snap judgements in our workflow. Those have to be evaluated subjectively.

My daily struggle isn't against programming concepts, its against getting distracted and losing focus. It's also against not being able to program during the day because I get ultra uncomfortable when people look at me programming. Sorry for blogposting but I just want to live in a small closet alone.

what's the inverse of the map higher order function called?
that is, a hof that takes one value and calls n separate functions with it?

ELF reader API to add to my general purpose library

>not being able to program during the day because I get ultra uncomfortable when people look at me programming
What? Why?

>Good code is still reasonably subjective as well, though
i beg to differ; believe it or not, i actually have a method to develop objectively ideal software. for a given project, i decide on an approach and start writing code. if at any point i notice a flaw in my approach that can't be easily corrected for by the time i catch it without introducing other flaws, i throw the project in a junk folder and start over from the beginning with this new information in mind. heuristically, the project tends gradually towards an objective ideal with each generation, like a genetic algorithm. haven't managed to release anything yet, but when i do, it's gonna be perfect, god dammit

try some meth dude, you'll focus so hard you won't be able to sleep for 4 days

stop repopulating the name field after I clear it you son of a bitch

>a hof that takes one value and calls n separate functions with it?
but why

map
f(g(x)) -> h(x) -> y

or in C++:
std::transform(beg, end, out, [x](auto fn) { return fn(x); });

Probably doesn't have a name, but in Haskell this is
mapfn v = map ($v)

That's genius, it's like bogosort for software engineering

It's going to sound stupid but I'll try and explain it I guess. My brother gives me shit for spending time on the computer instead of going outside, I'm 25 and he's 28. When I was 20 I wanted to be a writer so I wrote a decent amount on the computer but never published anything. I played video games the entire time too. For the past two years I've been learning to program and trying to make games along side my normal job but the games I make still look like utter trash. I feel extremely embarassed that its taken me so much time to even get to this point so whenever people look at what I'm doing I tab out and browse Sup Forums or I pretend to be playing a game. I know I sound like a bitch but even though I'm aware of it it's not a feeling I can just fix. I can't justify how much time its taken me unless I produce equivalent results and I just cant do that right now and if I keep bitching out like this I'll never get there. If I could just be alone I would spend my time well.

How do I nest 3 dictionaries made of list indices in Python?

making dictionary from list indices

list1[x]:list1[x+1]

how do I make it like

(list1[x]:(list1[x+1]:list[x+2]))

oh my god developing haskell in windows is a nightmare. apparently there's a bug in ghc and it tries to allocate literally terabytes of memory on startup. even simple stuff like ghc --version takes 50+ seconds

There are plenty of justifiable reasons for a higher order function like that. For example, a hyperparameter search. You want to process data in N*M different ways and select the best, so you use a list comprehension to generate N*M processing functions based on your two parameters. Then you call this special map function on your function list and pick the best result.

>whenever people look at what I'm doing I tab out and browse Sup Forums
I would be more worried about people seeing Sup Forums than practicing programming... Anyway, it sounds like you didn't have the chance to get a degree in programming, but if it helps to get you that kind of perspective, in the world of college CS, you'd be surrounded by other programmers just like you, some of them morons, and so it's completely normal to be seen programming. Same goes for the workplace too. That's the frame of mind that people have. In fact, sometimes it's seen as a good thing to be seen programming since a lot of programmers have nice careers set up for themselves.

I guess my opinion is, I think you might be spending too much effort comparing yourself to others. In the internet age, where you can easily google the most amazing results in the world for any given thing in just a few seconds, I think this is kind of dangerous. Remember, everyone has their own circumstances to move at their own pace. For example, you're keeping a job while you learn to program. And for that matter, game development is very time consuming by nature.

For me at least, I try to compare myself to others in productive ways that help me keep my sanity.

Okay so I wrote a standalone node.js module which contains a bunch of functions I would like to use on both the client-side and the server-side of my website.

Using it on the server-side is easy: I can just add it to my package.json and then require() the module.

How do I use it on the client side, though? I've already put it in a package.json and let NPM install it, but what do I do with the files in the node_modules folder?

There are existing solutions like browserify and webpack which let you use modules the right way and bundle your packages with your build (and do other nice things too).

But some packages which are meant to be used with client code like socket.io have their own solutions that just attach a route serving the client file to your webserver.

And lastly some packages just dump their client side code in a spot in their npm package which you can find server-side with require.resolve. A lot of these are bower packages too, if you just want to do it that way.

>the Chad programmer:
Doesn't have to think of how to design a function before writing it
Hard-codes everything
Uses only the most low-level languages
Nested if-else loops up the wazuu
Merges before pushing into a git
Doesn't even know what a for-loop is
Uses Objects to define Objects
Usesw generic names for fucntions, like DoesStuff()
Doesn't follow naming conventions
Seeding impregnates all systems forcibly
O(n!^100000000)
public class doesathingthatisnotanotherthing{ public static void main(str [] args){while(null != 1){sayathing(4);sayathing(8);sayathing(7);sayathing(2);sayathing(2);sayathing(9);sayathing(1);}}}

>the Virgin pajeet:
Works diligently to plan before programming, to optimize functionality and performance while balancing memory and speed efficiency
Uses variables
Can't program in the presence of others
Uses high-level programming laguages
only uses for loops when needed
Pushes into development branch to ensure nothing goes wrong before merging to master branch
Has a CS degree
Afraid of OOP, does it as efficiently as possible
Follows naming conventions, uses helpful specific names like calcMin()
Seeding only when systems consent
O((n log n)/(n^2))
print("Hello world")
has more fetishes than strings in an array

k

My brother browses Sup Forums and Sup Forums so in regards to him seeing me browse Sup Forums I regard him as a brainlet plebian in that matter. It doesn't help with the other stuff though, feeling shitty about your work doesn't have to make sense. Your suggestions did help though and I'm going to work at getting used to working under conditions I don't necessarily consider ideal. Right now I schedule my day around being awake when other people are asleep and I work at the gas station right before I go to bed so I avoid them as much as possible. I'll try moving my schedule up slowly every day until I'm deving while people are awake during prime time. My computer is in the kitchen and that leaves the secondary effect of the family being right behind me when people decide to get drunk and yell at eachother. If I can get used to deving under these conditions though, nothing will stop me in the future. In a way this is a golden opportunity.

Best way for someone with knowledge in other languages to learn Javascript?

thank all
love u

That's the thing... GHC has a garbage collector that relies on purity, so it allocates extremely fast, and collects extremely fast too. If the OS breaks the collection process, then...

Actually, it looks like the linux subsystem might not honor laziness of MAP_ANONYMOUS or something similar, since it apparently actually tried to allocate 512GB in the case of github.com/golang/go/blob/663226d8e130470c1a627c64cf489261ebb6da08/src/runtime/malloc.go#L258-L286

>I'll try moving my schedule up slowly every day until I'm deving while people are awake during prime time.
That sounds like a good plan. Gradual steps helps both in starting and stopping habits.
>If I can get used to deving under these conditions though, nothing will stop me in the future.
I agree man. To be honest, I grew up extremely lucky... If I grew up in that environment I don't think I'd be this far right now. I feel I never "push" for my personal goals the way I see other people do. I guess you could say I feel like I'm full of interest, but little passion and drive.

I'm trying to create a system capable of instantiating a wide variety of messages from a serialized state. Basically, JSON message comes in, well-constructed object comes out.

What kind of object is made depends on the data in the message. Each message has a "type" field which is a hardcoded number unique to each type.

How do I best go about constructing the proper message, given the type of the message?

Considering the fact I want to split the large "enum" of type-numbers into several files, how can I best ensure that each type-number is unique?

yeah I'll probably boot up a linux virtual vm to build Haskell programs. I've been waiting 30 minutes now for my twenty line program to compile

>That's genius, it's like bogosort for software engineering
haha, thanks. the kicker is that i actually do this. i *really* don't recommend it, though, unless you happen to have unlimited time to spare. not that i do, i'm just so obsessive about code that i often forget. currently trying to remind myself i live in the real world long enough to actually publish something (and end the irony of being a passionate programmer of many years with no significant published work), even if it isn't a perfect reflection of some fundamental universal ideal (outrageous, i know). much as it pains me, i guess people will have to settle for just an excellent piece of software

I decompiled my C code into 32 bit nasm. What is the 8H meant to be? Isn't it meant to just be 8?
c_heap_insert:; Function begin
push ebp ; 000F _ 55
mov ebp, esp ; 0010 _ 89. E5
sub esp, 32 ; 0012 _ 83. EC, 20
mov eax, dword [ebp+8H] ; 0015 _ 8B. 45, 08


Further down there's also this. What does the 0CH mean?
mov dword [eax+0CH], ecx ; 00CB _ 89. 48, 0C


I imagine it has something to do with the frame alignment?

look into your languages reflection features

man the fuck up dude these are the type of problems that bother a 15 year on not a 25 year old. Do what the fuck you want with your life, fuck your brother

Thanks.

You are bjoth right and wrong in your assumption that the issue is in your frames alignment. I won't work for you for free so I'll Let you figure out what I'm mean.

Hint: it IS meant to be 8.

Good luck.

>variable naming: variable names should clearly demonstrate the purpose of the variables. Literals must be camelCased.
>Literals must be camelCased
What did they mean by this?

They meant literals must be camelCased.

How do you camelCase a literal?

What is that from?
If it's a book, it should immediately be dropped.
If it's a class, tell the lecturer they're fucking stupid then drop it.
If it's a coding guideline, you should send a patch replacing all of the crapCased identifiers with proper ones.

I'd also like to know who "they" are, but I think the confusion was from the word literals. As if you can write your integers (not your variable names) in camelCase.

It's a shitty first class, and I'm not dropping it, otherwise I wouldn't be able to go onto the second year classes.

Yeah, there's no performance detriment as long as you avoid the GPU, which nobody uses in Haskell anyway.

I would maybe try forcing yourself to do small "hackathon" style projects, where you finish a project in 36/48 hours or some such on a weekend. Doing a few of those teaches you a different skill, which is how to make a "working" decision given x amount of time to decide. Maybe just go to a real hackathon to work on your own thing. Free food, man.

Haskell has me intrigued. Any good resources for learning it? I've never really worked with functional languages before.