/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

open-std.org/jtc1/sc22/wg14/www/docs/n2030.pdf
linux.die.net/man/3/asprintf
twitter.com/SFWRedditImages

First for C

Second for C

C is a disservice to intelligent programmers. It has almost 0 features that a modern and intelligent programmer uses to be productive. Since C is such a timesink, it's popularity is falling more than any other languages in the market.
C is dying and it should die ASAP

Third for C

Fourth for C

...

Fifth for C

SELECT * FROM a where a.x != a.y;This returns 0 rows.
SELECT * FROM a where a.x IS NULL AND a.y IS NOT NULL;
This returns many rows.

What the fuck?

IP count is not rising, C toddler

You're a retard. kys

Sixth for C

>Get sizes
>Allocate new string with appropriate size
>Call sprintf
????

Anyone here use javafx before?

I am trying to get an ArrayList that stores objects into a listview. I looked up all the standard ways to do this but all the examples are just arraylist with strings and not objects.

Because you cannot use arithmetic comparision on NULL values.

C programmers are actually retards in general. C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
C has no advanced features like C++ does.

You jelly because C is a better programming language than whatever the shit you use
Stay jello prancing la-la homo man

Seventh for C

Is all the anti-C shilling just a big elaborate ruse or is it just assblasted rustniggers?

t. lazy Javascript shill who hates memory management

>C is a better programming language
C is just as bad as brainfuck garbage.


Last time I checked C doesn't even have generics. What a joke!

Here you go.
#include
#include
#include
#include
#include

char *concat(size_t n, ...)
{
va_list args;
va_start(args, n);

// Find total length of output string

size_t len = 0;
va_list iter;
va_copy(iter, args);

for (size_t i = 0; i < n; ++i) {
const char *str = va_arg(iter, const char *);
size_t n = strlen(str);

// Overflow. Only sensible option is to fail.
if (len >= SIZE_MAX - n)
return NULL;

len += n;
}

va_end(iter);

// Null terminator
++len;

char *res = malloc(len);
if (!res)
return NULL;

char *ptr = res;
for (size_t i = 0; i < n; ++i) {
const char *str = va_arg(args, const char *);

// Using the non-standard (but POSIX standard) stpcpy,
// so we aren't constantly rescanning over the string
ptr = stpcpy(ptr, str);
}

va_end(args);
return res;
}

int main()
{
char *ptr = concat(4, "Hel", "lo, ", "Wor", "ld!");

printf("%s\n", ptr);

free(ptr);
}
I actually wrote this in reply to another user a few threads ago.

We've known C is shit for 30 years now

Eww what an ugly piece of code. No wonder C is a timesink

Thank you. The expression I was looking for is
SELECT * FROM a where a.x IS DISTINCT FROM a.y;

Yeah, better as a languagelet.
Call me when you C toddlers have learnt to use lazy evaluations

def concat(*s): return ''.join(s)

>generics
Useless bloat.

Is this a satire? Or C is truly this shit

>generics
>useless
hahaha spotted the fizzbuzz master

It's probably the same buttblasted baboon posting it over and over again as if it made its stupid uneducated opinion true, my dear.
His primitive brain cannot grasp the simplicity and elegance of such a beautiful language, hence he has to resort to name calling and low tier shitposting.
A pity really.

Is this correct?
;; applicative order
(sum (+ 1 2) (+ 3 4))
(sum 3 7)
(+ 3 7)
(10)

;; normal order
(sum (+ 1 2) (+ 3 4))
(+ (+ 1 2) (+ 3 4))
(+ 3 7)
(10)

>generics in C
Are you fucking retarded? It's like asking for garbage collection in asm.

Brainfuck is more simple than C. C is, in your logic, is shittier than Brainfuck


dumb cartoon toddler

>Double reddit spacing
Double kill yourself.

What if I don't?

>generics are useless
?

You fail at logic.

Brainfuck is not as elegant as C, you dumb redditor

Simplicity is elegance

That's why lambda calculus is da future.

>C is, in your logic, is shittier than Brainfuck
How do you deduce that from what he posted?

dis not true..
not true at all mr froddo

"Everything Should Be Made as Simple as Possible, But Not Simpler"
~Famous meme master

Stay in denial. Simplicity and elegance are side effects of each other

Does C have strings?

Fuck off dumb frogposter

Of course it does idiot.
It just doesn't have a dedicated string type.

Frogposters deserve the death penalty

Doing some test for map generator.

That's like saying "oh the language doesn't have chars, we use ints to represent chars from the ASCII table"

Does C have lexical and dynamic closures?

No it doesn't you tiny, little man.

A string in C is a null terminated array of chars. However, there is no type which can guarantee that it is, or points to, a valid string.
A char * often points to a valid string, but it doesn't _have_ to.

There is a proposal for closures in the next C standard.
Clang already supports them, because Apple uses it for their API. You may need some extra runtime libraries though.

>There is a proposal
Hopefully it gets implemented within this decade.
Does C have dynamic function creation

KEEP THE BLOAT OUT OF C
KEEP THKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CKEEP THE BLOAT OUT OF C
KEEP THE BLOAT OUT OF CE BLOAT OUT OF C

