@SorteKanin@feddit.dk avatar

SorteKanin

@SorteKanin@feddit.dk

This profile is from a federated server and may be incomplete. Browse more on the original instance.

SorteKanin,
@SorteKanin@feddit.dk avatar

Honestly goodreads just sucks. I’ve heard literal.club might be better. Though I’m not sure it supports that use case either.

SorteKanin,
@SorteKanin@feddit.dk avatar

At the time, it said it’d made much of Slay the Spire II in Unity, but would still migrate to a different engine if Unity stuck to its guns.

Good on them for switching even when they had already started development!

SorteKanin,
@SorteKanin@feddit.dk avatar

Også Mikkeline Thomsen ser en række problemer i, at den digitale infrastruktur i så høj grad er på Facebooks hænder.

  • Problemet er jo, at de her grupper hele tiden lever på Metas nåde.

Ja, og ikke nok med det så er det frivillige arbejde der foregår på Facebook jo en form for frivillig arbejde for Mark Zuckerberg. Og det er jo ikke så fedt. Mindes denne post:

https://feddit.dk/pictrs/image/3345e0f5-26dd-4749-adcf-054ce4bdc3b8.webp

  • Ville jeg ønske mig, at der fandtes en anden platform, der ikke var ejet af en amerikansk tech-gigant – ja, men når borgerne bruger det så godt, så synes jeg, at det er positivt.

Ja, hvis bare det fandtes… 🥲.

SorteKanin,
@SorteKanin@feddit.dk avatar

Jo, men alle brugere behøver heller ikke deres egen instans. Så længe man som bruger kan finde en instans man gerne vil være på, så er det jo fint. Så kan man jo også deles om udgifterne og moderationsarbejdet osv. :)

Der er mange måder at bidrage på som ikke behøver nogen teknisk kunnen.

SorteKanin,
@SorteKanin@feddit.dk avatar

Interessant! Jeg gad vide hvor godt den forbinder med Lemmy?

SorteKanin,
@SorteKanin@feddit.dk avatar

Jojo, desværre er det ikke per automatik nogen garanti for at det forbinder godt :P

SorteKanin,
@SorteKanin@feddit.dk avatar

Kan godt se din pointe. Ja, der foregår frivillig arbejde på Facebook men er det på bekostning af andet arbejde eller støtte? Tilføjer det noget eller er det et nulsumsspil?

I en rigtig demokratisk stiftet forening har man en bestyrelse, som sikrer at gruppen ledes efter medlemmernes interesse.

Hvis Feddit.dk bliver noget større kunne jeg godt forestille mig en fremtid hvor det bliver til en demokratisk forening. Jeg er dog ikke sikker på hvordan det kan lade sig gøre i forhold til donationer og kontingent (jeg har ikke lyst til at Feddit.dk kun bliver styret af dem der betaler). Større problem er måske også at jeg ikke er sikker på hvordan sådan en forening kan oprettes eller fungere samtidigt med at opretholde anonymiteten.

[US] At a sushi restaurant, is it considered good ettiquette or bad ettiquette to order rolls cross several rounds?

When we go out for sushi with friends we usually order as a group and order a couple of specialty rolls for the table at a time, sometimes making several orders through the evening as time and appetites allow. The idea is manifold: not to over-order food, to spread out food delivery as we drink sake and socialize, to...

SorteKanin,
@SorteKanin@feddit.dk avatar

The question comes up because our server (a delightful young lady who was all to happy to “spill tea” with us) let us know the chef was annoyed our table was making multiple orders.

Sounds like a shitty chef. I think it really depends on the place but I would say most sushi places are happy to take multiple orders.

SorteKanin,
@SorteKanin@feddit.dk avatar

Kan det virkelig passe at 5/7 ugedage med arbejde/uddannelse blot er en moderne arbitrær konstruktion som egentlig ikke har noget at gøre med hvor meget mennesker bør eller kan arbejde effektivt? Hmm… 🤔

SorteKanin,
@SorteKanin@feddit.dk avatar

Jesus christ they even have a “Vaccine Risk Awareness Activist” character and when you ask it to repeat, it just spits absolute drivel. It’s insane.

SorteKanin,
@SorteKanin@feddit.dk avatar

What are you referring to? I feel out of the loop

SorteKanin,
@SorteKanin@feddit.dk avatar

