[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: 1694019284961.jpg (42 KB, 800x418)
42 KB
42 KB JPG
Are there other programming languages as performant yet expressive as Rust?
>>
>>106518844
Zig, Odin, D, C++, and C3
>>
by performant I meant be a man but perform like a ugly woman, and by expressive I meant express my libtard opinions everywhere
>>
Yeah, but programmers will look at the second and refuse to "learn" it because it's "different". All kinds of reason will be manufactured to justify the first and shun the second. Imagine a Ctard having to understand that. His brain would explode.
>>
No
>>
>>106518844
Yes
>>
>>106518844
First is better. The second looks like a software "engineer" larping as a mathematician.
>>
>>106518998
explain the right code in detail without using ai
>>
>>106518844
What even happens on the right? Is it all performed sequentially, or are multiple stages of the pipeline combined for performance?

I know all compilers and processors resort to "just trust me bro", but is expressing intent what you want in a low level language? This style makes it very difficult to reason about the efficiency of the actual implementation. In something like Haskell you just have to accept it, but not in a systems language.
>>
>>106518844
C++23
>>
>>106518844
left is written to be as easy to read as possible
right is written by someone who think they're clever

anyone who would prefer the right code over the left, even in the case where the generated code is identical, is an idiot who does not appreciate or value simplicity

KISS
>>
>>106518964
>C++
With the STL? I doubt that.
>>
>>106519142
Functional programming techniques are a trade off. They're not as performant but it's more expressive. If you care about speed on the order of nanoseconds functional programming is probably not for you.
>>
>>106519107
not that anon, and I don't know rust but
>filter
>map
>higher-order functions
this is clearly functional programming, so you could just guess

>numbers -> argument
>.iter() -> a function to iterate through each number
>.filter ... x % 2 == 0 -> while number is even
>.filter ... x < 100 -> while less than 100
>.map -> for every x, do x * x, looks like set notation
>.sum -> sum all the results
>>
What the fuck is that && notation?
>>
I mostly work with Julia and Fortran because I'm in academia, but I really think Rust might be the definitive programming language (as long as they stop Javascriptfying it)
>>
>>106519165
STL has similar garbage to the right example
>>
>>106518844
>type noise
>crappy python-like syntax
>random &s lets muts and fns
no thanks
>>
Every single aspect of rust has managed to look as ugly as possible, even these simple things. It's an impressive feat.
>>
>>106518844
These two separate ifs are just there to make the right look better
And how do you debug the code on the right? Left I can put a breakpoint and see exactly what the computer is doing step by step
>>
>>106519221
>as long as they stop Javascriptfying it
They won't, that's the real problem with it. When your package system is essentially npm, it doesn't matter how good the language is, the software is always going to be webshit.
>>
>>106518844
Even JS looks better than the shit at the right
>>
>>106518844
Zig isn't bad. Its a nice balance between QoL features of Rust, and keeping things simple. Honestly, I wish it had hit the mainstream appeal that Rust did.
>>
>>106519373
It's a reflection of its contributors.
>>
>>106519172
>If you care about speed on the order of nanoseconds functional programming is probably not for you.
kys robert
you really bragged about your spacewar clone running at "almost 30 frames per second even with hundreds of objects on screen" on a modern computer as proof that clojure isnt slow. you're so fucking stupid
>>
>>106519338
>python-like syntax
lol... lmao even...
>>
>>106519380
stop noticing things anon
>>
the issue with using higher order functions to behave "functionally" in compiled languages is you have no idea what the compiler is doing under the hood. one of the reasons you would choose a compiled language is for performance and manual control, so this seems like a downside. the left example is very clear what the assembly will more or less look like. with higher order functions the right example could be 10 times slower, or according the image produce the same instructions. very much non obvious.
>>
>>106519142
It's just inlining.
>>
>>106519681
if it is just inlining then op's image is wrong, or the compiler is black magic and can understand intent.
>>
>>106518844
>expressive
you mean unreadable? literally what is the usecase when you can just do what's on the left in a fraction of the time and it takes a fraction of the time for other people to comprehend
>>
>>106519380
Step into the enumerator hell.
>>
>>106519703
>right is unreadable
Tell me your a woman and minority without telling me your a woman and minority
>>
>>106518964
None of these guarantee memory safety.
>>
>>106519752
Not him, but OP never talked about memory safety.
>>
>>106519752
No one outside of redditors has ever cared about memory safety.
>>
>>106518844
The left is better in every way imaginable.
>>
>>106519380
> how do you debug the code on the right?
Put a breakpoint in the lambda. Ir if the debugger doesn’t allow that, pass a function with a breakpoint in it. Or just use print statements like a sane person.
>>
>>106519221
>Julia and Fortran
A still-birth and a zombie, based.
>>
>>106518844
Left has the structure of every language commonly in use to solve the problems in industry.

Right is structured entirely different.

Are there VERY significant benefits to using the right? If not, wouldn't it make sense to stick with a syntax and grammar that's in use everywhere?

Language wars, in general, are retarded because everyone who knows more than one is aware that different tools are for different jobs, but the rust arguments are unique in the sense that the language is arguably not a significant enough improvement at any job, nuts is still pushed with religious fervor because rainbows.
>>
>>106518844
>SlavedIn
jeet detected
YWNBAR (you will never be a rustacean)
>>
>>106518844
This shouldn't generate the same assembly, unless the compiler is smart enough to see how it can be optimized, which even as a Rust fanatic I find hard to believe. Thoughever it is definitely possible that array operations can be optimized if the compiler detects that the array is never used again, applying a zero cost abstraction over it.

>>106519107
KYS retard. It should be obvious to anyone who isn't a nocoder, even past syntax.
>Create an iterator over the array.
>Iterate over the array, creating a new one containing any element x that passes the predicate x % 2 == 0.
>Trivial if your IQ is above 20 considering the above.
>Apply the function x*x to every element x of the array and return this new array.
>Return the sum of every element of the array (.sum() is a shorthand for .fold(|x, a| x+a), though I wouldn't expect (you) to know that)
>Rust implicitely returns an expression if it isn't followed by a semi-colon, since all of this is a single expression, the result of .sum() is returned.
Left code:
>For every element of this list, if it is even and if it is lesser than 100, add it's square to the sum, then return the sum.
Right code:
>For every element of this list that is even and is lesser than 100, square it and return the sum of every element.
Those obviously mean the same thing, but the functional approach is simpler to read as the logic reads as if it was processing everything at once rather than one element at a time.

I miss pre-2012 >>>/g/ so much like you wouldn't believe. How far have we fallen that higher order functions are alien to the average user.
>>
>>106520665
I will also add that the right code could be written as numbers.iter().filter(|&x| x < 100 && x%2 == 0).fold(|&x, acc| acc + (x*x)). Though I always forget whether the accumulator or element goes first in fold's arguments.
Left would still require a few lines, though less. Bad faith post with the right conclusion.
>>
the older i get, the more i prefer readability
>>
Why do low IQ think right is complicated?
>>
>>106519142
agreed. this is why i always code MIR directly. much more explicit.
>>
>>106520716
It's probably not complicated, but the syntax is completely different from C, C++, C#, Java, JavaScript, Python, and Typescript. I'm probably missing a dozen more niche languages that are actually in wide commercial use.

So, people rightfully ask:
>why?
And the answer seems to be, because.
>>
>>106519672
>the issue with using higher order functions to behave "functionally" in compiled languages is you have no idea what the compiler is doing under the hood
Most IDEs let you see inside stdlib Rust functions. Rust stdlib is very readable in contrast to glibc.
>>
>>106519172
correct. functional LLVM IR is really disgusting.
>>
>>106520739
>It's probably not complicated, but the syntax is completely different from C, C++, C#, Java, JavaScript, Python, and Typescript.
Higher order functions are common in JS and TS too. Swap sum for reduce and you got JS code here.
>>
>>106519193
i too get filtered by things like irrefutable patterns
>>
>>106519172
Rust compiler is really good at optimizing these type of expressions. Sometimes it can be even faster than explicit loops.
>>
>>106520749
It's almost kinda close enough to something in JS isn't an answer to "why learn this" either.
>>
>>106520764
>why learn this
Because functional style is more succinct and easier to reason about than imperative style code.
>>
>>106518844
Everyone in this thread is so used to shit software that they can't imagine what it would be like to use a compiler that you can actually trust to optimize things reasonably and consistently. Many such cases indeed!
But that being said, one of the biggest problems with Rust are the terrible compile times (though not as terrible as C++). Most of it is due to deeper architectural issues, but writing code like in the right side everywhere doesn't help.
>>
>>106519672
agreed. compiled languages were created to do things manually. and with good languages, we all can just compile code bases accurately in our heads with great accuracy, down to the specific unrolled loops and SIMD optimizations. rust just prevents us from doing that, and this is really why it's horrible.
>>
>>106520772
Wrong.
>>
>>106520818
No
>>
File: 1744461006378.png (261 KB, 2560x1227)
261 KB
261 KB PNG
>>106520816
>and with good languages, we all can just compile code bases accurately in our heads with great accuracy, down to the specific unrolled loops and SIMD optimizations
Naive
>>
>>106520824
I am correct. Read this faggot, who is right.
>>106519672
You have 0 idea what your functional code is doing under the hood. You rely on the compiler to completely change your code for any sort of semblance of performance. You can only reason about the surface level of your code which is fine if you're aim is to be some sort of webdev I guess.
>>
File: 1661817442993494.jpg (80 KB, 640x427)
80 KB
80 KB JPG
>>106518844
int
f(const int *a, int n) {
int x = 0;
for (i = 0; i < n; i++)
if (a[i]%2 == 0 && a[i] < 100)
x += a[i]*a[i];
return x;
}
>>
>>106520831
>I am correct. Read this faggot, who is right.
Nope.
Functional style code generally uses less lines of code and uses high level abstractions that are easier to reason about. Imperative code has way more moving parts and it's much harder to find invariants of your algorithms.

>You have 0 idea what your functional code is doing under the hood.
Pretty much every IDE let's you see implementation of any stdlib Rust function.

>You rely on the compiler to completely change your code for any sort of semblance of performance.
This happens to all the code all the time. See
>>106520829

>You can only reason about the surface level of your code which is fine if you're aim is to be some sort of webdev I guess.
You can reason about everything that you can reason about imperatively written code.
>>
>>106520856
>high level abstractions are easier to reason about.
yeah and then you wonder why your code is slow as shit
and then you want to reason about the TECHNICAL side of your code and the motherfucking chore begins

not to mention you can create your own abstraction
but i guess crabs just cant be trusted with that
>>
>>106520432
>Left has the structure of every language commonly in use to solve the problems in industry.
In pretty much all projects I have worked for in typescript, right one is the preferred one. In projects I lead I enforce that, but I worked in clients where they even had linters that detect common imperative style code that can be converted to functional one.
>>
>>106520878
>yeah and then you wonder why your code is slow as shit
My code is very fast.
If in doubt, benchmark it. That's a good motto to have.
>>
>>106520794
>a compiler that you can actually trust
It’s de facto trust because there’s no language spec. The response to this is that whatever the compiler does, defines the correct behaviour. You either trust it or avoid the language.

Since the types of optimizations applied are probably not documented (do you even know if it optimizes for speed vs space?) not to mention unspecified, I suppose such constructs should be avoided for a lot of systems programming.
>>
>>106520892
>my code is very fast
compared to what? python?

good luck optimizing your code when the abstractions dont map to the assembly
but i guess you never have to do that all you ever write is fizzbuzz
>>
>>106520903
>It’s de facto trust because there’s no language spec
https://rust-lang.github.io/fls/
>>
>>106520906
>compared to what? python?
I usually compare it against C because that's the only language many nocoders here can understand.
>>
>>106520856
>less lines of code
>easier to reason about
Idk man. This >>106520843 reads like a news headline, and I'm new as shit. Everyone's familiarity with the syntax and having learned the sequencing in almost every programming context is going to make your paradigm a hard sell unless you start presenting some major benefits.

Calling people low iq if they don't do what you do isn't a benefit btw. Just in case you needed someone to tell you that.
>>
>>106520917
if you can understand c youre NOT a nocoder, by defiition
also its the fastest around
also also- do you compile your c with -march=native?

i almost never see it on rust vs c benchmarks
>>
>>106520878
>not to mention you can create your own abstraction
If you do this you invalidate all of your schizobabble. As many people mentioned, it's very easy to just ctrl+click Rust stdlib functions and see their code, so there's no difference. You're advocating for doing the same thing, just N times in every codebase instead of one time in the compiler.
>You rely on the compiler to completely change your code for any sort of semblance of performance.
This happens all the time for imperative code as well. If you've never heard of loop autovectorization you shouldn't be posting in this thread.
>>
>>106520912
That’s the Ferrocene Compiler, not the default authoritative Compiler that 99.99% crabs use.
>>
>>106520934
>If you do this you invalidate all of your schizobabble.
how?
(dr the rest im fairly certain is sad homonems)
>>
>>106520928
>Idk man. This >>106520843 reads like a news headline
And it has so many moving parts that you have to really read into every declaration, operation, comparison to deduce the invariants or possible mistakes.
In contrast, functional style reads nearly like English. Iterate over this, filter out this, map this and then sum.

>Calling people low iq if they don't do what you do isn't a benefit btw. Just in case you needed someone to tell you that.
I haven't said anything about IQ.
I don't care about your IQ, I only care about code.
>>
>>106520917
>C
>nocoders
Alright. We've gone off the map here. This is no longer a reasonable discussion.
>>
>>106520948
hes googling what -march=native does for c, kek
>>
Rust hobbyist here.
>for... in
is an Iterator.
so
>for number in numbers
and
> numbers.iter() are indeed the same from the compilers perspective. Rest is probably compiler being slightly clever after lexing.
I'm still not sure if those produce same assembly. Maybe someone will check these (im phoneposting rn). Won't trust Powerpoint slide.
Also these two if-s on the left and two filter calls on the right should be merged.
For two reasons
1) it will be the same and reduce nesting
(Left)
It will be the same and remove redundant call (right)

2) it will be easier to reverse single logical expression than nested if-s or multiple chained calls.

