[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
▼ Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: seven_thousand_lines.png (134 KB, 1932x1187)
134 KB PNG
> C++23/26
> printing hello world produces 6000 lines of assembly instructions
Absolute state of C++
>>
>>109934411
still more efficient than (ass) (c)Rust
>>
>int main(void) to auto main(void) -> int
No one asked for this retarded syntax, next they'll have you write fn at the start like all other modern shit languages
>>
#include <stdio.h>

static char * data = "Hello, World!\n" ;
int main(void) {
printf("%s",data);
return 0;
}


.LC0:
.string "Hello, World!"
"main":
sub rsp, 8
mov edi, OFFSET FLAT:.LC0
call "puts"
xor eax, eax
add rsp, 8
ret
>>
Irrelevant. Modern CPUs are too fast for that to matter
>>
File: IMG_2180.jpg (44 KB, 620x675)
44 KB JPG
>>109934411
Shit output is the price to pay for using a shitlang but it's the price that must be paid because I must use a shitlang just because ok.
>>
>>109934506
>call "puts"
Now show code for puts.
>>
>>109934511
but

sobering. Targeting slow embedded machines? skip cpp
>>
>println()
??? what is this bs? in c++ you are meant to use the stream operator and stream to stdout. Otherwise just use printf() and c strings.
>>
>>109934411
>auto main(void) -> int
What the fuck is this shit? Why do you even have auto if you need to do the -> int shit?
>>
>>109934612
Because of their low intelligence, they assume that your methods are flawed.
>>
>>109934411
The c++ standard library should not be used by any person for any reason. All c++ headers are banned from my code.
>>
>>109934478
This, why are all languages using
 -> 
now? It's retarded because it means the opposite thing, the arrow mean assignation but if body is forward or (and) in the left we can assume the thing we are assigning is the function header to the function body:
blablabla MyFunction(blablabla) -> int {}


It should be:
blablabla MyFunction(blablabla)  int {}

And it's read as my function is ... function body.

>auto
Oh great, keep overloading keywords faggots.
>>
>>109934701

I put an arrow in the second code block. (U+2190)
>>
>>109934708
Great, the fuck is wrong with this forum? λ λ λ λ λ
Why we can't unicode?
>>
>>109934701
Just use the penis operator =>
>>
>>109934737
To the other side, anon. <=
>>
>>109934701
>It's retarded because it means the opposite thing
Well not really in the history of programming languages <- means assign much more often
>>
>>109934411
It is an interesting kind of logic to assume that the arrival of a new menu item implies there is something wrong with the existing ones and that you should not order them.
>>
>>109934411
Is that including the libraries?
>>
skill issue
>>
>>109934411
Just use -Os nigger.
>>
>>109934746
Exactly, it's in the opposite direction.
>>
>>109934411
Skill issue.
int main(){}

extern "C" int puts(const char*);
int $ = puts("Hello, World!");

main:
xorl %eax, %eax
ret
.LC0:
.string "Hello, World!"
_GLOBAL__sub_I_main:
subq $8, %rsp
movl $.LC0, %edi
call puts
movl %eax, ($)(%rip)
addq $8, %rsp
ret
>>
>>109934796
>call puts
Post code for puts.
>>
>>109934693
I'll use up to C++11. The rest needs to fuck off.
>>
>>109934828
The standard library of any version is garbage. Whilst useful language features have been added after c++11.
>>
>>109934765
>-Os
5000 lines of code.
>>
>>109934887
I don't like them. Auto disgusts me.
>>
File: rustranny.jpg (279 KB, 900x1604)
279 KB JPG
>>109934411
If you're trying to promote Rust, you failed miserably.
>>
i'm thinkin' Forth is the tru compiled language for heavily memory-constrained computer systems.
>>
>>109934817
>>109934535
-nostdlib -static -O3

void _start() {
const char msg[] = "Hello, World!\n";
long ret;
__asm__ volatile (
"mov $1, %%rax\n"
"mov $1, %%rdi\n"
"mov %1, %%rsi\n"
"mov $14, %%rdx\n"
"syscall\n"
"mov %%rax, %0\n"
: "=r"(ret)
: "r"(msg)
: "rax", "rdi", "rsi", "rdx","r11","rcx","memory"
);

__asm__ volatile (
"mov $60, %%rax\n"
"xor %%rdi, %%rdi\n"
"syscall\n"
:
:
: "rax", "rdi","r11","rcx","memory"
);
}


Assembly:


_start:
movabs rax, 6278066737626506568
lea r8, [rsp-15]
mov QWORD PTR [rsp-15], rax
movabs rax, 2851464966991703
mov QWORD PTR [rsp-8], rax
mov $1, %rax
mov $1, %rdi
mov r8, %rsi
mov $14, %rdx
syscall
mov %rax, r8

mov $60, %rax
xor %rdi, %rdi
syscall

ret

> BUT WHAT ABOUT SYSCALL!?!?
Fuck you.
>>
>>109934974
Can you even run any executable on Linux or Windows without linking it to C libraries? As far as I know, everytime you compile a binary, it's linked to the C library. It doesn't matter which language you use. This is because both Linux and Windows are written in C, therefore all executables must use the C library. So how exactly does using yet another language with a different syntax help? Like, how dumb does one have to be to criticize the C library?
>>
>>109934612
println lets you do compile-time format specifiers, printf doesnt. Simple as.
>>
>>109935092
>The shit-tier code is everywhere so don't criticize it
No, that's why you criticize it, so things improve everywhere.
>>
>>109935123
>>109935144
https://en.cppreference.com/cpp/io/println
Seems println does the same as printf but appends '\n'
You don't know how to code and you don't know how operating systems work. Simple as.
>>
>>109934974

>BUT WHAT ABOUT SYSCALL!?!?
Anyone asking this is retarded. It's code that's not part of your program and cannot be a part of your program.
>>
>>109934411
why did you turn hello world into global dynamic string you utter retard
>>
File: 1771605626967276.jpg (91 KB, 1080x871)
91 KB JPG
>>109935168
You are a complete nigger nocode larper.
>Seems println does the same as printf
Laughably wrong.
You've never written C++ and it shows.
std::println is a convenience wrapper for std::print <---- if you SQUINT you can notice the LACK of a trailing f????

printf is the C library function.
That is absolutely in no way shape or form the same thing as the new std print.
Kill. Yourself.
>>
>>109935371
Rust doesn’t use syscall or any OS calls. It writes to the vram/uart/net driver directly.
>>
>>109935390
>constexpr
>dynamic
retard
>>
>>109934411
>gcc
found the issue!
>>
>>109934411
>whats #include
>>
>>109934478
>int main(void)
void main() was fine too
>>
>>109935123
>println lets you do compile-time format specifiers, printf doesnt
if the string is provably constant, the format specifiers can be baked in instead of looked up
>>
>>109935123
If you don't like the newly released ice cream, you can simply choose the menu item you usually have; it hasn't been discontinued. Simple as.
>>
>>109935696
Correct, you can continue to use printf is you want. You can continue to use iostreams if you want.
But you can also choose to use the new and improved, faster, constexpr-friendly std::print. That's what I'll do. Enjoy your vanilla ice cream, I've got an orange creamsicle.
>>
File: cpp.png (49 KB, 1184x431)
49 KB PNG
>>109934411
seems like a std::println problem. I wasn't aware it shits out so much bloat. I wonder if they can fix that or is it fundamentally broken.
>>
>>109935371
>Anyone asking this is retarded.
or trolling. or both
>>
File: default.png (115 KB, 1356x546)
115 KB PNG
>>
>>109935482
Bodied him
>>
>>109934411
That's what you get for using the std::format bloat.
>>
>>109935092
C and C standard library are completely separate things. You can use the win32 api directly without linking to any standard library or even any compiler supplied libraries.
>>
>>109938558
No, not on UNIX.
>>
>>109938558
The C compiler can insert random calls to memcpy and other C functions even if you pass the proper flags to the compiler like -nostartfiles -nodefaultlibs -nostdlib -ffreestanding etc... because the compiler is a bitch, some compilers like clang also required the compiler specific library.
>>
>>109938844
Its not a big deal to provide your own memcpy implementation. Its like 3 lines of code. As for the compiler specific library. That is pretty universal across all languages. And typically the only actual functions that a compiler will require is division routines.
>>
>>109934411
I love a lot of modern C++ language features, but hate most everything in the STL and runtime. I usually just compile with `-nostdlib++ -fno-exceptions -fno-rtti -Werror=global-constructors` and call it a day.

C++23's printing is an absolute travesty. I have a 30k LOC C++ userspace GPU compute library that compiles twice as fast as a 3 line std::print "Hello World". Who thought this shit was okay
>>
>>109934411
>>
>>109935144
Since you’ve never tried it yourself, you can’t tell which is better. You’re just a slave to the viral buzz you’ve heard about.
>>
>>109934714
The day emoji were added to Unicode, some smartasses started adding them to posts and moot being moot he as usual took a Gordian knot approach where normalization tables filter odd-looking variant glyphs back to the alphanumerics they resemble but also stripping out pretty much anything taking multiple codepoints to display. The only place it doesn't apply that is showing original filenames.
Just so no one is triggered by seeing emoji or an anon bypasses a wordfilter.
>>
>>109934478
c++ legit gives me a headache whenever I try to read its bullshit modern syntax. The only one that's been worse to read is java with its 40 layers of inheritance and composition indirection for each element but you could say thats more of a community issue than a language problem.
>>
>>109934478
Is there anything more banal and low-IQ than complaining about minor syntax choices?
>>
>>109934612
>stream operator
un-intuitive, ugly bloat.
>>
>>109934411
The vast majority of that seems to be lookup tables for handling Unicode characters.
>>
File: O2.png (88 KB, 1357x596)
88 KB PNG
>>
>>109934478
they didnt do that just for the syntax. there are internal reasons that i don’t fully understand but it’s to do with static type checking and backwards compatibility
>>
>>109934701
>assignation
IQ level of syntaxtards
>>
>>109934478
What the fuck kind of gay shit is that? Why even change it?
>>
>>109934701
>why are all languages using -> now?
Because typing higher order functions pointers/references without it is pain in the ass.

eg: int -> (int -> int) -> int vs (int(int(int)))(int)
>>
File: 1764683338561965.png (678 KB, 1000x1000)
678 KB PNG
>>109934511
This is the exact reason modern software sucks donkey asshole.
>>
>>109942521
right just makes more sense. lay off the sugar
>>
>>109934420
>>
>>109942603
It came into existence because it was necessary. However, there are simply retards who use it everywhere..
>>
>>109942230
Dude, you are asking me too much, I barely understand English.

>>109942521
It should be :=
>>
>>109936029
what the fuck is wrong with println?

isn't that fucking new?
>>
Trailing return type, useful if the return type depends on argument names, such as template<class T, class U> auto add(T t, U u) -> decltype(t + u); or is complicated, such as in auto fpif(int)->int(*)(int)

https://en.cppreference.com/cpp/language/function
>>
File: Niklaus Wirth.jpg (1.07 MB, 876x1200)
1.07 MB JPG
>>109942922
Jesus, the language is so nigger.
>>
>>109938558
based
>>
Yes, but what is the size of your executable?
>>
>>109942942
Therefore, anyone who indiscriminately uses it—even when it isn't a template—is a retard.
>>
>>109935371
>>109934411
>another trash thread created by resident rust tranny sex offender that can't program in any language
>bonus: op gets destroyed
it's always beautiful to witness
>>
>>109935492
>Rust doesn’t use syscall or any OS calls.
most retarded and blatant lying i've seen thus far. if it's supposed to be bait, it's ultra shitty.

>It writes to the vram/uart/net driver directly.
like any other language? wow. fascinating. really fascinating. moron.
>>
>>109942942
>>109943045
>t. never tried to return a function pointer without an alias
>>
>>109942987
just checked out of curiosity:
std::puts - 14,472 bytes
std::cout - 14,472 bytes
std::print - 121,128 bytes

flags:
g++-14 -std=c++23 -O3 -s -ffunction-sections -fdata-sections -Wl,--gc-sections
>>
>>109934411
>auto main() -> int
Why not use
>int main()
or it's like C therefore bad?
>>
even C++ nerds are ashamed to use std::print in public
https://www.youtube.com/watch?v=TreruByxQWE



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.