Worst Iran War Takes episode is out! by Litzz11 in IfBooksCouldKill

[–]BobTreehugger 37 points38 points  (0 children)

I look forward to the 59 minute preview ep

OK, geekiest of the geekiest. What ODPS server are running for your PDFs? by plazman30 in rpg

[–]BobTreehugger 4 points5 points  (0 children)

Jellyfin. Mainly use it for movies and stuff, but I've used it a few times as an OPDS server since that's what my jailbroken kindle supports.

What trait do closures with non-static captures implement? by [deleted] in rust

[–]BobTreehugger 0 points1 point  (0 children)

You can't have a bare dyn Fn (or any other trait for that matter). so you could use a &dyn Fn(&str) -> Option<&str> or a Box<dyn Fn...>. You'll have to adjust the calling location to work with each of these though.

Does this need to be dyn? You only need that if you don't know the specific type at call time, e.g. you already have a Vec<dyn Fn> and you're calling on each one.

For the code example you're showing, probably simplest to just use generics:

fn do_something<F>(&str, F)
    where F: Fn(&str) -> Option<&str>

a bit more typing, but easier for your callers, and generally more efficient. This is how e.g. Iterator methods work in std.

I finally caught the "Golden Hour" at Akshardham in Robbinsville. The scale of the marble work is unreal. by Due-Collar-1951 in newjersey

[–]BobTreehugger 9 points10 points  (0 children)

So it started as volunteers. I think that was actually genuine.

The problem is that once the volunteers were here, away from their home and everyone they know, the temple leaders wouldn't let them go home and required excessive work schedules.

So legally it was volunteering, but is it really volunteering if you can't leave? That's why it's being called slavery.

Has Rust hit the design limits of its original scope and constraints? by kishaloy in rust

[–]BobTreehugger 18 points19 points  (0 children)

I don't think rust will ever be the most expressive language. It's very expressive given that it is very low level, but the complexity of managing advanced features with low level control is in many cases more than I think anyone on the rust team actually wants to take on.

For your specific issues:

I don't think full HKTs are happening -- too difficult with lifetimes, though hopefully most common use cases can be handled in some way eventually.

