• 0 Posts
  • 10 Comments
Joined 1 year ago
cake
Cake day: August 4th, 2023

help-circle




  • Codex@lemmy.worldtoAsklemmy@lemmy.mlTouch Typing
    link
    fedilink
    arrow-up
    5
    ·
    2 months ago

    Try a typing game, there’s lots of them now in several genres. I learned to touch type in secondary school, doing the old fashioned thing of taping a sheet of paper over the keyboard (and typing under it) so you can’t see the keys. That works but I believe in the educational power of games, and it’ll be more fun.

    Otherwise, just practice. If you use lemmy on mobile, try switching to desktop to type more. Start writing letters to people or short stories or anything that just encourages you to type more.





  • I agree with the other suggestions so far, to wit:

    1.dyn is fine, when you need it. People will give you a lot of guff about performance but vtable lookup on a dyn is no less performant than the same thing in C++ (in higher level languages almost every call is dynamically dispatched and those are used for plenty of serious, performant work).

    1. Use enums more.

    2. Use traits and generic functions

    And I would add a couple of other thoughts.

    For some DI type work, you can use cargo’s Features to define custom build flags. You can then put variants on the same code (usually implementing a trait) in different modules and use conditional compilation on the Features to swap out which code is used. This is like a compile-time strategy pattern. I use it for testing, but also to swap out databases (using a local in-memory to test and a real one in prod) and to swap out graphical backends on my roguelike (compiles to OpenGL on windows but Metal on my Mac).

    You’ll probably want to learn Rust’s macro system sooner than later as well. Sometimes a macro is better than a function when you need to generically operate over several types (function argument overloading, in other languages) or work on something in a general but well-structured way (tree walking for example).


  • Codex@lemmy.worldtolinuxmemes@lemmy.worldBackdoors
    link
    fedilink
    arrow-up
    3
    ·
    7 months ago

    I’ve gotten back into tinkering on a little Rust game project, it has about a dozen dependencies on various math and gamedev libraries. When I go to build (just like with npm in my JavaScript projects) cargo needs to download and build just over 200 projects. 3 of them build and run “install scripts” which are just also rust programs. I know this because my anti-virus flagged each of them and I had to allow them through so my little roguelike would build.

    Like, what are we even suppose to tell “normal people” about security? “Yeah, don’t download files from people you don’t trust and never run executables from the web. How do I install this programming utility? Blindly run code from over 300 people and hope none of them wanted to sneak something malicious in there.”

    I don’t want to go back to the days of hand chisling every routine into bare silicon by hand, but i feel l like there must be a better system we just haven’t devised yet.