jkap

CEO of posting

butch jewish dyke
part of @staff, cohost user #1
married to @kadybat

This user can say it
osu stats


๐Ÿ”ต tumblr
yrfriendjkap.tumblr.com/
๐Ÿ˜ mastodon
xoxo.zone/@jkap
๐Ÿ–ผ๏ธ icon credit
twitter.com/osmoru
๐Ÿฆ twitter
not anymore lol
๐ŸŽฌ letterboxd
letterboxd.com/yrfriendjkap/
You must log in to comment.

in reply to @jkap's post:

๐Ÿฆ€

Programming languages are just tools, after all. Tools don't do much if you don't have anything to build.

Big companies have reportedly had positive results with using Rust for performance-sensitive backend code, which I only mention because it might be relevant to you/staff. Worth a shot if there is actually a bottleneck somewhere that can't be solved unless the code just runs faster.

the kinds of problems a system like the cohost servers need to solve are rarely ones of raw compute at all; rather, keeping all the data indexed and hot in cache for all the myriad ways users will be slicing it. at this scale that mostly means wrangling databas schemas and cache invalidation heuristics rather than cranking out data structure lookups in 10% fewer cpu cycles, because the dominant costs are all about hotly contended disk pages.

when the service grows much larger and you have so many disks per server that they can saturate, or you have significant spend in frontend webservers, you can save a lot of money by using faster languages this way but it's more of a later-stage concern

I was never actually a programmer but back in the day everything unix was written on Suns and I was a Linux early adopter and I get used to messing with the include paths and Makefile things to get stuff to compile. I kinda understood the overall configure / make build process. Now the rust people have stuff where there is no configure script, no makefile, I don't understand how this even works! I haven't found a sort of intro that is like "I'm absolutely not gonna write a program in rust, but someone I know like third-hand did and I'm old and have no idea even what tools to use to compile it, please explain" but I guess I need that!

If you're still looking, I can offer a brief summary :)

Rust can be thought of at two levels: the compiler, and the rest of the toolchain surrounding it. A typical rust installation includes all "extra bits" on top of the compiler as well -- like the build system "cargo", the linter "clippy", and the formatter "rustfmt". Typically this is installed with rustup, but some distros have dedicated rust packages as well.

The rust compiler is called rustc. It can be used directly, but 99% of the time you're going through cargo, the build system that comes packaged with it.

cargo reads from a Cargo.toml file (example) that specifies - among other things - dependencies of the library or application. Other files you're likely to see:

  • Cargo.lock - tracks which versions of each dependency is currently used
  • src directory - by default, where cargo finds the package source
  • build.rs - (rare; see below)

For most rust applications (and libraries), building is done with cargo build (debug mode) or cargo build --release. Running applications can be done with cargo run or cargo run --release. Both of these will download and compile all dependencies in the Cargo.toml (and all of the dependencies' dependencies, etc.).

Really, this should be enough on the vast majority of Rust projects. I.e.: Install the toolchain, then cargo build/run in the project directory.

Some rust projects have other build-time operations that need to happen (e.g., linking/compiling C code). This is typically done with a build.rs file, which is compiled and executed before the main project itself, and typically passes information through to the compiler via printing to standard out.

Typically, OS-dependent configuration (e.g, "enable this feature on linux only") is done with builtin language features.

(ps: David says hi)

Thanks! Super helpful! I was messing around building something the other day and got it to to work but it's super helpful to have a "this file does this, that file is for that" sort of thing for someone whose last exposure to this sort of thing was the better part of 30 years ago when all the details were different! (I've compiled a couple things here and there but mostly it's been some variant on "sudo apt install [thing]" for a long time now!)

ah, glad I could help! It's funny how some things have changed a bunch, but there's still plenty of projects building just the same as they have for the last few decades

I like rust a lot but it is a) not the right tool for everything and b) an actually difficult tool to use for some things. Keeping that in mind though it can be a joy to write

That being said I also had trouble learning it until I needed to.

I've been thinking about doing the "advent of code" thing in it this year just to force myself to get used to the syntax. Like Duolingo exercises or something.

I think it might be easier now that I've finally got a clear answer to "but how do you represent self-referential data structures in Rust" (the answer turns out to be "Rust programmers simply do not do that")

yeah a good way to keep current with rarely used languages is old advent of codes, too, especially if you already know the problems and are just forcing yourself to reimpliment the solutions you already know, instead of having to do math/planning you're already good with by then

Good luck! Advent of Code is coming up, could be fun. BTW I personally found the book Programming Rust (O'Reilly press, 2nd edition by @nora!) much more useful and engaging than The Rust Programming Language (No Starch Press, or free online)

can recommend, learned rust with it! the rust programming language is good, but programming rust, and in general books in that style are a lot better IMO, but it boils down to personal preference :3

(also i did not know that someone here who has been on my TL already wrote that, woa)

(python voice) if you're python inclined, there are nice rust toolkits to say "bundle this shit up in a library" and i think there's some for node too.

i can't say if it'll make a big difference to you, but being able to rewrite a slow thing in rust without rewriting the whole thing in rust does seem really useful and often overlooked

oh absolutely, i think neon is probably the best option for doing that with node (after very limited research), but the main thing is our slow parts are either Not Us (DB operations) or Nontrivial Rewrites (react SSR rendering). this might change in the future but for now, even a partial rewrite likely wouldn't be worth it.

it took me many attempts and over a year to understand rust (i have adhd so difficult things can be rly hard for me to focus on) but after i started to Get it it was the most fun i've ever had programming. i think it's definitely worth it

in reply to @jkap's post: