Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
retoor71041d@Liebranca I made my first Rust app yesterday 😕 It works very good 😕 It didn't contain any bug 😕 It wasn't much source 😕 One single sharable binary 😕
But based on what I've seen like if Some ().. C'mon what's next, no cap fr fr are probably functions too. Fr fr -
@retoor It's pattern matching. `if let Some(foo) = maybe_foo {}` matches maybe_foo against Some(foo). E.g. if it's the Some variant it binds the contents to foo
-
retoor71041d@12bitfloat normal devs call that truthy. Any more of such 'new inventions'? But thanks for the help on that yesterday.
-
@retoor It's not truthy because you're extracing values
You can also match against `Some(Some(foo))` or
`MyCoolEnum::VariantA(...)` or even `MyStruct { a: 20, .. }`. The latter only matches when the field is 20 -
@retoor That only works for null (and empty strings I guess)
Here's a cool way to do fizzbuzz using pattern matching
https://play.rust-lang.org//...
Can't do that without pattern matching :P -
retoor71041d@12bitfloat no, why would you :p But did you make that for me? 😍 Aww. I'm really annoyed by not the "%s" in that code tho.
-
@retoor What am I looking at 💀 Most readable C code lol
How does that even work? I thought the format string has to be a literal? 🤔 -
retoor71041d@12bitfloat huh indeed, is that thihg now calling always with the int patam while not having it defined in the first argument? Wtf indeed. But idea is solid.
-
@retoor Huh, it actually works https://godbolt.org/
You learn something new every day :D
Unused params in vararg functions should be fine I think -
@retoor Last I tried rustc it didn't likit when I `};`'d all over her face and tits, which ruined the mood for me.
Anyway, it's C++ but worse. Perhaps there's an octopusdog inside all of us. -
retoor710419h@Liebranca I decided to do a small project to do with it. I made project generation AI software. I'm creating that for the rust project. Can't stand the syntax. I'm worried that it's something like react. Something you learn so much weird shit for that you end up with a stockholm syndrome. Do programmers realize that the syntax is to benefit user, not the machine? This is why I consider python one of the best languages ever made and Rudy maybe one of the worst. A new language that is hard... Not very attractive. Compiling it ain't a joke either.
-
Liebranca123517h@retoor rust, specifically, suffers from it's syntax primarily.
I say 'specifically' because any compiler that gives you a high number of features/guarantees is inevitably going to result in the language itself requiring the programmer learn many more concepts to utilize it effectively, to say nothing of the striking increases in compilation time.
But this is true for *many* languages other than C++ and rust, it's a problem inherent to high-level programming in and of itself, in that you're stacking complexity, which leads to the 'befuddling' quality of code -- ie, there's too much shit to keep in your head to fully understand how anything at all works without mind-altering, preferably injectable drugs.
rust syntax, had it learned lessons from the innumerable syntactical idiocies of C++, would be a lot better off. However, the language leans on and propagates said intellectual failures of humanity, resulting in its decisive failure to fulfil the promise of replacing C and C++. -
12bitfloat1058816h@Liebranca tf are you talking about. Rust did learn from c++, thats why it doesnt look outdated with 5 different ways of doing the same thing
-
12bitfloat1058814h@retoor They are all different for different usecases. Remember, Rust is a systems lang!
str -> std::string_view
String -> std::string with utf8 guarentee
OsStr/OsString -> no utf8 guarentee because filenames/envvars might not be utf8
CStr/CString -> no interior null bytes and are null terminated for C interop -
12bitfloat1058811h@retoor Makes sense. The other types are only useful in certain areas (e.g. dealing with the os, like paths)
-
@12bitfloat Pardon, you did not learn how to read.
"[rust syntax], had it learned lessons from the innumerable syntactical idiocies of C++, would be a lot better off."
7mar. -
@Liebranca Please enlighten me what syntax Rust has taken from C++ instead of learning from it
Because the answer is literally nothing. Rust doesn't look like C++ at all nor does it have the syntactical issues that C++ has. For starters, Rust's syntax is context free -
@Liebranca I think you're just a retarded hater with no actual arguments, which isn't surprising considering you likely have never written 10 lines of rust code
Of course you don't like it. You have zero clue how it works or what it does -
@Liebranca Also, bro, 75% of your github projects are C++ and Perl. Fucking perl of all things. And this man is criticising syntax
...yeah okay. Guess we just have *very* different preferences ;P -
@Liebranca Which is good because they have horrible syntax, none of which landed in Rust
Gimme an example of bad rust syntax and what your critique of it is -
@12bitfloat
macro_rules! forward {
( $( $fn:ident( $($param:ident: $ty:ty),* ) $( -> $ret:ty)? ),+ $(,)? ) => {
impl Build {
$( fn $fn(&self, $($param: $ty),* ) $( -> $ret)? {
self.config.$fn( $($param),* )
} )+
}
}
}
src: https://github.com/rust-lang/rust/...
Critique: It's shit.
Another question? -
@Liebranca Declarative macros is such a copout answer. Nobody writes them on a daily basis and they barely even qualify as "Rust syntax" (more like a preprocessor)
Even then, tell me how to improve it. How would a Liebranca approved declarative macro system look like, that has the same power as Rust's current syntax?
Let me have a guess, it'll look pretty much the same because that's just how declarative macros work -
@Liebranca Oh yeah and how is that in any way related to C++?
It's a feature C++ doesn't even have, and the only thing you could criticise. Hundreds of thousands of lines of Rust code: ifs, whiles, structs, traits and you couldn't find one example there to criticise....
Wonder why -
@retoor You can't really use utf8 for paths because on windows paths might be in some weird codepage or utf16 and on linux paths can contain any byte except nul
For most stuff storing paths as utf8 is fine, but Rust is meant for robust systems development. They don't want to lie to you and give you a wrong abstraction, so they force you to deal with it
Imagine writing the `ls` util in rust and somebody creates a file with a non-utf8 path. Now you can't list files in the terminal anymore because it crashes.... fun times :P -
retoor71045h@12bitfloat I do not agree it's worth a data type. Could've been just a function. It's a total mistake imho. What's next, emailaddressstring. It's really really, stupid.
-
@retoor String is guarenteed utf8 because it makes everything easier. You can't use utf8 for paths
It's really that easy. Other languages will silently fail if you have weird paths. Rust is made for robust programs, not silly scripts -
retoor71044h@12bitfloat no, it's just bad. It's really, really bad. Should've been just a function safe_path or something. If you don't see that..
-
@retoor Different strokes for different folks :P
Rust is a serious lang for serious programs. Safety isn't optional, it's required
But I can see you're getting frustrated. That's pretty normal when learning rust. I was cursing rust in the first few weeks too -
@retoor To expand on why it's good to have different types: Rust has this idea of safety by design (or construction? don't remember)
If you hold a type T, it IS a valid T. It can never be in a bad state. Like in C when you declare a variable without initialising it, it has undefined contents. In Rust that's impossible. Same with references: If you hold a &T then you are guarenteed to hold a reference to a valid and existing T
This is very powerful because it makes certain properties be enforced at compile time. You can't accidentally have a string that isn't utf8 which will then fail in weird ways at runtime. Or a path which accidentally contains weird symbols you weren't expecting
It makes your code more robust by pushing these errors from runtime to compile time. Rust forces the programmer to deal with these intricacies instead of pretending they don't exist -
retoor71043h@12bitfloat python also just use it's utf8 string for paths... I really thing it's a design flaw and it should be a function to format a path. It's overengineered to make it a type. Just plain stupid.
-
@retoor Python is designed to be easy and fast to program, not to be rigorous and robust. Which is fine! I like python but Rust just has a different mindset
Python strings are btw a little more complex than just utf8 (if I remember correctly)
But okay, now you code a script in python and somebody with a really weird setup wants to use it. And they can't because their paths contain non-utf8 sequences. Python will just crash or silently do the wrong thing
That's fine for the 95% case but Rust is designed for the 99.9999% case
Consider,
```
namespace A;
macro m00 a,b;
··display a,b;
end macro;
macro m01 a;
··m00 a,$0A;
end macro;
m01 $24;
end namespace;
```
OUT: $0A24 ("$\n").
Ah, but you just HAD to fuck me in the ass, didncha fasm2? Initializing anal bleeding:
```
namespace B;
A.m01 $24;
end namespace;
```
OUT: illegal instruction 'm00'.
Explanation: macros carry no context, and so 'm00' is unreachable from 'B' namespace.
Could I maybe write a code-capture macro to generate a wrapper that resets the namespace? Yes, and in fact, I did; brilliant exercise in mystical mindfuckery.
But why try so hard? Just pass the fucking ref, like a MAN.
EXPLICIT CTX, BITCH.
```
define @CAS $non; current addressing space
define %ICE @CAS;
macro self:PA&; recursive macro, uuuh spooky-spooky
··match ice , %ICE;
····; self->proc(args)
····match =-=> proc (args) , PA;
······path.proc ice,args; pass ref and args
····; ^self->proc()
····else match =-=> proc () , PA;
······path.proc ice; pass ref only
····; ^sneaky sneaky. set current context when self ctx;
····else match cas , @CAS;
······%ICE equ cas.PA;
····end match;
··end match;
end macro;
```
ALL TOGETHER NOW
```
namespace A;
macro m00 ice,a,b;
··display a,b;
end macro;
macro m01 ice,a;
··self->m00(a,$0A); could also be 'ice.m00 ice,a,$0A' lmao
end macro;
end namespace;
namespace B;
self A; set ice
self->m01($24);
restore %ICE; back to previous
end namespace;
```
OUT: $0A24 ("$\n").
A-há, now **I** got you from behind motherfucker!
Final note: this is 100% perl DNA seeping through the cracks of my sanity and into a fresh fasm2 framework. Why? Dingle-dongle-jungle-berries, that's why. Also crack.
Have a nice wallop.
rant
recursive virtual constexpr sodomy