[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / 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

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: cppvrust.png (211 KB, 1278x1048)
211 KB
211 KB PNG
Here is two powerful languages with their syntax compared

which one does /g/ prefer? Technical explanations only.
>>
>>108377566
No one uses that trash in C++.
fuck is that?
>>
>>108377575
its modern c++ and basically all work places demand that
>>
File: 1758158412950813.png (78 KB, 972x923)
78 KB
78 KB PNG
>>108377566
Ok unc, here is how modern people do it, maybe you can learn
>>
>>108377566
I don't know either language, but I would prefer to use the top since it looks more fun.
>>
>>108377566
Does rust not have return statements?
>>
>>108377611
it has, but you can leave it out on the last line by not writing ';'
>>
>>108377575
How do you range bro
>>
>>108377566
Wow both look like shit
>>
>>108377581
>basically all work places demand that
No one demanded this shit. wtf?
You use functions to accomplish what you want, no hidden mechanism and other trash. That is the foundation of both C and C++. Adding more stuff that can introduce even more undefined behavior, so much that even the creator cannot explain it, is the exact opposite of why people love C and its continuation C++.
After C++11 Bjarne truly went nuts.
>>
>>108377566
both are unreadable and can't be debugged by stepping through the code, also enjoy c++ stdlib error output
>>
>>108377566
>Here is two powerful languages
Here are two powerful languages

Perhaps your own loose grip on language is the real topic, here?

p.s. "Powerful" is not how I could describe C++. Having never used Rust, I can't comment on it.
>>
>>108377659
experts wrote this in the compilers I think you should trust them
>>
C++ creators be like let's add even more confusing shit that no one is going to use.
>>
>>108377566
ranges:accumulate?
I remember std:accumulate and didn't work like that.
either way, i prefer rust in this case.
>>
>>108377581
You don't have to use the awful ranges library. No workplace I've been in has mandated it.
>>
File: 1750408323766988.png (128 KB, 348x301)
128 KB
128 KB PNG
>>108377600
>he needs an ai to tell him how to sum an arithmetic series
they really let anyone write code these days
>>
File: 1761475999294363.jpg (87 KB, 956x1024)
87 KB
87 KB JPG
local function calculate(bottom, top)
local n = 0
if bottom % 2 ~= 0 then
bottom += 1
end
for i = bottom, top, 2 do
n += i
end
return n
end
>>
>>108377623
is this meant to be elegant or some shit?
>>
>>108377659
Nah, you don't get it chud. If you don't use the latest C++33 features in every line of code, you're fired. It's the future now.
>>
>>108377754
luddite unc moment
>>
>>108377758
Is this Bash?
>>
File: file.png (46 KB, 567x882)
46 KB
46 KB PNG
>>108377823
>>
>>108377611
The return keyword in rust is a control-flow thing. Even something like fn a() { return 5; } will result in () rather than 5. return just says "exit the function with the value of the expression following return at this point". If an expression is terminated with ; then its value is (). It makes sense in the broader context of the language but it is kind of stupid if you look in isolation.
>>
>>108377775
Sorry my toolchain does not support std::start_lifetime_as do I have to copy the shitty hack patch from newer libstdc++ and implement it myself?
>>
Most languages have been able to do this forever
static int calculate(int bottom, int top) =>
Enumerable.Range(bottom, top + 1).Where(x => x % 2 == 0).Sum();
>>
>>108377855
>where
what a terrible choice of the word.
>>
>>108377861
It is based on SQL terminology
>>
>>108377623
Wow, that's gayer than I ever imagined.
>>
>>108377855
Best answer. Readability over irrelevant performance differences.
>>
>>108377766
its actually kinda nice when you can omit it if you just do a little wrap for something
>>
>>108377775
x) Python for AI
This is hopeless.
Even C is slow for such math demanding operations
Rust? is same garbage like Python !
You want speed from this idiotic approach to so called AI well time to get back to assembly fellows !!! Yeah tears and burning eyes
>>
>>108377566
Here:
int calculate(int bottom, int top)
{
int j;
for (j = 0, bottom = bottom & ~1; bottom <= top; bottom += 2)
j += bottom
return j;
}



[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.