As for styles, I use both. Hate or love it, future is multi-paradigm.
>>
>>106520945
>In contrast, functional style reads nearly like English.
The problem isn’t so much working out what it does (this case is trivial), but that it’s like Lisp where you encourage a style of programming where the programmer doesn’t understand the costs of everything. Maybe the compiler magic does the right thing this month, and the behaviour changes in the next.
>>
>>106520965
>encourages using recursive
>more readable
kek
>>
>>106520960
>[the] future is
Jeet detected.
>>
>>106519142
the only thing confusing here is the . syntax instead of |
>>
>>106520994
You’re missing the point. There’s no confusion about intent. What we don’t know is how the compiler implements it.
>>
>>106520665
See for yourself
https://godbolt.org/z/64cjnKevM
>>
>>106519858
>pass a function with a breakpoint in it
informed
>Or just use print statements like a sane person.
enlightened
>>
>>106521082
i came to the conclusion gdb is pretty much worthless
it provides the same information as printouts
only everything is in hex now
>>
this has been predictably fun.
seeing nocoding/barely coding /g/eets' inability to clock sarcasm and irony is never not funny.
i left multiple sarcastic comments in this thread, and not a single one was clocked. the retards always think their larps are passing lol.
>>
>>106521104
You are so sophisticated and handsome.
>>
>>106518844
Rust is unusable as most of the people who have ever tried it can readily confirm.
>expressive
Except for the endless number of completely normal and correct programs that it doesn't let you express without unsafe blocks or compiler errors, whereas every other programming language ever conceived handles them without a hitch.
>>
File: 1746524433379388.jpg (36 KB, 577x577)
36 KB
36 KB JPG
>>106518844
wtf is |&&x|
>>
File: crab-knife.png (12 KB, 749x750)
12 KB
12 KB PNG
>>106521145
if you squint a little it looks like a crustacean
im fairly certain arthropods were used as a template for the syntax of the language
>>
>>106520965
I can understand why you would have this kind of paranoia in the C world where there's a bare-bones spec that doesn't say anything about optimizations and then a dozen C++ compilers which support C as an afterthought and barely care about supporting the spec anyway.
But in Rust there's zero reason for it. You check the assembly once, see that it works and you can trust it to work, and that's it.
Personally I still prefer imperative style because I find it more readable, but that's just an unreasonable argument that nobody would make unless they have multiple years of being abused by shit C/C++ compilers
>>
>>106520929
Many CS freshman get taught C as their first language but still can't write non trivial programs. That's how you get a nocoder that can read C.

