I find the dependency creep for both rust and node unfortunate. Almost anything I add explodes the deps and makes me sweat for maintenance, vulnerabilities, etc. I also feel perpetually behind, which I think is basically frontend default mode. Go does the one thing I wish Rust had more of which is a pretty darn great standard library with total backwards compatibility promises. There are awkward things with Go, but m…
With Go it's good to keep in mind the Proverbs, which includes this gem: A little copying is better than a little dependency.
Farewell, Rust for web
91–100 of 197 posts
Re: Farewell, Rust for web
#92I want to address this one point: > Similar thing can be said about writing SQL. I was really happy with using sqlx, which is a crate for compile-time checked SQL queries. By relying on macros in Rust, sqlx would execute the query against a real database instance in order to make sure that your query is valid, and the mappings are correct. However, writing dynamic queries with sqlx is a PITA, as you can’t build a dyn…
sqlx doesn't build queries, or at least it minimally builds them. Which I think is the thing the OP is complaining about. And, IMO, making dynamic queries harder is preferable. Dynamic queries are inherently unsafe. Sometimes necessary, however you have to start considering things like sql injection attacks with dynamic queries. This isn't to poo poo sea-orm. I'm just saying that sqlx's design choice to make dynamic…
Depends on what you mean by "dynamic query". You are dealing with injection attacks as soon as you start taking user input. Most useful user facing applications take user input.
In a simple case it might be "SELECT * FROM posts WHERE title LIKE '%hello world%', where "hello world" is a user specified string. This is easy with sqlx. Where things get more difficult is if you want to optionally add filters for things like date posted, score of the post, author, etc... That makes the query dynamic in a way that can't be solved by simply including a bind.
That's where sea-orm shines over sqlx IMO. sqlx will force you to do something like
```
let mut my_query = "SELECT * FROM posts WHERE title LIKE '%' + $1 + '%'";
let mut my_binds = vec![args.keyword];
if let Some(date) = args.date {
my_query = format("{my_query} AND date = $2");
my_binds.push(date);
}...
```
Your building a string and tracking binds. It gets messy. A good query builder like seaorm has lets you do something this:
```
let mut query = Posts::find().filter(Column::title::like(args.keyword));
if let Some(date) = args.date {
query = query.filter(column::Date::eq(date));
}```
This pays off as your queries get more complicated. It pushes the string manipulation and bookkeeping into a library, which can be more thoroughly tested.
It also lets you pass around typed partial queries, eg in the example above query might be returned from a function, which helps you build more modular code.
Re: Farewell, Rust for web
#93Earlier quoted context omitted.
It does work well logically but performance is pretty bad. I had a nontrivial Rust project running on Cloudflare Workers, and CPU time very often clocked 10-60ms per request. This is >50x what the equivalent JS worker probably would've clocked. And in that environment you pay for CPU time...
The rust-js layer can be slow. But the actual rust code is much faster than the equivalent JS in my experience. My project would not be technically possible with javascript levels of performance
A demonstration of that by the creator of Leptos:
Re: Farewell, Rust for web
#94due to the nature of safety in Rust, I’d find myself writing boilerplate code just to avoid calling .unwrap(). I’d get long chain calls of .ok_or followed by .map_err. I defined a dozen of custom error enums, some taking other enums, because you want to be able to handle errors properly, and your functions can’t just return any error. This can be a double edged sword. Yes, languages like python and typescript/JavaScr…
The times something like that happened to me AND wasn't a trivial fix can be counted on half a hand. A tradeoff I'd take any day to not have to deal with rust all of the time.
Re: Farewell, Rust for web
#95Earlier quoted context omitted.
The rust-js layer can be slow. But the actual rust code is much faster than the equivalent JS in my experience. My project would not be technically possible with javascript levels of performance
That's fair and makes sense. In my case it was just a regular web app where the only reason for it being in Rust was that I like the language.
Re: Farewell, Rust for web
#96Earlier quoted context omitted.
It's not Turing-complete, and as you say, it's a markup language and it's not general purpose. But neither is a necessary component of "programming language".
Ifs and enumerations are a simpler requirement than Turing completeness. They're an even more basic version of giving the computer logic to evaluate.
For that matter, it wouldn't take much to get HTML to have those features... though the DOM, JS and even WASM do so well, we don't need it generally speaking.
Re: Farewell, Rust for web
#97Earlier quoted context omitted.
Those deps have to come from somewhere, right? Unless you're actually rolling your own everything, and with languages that don't have package managers what you end up doing is just adding submodules of various libraries and running their cmake configs, which is at least as insecure as NPM or Crates.io. Go is a bit unique a it has a really substantial stdlib, so you eliminate some of the necessary deps, but it's also…
The tradeoff Go made is that certain code just cannot be written in it. Its STD exists because Go is a language built around a "good enough" philosophy, and it gets painful once you leave that path.
Re: Farewell, Rust for web
#98Earlier quoted context omitted.
IDK, I still miss Rust's strictness and exhaustive enum matching.
I don't know about what other strictness you're referring to but exhaustive enum matching is common check in most TS stacks via eslint. Yea, it's not builtin, just saying there's a solution and it's super common.
Re: Farewell, Rust for web
#99Earlier quoted context omitted.
sqlx doesn't build queries, or at least it minimally builds them. Which I think is the thing the OP is complaining about. And, IMO, making dynamic queries harder is preferable. Dynamic queries are inherently unsafe. Sometimes necessary, however you have to start considering things like sql injection attacks with dynamic queries. This isn't to poo poo sea-orm. I'm just saying that sqlx's design choice to make dynamic…
> And, IMO, making dynamic queries harder is preferable. Dynamic queries are inherently unsafe. Sometimes necessary, however you have to start considering things like sql injection attacks with dynamic queries. Depends on what you mean by "dynamic query". You are dealing with injection attacks as soon as you start taking user input. Most useful user facing applications take user input. In a simple case it might be "S…
For this specific example, the better way is something like this
let result = if let Some(date) = args.date {
sqlx::query("SELECT * FROM posts WHERE title LIKE '%' + $1 + '%' AND date = $2")
.bind(args.keyword)
.bind(date)
.fetch()
} else {
sqlx::query("SELECT * FROM posts WHERE title LIKE '%' + $1 + '%")
.bind(args.keyword)
.fetch()
}
But I get how this would be untenable if as the number of query param combos goes up. In that case dynamic SQL really is the only sane way to handle something like that.Re: Farewell, Rust for web
#100Earlier quoted context omitted.
That's fair and makes sense. In my case it was just a regular web app where the only reason for it being in Rust was that I like the language.
did you profile what made it so slow specifically? sounds waaaaay worse than I would expect
edit: and it cold started quite often. Even with sustained traffic from the same source it would cold start every few requests.