/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

youtube.com/watch?v=_F5uPLdMaJg
github.com/uutils/coreutils
github.com/das-labor/panopticon.git
github.com/cocuh/intellij-background-chibichara
developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information
github.com/jpbarrette/curlpp/blob/master/examples/example01.cpp
twitter.com/SFWRedditVideos

Killing myself in c#

Also first for rust

C + + 1 7

C++(+)

Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

Working on an IRC enabled bot that should constantly stream toprated games of a videogame or optionally search and find games the viewers request it to stream.

Rust

>youtube.com/watch?v=_F5uPLdMaJg
>open talk
>the guy introducing is the same as the last two (three, four?) years
>Alexandrescu still hasn't fired these unprofessional fucks
What's wrong with him? Is he oblivious to it or is he getting this good a deal on them hosting the conference?

Recommend me somewhat interesting project to try out Rust, somethin at least little bit useful not fizzbuzz shit

>or is he getting this good a deal on them hosting the conference
If I were to guess, it would be this, or he likes them for the some god forsaken reason. Either way, I understand your pain, user: that shit's unbearable.

a 3d maze generator.

That sounds bit hard esp for first time rust user...

Then maybe fizzbuzz is for you, champ.

>Anime
Hi!
Go to hell.

Command line unix file manager / fork of ranger

That sounds OK, thanks

best way to do multiple return in C?

No.

I want to learn C# for Unity but my brain is definitively not wired for anything like that.

And the documentation isn't retard tutorial enough for me.

Passing pointers to the function.

Pack your returns in a struct you've defined specifically for the function. And then on the calling site directly move the values out of the returned struct.
Gives the compiler the most room to move.
Using pointers to return stuff has problems with aliasing, can make code a lot slower.

Mostly talking about a text based multilayer maze.
So not a graphical 3d one but just a {X,Y,Z} one.
So something like the one in my picture.

>Using pointers to return stuff has problems with aliasing, can make code a lot slower.
If you're not reading shit from the pointers, no it won't. However, restrict exists for all of your aliasing problems.
A struct is just another annoying type to worry about, and C doesn't really have a nice way to unpack them.

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

None. Let the user manages that through the arguments.

Please, don't say that.

contribute to uutils
github.com/uutils/coreutils

>let's remove c++'s problems by adding ours.

Thank you for using an anime image.

I told you to kill yourself years ago.
Why haven't you done it yet?

Just jump into unity with the basic shit. Put a cube in and figure out how to change its color on keyless. Just Google your way through it. That's what I did 3 years ago and now I do it professionally.

Also I'm here if you really need retard help

Who said that and why are you quoting it?

Hey guys can you help with a little python problem?
I have a package that will contain multiple modules ('server' and 'client'), and structured it like this:

package
├── clients.ini
├── config.ini
├── docs
├── logs
├── Makefile
└── server
├── aes_auth.py
├── aggregator.py
├── clientsparser.py
├── cli.py
├── custom_http_errors.py
├── __init__.py ## This file runs the server
└── server.py


I cd into 'package' and use 'python -m server'. It runs fine, but when I quit it using ctrl+C I get:
/usr/bin/python: No module named server.__main__; 'server' is a package and cannot be directly executed


I have no idea where the error stems from really, I read the hitchhikers and the PEP on package structuring but I'm still lost, anyone have an idea where to start looking?

The thing is that when I google features I want I find code that doesn't work at all or I don't know enough to take the parts I need/change it.

Or I don't find anyone who has tried making the same thing

well what kind of stuff are you trying to make?

I've only heard bad things about C. I don't mind spending a few days/weeks learning a language but I don't really want to if it's useless. Should I?

Oooh i imagined like real 3d maze u know like in fps games, thats managable then haha

you should definitively not.

it's pretty useless if you're not getting very low level with it. if you don't see yourself working in any environment where C would be useful then there's no need to learn it.

Personally I would say learn a little bit and see if you need it from there.

>C doesn't really have a nice way to unpack them.
The compiler does. If you pack them in a struct and assign the members of the struct to other variables the compiler infers that it could put those return values wherever you store your variables. If you pass a pointer the compiler simply does have less freedom to operate, regardless of restrict because it often can't be sure where they're pointing to. In the trivial cases it certainly can but in the not so trivial cases adding a pointer to the mix just adds one too many steps to the process and the Compiler says "fuck it" and does whatever it has figured out so far.

