/dpt/ - Daily Programming Thread

old thread: What's your favorite programming beverage?
I just made a latte with instant coffee and frothed whole milk.

Other urls found in this thread:

tour.dlang.org/
wiki.dlang.org/Books
dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes
puzzling.stackexchange.com/questions/52415/martin-gardners-the-twiddled-bolts
en.wikipedia.org/wiki/Long_short-term_memory
gist.github.com/anonymous/b9b1a4699bfc1039bd067fca78d7a6a5
gizmosnack.blogspot.com/2013/04/tutorial-nrf24l01-and-avr.html)
twitter.com/SFWRedditGifs

What is it about C that that scares stupid webdev kids?

why does go come with a http server? i seriously don't know why programming languages would come with libraries that make it easy to host http servers

Anyone here use a standing desk?
If so, would you say you're more/equally/less productive/effective with it than a normal desk?

How many shots?

like 3, probably

Go having an http server is probably it's only redeeming feature, it's managed to carve out a niche being an ideal language for server backend programming.

Programming is a terrible profession. For one, you are not respected at any normal company. You're known as 'IT' or 'tech' and everyone gossips about how disgusting everyone is in the department. Every day, some Alpha who probably does nothing at his job except get his secretary to suck his dick in his corner office cucks you into doing random bitch work, and then yells at you when it's not done by the deadline despite it being impossible to complete the work requested. Not only that, the code rarely works, your co-workers are smelly Indians brought in by Tata Consultancy and connive to replace your job at all times for half the salary, and the work never, ever ends. You pollute your body with sugar and toxins, deprive it of sleep, and let it rot while you sit the majority of the day, neglecting any healthy exercise, social interaction or life goal attainment. It's like a Postal worker, but coupled with feelings of patheticness, loneliness, helplessness, rage and total hopelessness.

Women, when they hear you are a programmer, instantly remove you from the potential pool of mates as they know your earning potential is maxed early and your career over at 35. They are also instantly disgusted by you. It is far better to tell a woman you are on welfare than to out yourself as a computer programmer. It's also highly embarrassing for a woman to date or be married to a programmer, as virtually everyone knows they are the grown up version of the hopeless virgin in high school. One who never really grew up and became normal and fit into society, but rather found an environment where he could escape the reality of his situation and be invisible, able to hide the toxic shame and utter humiliation that is the programmer.

After Dentists, programmers have the highest rates of mental disorders, especially depression and suicide.

Programmers, why haven't you taken the cyanide pill?

t. can code fizzbuzz

>"latte"
>instant

Threadly reminder that dlang-chan has RAII; she's quite fast in execution and compilation; and she's super duper cute! Say something nice about her, /dpt/!
>ywn never be recognized by andrei for the advocating of dlang-chan on an anonymous imageboard

>Tour
tour.dlang.org/
>Books
wiki.dlang.org/Books
>GC
dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
wiki.dlang.org/Libraries_and_Frameworks#Alternative_standard_libraries_.2F_runtimes

Why is she so cute, anons?

I'm learning C# and was wondering if y'all could review one of my exercise solutions. It's from the book C# Player's Guide. The challenge is attached.

Here's my solution:

using System;


namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for(int row = 0; row < 5; row++)
{
for(int spaceColumn = 5; spaceColumn > row; spaceColumn--)
{
Console.Write(' ');
}

for(int starColumn = 0; starColumn < row + 1 + row; starColumn++)
{
Console.Write('*');
}

Console.WriteLine();
}

Console.ReadLine();
}
}
}

Thanks for any help.

Previous Dlang-chan was cuter.

Why did you like her so much, user? Was it her cuteness derived from her genki tomboy plainness? Was it her happy expression as she waves in people to try out her wonderful features?

First she wasn't stupid enough to wear high socks with sportswear.
She gave an impression of candid cheerfulness you do not notice in the current Dlang-chan. I really wanted to cuddle with her.

While your first point is kinda stupid, I agree with the rest. I'll consult with the other gentleman that are part of the deciding D's waifu mascot.

