/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1510519669027.png (1280x720, 557K)

Other urls found in this thread:

godbolt.org/z/3dSCE-
chromium.org/developers/version-numbers
twitter.com/NSFWRedditVideo

dumb hamster poster

godbolt.org/z/3dSCE-
who is in the wrong?

>msvc
although if clang can't compile it then it's garbage

the gnome

ending my painful existence

clang cant compile it either

Nth for Nim!
const H = 5

proc rep(ch: char, n: int) =
for i in 1..n:
stdout.write(ch)

for i in 1..H:
rep(' ', H-i); rep('*', 2*i); rep('\n', 1)

Are references just pointers for brainlets?

no

How to spot a bad programmer/LARPer

>using list comprehensions in a functional language to do the same thing as map or reduce
>uses "loops" for everything
>writes all their "FP" code like it's in fucking python, no pattern matching or overloading functions, just if statements and "loops"

HONK HONK

what language

Inlining does NOT makes your executable smaller you absolute shitter.

I want to get a job in graphics programming.
What languages should I absolutely know?
What APIs should I absolutely know?
Currently I can only come up with C/C++, Lua, and Javascript for languages, and Vulkan, OpenGL, and WebGL for APIs.

It does if the function you're calling is only used once, which is a common occurrence when using templates.

>You've just been upgraded to uTorrent version 3.5.5.1.45146
>version 3.5.5.1.45146
fucking why

Oh yeah?
No inlining: 311.1kb
Inlining: 295kb

Lets check another project for good measure
No inlining: 108.8kb
Inlining: 104.7kb

This is with LTO btw. While it doesn't decrease it by much, it certainly doesn't increase it, and you eliminate a lot of call overhead and collapse of a lot of abstractions.

It's probably similar to this.
chromium.org/developers/version-numbers

>9 digit versions
nice

they could also add the time and date to the version to make it even longer
why don't they just take the MD5 hash as a version number directly

Git commit as the version number or fuck off

>trivial project
I am sorry for not assuming your retarded the first time.

My retarded what?

got em

MajorVer.MinorVer.Build&Patch

you just can't name a better versioning scheme.

GitCommitHash

Well that was easy

SemVer

This post smells of crustaceans

Joke is on you. I use Rust, Nim, D, Haskell, and Zig so my lib versions will never reach 1.0

Im starting to study terraform and also circuit breaking in ruby

Attached: square_root.jpg (542x480, 41K)

People that doesn't follow TDD (or even try) should burn in hell and program in C the rest of their miserable lifes

Attached: 52948762_2520252054669344_8880475901075128320_n.jpg (540x516, 39K)

majorver.minorver[alpha/beta/release a/b/r]

nobody will agree on when to move from alpha to beta and now you can't keep track of minor changes/patches

and with your no one will know what version is safe to use
with you just know release is battle tested, beta is in the test phase and alpha is very fresh and may contain harsh bugs

>no one will know what version is safe to use
the latest patch of every major.minor
versioning is for released libs/programs. If you want to provide previews, name it preview/dev/nightly that are based off major.minor with different builds-patches for changes that may or may not make it to release.

TDD is only useful for writing throw-away code for some throw-away project. Large projects require careful planning and designing before writing the code.

I want to get gud at working out a design and algorithms on paper before I start coding. I'm convinced this is a good habit to get into.

Any books/articles about this? I realize what pseudocode is but I'm interested in something a little more... formalized? I don't know if that's a word. I just want some good wisdom regarding design.

A full book would be great, or just whatever you have to say about it.

Attached: composer with quill.jpg (914x1024, 398K)

in C
how do I make one pointer point to what ever another pointer is pointing to?
For example A and B are two pointers, pointing to nodes in a linked list
will B = A make the values they point to copy over each other
or will it make B point to the value A is pointing to?

Learn graph theory, that's probably the most useful branch of math and the closest you can get to algorithm formalization, since no such system exists and it will probably be proven one day that such a system can't even exist in theory. There's also lambda calculus, but you're not a nerd are you.

use pointers to pointers

>I'm convinced this is a good habit to get into.
It's not
First you do it in your head and then you write it on the computer
Why introduce an uneccessary third step because you want to look smart

The pointer is storing an address in memory of some data (what it is "pointing" to). Doing B=A sets B equal to the address stored in A. So yes, it will make B point to the value A is pointing to.

int i;
int* ptr = &i;
int** ptr2Ptr = &ptr;

>There's also lambda calculus, but you're not a nerd are you.

Definitely not a math nerd. Though I think I could become one if I put in the effort. I just haven't yet.

what are some application of network flows

How do I make this better?

if (y1 > y2)
earlier = 2;
if (y2 > y1)
earlier = 1;
if (y1 == y2) {
if (m1 > m2)
earlier = 2;
if (m2 > m1)
earlier = 1;
if (m1 == m2) {
if (d1 > d2)
earlier = 2;
if (d2 > d1)
earlier = 1;
if (d1 == d2)
earlier = 0;
}
}


Since I'm learning C I figure I ought to learn to be efficient while I'm at it. It just seems like I'm evaluating those expressions too many times.

In c++ lets say I have 2 clases A and B with member functions A.f1() and B.f2() that are used in the other class:
So A calls B.f2() in some function A.f3() and B calls A.f1() in B.f4()
How do I need to declare shit so that it works

give me the full signatures

check out recursion (recursive functions)

Why does Python need a dict() function when doing emptyDict ={} does the exact same thing? is it because of casting?