So if your only intent is multiple returns and not to work on memory in place (another common use for output arguments) making a struct is better.

I agree that having another struct in there is slightly ugly but how much of an issue is that really? Unless you name it confusingly I don't see the issue. If you use autocomplete of some form and you don't have a way to mark certain names as not valid candidates for autocompeltion that's an editor issue clearly. If you look at the code written this way I think it's better than having to pass an output argument simply because it's more explicit because a return is a one way thing and an output argument isn't necessarily that. Defining a struct at the top of your function definition isn't that ugly even. It's certainly more ugly than single return functions but it's better than output arguments.

Yes

Someone give me a brief gestalt on generators in Python.

When the fuck would I use one of these?

C is still used in a lot of places, especially open source software, and basically everything low-level. It wouldn't be an overstatement to say it's the foundation of modern computing.
If you don't know C, there is a seriously large swath of very important code that you will be incapable of reading and understanding.
Fucking just learn C. Don't fall for the rust-shills' memes.

What a clueless idiot. Perfect Sup Forums type

>memes

Basically inventory system, a collection system, and I need to have the meshes of items collected during a playthrough appear in a scene but without like being all in the same point passing through each others.

alright try this.

for inventory, just start with a List, you'll need to import systems.generics (unless you're on 5.6 I believe its default import now). Just add picked up items to the list. Then look into using the unity UI system and basically just set up designated spots for the menu to pop up, and overlay thumbnails in the menu for the items the user has. You can go way more in depth and there are way better systems, but this is probably the most beginner.

collections obviously the list, and use colliders for pickups, if they shouldn't collide with them, set the "is trigger" checkbox on the collider.

keep a second list and every time an item is picked up, if its never been picked up before add it to the list, if it has been picked up before, dont add it. when you need to show them just go through this list.

Might have misunderstood you on that last one, so if I got that wrong try explaining it a little better.

also there are plenty of tutorials on inventory systems, but they will vary in complexity. theres some made for RPGs and others made for simple display. search around you can definitely find plenty.

>It wouldn't be an overstatement to say it's the foundation of modern computing.

I'll try looking up what you said. A friend told me I shouldn't need list for what I wanted but I don't know shit.

Anyway I need to search more. Thanks

I mean, I'm more of an AI programmer (super shit with any GUI) but you'll almost always need some sort of list to track an inventory. You may not use List specifically. i'd run that by him though. He might be more knowledgeable in this area than I am.

github.com/das-labor/panopticon.git

>GPL V3
>GPL
Why would you want to ever touch that?

Any good IDE/setup for rust?

Eclipse has a rust plugin doesn't it?

VS Code probably has a decent rust setup now.
But i think it actually has an "unofficial-official" IDE now.

Why do people state C# is better then Java?

Why does it matter? Something being better than absolute shit wouldn't really mean anything.

Because they use windows.

Yeah, it's a statement with no weight to it.
It's like saying a pile of horse shit is better than a pile of cow shit.

Because it objectively is. You can argue about .NET vs JVM, but C# is miles ahead of Java. Mostly because the latter is too focused on backward compatibility and haven't improved in the past 20 years.

The language itself is far better, but the ecosystem is another story.

C# has a lot of syntax sugar that makes it pretty easy to write and get things done. Java has thankfully started to "catch up" with streams, but there's 20 pain points in one day if you're used to C# and you go to write something in Java.

In addition to the language itself, C# has a really fantastic toolset surrounding it. Depending on what you're trying to get done, you can spend a few minutes with C#, spend a few dollars in Azure, and have something delivered and hosted that Just Werkz™

Overall, Java isn't bad at all; there's many things it has going for it. Java has much better multiplatform support, even with the release and improvements to Mono and .NET Core, but overall using C# to accomplish tasks in a business environment is extremely efficient and easy.

I would say that I prefer C#, but I would not say that C# is objectively better than Java.

Anyone who says this is making absolutes without context.

How much does Microsoft pay for one of these posts?

I found best intellij plugin in the world!

github.com/cocuh/intellij-background-chibichara

Did you even read the post you're responding to?

about the same as oracle pays an intern to break java for the day

I've been working on a logic circuit simulator. I still have some features to add, and there are probably some bugs I haven't found yet, but I think it's starting to work pretty well now.

what'd you use to build it?

Looks wicked.

Why does it look like shit tho?

