Here is two powerful languages with their syntax comparedwhich one does /g/ prefer? Technical explanations only.
>>108377566No one uses that trash in C++.fuck is that?
>>108377575its modern c++ and basically all work places demand that
>>108377566Ok unc, here is how modern people do it, maybe you can learn
>>108377566I don't know either language, but I would prefer to use the top since it looks more fun.
>>108377566Does rust not have return statements?
>>108377611it has, but you can leave it out on the last line by not writing ';'
>>108377575How do you range bro
>>108377566Wow both look like shit
>>108377581>basically all work places demand thatNo 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.
>>108377566both are unreadable and can't be debugged by stepping through the code, also enjoy c++ stdlib error output
>>108377566>Here is two powerful languagesHere are two powerful languagesPerhaps 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.
>>108377659experts 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.
>>108377566ranges:accumulate?I remember std:accumulate and didn't work like that.either way, i prefer rust in this case.
>>108377581You don't have to use the awful ranges library. No workplace I've been in has mandated it.
>>108377600>he needs an ai to tell him how to sum an arithmetic seriesthey really let anyone write code these days
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 nend
>>108377623is this meant to be elegant or some shit?
>>108377659Nah, 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.
>>108377754luddite unc moment
>>108377758Is this Bash?
>>108377823
>>108377611The 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.
>>108377775Sorry 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 foreverstatic int calculate(int bottom, int top) => Enumerable.Range(bottom, top + 1).Where(x => x % 2 == 0).Sum();
static int calculate(int bottom, int top) => Enumerable.Range(bottom, top + 1).Where(x => x % 2 == 0).Sum();
>>108377855>wherewhat a terrible choice of the word.
>>108377861It is based on SQL terminology
>>108377623Wow, that's gayer than I ever imagined.
>>108377855Best answer. Readability over irrelevant performance differences.
>>108377766its actually kinda nice when you can omit it if you just do a little wrap for something
>>108377775x) 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
>>108377566Here:int calculate(int bottom, int top){ int j; for (j = 0, bottom = bottom & ~1; bottom <= top; bottom += 2) j += bottom return j;}
int calculate(int bottom, int top){ int j; for (j = 0, bottom = bottom & ~1; bottom <= top; bottom += 2) j += bottom return j;}