/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1533675651588.jpg (1920x2163, 1.25M)

Other urls found in this thread:

superuser.com/questions/231776/how-do-i-see-a-history-of-what-ive-post-ed-in-google-chrome
pastebin.com/TZwjk40q
Jow
github.com/awesomekling
twitter.com/NSFWRedditVideo

Reply to this post or you will have to use javascript for the rest of your life

Much better

Attached: 1541357620471.gif (791x935, 1.11M)

OP is a faggot.

PYTHON!

>anime incels

Attached: 1502301401220.jpg (316x202, 30K)

thank you, based user!

@70561916
*GHCJS blocks your path*

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

playing with Direct3D 12

Attached: d3d12.png (1007x736, 1.91M)

dumb frogposter

What is this, Jow ForumsProgrammerAnimemes?

it's like you're waifu

looks like one of those magic eye pictures

Attached: Stereogram_Tut_Random_Dot_Shark.png (800x400, 183K)

True. I'm trying to make a shared than can render a large picture made up of tiles of textures.

There are worse fates

fuck you

It seems that JavaScript is a bit less worse than enterprise Java/C#

Attached: thumb_opened-52-minutes-ago-1-2-hurts-just-a-little-bit-29979575.png (200x260, 37K)

I have some programming experience, but no experience whatsoever doing anything with javascript or web development.

I want to make a chrome extension that will log posts (contents and URL) I make on Jow Forums. How would I do this? (as for why I want to do it, well I feel like it might be an incentive to post less, if I can go back and look at hard evidence of my stupidity).

main trigger would be getting re-directed, it would pause and do something like: superuser.com/questions/231776/how-do-i-see-a-history-of-what-ive-post-ed-in-google-chrome

then record the redirect URL (excluding Jow Forums.org/board/post)

In the meantime I'll be doing this autism manually, which might in itself be enough incentive to post less, but I'd appreciate any help with actually executing it.

Daily reminder that infinite loops are undefined behavior in C++.
So you can't actually write a zero-cost wait loop (like waiting on a watchdog reset) in standard C++.

>C++ is shit
We already knew that.

going through tour of c++ and it was fine until barney started using his meme buzzwords such as invariants, static casts and whatnot
I hope I won't have to go actually read his large book in the end

Attached: 1495436224553.png (703x960, 506K)

You can probably do it in a greasemonkey script accessing the user storage. In firefox anyway, shift+F9 and go to Local Storage > boards.4channel.org

I think those Jow Forums-track-* entries are your posts so the javascript can track (You)s

> buzzwords such as invariants, static casts
t. brainlet

settle down barney, I'll go look it up when I'm done reading

>meme buzzwords such as invariants, static casts
lol retard
maybe C is more your speed after all

>have access to a powerful search engine that can find anything in the biggest pile of information mankind ever made
>I hope Iwon't have to go actually read this large book

I'm working on an application that only had one developer before me, but it looks like a dozen people had worked on it. Throughout the code base, a single data element will have multiple different names. It's like he couldn't decide what to call it, so he just said "Why not both?" and switched variable names periodically for what is a single element. Likewise, the reverse is also true. Two different elements will have the same name in different parts of the code base. So when I see the variable "userId", I have no fucking idea whether that's the numeric primary key or whether it's the username because he'll use that name for both depending on where it is in the code base.

I'm glad he resigned. I have no clue how people like this function in daily life. How could someone who's brain is so rattled that this convoluted mess makes sense, yet they can wake up in the morning, brush their teeth, bathe themselves, drive a car, and all the other things one does in a day. Do they just go through life with their brain that rattled? Do they just perceive the world through a mind in chaos? I have no reason to believe this man was schizophrenic. I know him. Yet the code reads like it was written by someone with a fractured mind. If such simple tasks cannot be completed without such wild inconsistencies, I cannot imagine any task in their life not being absolute mental hell for them.

she thinks "invariant" and "static cast" are "meme buzzwords", what the fuck else did you expect from a literal retard?

stop bully, I get what they mean I just failed to see their use case from the literal 1 or 2 sentences they were mentioned in

it's healthy bullying

fuck you

Attached: gyate_patchouli_black.png (800x520, 19K)

all bullying is healthy

We are all volcels in this thread.

Attached: 1525116698301.jpg (874x1200, 399K)

Infinite looping shouldn't be supported by any decent language anyway, so who cares.

C is not decent?

Obviously JavaScript

What languages do you consider decent?