Gab is a far-right social media, as far as I can gather. They’ve made an ensemble of AI chatbot characters and this one is their default one.

SorteKanin,
@SorteKanin@feddit.dk avatar

Ah right of course, thanks

SorteKanin,
@SorteKanin@feddit.dk avatar

Need Lemmy Enhancement Suite with this feature

SorteKanin,
@SorteKanin@feddit.dk avatar

Vent… er dette et ordspil på armatur? Det tog mig alt for lang tid at indse

SorteKanin,
@SorteKanin@feddit.dk avatar

Rimelig nice opgradering 🚀

SorteKanin,
@SorteKanin@feddit.dk avatar

I wanted to serve pages in my blog. The blog doesn’t actually exist yet (but works locally, need to find out how I can safely host it later…), but lets assume it becomes viral, and by viral i mean the entire internet has decided to use it. And they are all crazy picky about loading times…

Of course it depends if doing this kind of optimization work is your goal but… if you just want a blog and you want it to be fast (even with many visitors, but perhaps not the entire internet…), I would say make a static web server that just serves the blog pages directly from &'static strs and predefine all blog posts ahead of time. For example, you could write all your blog posts in HTML in separate files and include them into your code at compile time.

You’d need to recompile your code with new blog post entries in order to update your blog… but like how often are you gonna add to your blog? Recompiling and redeploying the blog server wouldn’t be an issue I imagine. That’s how I would do it if I wanted a fast and simple blog.

Also general software development wisdom says “don’t code for the future” aka YAGNI - you aren’t gonna need it. I mean, sorry, but chances are the whole internet will not be crazy about visiting your blog so probably don’t worry about it that much 😅. But it is a good learning thing to consider I guess.


<span style="color:#323232;">#[derive(Clone)]
</span><span style="font-weight:bold;color:#a71d5d;">pub struct </span><span style="color:#323232;">Page<</span><span style="font-weight:bold;color:#a71d5d;">'a</span><span style="color:#323232;">> {
</span><span style="color:#323232;">   </span><span style="font-weight:bold;color:#a71d5d;">pub </span><span style="color:#323232;">title: </span><span style="font-weight:bold;color:#a71d5d;">&'a str</span><span style="color:#323232;">,
</span><span style="color:#323232;">   </span><span style="font-weight:bold;color:#a71d5d;">pub </span><span style="color:#323232;">endpoint: </span><span style="font-weight:bold;color:#a71d5d;">&'a str</span><span style="color:#323232;">,
</span><span style="color:#323232;">}
</span>

I’m a little confused about the use of the word “endpoint” here - that usually indicates an API endpoint to me but I would think it would be the post contents instead? But maybe I’m just too hung up on the word choice.

I wanted to create a HashMap that held all my pages, and when I updated a source file, the a thread would replace that page in the mapping.

To me, this sounds like you want to dynamically (i.e. at runtime, while the server is running) keep track of which blog entry files exist and keep a shared hashmap of all the blog files.

So there’s multiple things with that:

  1. You’d need to dynamically allocate the storage for the files on the heap as you load them in memory, so they’d need to be String or an Arc<str> if you only need to load it in once and not change it. Since you don’t know at compile-time how big the blog posts are.
  2. As you note, you’d need a way to share read-only references to the hashmap while also providing a way to add/remove entries to it at runtime. This requires some kind of lock-syncing like Mutex or RwLock, yes.

why can’t I have a AtomicPointer to my data that always exist?

Does it always exist though? The way you talk about it now sounds like it’s loaded at runtime, so it may or may not exist. I think I’d need to see more concrete code to know.

and I’m actually calling unsafe code. I have heard it can produce unexpected error outside it’s block.

Yes, indeed. Safe code must never produce undefined behaviour, but safe code assumes that all unsafe blocks does the correct thing. For instance, safe code will always assume a &str contains UTF-8 encoded data but some unsafe code may have earlier changed the data inside of it to be some random data. That will break the safe code that makes the assumption! But it’s not the safe’s code fault.

Unsafe in general is a very sharp tool and you should be careful. In the best case, your program crashes. In worse cases, your program continues with garbage data and slowly corrupts more and more. In the even worse case, your program almost always works but rarely produces undefined behaviour that is extremely hard to track down. You could also accidentally introduce security vulnerabilities even if your code works correctly most of the time.