>also also- do you compile your c with -march=native?
I let whoever I am talking to decide on flags they want. I even wrote my own testbed to micro benchmark C, Rust and others performance.

>>106520936
Ferrocene compiler is just rustc.

>>106520948
Wdym?
/g/ is full of people who talk about C without actually programming anything non trivial.

>>106520965
>where you encourage a style of programming where the programmer doesn’t understand the costs of everything.
git gud
It really isn't much harder to value cost of some functional code vs imperative code. You are just struggling with it because you are inexperienced in writing functional code.

As always. If in doubt, benchmark it
>>
>>106521014
well i don't know my compilers (and rust). it probably reads that it's an iterating function, so for every argument it constructs a for case, which's then converted to a goto enclosed assembly. if rust's . syntax is the same as any c-like (i.e. a.b() means b is a member of a), then you get a limited selection of iter() higher order function members, which are naiver loop templates. then the compiler pastes arguments to these higher orders as a code and compiles the result to assembly.
probably.
>>
>>106521014
>What we don’t know is how the compiler implements it.
Pretty much any IDE let's you see inside any standard function.
>>
>>106521173
>see that it works and you can trust it to work, and that's it.
fundamentally incompatible with the usecase for c:
when you want an expressive language because youre rolling out non standard solutions

then you want an asm macro system, not a language that "takes care of everything for you"
no need to have the issue of compiler bonanza
>>
>>106519142
iter() creates an iterator out of the array. It's an object that just maintains a pointer and supports a next() function that increments the pointer. The filter and map functions transform one iterator to another. So you've got like a Map<Filter<Filter<Iterator<T>>>> type think, that every time you do next(), it performs all of these operations. Finally, sum() just loops over the full iterator.

