/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
mywiki.wooledge.org/Bashism
tratt.net/laurie/blog/entries/how_can_c_programs_be_so_reliable.html
mega.nz/#!M5tF1YCK!cRZttDs3AFTYa_16UdzzjjhdosoXtL9irsWDg4lJIdg
pastebin.com/0vzyJ3ss
youtu.be/ehyHyAIa5so?t=1366
pcg-random.org/statistical-tests.html
pastebin.com/iULh7KiP
twitter.com/NSFWRedditVideo

do you wear wool arm warmers to optimize typing in the winter months? if not, why? do you hate productivity and programming gains?
>improved bloodflow
>warms blood up so you won't have shaky hands
>looks cute so you get in touch with your inner programmer
>people will compliment them

First for Rust is for brainlets

sad loli

anime and c++ are cancers

this makes a lot of sense

wtf is wrong with her knees

>spend 50 hours writing fancy OOP messaging system
>with requests and queing and packeting, and different types of messaging for ultimate efficiency
>optimize down to be on the stack with fifo ringbuffers ect
>turns out have to wait for master to clear ringbuffer to make more room anyway

>could have just waited at messaging time for the master to snarf up the bytes as they are generated instead of adding them to queue in the first place seeing as it has to buffer after only a ~100bytes anyway

defintely 100% not going to delete all my bloat now; just contributing to the economy :^)

that's why I posted it.

...

the best solution is always the simplest one

...

my interface is so perfect though its existence is a positive in itself

>thinks he's being clever
>turns out he just doesn't know what he's doing
>keeps around heaps of useless code anyway because it makes him feel smart

yeah but imagine how cool it'll be if we switch to a microcontroller with more memory or if the user wants to do something in the ~80ms when we arent clearing the ring

What's the best non-meme language that can be used for simple personal stuff like mass-renaming files?

My language will save systems programming.

posix shell command language

where can I start learning this?

PowerShell or Bash.
If you need to do shit more advanced than renaming files, use C# through .NET Core.

The only three you really need.

awk

pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

Why is it such a fuck around to get domains registered?
I want one for life god damnit

wait so what's the difference between shell and bash?

>he doesn't know the difference

posix shell is decades old and standardized
any POSIX-compliant shell will run a shell script correctly
bash is a shell that adds a bunch of non-standard features, but since it's so commonplace, this isn't really a problem for many people

Bash-specific syntax is ugly as fuck to look at tho.

My RC522 board died today and now I'm sad. They take 30 days to get here if you order them from China and they are 7x more expensive if I buy them locally.

why did it died

No clue. The LED still lights up when I supply it power but I can't communicate with it anymore. Nothing changed, I just tried to use it one day and wouldn't work.

so I shouldn't really bother with the bash stuff?

that's up to you
I personally don't bother with it, but some bash-isms like double star globbing are incredibly useful when you're writing some quick scripts and don't feel like traversing all directories with some mangled abuse of the find command

mywiki.wooledge.org/Bashism

Rate my FizzBuzz.

int x;

