• 0 Posts
  • 453 Comments
Joined 2 years ago
cake
Cake day: June 10th, 2023

help-circle
  • You might want to take a look at C/C++ again at some point, you didn’t mentioned a single thing that I expected, I expected you to complain about memory allocation, double frees or stuff like that, instead you touched on lots of very accurate pain points for C/C++ that people who use it for years feel.

    • Preprocessor directives: I assume you mean macros like #ifdef _WIN32, macros will change the code before it gets compiled, so they allow you to write meta-code, as in code that writes code. Rust takes this to a whole new level, so you might want to understand the basic concept before looking into advanced Rust. That being said, I don’t think these are complicated in and of themselves, nor do I think you’re having problem with understanding what they mean, and it’s more likely a question of why, and the answer is that some stuff should happen at compile time, e.g. checking if you’re on Windows or Linux do define how you deal with paths or something. But the same can be extended to knowing if a given feature is enabled so you can compile only parts of the program. The lack of package manager is a pain, but C/C++ predate lots of those concepts, and there have been lots of attempts. Also if you’re using Linux your system already has a package manager so using some common standard like CMake for your projects makes it all “just work” (most of the time)… But yeah, this one is a pain, no question about it, and Rust solved it properly.
    • Essentially the compiler couldn’t find something, they shouldn’t appear randomly and that’s perhaps a VS bug, never used VS for C/C++ development so I’m not sure on that one, but whenever I had link errors I was forgetting an include or a library on my CMake.
    • What do you mean by errors? Compiler errors? You learn to read them with time, but yeah, Rust compiler errors are much nicer, although they can lead you into a rabbit hole by suggesting changes you shouldn’t use.
    • I do know that, it’s not intuitive if you’re thinking on a higher level, but if you think on low level stuff it makes absolute sense. I can’t think of why this would have caused you trouble needing debugging though, you could be occupying more memory than necessary, or you could be running into problems with unions, but I can’t think of why the order of a struct would make anything crash unless you’re naively converting between types by casting a pointer, which is a red flag on its own.
    • Well, C doesn’t need strings, what is a string? It’s just an array of characters. C tries to not impose anything on top of the very basics, so it makes sense it doesn’t have a string type, appending to a string or to an array of numbers is essentially the same, you just deal with strings more commonly. And this forces you to think on what you’re doing, e.g. my_str += "something" sounds like a very simple thing, but under the hood you’re allocating an entire new string, copying the content from my_str into it, appending something and then deleting the old one. C forces you to do that stuff manually so you have to be conscious of what you’re doing, string operations are not cheap, and you can gain a lot of performance by simply preallocating all you’ll need from the start. Rust is similar here, while they do have a String type, they make a very big difference between it and a slice of a string, so that makes you conscious of when you’re doing heap stuff.

    I spent years with C/C++ as my main language, and I can tell you that I would also not choose it for a random project. However I would also most likely not pick Rust either. Python is my go-to for “I need something quick”. Rust would be my go-to for “I need something robust”, or “I want to make sure this will work as intended”, it will mean a more tedious development cycle with a very slow iteration (much slower than C/C++, e.g. adding an enum value can mean lots of fixes on Rust, because most places where you’re dealing with that enum would fail to compile because you’re not taking the new value into consideration), but it will mean that every step will be solid (if it compiles after adding an enum value, I’m sure it’s being considered).

    Do learn Rust, it’s fun and personally I see a LOT of future in that language, but it also abstracts some of the concepts away while still requiring you to know them, e.g. heap/stack. I think learning C/C++ for the core concepts is better, but if you know those concepts Rust is a better language overall.


  • Yeah, that’s a good approach, learn it and it’s one more tool under the belt.

    That being said, I think you need to have some good level of proficient in C/C++ before lots of the Rust things make sense. I’m not sure what frustrated you about C/C++, and if you’d like to ask questions about that I’m happy to try to answer them. But a lot of concepts are the same just shown under a different light. For example, on C/C++ you chose to use stack or heap by declaring variables or allocating memory and storing it in pointers, in Rust you don’t allocate memory directly, instead you use types that store information on Heap, e.g. Box. I think that’s a lot less intuitive, and requires you to have a good grasp of heap/stack before it makes sense, but it prevents you from doing stupid stuff you might do accidentally on C/C++ like store a pointer to a stack object after it goes out of scope.

    But I might be wrong, it might be that for me all of that made sense because I knew C/C++ but that to you it will make sense regardless, and might even teach you those concepts that are useful on C/C++ too.


  • While I agree with you that OP shouldn’t migrate to Rust, the language is not illogical nor a mix of any of those. There’s a lot of stuff that Rust does extremely well that can’t be reproduced in any of the other languages, such as Options or Result types. And while it can become confusing when lifetimes get thrown at it as a general rule it’s not. Also the compiler messages are so thorough, I don’t think I have ever seen anything come close to it.

    Rust is not for everything, nor for everyone, but saying it doesn’t have it’s merits is dishonest.


  • Let me start by saying I love Rust and think it’s great. I’ve been writing some personal stuff in Rust and it’s all that I’ve been looking for.

    However there is some stuff you said that makes me think Rust won’t be something you would fully appreciate Rust. Firstly every project, regardless of language, when it becomes big it becomes a hassle to maintain, especially if you’re not experienced enough to have set up a good architecture from the start.

    But more importantly, a lot of Rust benefits are stuff you didn’t mention, and some of the stuff you mentioned is not that important.

    • Speed: Performance gains will be minimal, most of the time your server takes on an API call is read/write disk/Network, and that takes as long as it takes regardless of language. Sure synthetic benchmark will tell you it’s twice the speed for a hello world, but the moment you start relying on outside stuff the line gets murky.
    • Less resources: Again, unless you have at least 10 instances of your service or are trying to get it to run in very minimal hardware conditions, you’re not likely to see any meaningful improvement. Sure your service now uses half the amount of RAM, but the hardware where you’re running it likely has a couple orders of magnitude more RAM than that anyways.
    • Garbage collection: You say that like it’s a bad word, but at the same time admit to have problems with C/C++, whose main differences are related to that.
    • Compilation: I don’t think you’re taking compilation into consideration, from line change to retest we’re talking a couple of minutes depending on the change. That can be annoying really fast, especially if you don’t understand the reason. Also, the Rust compiler is EXTREMELY pedantic, it will not let you compile stuff that you think should work because there’s an edge case that you’ve forgotten to consider because it’s not something you cared about, e.g. you can’t have global mutable variables because that can cause race conditions on multi-threading applications.
    • Security: you didn’t mention this but it’s one of the largest advantages of Rust, things like the Option or Result types as well as the match statements and the borrow checker are amazing and unmatched by anything else out there.
    • The Rust price: Rust is not free, you just pay beforehand, you win execution time at the expense of compiling time, you save on runtime errors at the expense of pedantic code checks, etc, etc. Rust is excellent if you understand why, and are willing to pay that price. Rust is for people who when the compiler says “you can’t do this because it will cause problems with X edge case” say “of course! Thanks!”, if you think “ugh, that’s never gonna happen, stupid compiler” then it’s not for you. To add to that, Rust can become quite complicated because of it.
    • A different way of structuring: Rust does not have classes or any OOP paradigms, it’s different from other stuff you’ve used and requires changes in how you structure your hada and application. Whether that’s for the best or not is very personal, but it’s definitely different.

    Finally I would like to finish up saying that Rust has the most excellent documentation: https://doc.rust-lang.org/book/ read that, then maybe do these https://github.com/rust-lang/rustlings if you get to the error types and are not drooling over the language, it might not be for you.



  • While I sort of understand your point our society already contradicts that. If a person were to die under suspicious circumstances, an autopsy would be performed regardless of the dead or any relative’s wishes, and that would violate the integrity of the body as much as an organ donation would. Therefore we as a society understand that there are limits to one’s personal beliefs.

    I also disagree with the person you’re replying to, I think the system should be opt out with the following conditions:

    • You must opt out yearly, on the 366th day since you last opted out you become an organ donor again
    • You must not have opted out of it over the past 5 years before you’re allowed to undergo any surgery that would jeopardize the integrity of your body, including organ transplants but also blood transfusions and potentially also any foreign object such as pins or bone grafts.
    • You cannot opt out if you have ever received an organ.
    • Your body cannot be autopsied, embalmed or cremated, as all of those would also violate the body. This includes police investigations.
    • Any family of anyone senile/old/incapacitated enough not to be able to keep renewing it (or the person himself if possible in a moment of lucidity) can be added into the permanent no donation list.



  • Nibodhika@lemmy.worldtoSelfhosted@lemmy.worldHelp with domain
    link
    fedilink
    English
    arrow-up
    13
    ·
    edit-2
    7 days ago

    Lots of questions, let’s take it one step at a time. You have a domain, now you can point it to your public IP, so that whenever someone tries to access example.com they ask their DNS server and it replies with 10.172.172.172 (which btw is not a valid public IP). Now that request will hit your router, you need to configure your router to redirect ports 80 and 443 to 192.168.200.101, that way the request to example.com gets to your local machine.

    Ok, so now you need your local machine to reply on that port, I recommend using Caddy it’s very easy to setup, but NGIX is the more traditional approach. A simple Caddy config would look like:

    example.com {
        respond "Hello"
    }
    
    
    jellyfin.example.com {
        handle {
            reverse_proxy http://192.168.200.101:1020/
        }
    }
    

    So after the request reaches Caddy it will see that the person tried to access, example.com and respond with a “Hello”.

    If instead you had tried jellyfin.example.com the DNS would have sent you to 10.172.172.172, your router would send that to 192.168.200.101, Caddy would then send it to 192.168.200.101:1020, which is Jellyfin so that would get returned.

    There are some improvements that can be made, for example if both caddy and Jellyfin are docker you can share a network between them so Jellyfin is only exposed through caddy. Another possibly good idea is to add some authentication service like Authelia or Authentik to harden stuff a little bit. Also as you might have noticed Caddy can forward stuff to other computers, so you can have one machine on your network exposing multiple services on multiple machines.






  • I don’t want to give away too much, because some of the people I play with could find this (I don’t know if they use Lemmy but my nick is known and the details would be too unmistakable). But since they’re about to discover it anyways, the wonder does something, without charging the “proper” price for it, eventually they’ll start to lose control of it and it will start doing what it does to them. That should be subtle enough that even if my players find this they won’t know what’s coming but give you an idea. Hope that’s enough to satisfy your curiosity.



  • I started a campaign of Monster of the Week, one of the players created a paranoid character who thinks society is controlled by lizards and birds are spy robots for them. So of course I immediately switched my world around, to accommodate that, except it’s not lizard people, but actually Dragons that can take human form and control birds. The game only had a couple of sessions so the group never figured that one out.

    And in my current Mage campaign with a different group, they were given this amazing powerful magical wonder, and they keep using it nilly-willy, which is exactly what I expect them to do. Little do they know that it has a price, the price is not part of the current campaign though, they’re worried about other stuff, namely an enemy who they already planned 4 things to happen together, each of which would be enough to defeat him, and to make that happen they used the wonder, over and over again.





  • I don’t hate it, I think it has its uses, just like text generation. They’re great for brainstorming ideas or quick unimportant stuff like RPG campaigns, so for example an in-game fake company logo or a poem to contain hints for the players.

    However trying to use it for anything serious and final is stupid and dangerous. IMO any artist that had their art used to train a model should be able to claim royalties on anything created with that model, regardless of whether they can prove their art was used for the piece. And if the data used to train the model is not made public or can’t be verified, then ANY artist can. Maybe just 1% of the profits direct or indirect of that art, so for example you used AI to generate part of an invitation for a party, 100 artists could start a lawsuit and take every single cent you earned from the party. After all you indirectly hired them, it’s only fair they get paid, had you hired a single artist you could negotiate the price with them.