To me this seems extremely pointless. You're running logic circuit simulators on logic circuits.

Why is Brendan "Homo" Eich so bad at designing language?
>can't dynamically modify css class definition
>not multithreaded, dom functions are not required to be thread safe

Full story? Where is this from?

>>can't dynamically modify css class definition
what
>>not multithreaded, dom functions are not required to be thread safe
it probably wasn't made with big concurrency in mind

>>>can't dynamically modify css class definition
>what

If there is css class
.red {
color:red;
}

In js you cannot just do something like

document.css.classes['red'].color = 'green';

That would change color in dom object that has class .red into green.

starting out on some beginners' books for Python and Ruby, after being out of the professional IT gig for several years (in which i mainly used Oracle PL/SQL and Perl).

how pleb am i?

Not programming.
Discuss this in

BBC Basic, Brandy interpreter on linux.

Thanks.

I personally like how it looks, but anyway, it uses custom text character definitions to draw the components. It's limited to 8*8 pixels per character so everything ends up being pretty low res looking.

go shitpost to >>>/reddit/

developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Using_dynamic_styling_information

but i would add a class to the element instead and make a style rule for that

Web "dev" discussion doesn't fucking belong here. There is a special thread for your kind.

>bu.. b bu.. muh SAFE SPACE
use name so you can be filtered faggot.

I'm not the poster you're replying to, but webdevs bring the most mundane, stupid shit to these threads. A lot of it isn't even real programming.
Go back to your fucking containment thread.

>muh
Go be retarded somewhere else

Alright gee

How do I attribute an array position to a different array in another object? Using java btw

I don't understand the question

say I have int 8 in position 9 of array int x[10]

How do throw that into postion 2 of array int y[10]

Meant to quote you

y[2] = x[9];

That easy? wew

Nice dubs btw

y[2] = x[9];

You might need to read up on arrays some more m8.

IO () is such a bullshit type. It can only take on a single value, denoted IO (), but no two instances of that value are equal.

Why is the real world so ugly?

IO a is equal to IO b iff a is equal to b.
() is equal to ().

Not a hater of C++, I actually want to learn it and respect people who know it. But like coming from Python, I just wanted to download the HTML contents of a webpage right?

In python it'd be be something like

import requests; content = requests.get(url).content

In C++, I had to do all this:

#include
#include
#include

size_t fwrite2(char *contents, size_t size, size_t nmemb, std::string *s) {
size_t newLength = size * nmemb;
size_t oldLength = s->size();

s->resize(oldLength + newLength);
std::copy((char*)contents, (char*)contents + newLength, s->begin()+oldLength);

return newLength;

}

int main(int argc, char *argv[]) {
CURL *curl = curl_easy_init();
std::string s;

curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite2);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
curl_easy_perform(curl);
curl_easy_cleanup(curl);

std::cout

>Is this normal? To go through callbaks and 10 times more lines of code for something that's apparently not even memory safe?
That's because curl is a C library, you fucking dolt.

Also, yes that's normal for C libraries.

But everyone recommended it for C++ as well. I guess there's a wrapper curlpp for offering C++ functionality, though not sure how much easier it is

OOP > Functional > Procedural > Java-esque "OOP"

I guess curlpp makes it more humane github.com/jpbarrette/curlpp/blob/master/examples/example01.cpp

So I should just stay away from C libraries

>But everyone recommended it for C++ as well
Because it's relatively decent and up-to-date while other libraries that are equally up-to-date usually are proprietary and require you to use a restrictive license (as in, you can't use this for commercial purposes without paying us a gorillean dollars).

>I guess there's a wrapper curlpp for offering C++ functionality, though not sure how much easier it is
Depends on how well you like to deal with C.

Keep in mind that CURL strings doesn't play very well with C++ std::string because of RAII. You have undefined behaviour in your code.

This makes no sense. "OOP" and "Procedural" are types, but "Functional" is a value of those types.

>So I should just stay away from C libraries
No. That's fucking stupid.
Basically every library worth giving a shit about is written in C.
You need to realise that you're not working in some ultra-abstracted babby scripting language anymore.
import solution
soulution.run()
isn't going to work anymore. You'll actually have to learn how to program something.

I would highly recommend you stay the hell away from C++, though.

Ok I think I'm quite out of my depth. I did an undergrad in CS for nothing cause I'm still a dumbass

>""abstracted""