All of this shit gets inlined, which the compiler can then further optimize.
>>
>>106521184
>flags
afaik rust uses the equivalent thereof pretty much by default

what im saying, is that youre benchmarking against c when it fights a hand behind its back
and youre not benchmarking the language but the implementation
but that argument is kinda moot, because what isnt?
>>
>>106521145
It's for dereferencing because the function takes an array by reference and so does iter() so you technically have double indirection. However there is no actual pointer chasing in this example. It could be avoided by using into_iter() or by calling cloned() in the iterator which probably compiles to the same thing but I haven't tried.
>>
>>106521214
>36 000 different ways of doing the same is actually a good thing, chud
more object types = more interaction types = more code, more complexity, more situations for mistakes etc etc

rust is a disaster ergoinomics-wise
its a good example of everything NOT to do
>>
>>106521239
Still an improvement over the state of the art (C++)
>>
>multiple ifs/filters
>mod instead of bitwise operation
>sequentially processing an embarrassingly parallel problem

ugh
>>
>>106518844
I'd use Rust, but I'm not a faggot or a tranny.
>>
>>106521247
improvement? idk. youre close so it would be hard to tell for an external observer
but yeah, i concur
modern sepples is a pile of flaming garbage
>>
If in doubt, check it.

Why do you guys keep doing thinking for the compiler and arguing over what you *think* it will do.
It literally takes 5min to type this to godbolt.
>>
>>106521196
>fundamentally incompatible with the usecase for c:
C is high level language. It does the crazy things you wouldn't expect, just like Rust compilers. Often they use same backend compiler.
>>
>>106521278
>the rust tranny lied
Not the same assembly.
>>
>>106521288
>crazy things you wouldn't expect
such as?

im legit curious, i didnt encounter such a case in ~300 klocs of C
and im doing numbercrunching, so sometimes i use pretty wild shit out there, esp. in relation to memory layouts
>>
>>106518844
>Nachiket Kanore
Shit covered hands detected.
>>
>>106521294
Let's hear you explain the most performance significant differences in these assembly outputs.

I hope you won't humiliate yourself while doing so.

>inb4 no response
>>
>>106521304
See >>106520829
>>
>>106518844
Interesting, the same people calling you nocoder are also saying that the right is more readable than the left.
>>
>>106521288
>backend compiler
what backend does it compile?
>>
>>106521211
>and youre not benchmarking the language but the implementation
I don't benchmark a language. In practice, Rust, C++ and C are all equally fast.
What I'm doing is just proving wrong people who do not realize this.
>>
>>106521320
It is a backend for compilers. Eg LLVM.
>>
>>106521328
so it's a compiler backend
not backend compiler
eslfag
>>
>>106521317
???
i see nothing unexpected, or wild here
i hoped you were gonna show me instances where optimizations break your code
>>
>>106521278
are you using the same compiler?
>>
>>106520665
>without using ai
How many r's are in strawberry?
>>
>>106521346
If an optimization breaks your code then either you invoke undefined behavior or the compiler has a bug.
All I am showing you is that C is a high level language and its compiler does same optimizations that Rust compiler does.

>>106521278
>>106521356
Ah sorry, my bad.
>>
>>106521214
>It's for dereferencing because the function takes an array by reference and so does iter() so you technically have double indirection.
instead of being a specific feature, it is worth pointing out that this is just an example of an irrefutable pattern used in a binding position. it's not something that needs to be independently learned.
// just like how you can do this
struct SomeUnitStruct<T>(T);
let SomeUnitStruct(x) = SomeUnitStruct(5);
// you can do this
let &&x = &&5;

>It could be avoided by using into_iter()
it's a slice. you have no access to owned items. into_iter() would use the blanket impl for iterators.
>or by calling cloned()
*copied()
>>
>>106521184
>non trivial
The example functions square a number. Fucking lol.
>>
>>106521307
I don't see anything in OP's screenshot about "most performance significant differences". It says both produce the same assembly output. What you posted refutes that assertion. Now dilate.
>>
>>106521382
>no explanation
As expected
>>
>>106521366
>All I am showing you is that C is a high level language and its compiler does same optimizations that Rust compiler does.
so youre answering a question i didnt ask

im talking about interfaces
more precisely:
how the example on the right in the op doesnt map to code blocks
and so instead of mapping your code as separate units you have to map it as a big bowl of spaghetti where everything mixes toegether
in the example of the left you can profile each step of the operation separately
thats impossible in the code on the right
>>
>>106521379
>The example functions square a number. Fucking lol.
Yeah. Anything more complex would probably fly right above the heads of majority of contemporary /g/ posters.

>>106520665 is right
>>
>>106521392
Notice how your mental illness causes you to think I need to "explain" how two strings of text are not the same. Just gonna go ahead and add "Rust", "zero-cost" and "memory safe" to the filter now. Also notice how your mental illness causes you to reply again, even though I have already closed and hidden this cancer thread. :^)
>>
>>106521397
>how the example on the right in the op doesnt map to code blocks
Neither does left.

