/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

adamtornhill.com/articles/fizzbuzz.htm
github.com/Microsoft/MIEngine)
css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
github.com/Microsoft/MIEngine
twitter.com/SFWRedditGifs

The true fizzbuzz of the christ: adamtornhill.com/articles/fizzbuzz.htm

beautiful

first for idris

>not first
doesn't typecheck

Java is the best programming language!

Working on my thesis. Gonna conduct a generic correspondence analysis in R and compare to the results of a Javascript implementation I made out of scrap metal. then again it's friday night so I probably won't

In C++11, how should I compare weak pointers against shared pointers?

Looking to start a new project but I first need to set up a directory structure and git repo and configure a VS project and write makefiles and craft bat files to make VS call gcc and hnnnnggg I dont want to do all that.

weak.lock() == shared;

>tfw too much of a brainlet to do programming

Doesn't that use a mutex? That would create a nasty performance hit for my application.

I don't think it does, just casts weak_ptr to a shared_ptr.

Alright, thanks

>make VS call gcc
why?
also cmake is an option for creating Makefiles for multiple platforms or making a VS solution and then you can do cmake --build it

here's an example for building with VS
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G"Visual Studio 14 2015 Win64" ..
cmake --build . --config Debug
and an example which should probably work for mingw stuff
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build . -- -j5

I'm building my own dynamic array kind of thing and I'm building it in a way that every array element has a pointer to the following element. Does anyone know if this has a specific name?

a linked list?

kek

rinku risuto

Thank you.

Yeah I meant bat files to call make within bash (in msys2)
Can't use cmake since it''ll be a dos program, last time I checked cmake had no clue about djgpp. I'm sure there's some way to make it work, but it's unnecessary since I'm only developing for a single platform.

>dos program
why

it's fun, and I need direct hardware access.

Win32 is your friend.

black women are your friend

I wish. I'm too autistic.

holy shit no. seeing that api makes me puke every time. I'm depressed already, I don't need none of that LPCTSTR shit in my life.

Win32 is not my friend, pal

how so?

>tfw too
You had one job.

Come on, let's be real.

btw somewhat related,
How do I set up remote debugging through gdb in visual studio?
The client side doesn't seem too difficult (hooking all cpu fault exceptions and sending the right gdb commands over tcp/serial when they occur) but I have no clue how to set up gdb and VS on the server side.
Apparently VS has this stuff built in (github.com/Microsoft/MIEngine) but nothing explains how to actually use that shit.

don't make command line programs in 2017

Where's the picture of Varg?

Add add = new Add();
int num1 = 1;
int num2 = 2;

int sum = add.add(num1,num2);
System.Out.Println(sum);

public class Add
{

int add(int num, int num1)
{
return num + num1;
}
}

dont make gui programs ever

>OOP
never again

isn't it so beautiful? Look at how structured and Well defined that is

Now imagine we have 1000 objects and how easy that would be to manage using the OOP method of separating all the logic and code

you need to redo it

>// comment
>int m_intX, m_intY;

>setX, getX, Y

>int add()

>Make command line programs in 2017!

ftfy

way to lazy to type all the proper OOP to do all that

you'll never make it in india if you don't squeeze hard enough

I live in America tho

>not using static
>hurr my functions get namespaced i cant handle this
???

at least you can dream pajeet
at least you can dream

you're either writing an api or you're writing a program for other people to use. non programmers, 99.99% of the human population, must have a gui.

there's no excuse for not having a gui in 2017. it's easy as fuck to do.

You guys were really helpful yesterday so i've returned again. I'm a beginner at python, but i've randomly gotten the inspiration to try and make a program that will give you the sum of a series.

I wrote it all out on paper and basically i want to take 3 inputs from the user, "First number in series" "Last number in series", and the formula.

So far i've got the input easily enough, but what's got me lost is the formula. For example, if the user inputs "K+3", I would need to tell Python to replace K with the first and last number in the sequence and then get the sum.