for(x=1;x

tratt.net/laurie/blog/entries/how_can_c_programs_be_so_reliable.html

Where do I get them? Are they cheap?

>where do I get them
just search for wool arm warmers on alibaba or some other distributor of clothing, you can get them for like 2 dollars.

>not having hands
Pleb.

>OP image
I love when that happens.

All I ever wanted was a programming language with soft real-time GC + optional manual management, dynamic compilation, metaprogramming, compile-time reflection (including type reflection), gradual typing, meta-objects, operator overloading and value-types. Why can't it exist?

This is supposed to be easy but I'm not bright. There's a yugioh card with the following effect:
>Target 2 "Heraldic Beast" monsters in your Graveyard; Special Summon both those targets. Immediately after this card resolves, Xyz Summon 1 Xyz Monster using those 2 monsters only.

Knowing the above shouldn't really matter, but I want to simply change this to 3 monsters, but the lua script's making it look retarded to do. mega.nz/#!M5tF1YCK!cRZttDs3AFTYa_16UdzzjjhdosoXtL9irsWDg4lJIdg

>inb4 the answer is to add one or two simple lines to the script

does anyone else always imagine the author is a cute girl when reading programming blogs?
they seem to have a decidedly feminine voice

if you dont, you should try it

that's my general outlook on life. Assume cute girl until proven otherwise. just makes life a bit brighter!

...

Any gotards around? Im trying to find out if theres a standard practice for *function* organization. i.e. Where does main() belong?
For whatever reason Ive always had my main() at the absolute bottom of the file, which I think is a carryover from writing C, and a lot of files I run into do this too.
But is that the standard, if there even is one?

they don't have feminine cute speech patterns, instead they sound closer to effeminate gay men, which ruins the illusion

most dev blogs aren't even worth reading unless they deal with systems programming, and these are written with an air of confidence, and certainly not in a nasal vocal fry.

...

Post the code directly or use a pastebin

...

lrn2thread

Over here pastebin.com/0vzyJ3ss

END, for now.

they're cute girls but they have feminine penises, how about that?

>2018
>Still using % for FizzBuzz
fz, bz = ["","","Fizz"]*34, ["","","","","Buzz"]*20
print('\n'.join(fz[n]+bz[n] or str(n+1) for n in range(100)))

>Brown haired girl wears pantyhose
No wonder the black haired one loses.

Damn those are cute. I wanna wear them & I wanna get a handjob from someone wearing them.
I wear these, they're enough for me considering I heat up like a furnace. Also badass hacker style. seriously though, really good design & quality.

Completely wild guess, but maybe this line?
Duel.IsPlayerCanSpecialSummonCount(tp,2)

beginner java pajeet here, when exactly should a class be a singleton?
if i have a class that only gets instantiated once, should it be a singleton class?

>being cold in winter
Do you have unisolated walls or something?

those seem to breathe considerably worse though. and they're not cute. But I appreciate that at least other people consider this aspect of optimizing the experience of typing.

>Nested conditionals
0/10

Write only 0/10


for i := range(1...100) {
fmt.Printf("%d\r", i)
if !(i%3) { fmt.Print("Fizz") }
if !(i%5) { fmt.Print("Buzz") }
fmt.Printf("\n")
}

>work in a big office with other people
>the gruff IT guys and business workers like it cold
>frail lithe programming body can't hold the temperature as well
Also it's better for the environment not to go too crazy on the heater, and you'll save yourself some money too.

Some features are very nice to have, like array variables.

>the gruff IT guys and business workers like it cold
>frail lithe programming body can't hold the temperature as well
Do you have fun with them after work hours? :^)

Changing that alone is a no-go, changing any other values to 3 won't work as well. It feels like new lines must be added for a third filter before the card can activate. Tried copy+pasting a filter and replacing its 2's with 3's but to no avail either. Unless there's something obvious that needs to be in there...

Wear a sweater. Youre like the women in my office that make us keep it at fucking 7i degrees and i cant focus because im sweating

again, these improve circulation, they are superior to sweaters, and much lighter to carry around, they are crazy superior.

>breathe worse
The back of the hand is all mesh, & I've never felt any discomfort in the palms. Added bonus: no more greasy/slippery gamepads.

Bad circulation in extremities.

and how am I like the women at your workplace? Clearly I have resolved the issue without worsening the experience of my coworkers. pay attention
yeah that's another thing, these improve circulation, not sure how much a normal glove does that? since it's just the hand.

>since it's just the hand
They help a lot, I only wear long sleeves when it's cold anyway. Again I'm a pretty hot guy so.

I still can't really imagine them having as good a range of comfortable temperatures, but if they work for you who am I to judge

please explain monads for a brainlet

Sure...well, have you ever had a burrito?

No. Just instantiate it once. Singleton is a fucking piece of shit meme. REEEEEEEE
Also GTFO of Java. It [by proxy of learning resources] only teaches bad practices.

youtu.be/ehyHyAIa5so?t=1366
I'm not sure I buy this.

Similarly thigh highs will actually keep your legs from falling a sleep from long sit down programming sessions. The more you think about it the more the memes make sense.

