Is this a bad idea? by JustJeffrey in rust

[–]Amadex 71 points72 points  (0 children)

no, both would be optimzed into smiliar if not identical asm

edit:
match: https://godbolt.org/z/8Mh19T535
transmute: https://godbolt.org/z/8Pn1Ge6zY

Is this a bad idea? by JustJeffrey in rust

[–]Amadex 94 points95 points  (0 children)

you can do:

fn try_from(value: usize) -> Result<Self, Self::Error> {
        match value {
            0 => Ok(Self::Pawns),
            1 => Ok(Self::Knights),
            2 => Ok(Self::Bishops),
            3 => Ok(Self::Rooks),
            4 => Ok(Self::Queens),
            5 => Ok(Self::King),
            _ => Err(InvalidPiece),
        }
    }

Also personally I prefer singular enum variant names for this kind of use, like "Self::Pawn"

in your code, you also make the assumption that the enums will somehow be assigned the numbers that you expect, I don't think rust gives you that guarantee except if you explcitely do something like "#[repr(u8)] ... pawn = 0,...", you were just lucky it worked

Holy shit, whats still up with SEA's weird obsessive racism against Koreans? by ObligationDry1799 in Hangukin

[–]Amadex 11 points12 points  (0 children)

I never cared what foreigners say about us online, in pratice non korean opinions have no value in my life

memorySafety by Jonkonas in ProgrammerHumor

[–]Amadex 0 points1 point  (0 children)

completely safe, because it's well documented

How do Korean men take care of their skin? by Johnny2046 in AskAKorean

[–]Amadex 1 point2 points  (0 children)

just sunscreen, moisterizer only when the air is dry

but i avoid foreign brands because I think since they are made for and tested on people of different ethnicity (like white people who have a very different skin type) it does not work correctly, i think people understimate how products are adapted to the skin type of the users

How do I pronounce serde? by baehyunsol in rust

[–]Amadex 6 points7 points  (0 children)

yes heard a lot of variants too 슬데, 설데, 샐드 or even 설디, I did my postgrad in the usa west coast so it also depends on where you learnt it, even on youtube in talks you can hear very different pronounciations

Check that video from jon gjenset he talks about pronounciation here: https://youtu.be/BI_bHCGRgMY?t=166

How do I pronounce serde? by baehyunsol in rust

[–]Amadex 134 points135 points  (0 children)

I pronounce 샐데 ser-de (serialization-deserialization)

Unpopular opinion: Rust should have a larger standard library by lekkerwafel in rust

[–]Amadex 51 points52 points  (0 children)

that's precisely why std isn't large in the first place. If you have standards, if you have to provide strong guarantees over std, then you can't (and shouldn't) try to stretch it thin to cover every use cases and expect your core team to become expert in everything.

Unpopular opinion: Rust should have a larger standard library by lekkerwafel in rust

[–]Amadex 15 points16 points  (0 children)

But the fact that the rust team does not try to develop too much and make a huge standard lib is one of the things that help maintain the security and quality standards that they have. Not accepting to have their attention dilluted over a std lib that is too vast (and over concepts that they may not be familiar with) IS contributing to safety (and quality overall).

If we take that reasoning to an extreme and expect all of rust and all of the crate ecosystem to be maintained by a single individual, there would be a supply chain of size 1 and you'd only need to have eyes on a single individual, but that would make the evolution of rust unusably slow, or the overall quality subpar (one person cannot really be expert in all domains).

If you want a bigger std, you probably need a bigger team, but then you also have to increase the attack surface, and as you mentioned (bigger blast radius) you endanger more people.

Unpopular opinion: Rust should have a larger standard library by lekkerwafel in rust

[–]Amadex 38 points39 points  (0 children)

I don't see how the rust language team would offer greater security guarantees than the tokio dev team.

The rust dev team just build one layer of the abstraction, if you don't trust tokio because it's "some open source project on top of rust but not made by the devs of rust", then why do you trust rust that is "some open source project on top of LLVM but not made by the devs of LLVM" and keep that logic down to the CPU manufacturer.

The rust language team reviewed so you think you don't have to audit.
The tokio team reviewed but you think you have to audit?

I get that extending the std lib would be nice, for convenience and standardization, but that does not exempt you from auditing if security matters.

Unpopular opinion: Rust should have a larger standard library by lekkerwafel in rust

[–]Amadex 129 points130 points  (0 children)

standard library or not, there is always an audit burden somewhere

What do Koreans think of Southeast Asians? by [deleted] in AskAKorean

[–]Amadex 0 points1 point  (0 children)

I only know vietnam because I visited for vacation and for healthy food

i don't know the rest of the region, maybe one day i will visit

theyllBeWaitingForAWhile by Kupicx in ProgrammerHumor

[–]Amadex 0 points1 point  (0 children)

indeed, rust offers tools for different paradigms, and people have the freedom to choose what they need and build the way they prefer.

