/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1484619016074.png (720x660, 390K)

Other urls found in this thread:

en.wikipedia.org/wiki/Mastermind_(board_game))
youtube.com/watch?v=IRTfhkiAqPw
twitter.com/SFWRedditGifs

Attached: 1547838318849.jpg (657x1279, 328K)

Meanwhile, 40+ years ago.
(< a b c)

[laughs in Haskell]

*ahem*

Attached: Screenshot_20190228-150843_Chrome.jpg (1050x828, 106K)

C syntax is garbage, it doesn't matter how you write it.

Attached: gg3.jpg (658x374, 46K)

>What are you working on, Jow Forums?
unsolved:

8 | |
3|6 |
7 | 9 |2
---+---+---
5 | 7|
| 45|7
|1 | 3
---+---+---
1| | 68
8|5 | 1
9 | |4

solved:

812|753|649
943|682|175
675|491|283
---+---+---
154|237|896
369|845|721
287|169|534
---+---+---
521|974|368
438|526|917
796|318|452

static char *
concat (char *s1, char *s2)
jesus this style is garbage

C is garbage, it doesn't matter how you write it.
FTFY

Instead of whitespace or curly bra keys, what about a scope determined by the pipe symbol?
int function()
| if (a)
| | return f
|
| return g

That seems like many extra characters to type

scope ... end is the best scope syntax

I wasn't talking about the C programming language, the syntax of all the languages based off it are also garbage.

Attached: 1493776957467.gif (500x321, 1.74M)

All of the disadvantages of using indentation, with none of the advantages.

*blocks your path*

Attached: 1545055579377.png (204x245, 6K)

Replace pipe with tabs and you've gotten python

In most cases the editor would insert it for you, like indentations. And in most cases it replaces ; at the end of the line

It had no indentation disadvantages, you can still write it in one line and actualy allows some very readable one liners
function () | if (a) || return g | return f


It's different.

yikes

Horstman? More like worstman

How good is it?
Can it solve harder sudokus that need you to do inference?

>It's different
how so?

>not foo(void) or bar(void)
pls go

There's literally an example in that post. Using tab combines scope with visual arrangement, using something else allows you freedom to arrange it how you like.

So what if you have something like this?
char* asd = "asdAasd";
int i;
const int n = strlen(asd)
for (i = 0; i < n && asd[i] != 'A'; i++);
if (i == n)
//do something
else
//...

Why?
It looks nice and saves space.

>clion
>sea lion
mindblow

Attached: clionsq.jpg (238x199, 7K)

>saves space.
you mean creates space

yes (the example posted is billed as the world's hardest sudoku).

although it doesn't really use inference like a human would, it's just a fancy depth-first search.

what does a < b < c even do in C?

Taking a break from working on my table widgets and drawing a new bitmap font in the style of mid- 90s Microsoft.

Attached: Screenshot at 2019-03-01 00-38-35.png (1920x1080, 945K)

(a < b) && (b < c)

NO im asking what does a < b < c
do? you wrote something else

Calcs a < b, which returns 0 or 1, then calcs 0 < c or 1 < c

wrong
it's either (a < b) < c or a < (b < c), probably the former. it compares the "boolean" result to the third argument, it's literally

int x = a < b
// x < c

what I meant to say is, a < b

is there a retarded usecase for this you have actually seen in code?

I posted in the last thread, < has left-to-right associativity, so it'd do (a < b) < c

i seriously doubt it

no
case a < b == 1
then compare 1 < c

case a < b == 0
then compare 0 < c

these are not the same as asking if a < b < c

In C? It's C. I'm sure there's someone who had to actualy compare the result of a comparison with something and did it. If a,b are numbers and c a bool then a

You're right, I was wrong, sorry, was mistaken. It's never actually came up in code but I thought it worked that way. Probably misread something. すみません。

Attached: 08.png (427x583, 189K)

So it's just bruteforce?
Looks like any other bitmap font

In your case, that's even wronger. In the original, A, B, and C is always evaluated, in your example, C being false shortcuts the A and B comparison.

If I have some large multi branch STL container like:
map[nigger[ass[actual std::vector i want to work with]]]]]
Should I just create a pointer to it instead of having to put that abomination a million times in my code?

Attached: 02f.jpg (655x527, 36K)

dumb frogposter

Please don't bully but inform me instead.

I normally just use a higher-level pointer, unless I'm misusing a pointer as an array.

Fuck off, stupid frogposter.
Your kind is not welcome here.

I deleted the fr*g. Can you help me now?!

No. You're a dumb sepplesfag too.

This is not the sort of behavior I want to see on my 4channel

If you place the function return type and the prototype on the same line, then you can't easily grep source code for a function by its prototype.

Does C# have something like function macros in C?
I want to make switch statement fallthrough:
#define fcase(x) (goto case x; case x:)

switch (k)
case 1:
// do something
fcase(2):
//...
break;
case 3:
//...
default:
//...

>using regex to parse C source code

You're fucking retarded

dumb fast question but how do i count() two separate and unrelated tables in one query? (postgres)

Misusing??
You know that i[a] is the same as a[i] right?

count the result of joining those 2 unrelated databases

Blew an entire day hunting down some bullshit edge case with hanging threads on an unfamiliar code base. I fucking hate multi-threading and aysnc so much. All I wanted to do was take it easy.

Attached: 1546572696811.png (376x341, 102K)