#include
#include
#include
#include
#include

void Ward::load(istream& ins)
{
ins>>data[used];
used++;
while(ins>>data[used])
{
cout> income;
}

istream& operator >>(std::istream& ins, Household& h)
{
h.input(ins);
return ins;
}

void Ward::display(std::ostream& cout)
{
for(size_t i = 0; i

So I found out smalltalk is considered by many to be a fun language. Why exactly? The IDE looks nice, admittingly. But don't most languages have decent to good IDEs nowadays?

>tfw the mental image of a bunch of IT bears in an office of twink programmers arouses me
>"IT-senpai, it's so cold, can you turn up the heat"
>"Nonsense, it's so warm in here I think I'll take my shirt off."

I need to get out of the house more.

go on

They're just monoids in the category of burrito functors.

Trying to find the smallest PRNG that can beat Smallcrush.

I now officially hate any language where everything is a dictionary. Smalltalk started it all and is the main language to blame. Python took it another step too far.

It kills any pretense of type safety or structure, encourages terrible hacky solutions to problems that could just as easily be done in a structured way in a sane language, and makes the language god-awfully slow.

Dynamic typing can be a valid way to get around undecideable type systems by handling type checking lazily at runtime, but encoding properties of a type into strings that can be arbitrarily changed at runtime is not a sane way to design a language.

Lisp family languages tend to be dynamic in a somewhat more sane and structured way. At the very least they have a symbol type that is distinct from strings. They tend to have either very structured OOP systems or they'll have proper multimethods, both are good, though I have a preference for the latter. Python and Smalltalk-inspired languages are pure anarchy, and people that have used the languages for too long turn into brainlets that know nothing about type theory, except that "your language should have metaclasses".

I'm a fan of PCG
pcg-random.org/statistical-tests.html

I'm absolutely stumped right now and I asked in SQT but I'm losing my mind trying to figure this out.

"Return
the result 1+2+4+8+16+32+..." So in other words, if 4 is entered then it should output 7. I made a program that successfully does this, but I do not understand WHY it works. Apparently I don't understand recursion.

public static int thing(int x)
{
if (x

Try opening it in a debugger and step through it.

could you post more of the ward and household classes in a past bin or something

>I made a program that successfully does this
>I do not understand WHY it works
It doesn't work. Your program computes 2x-1.

thing(4)
thing((4 * 0) + (4 + (4 - 2)))
thing(6)

learn what integer division does senapi

Thanks for the explanation, what code would work for this then, if you guys don't mind answering?

>do my homework for me
no

This isn't my homework, I'm doing an exercise trying to understand recursion. If you don't want to help me understand it, that's fine though, but you're wrong.

you have the

> public static int thing(int x)
{
if (x

user, I asked about smalltakThe language is considered "powerful" like LISP, but I'm not sure where it gets this description from. What's great about smalltalk?

actually, what is it suppose to return if a number that is either odd or negative is given

The code you posted is an infinite loop for any value greater than 1. If you get people to spoonfeed you, you will be stupid forever.

Honest to god, I've been trying to figure this out for hours and I just cannot figure this out. if you can answer this for me it will make recursion click for me and I will be thankful.

I'm just trying to understand it. I have understood other examples of recursion, but I do not understand this one at all. This is telling me that I don't actually know recursion, and if someone is willing to help me out here I will be able to understand it.

> public static int thing(int x)
{
if (x

There is a great irony in somebody wishing to write instructions incapable of articulating the problem they wish to solve. So far you have posted a vague description of a problem you wish to solve, and code that is fundamentally broken. Then you have whined about this for half a dozen posts. Consider a different path, or learn to act as through you want to be a professional logician.

Sure.

pastebin.com/iULh7KiP

I don't know what you're on about. Its a sequence. 1+2+4+8+16+32... and so on. If i enter 4 it should output 1 + 2 + 4. If I enter 8, it should output 8+4+2+1. I'm trying to write a method that accomplished this using recursion.

Instead of picking on people trying to learn, maybe you should get off your high horse and go fuck yourself faggot.