Trying to write my first non FizzBuzz program in C, a Simon game. I can't play yet but graphics and the sequence generation is done.

Attached: Screenshot from 2019-04-15 17-09-57.png (1920x1080, 244K)

OOP was a mistake

looping shouldn't be supported by any decent language anyway

Attached: eYEvD.png (620x429, 63K)

you can write loops in haskell

Any ALGOL-based language is the ugliest thing to ever "grace" this world with its presence.

Opinion discarded.

This isn't Haskell. Also, Haskell is harmful since it supports general recursion.

Any language that lets you get work done is harmful tbqh

Yes, you can emulate loops with recursion. There are no loops tho.

ocaml?

there are no loops in C, the compiler just emulates them with jumps

I'm trying.
For the moment I succeeded in extending the native Jow Forums thread watcher so you can manually prune all archived, but still alive threads. Feel free to suggest a better icon, though.
pastebin.com/TZwjk40q

Now I only have to find a way to call ThreadWatcher.toggleList so the whole thing can be hidden at will on desktop as well.

Attached: prunebroom.webm (320x200, 96K)

ironical shitposting is still shitposting

Is there a good C compiler which is guaranteed to halt? I am doing some metaprogramming and GCC/clang seem to be too bloated and shitty.

Ok anons I am using python
one error left in the program
So the program has 3 minor functions called by the main function.
in the minor functions it has to return some int's called aaa,bbb, and ccc.
I have the minor functions return aaa,bbb, and ccc
Now the error in the main function has to do with this line
file.write('the user choose:',aaa,bbb,ccc)
but it says aaa,bbb, and ccc are not defined

Just write a test program which checks other programs to see if they halt. It should be trivial.

1) bost code
2) define aaa, bbb, and ccc in the scope you do file.write

What is this code supposed to do?
#define ICE_P(x) (sizeof(int) == sizeof(*(1 ? ((void*)((x) * 0l)) :
(int*)1)))

My compiler already does that for programs in my language, but I can't guarantee that the C code it generates won't send GCC or clang into an infinite loop.

WHY DONT YOU USE A FUCKING SEARCH ENGINE FOR THIS THIS ITS ALREADY ANSWERED ON STACKOVERFLOW

You should obviously replace them with the variables you stored the return values of your three functions in.
Your main function has no access to the other functions' scope, and you probably shouldn't turn them into global variables either.

1) I had to copy and remove over 100 lines of code to show the core.
def ask_user_a():
print('1= color show 1')
print('2= color show 2')
print('3= color show 3')
aa=input('which LED light show do you want')
aaa=int(aa)
if aaa == 1:
print('1')
if aaa == 2:
print('2')
if aaa == 3:
print('3')
if 4

goddam javascript

shit it doesn't show indents here

why not just use Jow Forums X? It's already in there.

Nobody is saying it, but I will
I'm happy for you user
Keep up

Attached: 1552563332491.jpg (371x532, 27K)

What the christ, user

Attached: plasma_still.png (720x480, 474K)

how will the programming language D be remembered by future generations?

Attached: datastartrek.jpg (259x194, 7K)

use code tags
Jow Forums.org/rules#g

> remembered
I've already forgotten about it.

It will not be remembered by future generations.

def ask_user_a():
print('1= color show 1')
print('2= color show 2')
print('3= color show 3')
aa=input('which LED light show do you want')
aaa=int(aa)
if aaa == 1:
print('1')
if aaa == 2:
print('2')
if aaa == 3:
print('3')
if 4

return has a tab in it to make it part of def ask_user_a()

I remember when I asked here if letting people run code in VMs on programming training sites was not dangerous and you said that there would be absolutely no way to exploit it.

then a few weeks later the spectre vulnerability became public


what does being so wrong feel like /dpt/ ???

I'm a retard, so linking this here.

Also you need to "return ask_user_a()" if you want the function to recursively call itself until the user enters a valid number.
Also for the love of god, please rewrite it like this:
def ask_user_a():
print('1= color show 1')
print('2= color show 2')
print('3= color show 3')
aa=input('which LED light show do you want')
aaa=int(aa)
if aaa == 1:
print('1')
elif aaa == 2:
print('2')
elif aaa == 3:
print('3')
else:
print("Oops! That was not a valid number. Try again...")
return ask_user_a()
return aaa

def prompt_led_color():
color_choices = [1,2,3]
for i in color_choices:
print('%d= color show %d' % (i, i))
ans = input('Which LED light show do you want?')
if int(ans) not in color_choices:
print('Oops! That was not a valid number. Try again...')
return int(ans)