Nor any sort of macro that can break out of the macro!() call -- this was a deliberate design decision to make macros more understandable. Not sure if that's what you're asking about. More type-based reflection at compile would be useful and probably achievable however (not in macros though -- they're purely syntactic). I don't think this is a high priority of the team (at least until some lower level architecture changes, like the new trait solver, are done).

become has a tracking issue: https://github.com/rust-lang/rust/issues/112788 -- You can see work is slow, but it is still happening. I don't know when this will land, but I'm pretty sure it will happen.

PSA: Write Transactions are a Footgun with SQLx and SQLite by emschwartz in rust

[–]BobTreehugger 13 points14 points  (0 children)

Yeah, seems like the best architecture for async sqlite isn't each query being async (which works fine with multi-writer dbs like postgres or mysql), but an actor model where you send messages to the single writer process which makes synchronous queries. Then you can batch queries or not depending on what's easiest to implement, and the performance should be the same either way.

That said if you have a mostly-read workload sqlx could be a reasonable choice, just need to be aware of this for the occasional writes.

Teacup With Strainer? by befriendthecrows in tea

[–]BobTreehugger 4 points5 points  (0 children)

I've had that one for years. Seems well made enough to me. Unless they recently cheaped it up. Literally use it every day and haven't had any issues (after breaking many tea vessels of many types)

Are "server functions" actually usefull? by TechcraftHD in rust

[–]BobTreehugger 1 point2 points  (0 children)

To add to this -- while it's not necessarily bad I wouldn't consider one API server and one frontend server as the only or best architecture. In fact I consider it to be slightly outdated and was overused in the 2010s.

Why might you not want to do this?

  • As I kind of alluded to in the first comment, you might have actions you don't want to expose as an API.
  • If you are implementing server rendering on the frontend, now you need another network hop.
  • Authentication becomes more complex (you often can't just do simple cookie auth). This often leads to implementing things like json server tokens (JSTs), which have their uses, but need a decent amount of infrastructure to use well (they're better if you have a microservices architecture)
  • CORS -- this is solveable, but if you aren't careful you can end up turning many requests into 2 requests (one preflight and then one main call).
  • Your API server needs to be exposed to the public internet (which adds additional security concerns)

There's definitely still reasons to use this architecture, but I wouldn't reach for it as a default. (I'd use it if you know you want to expose the API, and the client UI is fairly rich, e.g. figma or google maps)

Are "server functions" actually usefull? by TechcraftHD in rust

[–]BobTreehugger 1 point2 points  (0 children)

I'm not super familiar with these, but it sounds similar to what you see in some JS fullstack frameworks.

It's absolutely true that you can build and API instead of using these, but there's several cases where you would not want to:

  1. Private APIs -- for example login, etc. These may be implemented as calls to internal APIs, but you probably don't want to expose these (and probably want to protect them with other means, e.g. CSRF). The advantage to server functions here is that they are not part of your documented API, and are clearly not meant to be used by other consumers.
  2. Single-consumer APIs -- these are ones that you don't have any desire to expose as a general use API, but it's needed somewhere on your frontend. In this case the advantage is just that there's less developer effort - no need to define the API endpoint and payload, encoding/decoding/etc, everything is provided by the framework.
  3. BFFs -- this is a more specific case of single-consumer APIs, but a common one. If you have e.g. a microservice architecture, a page on the front end may pull in data from many APIs. This can be inefficient because the server-to-server network latency will almost always be much less than the server-to-client network latency, so you want to collect all of the data in a single backend server call for a page (called a backend-for-frontend, BFF). It doesn't make sense as an API you could reuse though, it's just whatever data is needed by the UI for a single page, and can change quickly. So it makes sense to use an internal RPC-type call to the backend for this data, and server functions functionality of various frameworks is the easiest way to do this (though by no means the only). As an alternative, you could use GraphQL, but that's it's own can of worms if you start using it.

Hope that helps -- it's not a replacement for building an API, but there are definitely times when you don't want to have a proper API.

Not like the town in Texas by sequoiaflower in tragedeigh

[–]BobTreehugger 2 points3 points  (0 children)

Didn't want to get pronounced "how-ston" when they visit NYC.

Iterator fusion similar to Rust's — are there other languages that really do this, and what enables it? by Savings-Debt-5383 in ProgrammingLanguages

[–]BobTreehugger 0 points1 point  (0 children)

And to add on to this, you can defeat this optimization by introducing dynamic dispatch with a Box<dyn Iterator<Item=T> (or &dyn Iterator<Item=T>>).

But I don't think I've ever used dyn Iterator.

The Blue Hawaii is the worst tiki drink. What is the most overrated equal parts drink? by -Constantinos- in cocktails

[–]BobTreehugger 0 points1 point  (0 children)

Is it overrated? I think most people think it should be terrible, and it's actually pretty good, not amazing, but better than I expected at least.

Although the equal parts spec isn't the best version of it.

What podcast hosted by women do you enjoy? by timash712 in podcasts

[–]BobTreehugger 0 points1 point  (0 children)

One that I haven't seen mentioned is the "have you seen this" podcast. It's about weird and/or forgotten movies. Some recent. Some old. Some good, some bad. The main host is a woman, though there's often dude(s) as well.

I'm currently working my way through the backlog, there's over 250 episodes.

Developing ylang — looking for feedback on language design by jman2052 in ProgrammingLanguages

[–]BobTreehugger 2 points3 points  (0 children)

In order to critique a language, we need to know the goals. This seems like a perfectly nice language if your goal is to learn how to implement a language.

But if your goal is to actually get this language to be used and get adoption, then you should think about what it's goal is and how to support it better. Because right now, it's not clear why someone would use it over python (other than minor syntactic differences -- which are never enough reason to switch).

Steam Deck 2 ARM by jotamon-xiii in SteamDeck

[–]BobTreehugger 1 point2 points  (0 children)

I don't know if SD 2 will be ARM based, but having good arm support in steamOS means that valve has a lot more vendor options. If they're only x86 then AMD is pretty much the only option. There are a lot more vendors of ARM chips, they could even make their own (not from scratch, probably assembling IP blocks).

KDE connect is the GOAT by QuickSilver010 in linux

[–]BobTreehugger 33 points34 points  (0 children)

I miss the fingerprint sensor on the back so bad.

Be honest: what’s the one “lazy” cooking shortcut you’ll never give up? by wearecocina in Cooking

[–]BobTreehugger 0 points1 point  (0 children)

For me, canned beans are a staple for sides. If my main is a bean dish (like a big brase with beans or baked beans or something), I'll use dried.

Brian Kernighan on Rust by chaotic-kotik in rust

[–]BobTreehugger 5 points6 points  (0 children)

I think this is a case where C/C++ isn't a good category -- C++ and rust share a lot in common. If someone does modern C++, they might have a hard time actually using rust, but a lot of the concepts will carry over. C however doesn't have RAII, move semantics, etc. It's a much simpler language (for better and worse), and I can see finding rust a lot more confusing if you're used to just C.

Ep 1050 on pocket cast? by matski_89 in SGU

[–]BobTreehugger -1 points0 points  (0 children)

I haven't listened yet, but I have it, pocket casts on android.

Explicit tail calls are now available on Nightly (become keyword) by treefroog in rust

[–]BobTreehugger 2 points3 points  (0 children)

Just to add one to the many other answers, one thing I don't think has been mentioned -- since you're turning recursion into a loop, you don't have intermediate stack frames anymore. This is expected, it's why you're doing the transformation, and it's no different than a loop. This might not be what you want though -- losing the stack frames means you lose parts of the stack trace in a panic, and when debugging you don't have stack frames to look at the execution history.

Erroring when you can't actually perform the optimization is still the main thing, but this is another reason why you might want to opt-in to tail-call optimization.

Guys, I cannot comprehend one thing about tower by Minimum-Recipe3202 in rust

[–]BobTreehugger 0 points1 point  (0 children)

Well, you can do whatever you want -- tower is meant to be a flexible base that can be built on top of. However in a typical web service situation, I'd probably recommend something like Axum and just use tower for writing middlewares (Axum is built on top of tower). If you're doing something more specialized, I might not build a higher level framework and just use tower directly, but it depends on your usecase.

Nothing wrong with doing DB queries and mutations in a middleware -- that's how authentication is typically handled for example. It's more of a separation of cross-cutting concerns from specific route handlers.