puzzling.stackexchange.com/questions/52415/martin-gardners-the-twiddled-bolts
>when i'm next using a screwdriver, i'll remember the 'righty tighty lefty loosy' rule - it should save me some time!

are these people fucking retarded? i'm probably a genius but even a normal person would know how to turn a screw surely

>I'll consult with the other gentleman that are part of the deciding D's waifu mascot.
Good. This is one of my sticking points with the language. I can't endorse this as it is now.

>your first point is kinda stupid
If you actually used programming socks you'd know how unsuitable these things are for swift movements

this

i would expect knee high socks at most

You just need a garter belt. She's probably using the kind that only connects with the center of the socks. It's really hard to notice.
You sure don't sound like you're using programming socks. What kind of engineer doesn't find solutions to be able to program on the go?

Its not even hard

2D != 3D

pic related

I've seen this pasta on Sup Forums recently.

>Programming is a terrible profession. For one, you are not respected at any normal company.
>You're known as 'IT' or 'tech'
Stopped reading. What a terrible pasta.

>latte
>frothed milk
>instant
are you trying to trigger my autism user?

Anyways, I usually program at night so usually a beer.

i prefer this one

programming is an incredibly degrading job that offers 0 job security and is the vocation most plagued by ageism by a far margin. You are not respected at any normal company. Every day, some Alpha who probably does nothing at his job except get his secretary to suck his dick in his corner office cucks you into doing random bitch work, and then yells at you when it's not done by the deadline despite it being impossible to complete the work requested. Not only that, the code rarely works, your co-workers are Indians brought in by Tata Consultancy who will replace you for half the salary and you have to train them to get your $500 severance, and the work never, ever ends. You pollute your body with the caffeinenated jew, deprive it of sleep, and let it rot while you sit the majority of the day, neglecting any healthy exercise, social interaction or life game goal attainment.

It's like a postal worker, but coupled with feelings of loneliness, helplessness and total hopelessness. Programmers are too depressed to go postal, a sad state of affairs. After dentists, programmers have the highest rates of mental disorders, especially depression, transgenderism and suicide.

It gets worse. Women, when they hear you are a programmer, instantly reject you. It is far better to tell a woman you are on welfare than to out yourself as a programmer. It's highly embarrassing for a woman to associate with a programmer, as everyone knows they are the grown up version of the hopeless virgin in high school. One who never really grew up and became normal and fit into society, but rather found an environment where he could escape the reality of his situation and be invisible, able to hide the toxic shame and utter humiliation that is the programmer.

Programming's father, Alan Turing, 404'd himself with cyanide because he was a programmer. Brogrammers, why haven't you taken the cyanide pill and quit jewgramming and turned to a respectable profession?

Turing killed himself because he was pumped full of girl hormones after he was caught sucking dicks.

>he was pumped full of girl hormones
No. Bet those chavs didn't even know what a hormone was frankly.

>tfw programming as a hobby; engineer by career
>self taught, etc
>mainly use C and C# but also fluent in few other langs

Half the CS memers i've met were autistic and couldnt handle their major. All they really have to learn is java, python, and at most how to write a fizzbuzz in C.

Producing Windows-only software is immoral.

>mfw c++ needs examples of how to use the standard library functions, because the function definitions are horrendous

Which of the three standard library is it?

redpill me on generic programming

>What's your favorite programming beverage?

If I wanted to write my own game engine from scratch in c++ on linux, then wanted a friend to help me who uses windows would that be a mah majoror hurdle?

Major*

No, use SDL/SFML/etc with a proper build system and be platform-agnostic

Instead of doing a for loop for spaces, you can just do

Console.Write("".PadLeft(5 - row, ' '));

You can abuse templates and/or C preprocessor macros to insert huge amounts of type agnostic code into your translation units and bloat up the size of your binaries by a considerable amount in any non-trivial software project.

Ex:

using System;

class Program
{
static void Main()
{
for (int i = 0; i < 5; i++) {
Console.Write("".PadLeft(5 - i, ' '));
for (int j = 0; j < (i * 2) + 1; j++) Console.Write("*");
Console.WriteLine();
}
}
}

>tfw run out of ideas and no drive to improve existing projects because they work good enough.