because pythonfags lied to you when they said there is only one way of doing a thing (the so-called non-existent pythonic way)

wihtout constructors and shit:
// A.h

class B;

class A
{
public:
void f3()
{
b->f2();
}
void f1() {...}

private:
B* b;
}


// B.h

class A;

class B
{
public:
void f4()
{
a->f1();
}
void f2() {...}

private:
A* a;
}

I have been studying recursion. Thanks for the tip, I'll think about how I can do this recursively.

just put them both in one header
forward declare the classes, fully declare the classes with declared member functions, then finally define the member functions outside of the classes

Thanks

Attached: 1495343886502.jpg (1375x645, 83K)

retard

card-dealing algorithm in sudo-code:

create a deck of 52 cards
let the user input the number of cards they want in their hand
make sure the number of cards wanted in hand doesn't exceed the number of cards in the deck
get a random card from the deck, put it in the user's hand and delete it from the deck
repeat until the user's hand is full
if the user's hand total value is a multiple of 15, return fizzbuzz

that's about it, right?

Attached: 3.jpg (655x527, 36K)

This or just shuffle the deck and deal the first n hands (the number the user wants)

Today I'm finishing the backend of my truck geotracking app. Can't wait to set the server up, plug the arduino into my car and get some test position data

TDD is actually intended for long-term, massive, code bases. take for example a compiler like gcc, with TDD, you aren't afraid to work on the code base because as soon as you mess something up, you will know it.

Absolutely correct. See also: web browsers, databases, etc.

redundant parens are as awful as compiling a C project using g++

There are no redundant parens in Lisp.

do I have to make my own shuffling algorith or most languages provide some function or method to achieve that?

Writing tests is not the same as tdd.

TDD enforces unit testing.

Just do a normal fisher-yates shuffle, it's 5 lines of code and pretty simple to understand.

please don't refer to TDD an anything but Type Driven Development, I.E, first class types.
Test driven development is such a stupid phrase

Are php and mysql cancer to work with? If yes how cancer? I might get a junior developer position. Is it worth it

Anyone who doesn’t TDD is a fucking moron. Enjoy spending the majority of your time testing. When my code is finished it’s already tested.

>Anyone who doesn’t TDD is a fucking moron. Enjoy spending the majority of your time testing
thats what you're doing though

i adopted TDD after listening to Uncle Bob, it turned me into a 10x programmer.

Attached: oww.webm (960x540, 1.06M)

>Uncle Bob
You turned into a 10x loser.

why? Uncle Bob's trilogy is the best when it come to programming and software engineering. The guy is wisdom reincarnate.

Attached: wdsa.webm (960x540, 483K)

now my thirld world chess take into account the pieces HP.

:)

I feel like a god.

Attached: Captura de pantalla de 2019-05-01 11-09-03.png (1026x626, 104K)

TDD turns you into a 0.5x programmer because you're spending half your time writing pointless tests

what is this furry shit

a chess clone for an Jow Forums general.

>can't concentrate enough to do even the easiest meme #kode challenges

Attached: 1536767919974.png (500x522, 147K)

just generate a random number between 0 and 52 then put that card in your hand and remove it from the list if you're using python.

You literally don't even know what you're talking about.
Inlining collapses abstractions which allows further optimizations.

Uncle Bob is praised by idiots because he's one of them. He shares the same ideology as any other junior developer.

and?

Never watched his stuff, why doesn Jow Forums hate him? Also that user is probably baiting.

uncle bob has his own ideology based on TDD, SOLID, and extreme programming.

she is just a boomer that keeps talking about what happened and spouts nonsense about what could have been and what should be. all forms of OO are shit.

Found a gpg bug and wrote some patches to fix it. Nobody's reviewed it yet...

try to send a mail to Richard M. Stallman (PhD), the creator of the GNU project.

sasuga python

Attached: POO.png (382x71, 5K)

If your favorite programming language can't even run on winblows, it is unadulterated garbage.

Attached: 1556621670980.png (763x719, 534K)

t. (((coin man)))

Patchouli is FAT

if (y1 != y2) { earlier = y1 < y2; }
else if (m1 != m2) { earlier = m1 < m2; }
else if (d1 != d2) { earlier = d1 < d2; }

x = y || :default

|| returns y if y is not nil or false, :default otherwise. People have to study this?

or rather, return instead of setting a variable so you dont need to use else

Use brackets.
Use else if.
Use whitespace.
Use indentation correctly (first line should be indented I guess, copy/paste error).
Use a proper datetime library/type.
Alternatively, use math. Dates of the format yyyymmdd sort correctly by default.
For example 20010911 < 20190501 == true.
Favor transforming data to a structure that's easy to use, over writing complicated logic on badly formatted (for the purpose) data.

Your entire function is just
const diff = parseInt("" + y2 + m2 + d2) - parseInt("" + y1 + m1 + d1)
if (diff > 0) return 2
else if (diff < 0) return 1
else return 0


But it's normal-er for comparison functions to return 1, 0 or -1 depending on which is bigger.

she's 32

The maintainer is probably just busy. I'm just excited, it's my first contribution to free software. I can't wait to see what they'll say. When I first got my hands on the source code I couldn't make sense of it but I persevered until I could figure out a way to fix the problem. It's a small patch but I'm pretty proud of it

TDD, SOLID and extreme programming are a complete joke.

just compile to JavaScript and you are good everywhere.

what about ARM devices?