/dpt/ - Daily Programming Thread

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

Attached: 1525102272864.jpg (750x1000, 125K)

Other urls found in this thread:

github.com/Merkoba/Hue
ideone.com/pSrXqU
twitter.com/AnonBabble

nothing, kill yourself

nth for Nim (And Yuno!)

based trips

>whitespace scopers: destroyed
>} else {: destroyed
>atheists: destroyed
Today was a good day

Attached: def.jpg (1600x900, 90K)

>programming thread on /v/

Attached: 1513987289759.png (270x270, 5K)

You better crosslink that shit sempai.

fucking hell
they cute

Setting up a arbitrary file transfer client/server in python. I’m autismo and having trouble getting right into the code but i figured i’d abstract up to a state machine first and then work on getting that translated to code

error: a label can only be part of a statement and a declaration is not a statement
struct rtype *r = (struct rtype *) cur_op;

wtf is goin on here

>another day more spent on rewriting code to look more elegant than actually writing new stuff
Autism pls.

Conway's Game of Life using HashLife and SIMD

Oh dear.

Attached: garbage_collector.png (857x159, 38K)

>i'm agonizing over using 3 mallocs for my memory allocators when these people exist

Add a semicolon to the previous line.

Apparently switch statements don't like new variables

Trying to write a secure private voice assistant, but i'm having difficulty finding any human-sounding TTS that isn't botnet, SaaS, or shit.

Anyone know any open source TTS that sounds human?

It's because it's in a switch statement
Does this mean
LABEL:
struct ass hole = shitter;

will also throw the error?

if I want to see if a program is installed with python first I need to get the PATH folders and loop through them, but how do I know if the program is installed? Just search for a file with the name of the program?

That's an annoying ancient quirk of the C syntax.
I'd honestly propose that they change it for the next C version, but I don't know how to propose shit.

Solutions:
Add a semicolon
switch (a) {
case 0:;
struct rtype *r = cur_op;
}
or
forward declare
struct rtype *r;
switch (a) {
case 0:;
r = cur_op;
}

Yes. But this is fine.
LABEL:
;
struct ass hole = shitter;

For the second one, I didn't mean to add the extra semicolon.

This github.com/Merkoba/Hue

Which of these is better?

#1
if condition
return value
return other value

#2
if condition
return value
else
return other value

Depends. Personally I like
{
if (simple_check())
return early;

// lots and lots of code goes here

return result;
}

It doesn't matter.

Is there any good structure or patterns I can use for managing data to be written asynchronously to network sockets?

It strikes me that in libraries like ASIO, reading the data from sockets can be kept relatively isolated (i.e. you have a buffer per client), but if you want to queue something to write, you're inevitably going to have to deal with either some global singleton (like malloc or some custom allocator), or some hideous per-client mutex lock...

Attached: 33a53f47fe7e0cabc48440001f8ddea2.gif (500x307, 462K)

>all his projects are in javascript
*vomits externally*

In any case good for you user. Hus is nice but the UI looks like shit, i reccomend cleaning it up a bit.

Depends on which one you expect to be the most common, if other value is less common there is no point in checking every loop.

Nice, I feel like this type of chatroom will eventually become the norm.

>the UI looks like shit

;(

I try to make it better as much as I can continually. Personally I like it, but that's my standards.

Attached: chrome_2019-02-23_16-04-02.jpg (1920x1057, 359K)

I need software suggestions to start my software collective. What is something that would actually be useful?

Probably. The ability to show images or play videos without disrupting the conversation should be more common.

That's interesting
I'm surprised it took me so many years to ever actually encounter this

Well who posted the top video?
It this just a TV-and-chat? If so then you should check out this hot new thing called Twitch which is twice as interactive.

ANYONE?

Attached: botnet2.png (1700x770, 177K)

The assembly is surely the same. The only thing I can see changing is the stack frame so the else may be counter-intuitively faster.

Perhaps I misunderstand what you wrote, but that sounds like a spmc queue (ie. you have a source of data that you want to push to the connected clients).
There are multiple ways (including locks) to implement these, but it's difficult to give advice without knowing the details of your use case.

pls respond

I hope you're not doing programming on windows.

It's announced in the chat who either changed the image, tv, or radio.

There's also history windows for each of those.

Twitch streams work.

Attached: chrome_2019-02-23_16-17-16.jpg (1920x1057, 242K)

You should probably do something like this:
executable = "python"
for path in os.environ["PATH"].split(os.pathsep):
t = os.path.join(path, executable)
if(os.path.isfile(t)): print(t)

In linux you could probably do something as simple as
executable = "python"
os.system("which " + executable) == 0

I feel so dumb when people start talking about cache misses and shit

Once you understand what that is, it's not that complex.

I don't get who would think allocating in the middle of a switch is a good idea.

Cute OP

Attached: Yuno.jpg (1280x720, 97K)

The clients need to be able to read and process command packets. Some operations will be async so they can return at any time later on by writing packets. In addition clients may send commands or trigger events which cause other clients to receive messages.

So realistically, all command handling and thus packet writing will happen sometime after a packet has been read.

Attached: 1334750959982.gif (1024x640, 1.28M)

it deoesn't really matter. You could even use a ternary operator.
`return condition ? value : othervalue`
but like others have said, it doesn't really matter.

Sounds kind of comfy.

UI is still pretty gross though, also having more than one audible source open at a time is an invitation for earrape

on linux
I see thanks

Radio doesn't autoplay, unless you start it.

TV does autoplay if you don't have it locked or disabled.

Pic related is only the image enabled.

Attached: chrome_2019-02-23_16-23-58.jpg (1920x1057, 395K)

You shouldn't think about automatic variable allocation so literally.
The compiler is free to actually make space on the stack or assign a register whenever it pleases to.

It didn't matter in C89 since you were supposed to forward declare everything anyway, but a declaration directly after a label wasn't allowed for some reason.
It's especially silly because adding the null statement allows it to work.

>UI is still pretty gross though

The color theme and background image are completely customized, if that helps.

Attached: chrome_2019-02-23_16-26-45.jpg (1920x1057, 220K)

To be fare I'm not allocating anything, I'm using a switch statement on an enum in a union to determine which datatype I'm dealing with, and then casting the union as that type

I think a UI improvement which is pretty simple is to have the chat area clearly fenced by either a background colour change, line, etc. A line is useful because you can also let people resize the chat width.

1) fuck memelangs for introducing memory not being allocated where you goddamn tell it to be and 2) no, an allocation in a switch is a really stupid idea that's going to cause a bunch of bugs later.

