Live data from Hacker News

I love building a startup in Rust but wouldn't pick it again

propelauth.com

421–430 of 496 posts

Re: I love building a startup in Rust but wouldn't pick it again

#421

Earlier quoted context omitted.

Map’s second and third parameters are optional. Your functions aren’t required to implement them, which is good, because most of the time you don’t need them. Again, this isn’t a type system issue. It’s both an API design issue and a poor programming hygiene issue. (Don’t pass bare functions if you don’t know what the parameters are.)

> Map’s second and third parameters are optional. I mean, map always passes them in, so in that sense they aren't optional. Mixing that with functions that take in optional parameters, but aren't usually called with them, gives you a ticking time bomb, IMO. And double that danger when the language's type system allows you to call a function with more parameters than it could ever take. > Don’t pass bare functions if…

How would you change the Type System to fix this particular issue?

>> Don’t pass bare functions if you don’t know what the parameters are.

> This is exactly the kind of thing I want my programming language's type system to catch for me, if I'm working in a language with a static type system like TS.

Hows your compiler supposed to know you don't know what the parameters are?

Re: I love building a startup in Rust but wouldn't pick it again

#422

Earlier quoted context omitted.

> I’d love to use C# without having to deal with distributing the runtime, so I’d like to hear more! In the later versions of DotNet there are a couple of common ways to distribute (I'd suggest either DotNet 6 [LTS] or preferably DotNet 7 [current]). You'd usually use the dotnet publish command, which ideally produces one of three things, all of which are self-contained and can be deployed to a clean server without a…

Yes, "dotnet publish" is what I was thinking of. Wow, I didn't realize it could cross-compile! I can't quite tell from the .NET SDK repository -- any idea if this stuff works on Linux (i.e. building on Linux, perhaps for Windows)? I see mention of MSBuild, so I'm guessing maybe not. I love C#, but I abandoned it a while ago because I wanted to only rely on open source tools (just to ensure my code is usable in the fu…

Actually, it does work from Linux! I just tried it and "dotnet publish --os win" cross-compiled from Linux to Windows. Nice!

Re: I love building a startup in Rust but wouldn't pick it again

#423

Earlier quoted context omitted.

> Map’s second and third parameters are optional. I mean, map always passes them in, so in that sense they aren't optional. Mixing that with functions that take in optional parameters, but aren't usually called with them, gives you a ticking time bomb, IMO. And double that danger when the language's type system allows you to call a function with more parameters than it could ever take. > Don’t pass bare functions if…

How would you change the Type System to fix this particular issue? >> Don’t pass bare functions if you don’t know what the parameters are. > This is exactly the kind of thing I want my programming language's type system to catch for me, if I'm working in a language with a static type system like TS. Hows your compiler supposed to know you don't know what the parameters are?

> How would you change the Type System to fix this particular issue?

In TS you really can't (that's my point and why I prefer to avoid the language) because of JS and API baggage. But just about every other static language that I've worked in can complain for this kind of thing.

> Hows your compiler supposed to know you don't know what the parameters are?

Why does the compiler care about what I know? The compiler itself knows what the function's parameters are and it can tell me that something seems wrong because I'm asking it to call a function that maxes out at 2 parameters with 3 parameters.

TS does catch this kind of thing in a lot of places. It just intentionally decides not to do it for these kinds of callbacks because of the same JS and API baggage.

Re: I love building a startup in Rust but wouldn't pick it again

#424
post #32

I've been writing Rust professionally for a few years now and if there's one thing I've learned it's that if you ever write a function that takes a parameter of `impl Fn(&Vec ) -> &'a str` you are going to be in for some pain. Just make it `impl Fn(&Vec ) -> String`. It is highly unlikely that the extra allocation is ever going to be noticed in the performance. Just because Rust pretty much forces you to be explicit…

