[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Dude - what if we made C++'s syntax uglier lmao

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 53
Thread images: 2

Dude - what if we made C++'s syntax uglier lmao
>>
>>61672982
class:main::std::cout >> "lets try" >> endl;
>>
>>61673017
Why is endl scoped differently?
>>
>>61673046
Because I don't know C++
>>
>>61673046
In C++19, endl is non-deterministically scoped to simplify the syntax. In fact, all tokens that have a prime + 1 number of characters are non-deterministically scoped.
>>
>>61674726
kek
>>
>>61672982
With more template stuff and metaclasses potentially coming up, that should be an easy task.
>>
>>61672982
String reversing in (((rust)))
use std::io;

fn main() {

let mut x = String::new(); //or let mut x: String = String::new();
io::stdin().read_line(&mut x);

println!("{}", x.chars().rev().collect::<String>());

}


String reversing in C++
#include <iostream>
#include <string>

int main ()
{
std::string str ("now step live...");
for (std::string::reverse_iterator rit=str.rbegin(); rit!=str.rend(); ++rit)
std::cout << *rit;
return 0;
}


Importing shit in Rust
use std::io::prelude::*;
use std::{fs, io, env, process};


Including shit in C pee pee
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
#include <string>
#include <algorithm>
#include <bitset>


But WAIT, something something es jay double you xdxDXDDDDdddDD
>>
what if we made an SJW language? lmao
>>
>>61676419
kek
>>
>>61676419
String reversal in C++

#include <iostream>
#include <string>

int main()
{
std::string str ("now step live...");
for (auto rit = str.rbegin(); rit != str.rend(); ++rit)
std::cout << *rit;
std::cout << std::endl;
}


Or even better
#include <string>
#include <iostream>
#include <algorithm>


int main()
{
std::string str ("now step live...");

std::for_each(str.rbegin(), str.rend(), [](auto& c) { std::cout << c; });

}
>>
str.reverse;
>>
>>61676470
String reversal in (((Rust))) xdXDDDDDDDD
str.chars().rev().collect::<String>())
>>
>>61676470
Not him, but does C++ have map, fold, filter, zip, toArray yet?
>>
>>61676554
That's not string reversal though
>>
>>61676521
map = std::transform
fold = std::accumulate
filter = std::copy_if (or std::remove_if with negative logic if you want to do it inplace)
zip or convolution = you'd need to hack it together with std::transofrm
toArray = not to my knowledge, no.

Of course, there's always an option to use boost for convenience.
>>
>>61676554
>Just do this for the first example to make it less needlessly convoluted:
That's not reversing the string, though.
>>
>>61676590
>toArray
Oh, does it have things like split() or chars()
>no zip
hmm, if I was using C++ I'd actually make a seperate library for this, I use these very heavily
>>
>>61676521

>map
Make a copy, and use std::transform

>fold
No idea what that is

>filter
std::remove_if

>zip
Not in the standard library, I think. Might be able to get it with everyone's favourite second standard library though (boost).

>toArray
What is this?
>>
>>61676628
>What is this?
Think of it as a generic lazy splitter function
>>
>>61676632
It can also take varargs and return an array
>>
>>61676628
What about enumerate?
>>
>>61676614
>Oh, does it have things like split() or chars()
Yes

>hmm, if I was using C++ I'd actually make a seperate library for this, I use these very heavily
Use boost, it has everything and more.
>>
>>61676664
Is chars() lazy? If I have a billion character long string, str.chars().take(100000) should not take much time?
>>
>>61676419
awww sweetie are you sad because your language is just a fad with no actual spot in workspaces? maybe you should go learn real programming, dear.
>>
>>61676419
Your C++ string reversing doesn't handle Unicode properly.
>>
>>61676741
None of the C++ examples work consistently for anything other than ASCII. Fucking retards.
>>
>>61676741
Heh, I kinda expected that. I was trying out C++ again after all these years and I see it made 0 progress.

I'll just stick to my ((((((((Rust)))))))) since it's actually not a pain in the ass, at least for me
>>
>>61676695
>Is chars() lazy? If I have a billion character long string, str.chars().take(100000) should not take much time?
That's correct.