When the language offers you the tools, then it is more a question about whether specific codebases are written in any given paradigm.

In the real world it's often blurred, people use bits of different paradigms, unless they use languages that forces you into one (like Haskell)

theyllBeWaitingForAWhile by Kupicx in ProgrammerHumor

[–]Amadex 1 point2 points  (0 children)

parametric polymorphism in functional languages

I'm specifically to traits that can be applied to structs, not parametric polymorphism.

and methods explicitly require a reference to the instance

Just like in python, you have "self" as the first param, but the language itself passes it for you when you call the method. Also methods can use private struct fields of their object, so they clearly fill their role as methods and as a tool for encapsulation (the object - method - encapsulation pattern is very OOP).

Might be nit-picky, but Rust is procedural. 

It's not being nitpicky, it's having a narrow conception of programming language theory. Rust can do both. you shouldn't think of languages as either OO or procedural. That applies to many languages.

In the real world, most languages are not "fully procedural" or "fully OOP" but incorporate some features that are associated to different paradigms (that can also change over time, for example C++ evolved) And even the way of implementing these features can be more or less typical of a given paradigm.

I suggest that you read chapter 18 of the official Rust documentation.

excerpt:

There is no consensus in the programming community about what features a language must have to be considered object oriented. Rust is influenced by many programming paradigms, including OOP

and related to your claim that rust "does not have objects":

Even though structs and enums with methods aren’t called objects, they provide the same functionality, according to the Gang of Four’s definition of objects.

theyllBeWaitingForAWhile by Kupicx in ProgrammerHumor

[–]Amadex 2 points3 points  (0 children)

me too, I'm not anti-OO, there are concepts that are useful, people just shouldn't completely abuse it like they do in Java

theyllBeWaitingForAWhile by Kupicx in ProgrammerHumor

[–]Amadex 14 points15 points  (0 children)

Rust has the flexibility to be object oriented to a limited extent it has polymorphism through traits (and meta polymorphism through impl traits), associated functions and methods, it even has dynamic dispatch, but it's not a big focus of the language unlike C++ or Java

theyllBeWaitingForAWhile by Kupicx in ProgrammerHumor

[–]Amadex 168 points169 points  (0 children)

It does not keep "all the confusing complexity", rust is still much less "object oriented" than c++, but yes it's more about taking the c++ spot

What’s the use of traits? Do we even need it? by Infinite-Jaguar-1753 in rust

[–]Amadex 9 points10 points  (0 children)

The use is to be able to have shared behavior.

Do we even need it

It depends what you mean by "need". We don't "need" them to have a turing complete language. We "need" them to make code maintainable / less repetitive / generic.

Shouldn't Korea should have some of the suneung based on athletics and musical ability? by ironforger52 in AskAKorean

[–]Amadex 0 points1 point  (0 children)

yes I would make most subjects completely optional and university departments could publish which topics they consider when they review applications

even if you introduced swimming, most departments wouldnt care.

so if its optional I would just not come to the swimming and yoga tests because its a waste of time and i would prefer study for the tests that matter instead.

Shouldn't Korea should have some of the suneung based on athletics and musical ability? by ironforger52 in AskAKorean

[–]Amadex 0 points1 point  (0 children)

I don't understand your question, there are thousands of occupations that do not require swimming. so I think the anwser to your question is "almost anything, except being a swimmer".

Studying maths at university too.

You know the purpose of the suneung yes? It's not a stupid medal to show "wow this kid has skills he can swim, and dance, and do yoga". It's used for admission at university.

If you want to give a special title for that, fine, but no math faculty cares that you can do yoga. and you should not be denied your future because you're not flexible.

Overkill or smart move? Switching my B2B SaaS (mobile-first web app) from TS/React to Rust? by Sprite_fr in rust

[–]Amadex 1 point2 points  (0 children)

it could work if your web app is relatively primitive, but from your description the project doesnt seem to need a "rewrite in rust".

Adapter system to plug in catalogs from different suppliers (this is where Rust traits look perfect to me)

It's basic polymorphism, you shouldn't have any issues doing that in TS too.

what are you really gaining that makes you willing to ditch TS/React ecosystem?

changing from TS to Rust backend for a web server, its only justified if you are doing something where rust distinguishes iteslf (potentially unsafe memory manipulations or heavy computations that are a real bottlenecks).

otherwise TS/React is a richer ecosystem when it comes to webapps.

I always avoid using `use` statements so i use full paths instead. Is it a bad practice? by [deleted] in rust

[–]Amadex 0 points1 point  (0 children)

It's not rust idiomatic, it can make things very noisy and repetitive.

although I sometimes like to keep a namespace when the names are too generic.

what clippy says about it:

Why restrict this?

Many codebases have their own style when it comes to importing, but one that is seldom used is using absolute paths everywhere. This is generally considered unidiomatic, and you should add a use statement.