If you have a thicc function, do you use blank whitespace lines within the function to seperate different logical blocks of code? Is it good style?

like if you have a bunch of lines declaring variables, and then some other lines declaring some arrays and stream classes, and then some other lines looping through those stream classes, do you put whitespace in between those blocks?

>What are you working on, Jow Forums?
An implementation of Mastermind (en.wikipedia.org/wiki/Mastermind_(board_game)) for a school assignment.

Feels alright except I have to use sepples.

>If you have a thicc function, do you use blank whitespace lines within the function to seperate different logical blocks of code?
Yes.
>Is it good style?
I think so. There are probably people that aren't, but they can get fucked.
>
like if you have a bunch of lines declaring variables, and then some other lines declaring some arrays and stream classes, and then some other lines looping through those stream classes, do you put whitespace in between those blocks?
Yes. I would probably also separate the variables into their own groups if possible. Who wants to read a wall of text?

>thicc function

what

A function that is reasonably large by necessity, i.e. one that is impossible to decompose further into smaller pieces without creating some spaghetti code with bad tight coupling.

The function still follows the rule of "do one thing and do it well", it just has to be big to do that one thing.

youtube.com/watch?v=IRTfhkiAqPw
Watched this and I'm trying to rip apart small OOP projects on GitHub for fun.
OOP (not encapsulation, but OOP proper) is really only good for containers.

multi-threading is shit
async is comfy

>OOP proper
what's that

Nested query

I worked on reading the instructional powerpoint created by the training department to teach the users about the system I designed.

Noob question.

I want to set up some online hosting space that will run a program loop to wait for incoming text messages using the twilio API and return the output of a simple game.

My main question is how do i set up a space online that will wait for an incoming SMS to the program I want to run? I think I want to start with maybe just a small (web?) app that listens for incoming connections.

On my hobby project, I do it like this.
if (x == y)
{ x++;
foo();
} else
{ x--;
bar();
}

>impossible to tell where block starts

I find this the easiest to read.

ya if ur dumb

why is Java so shitty?

My problem is that I have no idea how to set up a server that just listens for incoming connections

struct some_struct_entry
{
char *text;
struct some_struct *next;
};

struct some_header_struct
{
int struct_count;
struct some_struct_entry **entries;
};

header = (struct some_header_struct * ) malloc(sizeof(struct some_header_struct));
some_struct_entry = calloc( 256, sizeof( struct some_struct_entry *) );

how to assign "string" to char*text for each entry with strcpy???

plz halp

Attached: 04ea21b26ecbbdacbfbf6df829c58e9a.png (800x800, 158K)

I am making a big open source project, in which every sub folder is pretty much a module by itself. i have been getting complains about 'having to download the entire rope for just one of the 50 sub modules', you can imagine them as individual npm packages, each one is a 'microservice' by itself. and most of them aren't directly related.
Should i make a repo for each one of the modules?

Attached: flat,550x550,075,f.jpg (550x373, 48K)

for (int i = 0; i < 256; ++i) {
some_struct_entry[i]->text = malloc(strlen("hello") + 1);
strcpy(some_struct_entry[i]->text, "hello");
}

for all 256 entries:
determine length of existing string
allocate memory for new string
strcpy(new, existing)

git submodules perhaps?

I don't even see it being a problem unless these modules are colossal, otherwise what's the issue?

"Maybe".
Having too many submodules/repos can be just as annoying as having too few.

>Should i make a repo for each one of the modules?

Yes. You can have a super repository that contains all the modules.

Is there a way to use git submodules in such a way that the submodule always points to the remote repository's HEAD instead of a specific commit?

ty my dudes

Attached: cgeZW6t.gif (400x224, 1.12M)

What should I do in order to learn natural language processing? I'm not a STEM student but I have dealt with programming, mostly web but some python and some veeery basic C development as well

Attached: 1439839912687.jpg (604x604, 43K)

its like a robot framework and we have for example a microservice only in charge of talking to a chip, another to check temperatures, another to check battery
and the idea is that if you like the system with web interface and all the nice stuff we have to check batteries, you can get that one, without having to install all other components, everything is modular

I know test coverage is a shit metric but man do I love seeing the coverage badge on my repo go up.

Attached: 1368074680665.jpg (416x297, 13K)

python natural language toolkit

trying to figure out a good deploy strategy for MQTT broker that won't break production =(

Any language you're using will have this ability (though some will be harder). Just dive in to the most popular web framework for it and figure it out.

>tfw starting to become addicted to programming
is this a good thing or not

Attached: 1550043428243.gif (511x512, 105K)

Fuck off, frogposting scum.
You're not welcome here.

okay, just hold still real quick before i leave...

Attached: 1549348193653.gif (607x609, 514K)

Fuck off, avatarfag.
You're not welcome here.

the clown one is ok

You know the more you get angry the less likely I am to leave, right?

Attached: 1550963468116.gif (815x815, 818K)

didn't know that one, thanks user

how likely are you to leave if someone reports you? not that i would ever do that clown frogfriend

Attached: 6-4aQ-Qp_400x400.jpg (400x400, 28K)

I'm liking that anime image you obviously pulled off of google images to try and make it look like you fit in.
You can fuck off too.

Attached: 1542859598835.png (538x538, 492K)

Don't be mean to my friend.

Attached: absolutelynobully.png (710x384, 192K)