/dpt/ - Daily Programming Thread

prev: What are you working on, Sup Forums?

Other urls found in this thread:

blog.rust-lang.org/2017/11/22/Rust-1.22.html
github.com/a-bonnet/pasclang
pastebin.com/Lbzi08Nj
stackoverflow.com/help/mcve
twitter.com/SFWRedditGifs

First for C++ was a fucking mistake.

std::string tokenizer in C++

Second for C++ was a fucking mistake.

try std::split,
auto x = std::split(str.cbegin(), str.cend(), x.begin(), '-');

...

Third for C++ is trying its best and deserves to be loved like everyone else!

That's just how STL looks like, user

auto x = ... x.begin () ...; sure about that lad?

And you defend that garbage?
Even C's janky string functions look 100 times better than that.

Cniles BTFO

>deserves to be loved like everyone else!
>like everyone else
Nobody who comes to these threads deserves to be loved, though.

hmm, I missed that bit.
Thanks for pointing that out.

Reminder that the Rust team has just released both 1.22.0 and 1.22.1 at the same time: blog.rust-lang.org/2017/11/22/Rust-1.22.html !
I bet you wish your favorite language devs were so productive

>we split strings now!
>still uses strtok under the hood
Reminder that CHTML++ is not a Turing-complete language, and it cannot split strings.

std::split(str.cbegin(), str.cend(), x.begin(), '-');
Looks reasonably legit.

there's nothing wrong with it and the parameters are consistent across different things like std::copy() so there is no mental overhead to it, and for example instead of begin() you can do arr + 0

The only difference between C and C++ is that C didn't have as much room to make mistakes. They are equal in density.

Nice memed, my friend, but there is no such thing as std::split.

Anime was a mistake.

ASKTUALLY thinking of making a library for it and making a proposal to the ISO.
But I have to decide whether this function should work with other containers.

>making a proposal to the ISO
Wow, so C++26 will finally have a split function.

Seems pretty simple, why don't you just do something like
void tokenize(std::string line,std::vector &res char delimiter='-'){
std::istringstream input(line);
std::string part;
while(std::getline(input,part,delimiter))
res.push_back(part);
}
?
Sometimes the standard solutions are good enough.

>C++ ISO committee
Why does this even exist? The changes your shitlang does every 3 years doesn't need to be ISO.

Because C++ matters enough to be legally standardized and have an official organization on it.

Why exactly do you guys need a split function? Can't you just use std::regex to pull all substrings that don't contain a space?

they're grossly incompetent hobbyist Ctards who are doing babby's first AST parser

But not a standard ABI.

SURPRISINGLY you guessed it right.
I'm also an employed STL programmer!

extern "C"

>copy each token into a string, then copy from that string into a newly allocated string in a vector
>tokenize entire string even if you only need first 10 tokens
Wow, this is bad. Meanwhile Rust's str::split is lazy and zero-copy.

> grossly incompetent hobbyist Ctards
Show us your complex non-fizzbuzz projects, user. (Protip: he won't ;^)

That isn't standard either.

Doxx yourself, user. (Protip: he won't ;^)

Why though? They never had the C problem of a million shitty incompatible compilers.

Updating your language every other year seems like something that shouldn't be standardized. It's not like there's a bunch of important projects that depend on this year and not the next year's C++ standard.

Just update your language somewhere else, ISO shouldn't a beta testing ground.

Either you are too retarded to figure out any of the myriad ways you can present a project without doxxing yourself (as if anyone even cares about you), or you're desperately looking for an excuse. Either option completely discredits you. Well played.

>bratfag is also a rustfag

not an argument. keep crying about your string splitting problems

Did your school have a programming club?
What was it like?

>calling people "incompetent hobbyist Ctards" is an argument
>pointing out that i don't have a single non-fizzbuzz project to show off is not an argument
It's really sad at this point. Just stop breathing.

you still haven't presented a convincing reason for why you can't strtok a str::string is such a critical issue for C++ as a language

This image really does describe dpt.

S-so is anybody working on something?

My school had like 10 of these bad boys and the teacher allowed me and my friends to practice programming and play games on them sometime.

>you still haven't presented a convincing reason for why you can't strtok a str::string is such a critical issue for C++ as a language
Because I don't think it's a critical issue for C++ as a language. I just couldn't help noticing the irony of anyone in this thread calling anyone else an "incompetent hobbyist".

Tokenizing and AST parsing are two separate tasks. And if they were really Ctards, they'd use Flex.

are you suggesting you're not an incompetent hobbyist? show us your projects (pro-tip: he won't :^))

>are you suggesting you're not an incompetent hobbyist
What I'm suggesting, tucktard, is that you should probably tune it down, because in trying to discredit others you are only drawing attention to your own deficiencies.

>Why though? They never had the C problem of a million shitty incompatible compilers.
It's called gcc which implements it's own c looking dialect which can't be used anywhere else.

Why don't you lead by example?

>you should probably tune it down
hurr durr i'm just lazily shitposting i don't care what you think

stop using non standard OSes that don't follow POSIX

>Using the shit known as POSIX
How does it feel like not having running water and not being connected to the sanitary sewer system?

Starting a lurk-only terminal script for Sup Forums with integrated mass-downloader. Lurk-only because of stupid captcha.

Already done that for a certain german imageboard.