>within this decade
The C2X standard is aiming to be done in 2021 or 2022, so you're out of luck with that.

>Clang already supports them, because Apple uses it for their API. You may need some extra runtime libraries though.

The new proposal isn't like Apple's Blocks though, is it?

Don't worry C89 is immutable.

im new to this board, so i hope i dont get too much shitposting for asking, but i have a question or two...

first, how do i post text the way everyone else does?

and second is pic related.
im trying to make my first game. its a basic oregon trail kinda idea, i get a bunch of events that can happen and choices for them.

im stuck at the random selection part. i want it to shuffle the events every time i start a playsession (i guess 5 events untill the game is over, even though i would put in like double the amount...)

ive tried a couple of ways of going about achieving the randomness thingy, but it always bugs out on me when printing it out or something...

anyone have any suggestions? would be greatly appreciated

im working in C, btw...

Okay, since I bet on the wrong horse.

Having to do that just to get declarations closer to statements that use them may well be the symptom of a function body that is getting too large. You can avoid that by splitting the function body into shorter functions.

I have the same problem in C++, because I don't want to get too many methods in my classes, but then I end up with gigantic methods with declarations all over the place. Eventually, while refactoring, I split the code inside public methods into shorter private methods. This way, it's even easier to define constant references at the start of the private methods to get more concise code afterwards.

What about dynamic function creation?
Does C have reflection? Instrospection?


I'm under the impression that C is for people from the stoneage, primitive and an insult to ingelligence of a human brain?
Does C even have mixins?

>scanf
Aaaaaaaye ;)

>The new proposal isn't like Apple's Blocks though, is it?
They basically are Apple's blocks. The proposal straight up says it's based on them.
open-std.org/jtc1/sc22/wg14/www/docs/n2030.pdf

Trolling too hard.

Oh, neat. I hadn't got around to reading the proposal yet, and needed the quick rundown.

cout, whatever suits your boat...

I get the feeling that you don't understand C and what it's all about in the slightest.

>Can't program without his 1000 layers of abstraction
Kill yourself senpai

One does not need all this bloat when one talks the language of the machine.

C is for newbies. Think of it this way:
During ancient times, counting to 10 was a big deal and a person who could count to 10 was considered to be "wise".

Fast forward a few century counting to 10 is so trivial we teach this to toddlers. Now toddlers appreciate the vast "knowledge" of counting to 10 while matured brains are busy with modern technologies.

C is from stone age and the people who still preach it is like overgrown toddlers that can't learn advanced things.

(You)

One does not need anything but assembly, C itself is a bloat

I just want to say that if you need a function to like sprintf() but which allocates its own memory, there is the GNU asprintf:
#define _GNU_SOURCE
feature_test_macros(7) */
#include

int asprintf(char **strp, const char *fmt, ...);


linux.die.net/man/3/asprintf

I agree. Doing trivial tasks in C feels like living in the stoneage (see ) while matured people have moved on and left those small tasks to primitive brains of average c tards

asprintf is actually really easy to implement yourself with just malloc and snprintf.

true. that explains why c defence force are so immature

Even worse

Not him, but that was for readability. You leave a blank line between paragraphs, and this has nothing to do with reddit. Also, Markdown != reddit.

Typical haskel faggots to be honest.
God I hate you retards, you fuckwads literally abstract for the sake of it in the most shitfaced retarded ways. PLEASE kill yourself before you write another line of production code.
P L E A S E.

>abstraction
These are necessary tools. Technically you can solve any problem in a basic turing complete language and anything other than what brainfuck has to offer is what you call "abstractions" or "bloat"

I literally CAN'T stomach weakly typed shit after years of C

CAN'T

Implementing God's fourth temple in HolyC.

typedef char * string;

Happy now?

It's not hard, idiot. No seriously. C is so simple and void of functionalities it feels like an insult to write C programs

You do code with code tags, you find them under Sup Forums's rules in the rules page.

>i want it to shuffle the events every time i start a playsession
Sounds like you need to place the events in an array and shuffle the array at the start of the session.

Also
>if(choice=='a' || choice=='A')
Surely C has a toLower function.
>if(choice.toLower() == 'a')

Please just end yourself you fat fuck...

>Surely C has a toLower function.
tolower() in .

>1GB/s

thank you for non shitposting answer

>toLower
bloat

my body is ready, now how should i go about teaching myself python? what are some of the best resources available?

The C Programming Language

This so fucking much.

Every single time,
Every single fucking time I see C codes I cringe visibly and I feel disgusted enough to puke.
D fag here

>D fag here
AHAHAHAHAHAHAHAHAHAHHAHAHA

haha
"no."

>D fag here
How does it feel going extinct

>tfw too intelligent for C

Simplicity is the ultimate sophistication.

>D fag here
Literally the same as C.

Do you happen to be one of those Sup Forums toddler? I dualboot GNU/Linux and freeBSD; marketshare is pretty irrelevant to me

No

>C is so simple and void of functionalities it feels like an insult to write C programs
>mfw to intellagent to use C
this is too much user