Everything got unrolled and vectorized.
Rust and C are high level languages. They do not map directly to assembly.
>>
>>106521366
>>106521397
(cont)
on another note, you seem to be at least mildly knowledgeable about things-
how does rust manage to take the code on the right and turn it into basically whats on the left?

is it based on idiomatical formulations, or is it some math magic at play?
>>
>>106521405
>no substance
>no explanation
>ad hominem
>projections
The holy cnile's discussion trinity.
>>
>>106521397
>in the example of the left you can profile each step of the operation separately
>thats impossible in the code on the right
lmao
>>
>>106521414
no; they do not
but procedural languages map to code blocks
if you chose the optimal pattern of memory access, youre exceedingly unlikely to have the order thereof to be rearranged
>>
>>106521414
>>106521429
and so theres a logial unit of code with a higher resolution that rusts you can rely on,
because rust has an additional code generation abstraction layer on top of it

c is better than rust at this
you wont equate them both despite your best efforts
>>
>>106518844
I don't understand the desire to abstract readable code to this level of unreadable bullshit.
>>
>>106519184
What if I want to filter an or condition
>>
>>106521416
>how does rust manage to take the code on the right and turn it into basically whats on the left?
It's literally just monomorphization and function inlining of the most basic kind.

sum is just fold with Add::add as the reducer, fold is just for(while let):
        let mut accum = init;
while let Some(x) = self.next() {
accum = f(accum, x);
}
accum

Looks similiar? It's taken from stdlib. f here is the Add::add, self.next is just the map+filter+filter+iter stack that just transform or skip values from iter. When you untangle it all you get very similar code except there is bunch of lambdas out there. But these lambdas are just free functions and Rust compiler can inline them all and in the end you get pretty much same code with only artificial syntactic differences.
>>
>>106521429
>but procedural languages map to code blocks
Not really. All this code got unrolled and vectorized to the point it hardly reassembles the original code structure.

>>106521436
>c is better than rust at this
Post your C code and we will benchmark it.
>>
>>106519162
This. They probably also don't have a job.
>>
>>106521471
eh, youre exaggerating
youre just looking at it from the lens of c
youre not working based on code blocks, youre working based on procedures

in a c usecase that sucks balls
but from a high level perspective i can very well see this is as comfy

im not discussing the &&x retardation
im just giving my opinion on the idea as a whole, not how it was implemented

think of the concept as:
youre not writing code per se, youre instructing the compiler what to compile
>>
>>106521499
Yeah but I'm thinking on this from the perspective of this shit broke production and now I need to debug it but every step of the loop is abstracted away and I can't attach to anything.
>>
>>106521497
>All this code got unrolled and vectorized to the point it hardly reassembles the original code structure.
youre still missing the point
>>106521499

>Post your C code and we will benchmark it.
i dont have the time for a code-out rn
i got stuff to do
but feel free to make a code duel thread
or post a subject ITT
in ~3 hours i should have time for that
prolly sooner
>>
>>106521499
>im not discussing the &&x retardation
It's literally same thing as **argv
Nothing retarded about this, just pointers being pointers.
>>
>>106521517
yeah forget about it then lamao
im assuming that rust works as advertised
>>
>>106521517
>Yeah but I'm thinking on this from the perspective of this shit broke production and now I need to debug it but every step of the loop is abstracted away and I can't attach to anything.
Example?
I never had any problems setting breakpoints inside callbacks.
>>
>>106521529
ah ok, i take that back
but still, this shows the attitude one has towards rusts symbols
>its retarded, by default, i dont even need to know what it does
>>
>>106521534
Dangerous assumption
>>
Rust is all about expressiveness. That's why they have abbreviations all over the place like function -> fn, it's really expressive AND it saves those precious few bytes.
>>
>>106518844
>Right side
>Everything named X
You should be Xecuted for that alone.
>>
>>106521551
kek. true
>>
>>106521561
Since when Rust guarantees correctness of cryptographic implementations?
These bugs have nothing to do with Rust semantics.
>>
>>106521575
its a breakdown of the ownership and/or lifetime model as i understand it
>inb4 b-but its because its in an unsafe block
and?
still part of rust. which is not a memory safe language
>>
>>106521605
This has nothing to do with lifetimes from what it looks like. More like just forgetting to clear buffers, nothing related to Rust semantics.
>>
File: 1741186441163520.png (152 KB, 1155x1101)
152 KB
152 KB PNG
>>106521561
>fixed in 0.4.3
>0.10.3 contains a fix
>>
>>106521683
if data gets out of scope then it shouldnt be available anymore, does it?
and a buffer that belongs to a decrypt function shouldnt be available to error handling, should it?

again, feel free to correct me if im wrong
( i havent been very attentive) but thats how i understand this shit

>>106521686
i dont quite understand what you mean

---

anyhoo, gtg
ill be back later
i wont reposd immediately but i will respond in max 2hrs. i think
>>
https://github.com/RustCrypto/AEADs/commit/d1d749ba57e38e65b0e037cd744d0b17f7254037
Yup, it's literally just forgetting to clear buffer.
Nothing related to lifetimes or ownership.

>>106521740
>if data gets out of scope then it shouldnt be available anymore, does it?
What are you talking about?
The function was literally called *_in_place, there was nothing going out of scope here. Also when doing cryptography you often clear buffers with sensitive buffers even after freeing them so sensitive data don't persist in allocated memory.
Have you even looked into the code you are talking about?
>>
>>106521764
>buffers with sensitive buffers
buffers with sensitive data*

>don't persist in allocated memory
deallocated/reallocated*
>>
>>106521764
stop engaging seriously with jeet llms. just laugh at them or feed them sarcastic takes they will happily train on.
their retardation must stay clear (not that this is in danger).
>>
>>106520665
They generate same assembly because rather than naively doing the operation of each layer they delegate it upwards to underlying iterators.
>>
>>106521764
>there was nothing going out of scope here
did you even read the stuff?
actually
i think its just plain dishonesty bc you looked at the second cve and skipped t he first one entirely