You could easily expand it to stop after 1 tokens if you wanted to.
You could make it more efficient if you needed to, maybe I am the odd one out where this seems fine to me.
How often do you need to do this and how large are those strings?
I basically do this function when I am reading a CSV file (although I don't push to a vector, I do something else)

You tell me, pajeet.

also, you can quality loops with reverse
reverse loop(container){};

also
ref loop(container){
element(); //T foo(){ return container[i];)
}

i'm on fire with all these brilliant ideas

>Why don't you lead by example?
Well, I'm the one who challenged that tard to post some actual non-fizzbuzz code that accomplishes something. But here's some, stitched together from a relatively small project:
pastebin.com/wez72zE5
You can actually do it without getting doxxed. Who would've thought?

Yeah, it's not fizzbuzz, but this is still in the realm of hobbyist and I don't see it as being much more complex than even a primitive parser, assuming you write the regex engine, tokenizer, etc. yourself.

I use snippets a lot and was thinking I needed one for something slightly more complex.

My thinking was that I would write the header, then use a script that takes all lines with parentheses and bring them to the source file, prepend the class name to the function, replaces semicolon with curly braces and adds all class variables to the initializer list of the constructor.
Seems like it would be best to use sed for this as I can easily port the regex to whatever lang that supports regex.

>attempts to devalue code he doesn't even understand
>still can't post anything of his own above fizzbuzz-level
Tell me more about how you're afraid of getting doxxed. Or what is it gonna be this time? You can't post anything because you're under an NDA? You kids are hilariously predictable.

Never knew these existed

Did I hurt your feelings just by describing it as hobbyist? Nothing in there is very complex or difficult to understand. I'm not the one you were asking to post, in any case, and I'm mainly just shy about my stylistic decisions.

I'm doing chores around the house instead of programming and it's a much more rewarding activity tbqh

>Nothing in there is very complex or difficult to understand
And yet you evidently don't understand what it is and what it does. Funny that.

>and I'm mainly just shy
So you have to show, just like every other incompetent shitposter ITT? I could keep posting increasingly complex stuff and it's going to be the same at every step: "T-t-that's nothing! H-hobbyist! I write REAL programs but I'm shy!" Now tell me more about how much you hurt my feelings by failing to present anything above fizzbuzz level.

>And yet you evidently don't understand what it is and what it does.
How is that evident? It's just a toy VM with its own primitive language, I can't even find anything in there that would require advanced theory and research. I mean I'm not knocking it, but if you think it's not hobbyist you're deluding yourself.

>I could keep posting increasingly complex stuff
Based on how defensive you're getting over this example, I really doubt that. I could post my own stuff, and I think you'd be correct in identifying it as hobbyist (and ugly), but I assumed when you were using that as insult that you would have something a bit more impressive to share. It's fine that you don't, just don't act like you do.

Discuss my FizzBuzz instead of shitposting.
github.com/a-bonnet/pasclang

> C++ is a language that is unique in providing zero-cost obstructions
Savage.

Who are you quoting?

>I could post my own stuff
I'm sure you "could". Just keep talking about it while having jack squat to show. So far I'm the only one in the entire thread who has presented evidence of even knowing how to program at all. Keep moaning about how code you can't grok "isn't even advanced research" (at least you got something right), fizzbuzzer.

My twitter feed.

That's a what, not a who.

>Haskell is a language that is unique in providing pure frictional programming
BTFO!

Typical Tumblr """wittiness""".

>you can post a 3 KLOC C toy program without getting doxxed
mind=blown

frick da police

>doesn't even have a 3 KLOC C "toy program" to show
The insecure fizzbuzzers' asshurt is palpable.

Alright, I'll post one file that's a part of a larger Haskell project just for the sake of it. It is hobbyist, and it is ugly, but it's a sufficiently complex skeletal mesh animation system that I built myself, including my own Blender plugin, and that works.

pastebin.com/Lbzi08Nj

Ok, aside from the lovely flamewar brewing up, how would you launch a get request that returns something on localhost or console?

I'm getting a JSON object returned.

Would I need to set up some kind of server hosting library, like WT?

c y k a b l y a t'

Here's a prediction: there will be dozens more butthurt post like yours, but not a single actual program will be posted.

I see this joke went straight over someones head....

lrn to isolate anomalies and provide laboratory setting experiments that consistently produce the phenomenon you've seen in the wild. CS is part of STEM fyi.

stackoverflow.com/help/mcve

...

>it's a sufficiently complex skeletal mesh animation system that I built myself, including my own Blender plugin, and that works.
>only posts a tiny loader
>j-just trust me, guise
At least you posted something.

I posted again one of my 3k+LOC project and no one will comment on it (as in the past). /dpt/ is not about programming.

rush b go

nice multi-line macros lmao

curl

That's a command on the Unix shell btw. Do you really know literally nothing?

Do you mean write a program that does HTTP requests? Libcurl is a widely used library for that.

One shitpost, zero programs. Keep going, kids.

The animation system is contained in there, buddy. All you do is set the joints in Haskell and call into this. Being tiny is a benefit when it actually does the job.

there was I time when you didn't either

thanks, googlin it

thanks for the (You)

>The animation system is contained in there,
struct model *model_read_binary(const char *path);
void model_load_indices(const struct model *model, uint32_t nptrs, void *ptrs[nptrs]);
void mesh_load_verts(const struct mesh *mesh, const struct joint *joints, void *ptr);
void model_load_verts(const struct model *model, uint32_t nptrs, void *ptrs[nptrs]);
void model_free(struct model *model);

Which one is the Haskell animation system?
>j-just trust me, guise!
Oh, my fucking sides...

Tru dat, but I didn't need to actively ask

>there was a time when you didn't either
Really made me think.

I'm not even going to make fun of your animation system if it's shitty. But for fuck's sake, at least DELIVER SOMETHING.

model_load_verts() does the transformations for the whole model and mesh_load_verts() does the bone transformations. How can you not see that?

The "load" just means putting them into a mapped OpenGL buffer.

It is a functional animation system, I don't know what more you expect to see.