In general, I would advise you to avoid unsafe like the plague unless you really need it. A hypothetical optimization is certainly not such a case. If you really want to use unsafe, you definitely need to carefully peruse the Rustonomicon first.

In your specific case, the problem is (of course) with the unsafe block:

unsafe { self.data.load(Relaxed).read_unaligned() }.clone()

So what is this doing? Well self.data.load(Relaxed) returns a *mut Arc<T> but it is only using safe code so the problem must be with the read_unaligned call. This makes sense, obtaining a raw pointer is fine, it’s only using it that may be unsafe.

If we check the docs for the read_unaligned function, it says:

Reads the value from self without moving it. This leaves the memory in self unchanged.

Here “self” is referring to the *mut Arc<T> pointer. So this says that it reads the Arc<T> directly from the memory pointed to by the pointer.

Why is this a problem? It’s a problem because Arc<T> is a reference-counted pointer, but you’ve just made one without increasing the reference count! So the Arc believes there are n references but in fact there are n + 1 references! This is bad! Once the Arc is dropped, it will decrease the reference count by 1. If the reference count is 0, it will drop the underlying data (the T).

So let’s say you get into this situation with 2 Arcs but actually the reference count is 1. The first one will drop and will try to free the memory since the reference count is now 0. The second one will drop at some later time and try to update the reference count but it’s writing into memory that has been freed so it will probably get a segmentation fault. If it doesn’t get the segfault, it will get a problem once it tries to free the memory since it’s already been free. Double free is bad!

So yea that’s why it probably works once (first arc gets dropped) but not twice (second arc gets a bad experience).

SorteKanin,
@SorteKanin@feddit.dk avatar

Cool, sounds like you have a lot of fun learning :)

SorteKanin,
@SorteKanin@feddit.dk avatar

How long did it take you before you started to become proficient enough in Rust that you could be productive for your employer?

Not too long, around 3 months maybe. But it depends how much time you spend obviously. Learning the language is fairly quick. Learning the more exotic parts of the language took a bit longer but that’s mostly cause I didn’t need those things until later. Learning the package ecosystem is also something that can take a bit of research and you kinda have to just keep yourself up to date about cool crates via blog posts and sharing on online communities like this. But all this will probably depend on your prior expertise. I have a master’s in computer science so it wasn’t a huge deal for me.

Were you already proficient in other systems level programming languages like C or C++ before learning Rust?

I was… okay at C++ before-hand so kinda. But honestly C++ is such a shitty language that looking back I barely had any grasp at that time honestly. With Rust, it’s so much easier and I understand how the system works so much better now, simply because Rust forces me to understand it. The compiler is a great teacher!

Did you get hired as a Rust developer or were you working or your current employer utilizing another programming language and you eventually move to developing in Rust?

I was not hired as a Rust developer. There was actually barely any Rust at the company when I joined. There were a few other colleagues interested in it and when I came in we really went for it. It took some convincing of management and stuff but now we use it in a lot of places and I write almost exclusively Rust at work.

But I think I was very lucky in this aspect. There are few places where you will have such an opportunity to influence the technology in that way.

Do you see there being more jobs utilizing Rust in the future?

110%. Rust is set to replace languages like C and C++, and at the same time it is heavily competing with other programming languages. Even languages like Python. There’s a huge opportunity to improve software reliability across the field with Rust.

Rust is supported by the largest tech companies in the world and is getting integrated into Linux. There has not been a language with this level of dedication and support behind it for a long time.

Growth is happening and it will only accelerate in the coming years. You can even see it happening on Google Trends. It’s a great time to learn the language to get ahead of the curve!

I know that’s a lot, so if you don’t want to field all of those, I understand, but I’m very curious so I thought I’d just put those out there.

Hey I made this thread to answer questions, thank you for asking! I’m sure there are many lurkers who were also curious.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • bokunoheroacademia
  • kavyap
  • mdbf
  • everett
  • magazineikmin
  • osvaldo12
  • ethstaker
  • InstantRegret
  • Youngstown
  • slotface
  • rosin
  • GTA5RPClips
  • cisconetworking
  • DreamBathrooms
  • lostlight
  • thenastyranch
  • Durango
  • khanakhh
  • tacticalgear
  • normalnudes
  • Leos
  • relationshipadvice
  • modclub
  • cubers
  • tester
  • anitta
  • HellsKitchen
  • sketchdaily
  • All magazines