>tag verification causes an error to be returned with the plaintext contents still in buffer
why the fuck do you end up with a buffer being exposed in error management?
error returns a buffer with plaintext.
like, fucking why?

however you look at it, its baaaaaaad
>>
File: file.png (132 KB, 1053x1031)
132 KB
132 KB PNG
>>106519698
>>106520665
>>106521972
>>106521014
>>106521416
This is basically how it gets optimized by inlining
>>
>>106521764
>>106522119
or maybe i misunderstand something
in any case its what the fuck
if its a bzezro problem
then its a fukken bzero problem

lifetimes, ownership, or just plain fucking retardation that wasnt caught by rusts' bellos and whistles

could be solved with a fucking arena.
go out of scope? nuke everything associated with it. done
>>
>>106522121
pretty nifty to be completely honest
i dont want this in my code, but i can see very well the appeal

but again, this hinges on the fact that everything behind the abstractions is correct
if its not, youre in debugging hell
>>
>>106522119
>did you even read the stuff?
Yeah I did. The issue was that they did not clear the buffer. The fix was to clear the buffer. A buffer that was passed by reference therefore it did not go out of scope, hence in_place function suffix.
No idea why are you still trying to argue it's something else. Everyone can click and read this 10 loc commit for themselves.
>>
>>106522146
>trying to argue it's something else
thats a strawman

im just having low standards bc its 4chan and the fastest way on the internet is to be wrong

but still: new argument: rust is not a silver bullet and necessitates careful consideration whther its worth it to adopt it into your toolchain
>>
>>106522160
>>trying to argue it's something else
>thats a strawman
I know
>>
>fastest way on the internet is to be wrong
fastest way TO LEARN on the internet is to be wrong
(theres always someone who will tell you exactly how, by how much, and why youre wrong + provide a detailed explanation of the thing youre wrong about)
>>
>>106522163
strawmen are gay tho
being wrong and not giving a fuck is one thing
but youre skirting the limits of decency with strawmen
>>
>>106522139
>but again, this hinges on the fact that everything behind the abstractions is correct
Boomers can't imagine using a tool that they can trust. Their whole life they had to work with shit compilers, shit languages, shit platforms and operating systems, shit graphics libraries. Everything they ever made was dangerously balanced on top of a pile of shit tools that could collapse at any minute.
This is the real revolution that Rust started: the concept of tools that work the way they should, without being an expert on inane edge cases or configuration hell.
But to be fair it's not really about Rust, all the newer languages like Zig also had no problem figuring this out. It really is a generational thing: the revolution will only be complete when the last boomer retires.
>>
>>106522196
>Boomers can't imagine using a tool that they can trust.
its not a boomer thing
its basic due diligence
and i can trust c.
in 300 klocs it didnt fuck me over once despite the fact ive been doing ubs bc i just cant be arsed to give a fuck
if you know what youre doing you dont need to care about ubs, apparently
>>
>>106520665
>KYS retard. It should be obvious to anyone who isn't a nocoder, even past syntax.

True.

>Those obviously mean the same thing, but the functional approach is simpler to read as the logic reads as if it was processing everything at once rather than one element at a time.

Based.

But I still hate rust.
>>
>>106520816
>agreed. compiled languages were created to do things manually. and with good languages, we all can just compile code bases accurately in our heads with great accuracy, down to the specific unrolled loops and SIMD optimizations

based sarcasm
>>
>>106518844
no. that's why Rust is objectively winning.
>>
>>106520941
>things I don't understand are ad homonem
wtf is with the quality of posters ITT?
>>
>>106519752
Rust is a shit language full of underwhelming and garbage buggy libraries (but at least its memory safe). Every time I go on some programming Discord, and ask about what library is recommended for problem domain X, invariably some Rustoid will come out of the woodwork and suggest a Rust lib. After I begin researching it, I'll find a ton of GH issues how said Rust library is buggy and sucky, and would-be users being gaslit by these superior-acting Rust people.

>>106518998
Nobody with a three digit IQ has problems grasping iterators, the problem with right isn't that it's different, but that it's not better.
>>
>>106522356
no, its the pr you developed
i still drtr but theres 99.9% chances everything past the first phrase is an ad hominem, when talking with a crab
>>
>>106522362
>After I begin researching it, I'll find a ton of GH issues how said Rust library is buggy and sucky
so, just like every other free and open source repository with more than 1000 GH stars?
>>
>>106522356
I don't believe it's real person, it must be some artificial stupidity.
>>
>>106522196
>What of the future? It is a matter of some concern to Real Programmers that the latest generation of computer programmers are not being brought up with the same outlook on life as their elders. Many of them have never seen a computer with a front panel. Hardly anyone graduating from school these days can do hex arithmetic without a calculator. College graduates these days are soft -- protected from the realities of programming by source level debuggers, text editors that count parentheses, and user friendly operating systems. Worst of all, some of these alleged computer scientists manage to get degrees without ever learning FORTRAN! Are we destined to become an industry of Unix hackers and PASCAL programmers?
This time for sure you're going to turn us all into quiche eating pascal programmers
>>
>>106522417
this c ould be interpreteed as im the ai (the c-ultist)
or the crab is ai

lehrn to spekk, negroid
>>
File: Wheatley_model_p2.png (191 KB, 360x345)
191 KB
191 KB PNG
They designed him to be the Weathley for the C programming language.
>>
>>106522121
Interesting.
>>
>>106522196
when I first started using Rust, my knees were shaking and I was forced to kneel.
cargo just works.
rust-analyzer literally, just works (unlike any other LSP I used)
rustup, just works.
probably the only thing that doesn't just work out of the box is cross compiling and cross-rs containers cover that usecase well enough I don't care so much.
>>
>>106522491
>when I first started using Rust, my knees were shaking and I was forced to kneel.
sounds like the intro to a perfectly average erotic fanfic
>>
>>106522515
all these things are true though. they're even true on Windows, not just Linux, which was mind blowing to me.
>>
File: ukaki2.png (15 KB, 400x400)
15 KB
15 KB PNG
>>106522525
anon
a language is supposed to be system agnostic