if __name__ == '__main__':
color_num = prompt_led_color()

Attached: 1501728487682.gif (460x234, 3.45M)

Is f# popular on /dpt/ yet?

> yet

Thank you anons

Understanding Monads

Attached: enemy of the state.png (478x618, 84K)

It’ve been using it nearly exclusively for about 12 years now :(.

I think it's neat

no no no no no!

Tell us about your 300k job in finance.

Oh hey I see it
A shark

You would probably want to avoid recursion and also catch bad user input. Something like this.

def prompt_led_color():
color_choices = [1,2,3]
ret = None
while ret not in color_choices:
for i in color_choices:
print('%d= color show %d' % (i, i))
ans = input('Which LED light show do you want?')
try:
ret = int(ans)
except:
print('Error parsing input %s' % (ans))
if ret not in color_choices:
print('Oops! That was not a valid number. Try again...')
return ret


if __name__ == '__main__':
color_num = prompt_led_color()

Attached: 1501528984181.gif (837x736, 299K)

so let me get this straight, imagine a class hierarchy: Shape->Circle->Smiley
Circle* c {};

Smiley* ps = dynamic_cast(c) // this is ok
Smiley& rs = dynamic_cast(c) // this is not ok, bad_cast

That's right. But ps is a null pointer.

>But ps is a null pointer.
why, isn't the whole point that it can cast to expected type OR a type derived from expected type

Please help

All that code is complete nonsense, I don't think you understand C++ at all.

thanks for elaborating

Attached: 1539364826236.png (640x480, 472K)

So no one should be able to write continuous digital regulators, controllers, etc?

I don’t have one :(. I do run my own company though. Should make about $50,000 in revenue this year.

You can't cast a pointer to a reference, you can only cast a dereferenced one. Your code doesn't even compile.
Smiley &rs = dynamic_cast(*c);

yea sorry I just noticed that, that's what I meant to write
but it would still give a bad cast because it's not the expected type, right?
this is why I'm asking, if you must know
>bruv your literal example code doesn't make sense

Attached: SumatraPDF_2019-04-15_18-25-27.jpg (676x850, 134K)

#define CCRITICAL(s, f, ...) if ((s) = ((f)(__VA_ARGS__))) do { \
fprintf(stderr, "Error in %s on %d in %s:", __func__, __LINE__, __FILE__); \
fprintf(stderr, "%s(%s) == %d\n", #f, #__VA_ARGS__, (s)); \
exit(1); \
} while (0)
#else

Is this good practice? I hate having to write out stuff like
if (status = f(x, y))
CRITICAL("failed to call f (%d)", status);

It'd be much cleaner to write
CCRITICAL(status, f, x, y);

D a shit.

Attached: 1551914022563.jpg (240x320, 26K)

Post your GitHub so I can contribute

Attached: 1540440373567.png (494x795, 411K)

github.com/awesomekling

I still have no projects

Attached: 1448740035264.jpg (1920x1080, 174K)

>Gustedt: At the language and library level, the part that is directly visible to programmers, not much is decided for now. We are really open to see what people bring in. My expectation is that we will see some C++ features integrated into C, such as attributes, compile time constants for all data types in one form or another, and perhaps initialization-induced types (AKA C++’s auto feature). Also there is a coordinated initiative with C++ for a new calling convention that could supersede the crude errno error return convention that we are dragging with us since the beginning. There are several people who ensure liaison with the C++ committee and they do an excellent job on these issues.

>But the C standard has another important role because it basically sets the machine model on which our computer architectures and also other programming languages build. The C standard calls this the “abstract state machine”. As an important feature here we have already voted the integration of the latest IEEE floating point specifications into the C standard. We also have formed a working group to revise the “memory model”, that is how programmers may or may not directly interact with the bare representation of data in the computer’s memory, how this may influence possible optimizations, and how such byte- and bit-level fiddling can be made safe and secure. This work follows Peter Sewell’s (et al.) papers on “pointer provenance” and we hope that we will end up with a memory model that is a suitable common ground for the diversity of system software and applications that C serves.

Only three more years until Rust gets BTFO and C reclaims its rightful throne

I have a retarded question, do various Programming language have different speed of writing something in the console?

What i mean is if i tell Python to write A a thousand times will it do it slower or the same as if done in C++ or Rust or whatever faster language there is

Attached: 367373467.jpg (477x477, 41K)