A lot of programmers will look at '`impl Fn(&Vec ) -> &'a str`' and think what the hell is that, alien hieroglyphics?

Loosely speaking, it’s a type signature for a function that

1. takes an immutable reference to a vector of strings and

2. returns an immutable reference to a string,

3. with the constraint that the strings in the input vector must not be freed before the result is freed.

It’s a reasonably concise way of saying all that.

Re: I love building a startup in Rust but wouldn't pick it again

#425

Earlier quoted context omitted.

With all due respect, you’re Steve Klabnik. That makes “Rust at a startup” a different equation.

I am one of roughly 50. I'm pretty sure the rest of them are not Steve Klabnik. I also just work there, the all-Rust bit started well before I joined! That said, you are right that it's a point worth considering.

>> I'm pretty sure the rest of them are not Steve Klabnik.

We have only your word for this.

Re: I love building a startup in Rust but wouldn't pick it again

#426
post #37

If you're thinking about building something in Rust, a good question to ask is, "what would I use if Rust didn't exist?" If your answer is something like Go or Node.js, then Rust is probably not the right choice. If your answer is C or C++ or something similar, then Rust is very likely the right choice. Obv, there are always exceptions here, but this helps you work through things a bit more objectively. Rust can be a…

> If your answer is something like Go or Node.js, then Rust is probably not the right choice. If your answer is C or C++ or something similar, then Rust is very likely the right choice. I've been saying that for a while. If you're building web backends, Rust is not a good choice. Go is so much easier. The green thread system gets rid of the thread/async distinction, garbage collection means you don't have to obsess o…

> It’s not that useful for phone apps.

If you’re building a large complex app that needs to be shared across multiple platforms, C++ is a common choice. Not talking about games here, think Office, Facebook, Zoom, WebEx etc. It easy to see Rust replacing C++ in that stack.

But as Rust is so much nicer that C++, I could see it becoming popular for smaller projects that want to share common logic, with a native UI on top.

Re: I love building a startup in Rust but wouldn't pick it again

#427
post #44

I can't get it why people would prefer to add "?" to everything instead of just having exceptions which automate that behavior. In the bad old days of C there were two kinds of programs: programs without correct error handling, and programs where half the loc are unhappy paths that do what exceptions do... with a huge amount of work. Today people are repeating the same mistakes of the past, putting a "?" on everythin…

Error handling in Rust is actually a lot worse than you think. In fact it may be the single worst aspect of the language. Fundamentally it is difficult to impossible to fix bugs without knowing what code caused it. Java-style exceptions give you a backtrace for free, which is a huge head start. With Rust you have to do a lot of manual plumbing with something like error_stack to get similar functionality, out-of-the-b…

> Java-style exceptions give you a backtrace for free, which is a huge head start. With Rust you have to do a lot of manual plumbing with something like error_stack to get similar functionality

With crates like anyhow and eyre you also get backtraces "for free" nowadays, without needing to do manual plumbing (all you need to do is toggle on a feature flag).

Re: I love building a startup in Rust but wouldn't pick it again

#428
post #37

If you're thinking about building something in Rust, a good question to ask is, "what would I use if Rust didn't exist?" If your answer is something like Go or Node.js, then Rust is probably not the right choice. If your answer is C or C++ or something similar, then Rust is very likely the right choice. Obv, there are always exceptions here, but this helps you work through things a bit more objectively. Rust can be a…

On the contrary. I’ve been recently writing a web service in Go… and omg what a terrible experience. Sure, I could prototype something very quickly, but now it’s almost impossible to refactor any of it without introducing subtle breakage. And it’s sooooo verbose and redundant and fragile.

I’m currently rewriting what I wrote in Rust to see how the prototypes compare and… I just feel so much at peace knowing that the type system and the borrow checker have my back and that I won’t encounter unexpected nil pointers or zero values. And I write this quickly as well.

(Yes, I do have experience with both languages, so none of these exercises were new to me. But I’ve been favoring Rust over the last couple of years.)

Re: I love building a startup in Rust but wouldn't pick it again

#429
post #388

Earlier quoted context omitted.

AWS doesn't charge for internal server-to-server transfers, so the answer is precisely 0.

That's only true for transfer in the same availability zone. https://aws.amazon.com/ec2/pricing/on-demand/#Data_Transfer_...

Availability and horizontal scale-out are separate axes, so that isn't relevant for this question.

Re: I love building a startup in Rust but wouldn't pick it again

#430
post #182

I don't agree. I think the author is conflating two things: 1. learning Rust, and 2. using Rust. If you take away "Rust made us slow because our team had to learn how to use it and thus we had slow iterations and it's harder to find hires with Rust knowledge" from the equation, then you aren't left with much argument against using Rust early. The iteration time issue with Rust is solved by experience. We use Rust and…

> We gain correctness. And at an early stage, correctness without paying for a massive QA team is a huge boon.

Compared to what? Java, C# and Go?

Post reply on HN