its like you were to give an ethnicity to producing fire
>>
>>106522546
ok, that's great, so why is Rust the only one that actually is in practice?
even go makes assumptions everything is POSIXy, even on Windows.
>>
>>106519242
and its a royal pain in the ass to use, because the language isn't expressive
>>
File: oekaki2.png (35 KB, 400x400)
35 KB
35 KB PNG
>>106522560
nono
youre talking about
>system specificities being abstracted away
and, ackshually, vanilla c does that too
its just that m$ft doesnt play ball
>>
>>106522572
huh? show me installing a full blown IDE-like C experience that works on both Windows and Linux?
You literally can't.
Rust can.
rustup works on both Linux and Windows.
>>
>>106522560
>>106522572
if we go into the autism of things this is a thing rust does right

instead of imposing interfaces to os makers
just fucking shim em
everything works on the same principles anyways
>>
File: oekaki.png (16 KB, 400x400)
16 KB
16 KB PNG
>>106522580
>IDE-like C experience that works on both Windows and Linux?
thats an ide problem
and i dont give a fuck abt corpotrash jeet nigger cocksuckers

all i care about is whats written on the bawx
and whats in said bawx

idiomatic c and rust are equal on that point
thats what the whole """"impredictability"""" of ubs on c is abooot
not so unpredictable when you understand that the nr 1 logic behind that is portability
>>
>not so unpredictable when you understand that the nr 1 logic behind that is portability
just fukken hyperspace your brain dood
how so youre limited to 3d or even 2d thinking?
you cant consider teh thesis and antithesis at onece?
get the fuck outta here even 60 iq niggers from africa can do that
>>
>>106522580
i use vscode + clangd on linux and windows and it just works
pretty much anything that uses llvm as a backend just works
>>
>>106522612
cont
this is a priori thinking
even fucking animals can do that
>>
>>106522601
ok, so you can't. got it.
>>106522613
clangd requires you use a build system that can generate compile_commands.json and can't even expand cpp correctly sometimes.
plus you don't have a package manager or formatter either. you're being disingenuous
>>
File: oekaki4.png (17 KB, 400x400)
17 KB
17 KB PNG
>>106522641
>ok, so you can't. got it.
my c is not portable in the slightest
keep fishing, faggot
>>
>>106522655
what is this avatar faggot even saying? see >>106522546
specifically:
>a language is supposed to be system agnostic

and yet you contradict yourself like a dumb nigger.
>>
>>106519752
define guarantee memory safe
https://youtu.be/jIZpKpLCOiU?feature=shared&t=1058
>>
File: fast-boi.png (56 KB, 331x679)
56 KB
56 KB PNG
>>106522655
(cont)
(just to wave muh humongous dick around...)
(also bc i dont remember whats the idiomatic way of saying to the compiler i want that, C mastering, anon, i summon thy)
>>
>>106522641
>clangd requires you use a build system that can generate compile_commands.json
doesn't have to come from your build system at all. also you don't even need it, just configure your fallback flags.
>and can't even expand cpp correctly sometimes.
you said c, now you're going to move the goal posts?
>plus you don't have a package manager
i don't care
>formatter
one came with the plugin i use. i don't use it though.
>you're being disingenuous
yeah, i'm the one being disingenuous kek
>>
>>106522684
not avatarfag
just oc
and you cant even look into the brightness of my radiance
and t hats why you want to talk in shadows

perish, skom
becausetyhereforehencesomething
thou art inferior
>>
>>106522690
>fast_double_generalized_get_period
in rust, this is just:
muh_str.find('.')
>>
>>106522698
>doesn't have to come from your build system at all
unless you have like 3 source files, it most certainly does.
>inb4 just use bear
didn't bother reading the rest. you're lying to people.
>>
>>106522709
no, it isnt
im 3x faster than the the libc equivalent when benchmarking against atoi
but also thats bc this code assumes string are terminated with 8 0's

>myh rust is 5% faster
nice
you only have 295% to go
>>
>>106522698
>>>and can't even expand cpp correctly sometimes.
>>you said c, now you're going to move the goal posts?
>he doesn't know what cpp is.
power of C amateurs.
>>
>>106522709
>>106522725
>295
195
bc im the unit, BITCH
>>
>>106522730
>sade homonem in lieu of technical argumentation
such is the power of rust

keep seething
this pleases me. this is suitable.
>>
>>106522699
actual schizo retard. wtf kek?
>>
>>106522752
if you don't know what "cpp" means in relation to C, you literally do not know C. it's that simple. there is zero reason to even talk to anyone about anything C related who doesn't know this.

kys amateur.
>>
>>106522755
no, its just that youre too slow when compared to me, only drunk
frensly advice: just go back to r*ddit
youre too slow
>>
>>106522580
clion

>>106522641
>clangd requires you use a build system that can generate compile_commands.json
and rust analyzer requires you to generate rust-project.json if you're not using cargo. god forbid.
>>
>>106522699
>not avatarfag
>13. Do not use avatars or attach signatures to your posts.
https://www.4chan.org/rules

avatarfag doesn't mean it can't be OC, your statement is illogical
>>
>>106522775
>clangd requires you use a build system that can generate compile_commands.json
>and rust analyzer requires you to generate rust-project.json if you're not using cargo. god forbid.
gcc c doesnt have this problem

why do programmers constantly try to make their lives harder than they need to be?
>>
>>106522775
>clion
depends on clangd or using a build system that generates compile_commands.json
it doesn't install a toolchain for you other than the related tools it ships with.
>>
>>106522400
No, its different.
I had some experience with the Rapier physics engine, which suffered from perf issues, physics stability issues, random crashes, despite it being shilled everywhere as being better than (Bullet/Jolt) because it's written in Rust(TM) and so the compiler ensures it cannot possibly have bugs
>>
>>106522780
>avatarfag doesn't mean it can't be OC, your statement is illogical
its true
but these picrel appear on something on the order of 0.1% of my posts