sims-like game i'm making.

>Teaching myself about neural networks
>Try to make a simple neural network to approximate the sine function
>Fails horribly
>Find out I wasn't normalizing my data with respect to my activation function, do that
>Still fails horribly
>Read more theory, find out how to prevent overfitting
>Specifically do the opposite
>Sometimes demonstrates somewhat nonlinear or even seemingly periodic behavior
>Still wildly inaccurate
>Try it again using an implementation from the book I'm reading
>Same shit
>That very same implementation scores about 95% on a validation set of handwritten digits from MNIST

What the FUCK am I doing wrong

i am a dipshit

few things in life are more infuriating than an unresponsive user interface

>ne0ndrag0nGolden.Apples.Trans.Horses
Dare I ask?

Can some loop wizards help me out here?

For i = 1 To 2
For j = 1 To 10
For k = 1 To 10
If k = j Then
'Incorrect
Else
'Correct
End If
Next
Next
Next


I have 10 objects. Each object can be in 3 states, 1, 2, or 3. Let's look at one of the combinations like 1111111111. For that one combination, I am trying to loop through all the ways one can get 8 out of 10 guesses correct for it. The loop above does this for 9 out of 10, but I can't figure out how to make it work for 8 out of 10.

evidently i don't know how to use secure tripcodes

what kind of neural network is it? if it's not an LSTM, there's your problem. it has no memory.

en.wikipedia.org/wiki/Long_short-term_memory

because the C family is intolerant of failure. compare to higher level languages where you can cock up a monster entirely consisting of copy/pasted stack overflow answers given by java evangelicals

C++ eternally btfo

I hope you changed your tripcode

C is surprisingly lenient on what it will accept as valid code, much more than most languages.

Even below-average people who have used a screwdriver more than once know how to turn a screw. What the fuck. Also who's that stupid rule meant for? It sounds like a kindergarten rhyme.

try the old one and see

Testing~

undefined behaviour is a bitch

see

So, you're a new trip user, where do you fit into the /dpt/ family? We've got already got mummy (OSGTP), daddy (Ruby) (female), and doggo (nv).

I like it.

pic: proof i'm the dev behind the sims-like game

the fuck's a /dpt/

thankies

Another solution in one line (you can use new String(char, numberOfTimes) to make a string of a repeating character)

using System;

class Program
{
static void Main()
{
for (int i = 0; i < 5; i++) Console.WriteLine("".PadLeft(5 - i, ' ') + (new String('*', i + i + 1)));
}
}

reads thread title

i'm too fucking tired

/dpt/ is this thread

counting the number of times an element appears in a list
countElements :: Ord a => [a] -> [(a, Int)]
countElements s
= sortBy (flip (comparing snd))
$ Map.toList
$ foldr count Map.empty s

count :: (Ord a) => a -> Map.Map a Int -> Map.Map a Int
count c curCount = Map.alter update c curCount
where update Nothing = Just 1
update (Just a) = Just (a + 1)
example
> countElements "help i need somebody help not just anybody"
[(' ',7),('e',5),('o',4),('d',3),('n',3),('y',3),('b',2),('h',2),('l',2),('p',2),('s',2),('t',2),('a',1),('i',1),('j',1),('m',1),('u',1)]
p> countElements (words "help i need somebody help not just anybody")
[("help",2),("anybody",1),("i",1),("just",1),("need",1),("not",1),("somebody",1)]
probably not optimal but I'm still learning.

i'm a c++ dev by night and js dev by day. webdev is easy but boring. also some of the shit i wrote for the game is pretty appalling and needs to be refactored

>if it's not an LSTM, there's your problem.

Does that apply to the XOR function as well? because I'm having trouble with that as well. I'll look into this, my network is an MLP

I don't care what languages you use, I care about which member of the family you are

fat unloved stepsister

>c++ dev by night and js dev by day

At some of the good big tech companies the programmers are treated better than others, sort of like first class citizens.

At any rate, in this job market, as a competent developer you can't be treated worse unless you're shit at finding jobs or a shit programmer.

It's usually not that hard to find an easygoing CS job.