You can do this in multiple ways, even,.
>>
>>61676769
It's more of an indictment of the C++ """programmers""" criticizing you. They don't actually know C++ either and their versions are just as bad. Several of them are blatantly ignoring error cases as well.
>>
>>61676521
Does McDonald's sell salads? Yes. Do you want to eat salads at McDonald's? No.


I'll never understand why people pretend it's so great to have crippled FP in imperative languages.
>>
>>61676825
I respect C++ and C++ programmers. It's just the kids of 4chan and 8ch that make me cringes

Who knows, I'll come back to C++ once it gets modules and UFCS, it's just my style
>>
>>61676858
What is ``FP``? Functional programming? C++ doesn't have functions? Rust does?
>>
>>61676825
They have extra time to remove the errors while you are waiting for your Rust code to compile.
>>
>>61676879
Only newfags stay stuck, it's true in both of the languages
>>
>>61672982
I program in C++ professionally, and in Rust for fun, and I'd love to be able to the Rust for work. The syntax and semantics are way more clear than C++.
>>
>>61676741
>>61676769

std::string doesn't give a shit about encodings, it just operates on chars. That said I have no clue if you could try stuffing in Unicode characters since it's all just bytes anyways.

>>61676825
>The standard std::string type is used for a string reversing example, which may not handle unicode characters. Surely this must mean that C++ programmers suck!
>>
C++19 on Linux when
>>
>>61676898
It doesn't mean all C++ programmers suck it just means you suck like all of the other C++ larpers on 4chan. The fact that you don't know if "you could try stuffing in Unicode characters since it's all just bytes" means you're a moron.
>>
>>61676869
>>61676882
Are you having a stroke or what?
>>
>>61676987
I've never had to deal with Unicode characters before when working in C++, so I don't know from experience. Does this automatically make me bad? Is someone who isn't very knowledgable about Unicode automatically a bad programmer?

What I'd expect to happen is that it would work normally, but that as soon as you start to muck with individual bytes (chars), you'd run into trouble if you're not careful.
>>
>>61677101
>Does this automatically make me bad? Is someone who isn't very knowledgable about Unicode automatically a bad programmer?

Absolutely.
>>
>>61677101
>Is someone who isn't very knowledgable about Unicode automatically a bad programmer?
yes. your program doesn't reliably work.
>>
>>61677101
You should be careful when parsing texts
>>
>>61677101
>Is someone who isn't very knowledgable about Unicode automatically a bad programmer?
Yes. Handling text data is the most important part of computing.
>>
>>61677101
String handling in C and C++ is extremely error prone and the source of tons of vulnerabilities. If you're going to use either language you should know the intimate details of how it works.
>>
>>61672982
Compile times are going to kill Rust. It's gotten so ridiculous and they just keep merging more language features. It's already starting to piss off the Firefox team and Firefox only has a tiny bit of Rust in it.
>>
>>61676419
>C++ by a rust developer
Wow that is fucking disgusting.

You can reverse a string with:

std::reverse(s.begin(), s.end())


All you need to include is string and algorithm. Interesting you feel you feel to lie to put rust ahead.
>>
>>61676769
You can't write proper C++ because you don't understand what the compiler does under the hood. You lack the understanding of computer architecture to write proper code.

You would know right away that UTF-8 and wide strings wouldn't be able to handle a reversing that easily. If you wanted to you could wstring, but the smart way is to use the locale header, covert the utf-8 into char_32t via codecvt and construct a basic_string<char32_t> and use reverse on that.

But you would know that already if you understood how computers work, which rust faggot do not understand as they are crippled by the safety concerns.
>>
>>61677614
And before you say it's slower, it's the same speed since you don't have to deal with the characters byte by byte when reversing. And you'll have a form that's easier to slice and manipulate.

Learn how computers work before embarrassing yourself and other rust lepers.
>>
>>61676628
fold = reduce, which is std::accumulate
>>
>rust getting this BTFO
What a good start to the day
>>
File: 0005.gif (18KB, 128x128px) Image search: [Google]
0005.gif
18KB, 128x128px
>>61672982
No one uses Rust. Why do we keep having these threads?
Thread posts: 53
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.