therefore its hardely avatarfagging
and youre now liable for bad report classification
AND
announcing a report

do you wanna go that way?
yes or no?
>>
>>106522787
>gcc c doesnt have this problem
gcc ecosystem doesn't even have a workable LSP or basic libraries like libclang to generate and manipulate C ASTs.
>>
>>106522807
i dont know what any of that means
all i know is that gcc gives me actual zero cost abstractions with force inlines
and thats all i fukken need bc i want my code to fukken do what its told to
>>
>>106522804
I did not report
I did not announce report, I reminded you it is against the rules
stop making shit up

>>106522321
this you?
The rule doesn't "make sure your avatarfagging is less than some arbitrary % of your post" or "hardly avatar posting is ok"
Stop making shit up
>>
>>106522822
>stop making shit up
that was a question wasnt it?
and you answered, and as such, i didnt escalate things further

bc i hate being a snitch, too
>>
>>106522730
yes i know that's the name of c's preprocessor. why would you assume otherwise?
you should know that it's obviously ambiguous, and if we're at the point to where you're intentionally laying semantic ambiguities in lieu of substance, then i think we're done here.
>>
>>106522789
>depends on clangd or using a build system that generates compile_commands.json
Rust analyzer requires rust-project.json
>it doesn't install a toolchain for you other than the related tools it ships with.
Because it's the IDE. What IDE does rustup install? For me, I just typed clang in the start menu and clicked install and it just worked.
>>
is there enough memory locket to unlock every slot for every crest?
>>
>>106523236
idk but i like women with with ass and big tits
especially when they wear bunny ears accessories
>>
>>106523625
cont
also thread theme
https://www.youtube.com/watch?v=y85SnFs4LqQ
>>
This fucking gay thread is still going?

What is it now, the most autistic c guy vs the least passing rust transexxual battling like karate fighters about something unrelated to the original timesink fight?
>>
>>106523668
yes, but only to t he untrained eye
were actually testing the limits of our knowledge
feel free to hide this thread
>>
we were supposed to do a code duel btw
CRABS, post subject
then we post code, each

im dronk now but if crabs dont show skill
then they should shut the fuck up forevermore
>inb4 dats not canonical c
fuck you
my code will be gcc based
if you dont have it... youre running m$ft
>>
File: nocodeshitters.png (45 KB, 193x343)
45 KB
45 KB PNG
fukken crabs
all talk,
no code
fukken farm animals from r*ddit
>>
>what if a drunken boi, but passionate about what he does beats rust
thats what prevents oldcrabs from posting btw
theres 25% chance but apparently what we say- matters
lamao
BRING IT ONNN
give subject faggots
lets code it out
>>
>>106522362
>I go on some programming Discord
>three digit IQ
mutex lock
>>
File: luigi.jpg (44 KB, 901x861)
44 KB
44 KB JPG
>>106523959
mutex = giving up on things
and thats a pro tip
>>
(yeah in 99% of cases you can reformulate the problem to be thread count agnostic)
>>
>>106522690
what does that function do?
>>
>>106518844
I will just post this again.
https://www.youtube.com/watch?v=B2BFbs0DJzw
>>
>>106524048
find any char that isnt conformant with expectations, just in an asynchronous manner
so as to make it easier for the cpu to maximize ILP
bc its async hronous with a couple fences (aka plces where computation synchronizes. gpgpu term, but its the best one i know)
>>
>>106524075
what expectations?
>>
>>106524048
>find any char that isnt conformant with expectations, just in an asynchronous manner
it takes chars 8 by 8
it maximizes the throughput up to 64 bit architecture without calling on arch intrinsics
theres alot of thought that wend into it
kinda redundant bc theres an idiomatic way to force the same
its just that i say that in an explicit manner
>>
>>106524109
any pattern of 8 chars
the unit that data gets parsed based on
im drunk, going to sleep
dont expect swift replies
>>
btw
strictly inferior to doing that with avx tier intrinsics
its just that it maximizes bus width based in the architecture
liken portably
and without ifdefs and other, related shit
>>
>>106524174
https://docs.rs/memchr/latest/memchr/memmem/struct.Finder.html

spend your time doing actually useful stuff (doesn't matter in what language), then learn optimizations later. ^ this ^ is readily available and widely used where it matters in the rust ecosystem. you are only winning games you're playing with yourself.. which is fine, as long as you're fully self-aware.
>>
>>106523959
As opposed to /g/ well known gathering place of intelligent, productive and successful programmers.
>>
File: file.png (2.14 MB, 1834x1005)
2.14 MB
2.14 MB PNG
>>106524067
Daily reminder that this is how his game looked after approximately 300 hours of full time-programming streams.
>>
Left is perfectly readable.
The benefits of functional languages aren't short map reduces like that, it's not having global state or state that's shared by multiple objects at least.
People always focus on the syntax of those toy examples, just use imperative code inside a function and make the function itself pure if you can.
>>
>>106524067
>>106524612
Why is he micro optimizing so early in development kek
Just make the game first. You can find hot loops later.
>>
>>106518844
Rust syntax is disgusting so I’ll never use it
>>
>>106524612
>300 hours of full time-programming
In the early episodes he spends most of his time explaining things and going on educational tangents. If you want to make game fast just use Unity or whatever. Everyone knows making your own engine with 0 libraries is not the way to do that.
>>
>>106524738
Because it's an educational stream about low level programming. It's not really about making a game, that's just dressing on top. Casey refuses to do any real game design because he's still traumatized from that one time he spent 3 years making a game before realizing it's not fun.
>>
>>106524582
>false dilemma
that's a lot of locking
>>
>>106522655
>>106522601
>>106522572
>>106522546
avatarfagging is against the rules. pls cease and desist immediately.
>>
>>106522121
Interesting, thanks for the information.
>>
>>106518844
rust is for troons and faggots



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