If anyone could help me out that'd be great. Preferably just tell me what command i need to read about without giving me too much of the solution.

Then again, it's so I probably won't

well either you build a parser for math expressions (nice exercise) or you have the user enter valid python code for the formula and then eval it

Look at the shunting-yard algorithm.

>What are you working on, Sup Forums?
Go+C thumbnailing library. Just finished MIME type detection and now need to fix 2 edge cases with OGG and MP4.

About to learn rust...

How much of a bad time am I in for?

You'll spend a day learing the borrowing rules.

Yeah, the random nesting threw me sidewards when I first saw it.

>you're either writing an api
yeah. you realize libraries make up a huge portion of software right?

and there are plenty of programs for which there would be no point to a gui. it would be retarded if grep was a 17mb binary and depended on gtk

>there's no excuse for not having a gui in 2017. it's easy as fuck to do.
There is. The only "sane" solution is GTK. And GTK is made by code monkeys.

the language is great but you're in for a terrible time

Which book should I read, Sup Forums?

1) K&R ANSI C
2) H. and P. Deitel - C How to program

Both are good, however:
First one is true classics, but it stand for an outdated standard (even though it perfectly compiles, the book would not provide the knowledge of how modern code is usaully written).
The second one is has a lot of side information, which is not useful at all, and looks overwritten, but provides modern standard.

So? Either two of these.

>studying CS
>haven't written a single line of code in 8 months

Fucking kill me.

there is no reason not to include a cli to your app in order to allow automated use

gui only applications are attractive but will eventually be pushed aside and become obsolete once gui styles changes

CS?

You can have gui application with full API. Like emacs.

Gombooder Seiens :DDD

gui only apps have a 5 year timer before they become obsolete. the core code, ideally, should be completely separate from presentation code

the number of abandonware that is now useless because the makers never thought to expose an api or cli is absurd

>When people think this is a fine API

type Stream struct {
Messages chan interface{}
// contains filtered or unexported fields
}

>the number of abandonware that is now useless because the makers never thought to expose an api or cli is absurd
Yes. We call that Windows.

heh

Enjoy you're non-portable bloatware

people are non-portable bloatware now?

>guibabbies
>people

o fog how dis write u code?

CHALLENGE: average two long ints in C

You should be smart enough to solve this.

>the number of abandonware that is now useless because the makers never thought to expose an api or cli is absurd

It's not 'useless', just hard to use.

How is that a challenge?

When they think they know how to program.

a+b
?

int average(long a, long b) {
if (a == 0 && b == 0) return 0;
if (a == 1 && b == 1) return 1;
if (a == 2 && b == 2) return 2;
if (a == 3 && b == 3) return 3;
if (a == 1 && b == 3) return 2;
exit();
}

int average (const int x, const int y)
{
if ((x < 0) ^ (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}

Can you do it?

average(1,1) == 0
nice

correct

What's it doing, /dpt? It's been internally operating for 2 minutes now.
I'm scared!

>correct
long

>rust
It's hard, you'll hate the borrow checker, once you grok it you will respect it a bit more. Hopefully NLL will come in soon.

what a gay webm

It's used in interviews to weed out people who can't actually program, such as this:
css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/

It's operating.

Internally.

Sending your code to Microsoft and the NSA so they can find exploitable vulnerabilities in advance

you can't average integers

N-Nandato

in C

Computer science can be studied without writing code, desu

return (a >> 1) + (b >> 1) + (a & b & 1);

...

>When people complain about no longer being able to do bible searches and you look but it's just bibles.org being down
Unreliable APIs are somewhat annoying.

a/2+b/2+(a%2||b%2)

You fucked up again. avg(1,0) should not be 0.

Oh, that's neat.

Usually I have to pay for something like that.

bump
>>>github.com/Microsoft/MIEngine
how do I use this mess?

Why not? Averaging up rarely ever makes sense for integer coordinate systems or binary searches or just about anything that would actually average. But if you want to average up, just replace a & b with (a ^ b).

>int average(int, int)
wrong

er |