calcopiritus

joined 1 year ago
[–] calcopiritus 2 points 1 day ago

In my experience, nobody really knows what OOP is, everyone has a different definition.

Most of the "OOP" features are implemented in languages that are not OOP. The only one that is to me an OOP-exclusive feature is class-inheritance. So IMO OOP=class inheritance.

There is plenty of criticism about inheritance, specially among rust lovers. Since rust implements other features associated with classes, except class inheritance. Such as: methods (and self keyword), interfaces (traits), default interface method implementation.

Anti-OOPs usually argue that encapsulation and interface is a much better alternative to class inheritance.

Some things class inheritance is criticized for:

Diamond inheritance problem: If there is class A. B and C inherit from A and override its methods. D inherits B and C without overriding them. What implementation should D inherit? B or C? Same happens if only B or C overrides.

Encourages having multiple layers of abstraction: it's not uncommon to see huge inheritance chains. MyCustomList -> OrderedVector -> OrderedList and Vector -> List -> Collection -> Iterator. Just by looking at MyCustomList, you don't know the entire chain, you just see "OrderedVector". You have to follow many nested links until you can know it all, and then you have to retain that knowledge along with tens of other inheritance chains.

Not ideal for performance: Inheritance encourages designs where the compiler will need to add a v-table to classes. These tables make implementation of OOP patterns much easier, but they require additional overhead when calling methods. Note that v-tables are not OOP specific, rust needs them also for trait objects. However, rust encourages designs with small amount of trait objects.

Not as intuitive as claimed: People are taught OOP with simple examples involving real-world objects like: car -> vehicle -> object. However, these situations are rare except in some specific cases like UIs, video games, simulations. In most other cases, you are dealing with concepts rather than objects. And even when you're dealing with objects, it's not a clear cut. Sometimes it might happen that bicycle -> car. Even though not intuitive, in some situations this may be a useful inheritance. But when bicycle inherits car, it no longer resembles the inheritance-chain of the real world, so that's extra work for the brain.

[–] calcopiritus 1 points 1 day ago

Don't need sudo or anything pre installed for vscode either. It will send the server to the machine via SSH and then run it automagically.

[–] calcopiritus 2 points 1 day ago (2 children)

You can do that with vscode too. And probably many IDEs.

The only real reason for which you would need to use vim in such cases is if the target computer can't run the vscode server, which I've never encountered yet.

[–] calcopiritus 11 points 3 days ago (2 children)

If I have to search something in a repo, I just clone it and use my IDE. GitHub search sucks, but I don't think it's possible to have a web experience that is on par with an actual environment an IDE.

[–] calcopiritus 2 points 3 days ago

I guess that's another way to avoid the overflow problem

[–] calcopiritus 7 points 3 days ago (2 children)

C:

int increment(int i) {
    return (int) (1[(void*) i])

However, if you wanna go blazingly fast you gotta implement O(n) algorithms in rust. Additionally you want safety in case of integer overflows.

use std::error::Error;

#[derive(Debug, Error)]
struct IntegerOverflowError;

struct Incrementor {
    lookup_table: HashMap<i32, i33>
}

impl Incrementor {
    fn new() -> Self {
        let mut lut = HashMap::new();
        for i in 0..i32::MAX {
            lut.insert(i, i+1)
        }
        Incrementor { lookup_table: lut }
    }

    fn increment(&self, i: i32) -> Result<i32, IntegerOverflowError> {
        self.lookup_table.get(i)
            .map(|i| *i)
            .ok_or(IntegerOverflowError)
}

On mobile so I don't even know if they compile though.

[–] calcopiritus 7 points 3 days ago (2 children)

Not really. When you pirate a movie you get the whole thing. Just as if you paid for it.

A succulent leaf, however, needs years to become the size of an actual plant they would sell.

It's even less damaging than pirating.

[–] calcopiritus 6 points 4 days ago

Some people would not select google though. And google can't afford people knowing that there's competitors to Google! So better fuck everyone over by just disabling the integration.

[–] calcopiritus 5 points 4 days ago

They make ruggedized phones. I don't think they make normal ones.

[–] calcopiritus 2 points 6 days ago

That's the thing. The reason El Salvador was so effective in eliminating crime is because they don't care about imprisoning innocent people.

You can't have the effectiveness without the collateral damage.

Which one is preferable? I don't know. But you can't eat the cake and have it too.

[–] calcopiritus 6 points 1 week ago

It's not all about the impact. It's also about the chance or impact. If you're going at that speed on pedestrian zones, you'll eventually hit someone, or be very close to doing so. Pedestrians go in any direction, and can change at any time in an instant. If you go fast, no matter how fast your reflexes are, they won't be fast enough to brake in time on pedestrian zones.

The roads not being safe for non-cars is not the problem for pedestrians. Use the bike lane in those cases.

[–] calcopiritus 38 points 1 week ago (1 children)

It is hard. Not everyone knows what colors are a problem for colorblind people. There are also many types of color blindness.

 

For those that don't know: Mount Balrior Raid Expert is an achievement of the new W8 raid. To get that achievement you have to obtain 100 points for each of the bosses of the wing. You obtain one point for each person in your squad for whom it was the first kill time ever that they kill that boss.

  1. It is a pyramid scheme. By design, only about 1/11 players can get it (at best).
  2. It encourages people that don't wanna train to do trainings. They are irritated more easily and are way less patient towards new players. Because they don't wanna train new people, they only want to get the achievement.
  3. It will only be harder as time goes on to get this achievement, further increasing the toxicity of it, as people rush to get it.
  4. It makes non-training runs worse. If there is an underperformer, you can't kick him because people will get angry that they wont get points for the achievement and they will leave. If you don't kick him, you'll both waste time on easily preventable wipes and people will also leave because of it.

Training runs should be done by people that actually want to train. If you want to encourage trainings, you should reward re-clearing wings, doesn't matter if it's a training run or not.

 

I want to do basically this:

struct MyStruct &lt; T> {
    data: T
}

impl &lt; T> for MyStruct &lt; T> {
    fn foo() {
        println!("Generic")
    }
}

impl for MyStruct &lt; u32> {
    fn foo() {
        println!("u32")
    }
}

I have tried doing

impl &lt; T: !u32> for MyStruct &lt; T> {
    ...
}

But it doesn't seem to work. I've also tried various things with traits but none of them seem to work. Is this even possible?

EDIT: Fixed formatting

view more: next ›