Sup Forums, someone just posted this shit on Sup Forums. I have no experience with programing and none of this shit makes sense. What am I looking at here?

gist.github.com/anonymous/b9b1a4699bfc1039bd067fca78d7a6a5

オナニー

Rate this
import std.conv;
import std.stdio;
import std.range;

void main(string[] args)
{
immutable max = (1 < args.length)
? args[1].to!size_t
: 0x4000;
size_t count = 1; // we have 2.
// flags[i] = isPrime(2 * i + 3)
auto flags = new bool[(max - 1) / 2];
flags[] = true;

foreach (i; 0..flags.length)
{
if (!flags[i])
continue;
auto prime = i + i + 3;
foreach (k; iota(i + prime, flags.length, prime))
flags[k] = false;

count++;
}
writefln("%d primes", count);
}

>tfw autistic as a birth condition; CS memer by major
>self taught, etc
>mainly use C and Ruby but also fluent in few other langs

Half the me I've met is autistic and can't handle my major. All I really have to learn is everything.

Guys how do I do the thing. I refuse to settle for being a lousy piece of shit just because I was born autistic. I am COMPELLED to do something with my life and this is what I've chosen. But I might be too autistic to do it. What do I do.

this is a bit better
countElements :: Ord a => [a] -> [(a, Int)]
countElements s
= sortBy (flip (comparing snd))
$ Map.toList
$ foldr (Map.alter (Just . maybe 1 (1 +))) Map.empty s

>import std.stdio;
Absolute garbage. I'm not even going to bother reading the rest of that.

You did bother enough to reply

>std.stdio
Literally why.
Why not just std.io.
Fuck, D-chan's designers have problems.

You can have your own uLib instead of std
So you can go uLib.module etc

Wow.
That seems only rather distantly connected to what I just said.

what os do you use kirie-poster

You can also have your own std.eio

Can anyone here into AVRs? I'm trying to get sven's nrf24l01+ blogpost working
(gizmosnack.blogspot.com/2013/04/tutorial-nrf24l01-and-avr.html)

With auto acks, the transmitter always sends till MAX_RT is set. The receiver interrupt never fires. I put caps across vcc and ground since that looked like a common problem. Also they're right next to each other.

To clarify, what I'm asking is, if stdio is already in std, why did they have to call it stdio. The std is implied by the fact that it's in std. They could've just called it io. And then, as you say, if someone wanted a different io, they could just do uLib.io instead of std.io. On the other hand, uLib.stdio wouldn't make any sense, because then stdio wouldn't be in std, making the term "stdio" a misnomer.

prime could be made immutable.
you should also use std.concurrency

its just a filter to block a potential malware domain

What if there is a new uIO in the std in future?

Then that problem is the responsibility of whoever put it there. You shouldn't be putting things in std unless you're a developer of the language itself, and if you are, you should know it well enough not to create naming conflicts like that.

Does anyone here like Lisps?

Theres a DIP in review right now for a @future in relation to its counter @deprecation

d has some wonky shit.
Another example is this gem for win32 stuff
import core.sys.windows.windows;

>import core.sys.windows.windows;
Ree.

Is it even possible to write a program people will use without relying on pure luck? I swear I've come up with original ideas, only to find they're already actively developed. It's like mathematics: even if you come to a realization all by yourself, someone has already written the proof for it 5 hundred years ago.

For the most part though, its std is pretty straight forward . But re-doing some module names is pretty low priority.

Anyone?

>His language still doesn't have CTFE
>His language still doesn't have modules

>tfw using the proper c++
Im glad i finally escaped the sepples hell

of course it is, you don't even need to do it better, just offer a decent alternative to w/e

Yes, it's possible by studying your ass off. What you're talking about -- coming up with something that really is original, and really is the first ever mature, developed idea proposed to solve some previously unsolved problem, no matter how small -- is hard these days, as you allude. In fact, it's so hard that it's the whole idea behind the title of PhD.

you dont need a lstm to approximate a sine function you fuck

>I'll look into this, my network is an MLP
Fucking bronies. I thought they'd all gone extinct. Go clop somewhere else ponyfag