I've tried the line, looks ugly.
To resize the chat you can hold shift and scroll the left edge.
Same works on the right edge to change the proportions of the image to the tv.

Hmm, looking at the official C grammar a bit more closely, there seems to be several distinctions between a declaration and a normal statement.
Apparently, this
int main()
{
while (1)
int a = 10;
}
is not valid.

You clearly don't understand how an abstract machine works, and the optimisations a compiler is allowed to take.
If you seriously give that much of a shit, use assembly.

struct rtype *r = (struct rtype *) cur_op;

That allocates a pointer to a structure. Use a goddamn union if you're using it, not some struct hackaround

Sounds like a textbook example of channel-based concurrency. Consider using go or a similar language with support for channels and coroutines.

>allocate different data depending on condition
>compiler "optimizes" it all so every variable is taking up stack memory
>blow up the stack because the compiler's smarter than you

Just finished working on this ideone.com/pSrXqU
i'll take any tips on style. I recently converted to braces next to brackets to save on lines, so i'm pretty open to being influenced.
plz please ignore the fact that i'm flexing a bit for a measly COP2221 assignment.

Attached: Screenshot_2018-07-30 Read manga Origin ch 013 online in high quality(1).png (621x856, 836K)

Anyone know any open source TTS that sounds human?

Attached: unrelated.png (1162x804, 420K)

We need to go wider

Attached: wide.png (2024x395, 317K)

Do you even understand how C scope and variable lifetimes work in C, you fucking moron?

looks horrible, well done

Also the proportions can be are controlled by settings.

Attached: chrome_2019-02-23_16-40-23.jpg (1920x1057, 127K)

Attached: Capture.png (358x293, 10K)

what aminays can i watch to improve codings

Attached: 1460648379809.gif (350x415, 79K)

Keijo

new game

PLEASE

BPS, it's about the best programmer and hacker in nippon. It's like 10 mins x 15 episodes so it's quick to go through. I enjoyed it.

Attached: [A-Flux] Battle Programmer Shirase - 01 [B7BFD140] [00:06:28.180].jpg (853x480, 260K)

ok thank you fends

Attached: 1492893075870.jpg (351x352, 38K)

just watch it

Attached: [A-Flux] Battle Programmer Shirase - 03 [854E2175] [00:04:15.756].jpg (853x480, 286K)

I want a project. What is something challenging and fun that will make me a better programmer?

make a gf

this and then sell her to me

something that solves a problem in your life

this but use bitcoin

Please don't meme on me. This is serious.

I have no problems in life other than no gf and feeling empty and worthless at all times.

Great idea! I'll just use go and have one trainwreck of a garbage collection nightmare during processing.

>I have no problems in life other than no gf
then is perfect

>I have no problems in life other than no gf and feeling empty and worthless at all times.

Perhaps some therapy would do you better than sitting inside and programming all day :)

I am not programming, which is the problem.

DOUBLE COMPILE

y'know somehow i don't think it is

but u do u im not your mom, user

std::forward
When t is a forwarding reference (a function argument that is declared as an rvalue reference to a cv-unqualified function template parameter), this overload forwards the argument to another function with the value category it had when passed to the calling function.

frankly, i'm lost.

to understand C++ you have to be mentally ill

Attached: 1549207777991.jpg (720x405, 23K)

I can't keep the sentence in my head long enough to parse it.

Attached: huh.jpg (374x374, 41K)

std::forward(t) is exactly equivalent to (T&&) t. That's all std::forward is.
Why do you need to do this? Because otherwise rvalue-ness won't be forwarded. rvalue references are lvalues.
int &&x = 0;

// this will not compile
int &&y = x;
// but this will
int &z = x;
// and so will this
int &&w = (int&&) x;

Attached: 1495402428175.jpg (486x417, 23K)

>blow up the stack because the compiler's smarter than you
Then clearly the compiler isn’t smarter than me.

Attached: 0E6FFB70-BA5C-4BC6-B93E-BE696CD5E6A3.jpg (680x588, 61K)

I think Stockholm syndrome is more accurate

Jesus christ, what a fucking mess of a language.
How do you possibly justify necessary complication/retardation like this existing?

why no static_cast?

>necessary
unnecessary*
Fuck

thnx

Because C++ had to be sure to have at least 5 different ways to do the same thing.

Backward compatibility. There is a better way to record lvalue/rvalueness in the type system but it would have broken existing code.

Same thing. I think it's easier to understand with a basic C style cast.