Live data from Hacker News

Using Rust at a startup: A cautionary tale

mdwdotla.medium.com

311–320 of 355 posts

Re: Using Rust at a startup: A cautionary tale

#311
post #310

Earlier quoted context omitted.

Is Java not a GC language, or does sun.misc.Unsafe not exist?

I don’t why people keep finding one GC language that has unsafe, then declaring my argument wrong. My point is you can find a safe GC language with all the benefits of rust.

The quantifier I infer from "GC languages simply will not allow it" is "all", not "some". Anyway, can you name such a language then?

Re: Using Rust at a startup: A cautionary tale

#312
post #280

Earlier quoted context omitted.

You can? Imperative, strong type system (no null, adts), reasonably fast, compiles to a single binary. I'm genuinely interested.

Go fits all of those, so does Ada.

I've used Go for almost two years on a side project and its type system is exactly why I'm doing Rust now. In my book, it is not okay that I add a new field to a struct and then nothing happens. No compile warnings, nothing. It's just assumed that I then wanted the zeroth value whenever it's created. ... And no adts. You just can't make something as simple as

    enum Foo {
        Bar(String),
        Baz(i32),
    }
Why? It's such a fundamental thing to be able to say "this piece of data is either this or that.. and then have the compiler tell you if you missed a case.

Ada is on my list of languages to look at. I'm cautiously optimistic about that one. But would you pick that over Rust as the simpler alternative? "Look guys! We're not moving fast enough with Rust because nobody seems to be proficient in it. Let's go with Ada instead!" .. I jest, but I will check it out and I really hope it hits the sweet spot for me

Re: Using Rust at a startup: A cautionary tale

#313

Earlier quoted context omitted.

You can? Imperative, strong type system (no null, adts), reasonably fast, compiles to a single binary. I'm genuinely interested.

Kotlin has null safety, and there are plenty of ways to turn jvm into a binary

It has no adts at all. Like I'm reading blog posts right now about how to do what should be the simplest thing

    enum Foo {
        A(String),
        B(i32),
    }
And it's.. not simple. And even if you manage to do it, it'll never be how Kotlin was meant to be written.

Re: Using Rust at a startup: A cautionary tale

#314
> Rust makes roughing out new features very hard.

> I don’t know about anyone else, but at least for me, when I’m building a new feature I usually don’t have all the data types, APIs, and other fine details worked out up front. I’m often just farting out code trying to get some basic idea working and checking whether my assumptions about how things should work are more-or-less correct. Doing this in, say, Python is extremely easy, because you can play fast and loose with things like typing and not worry if certain code paths are broken while you rough out your idea. You can go back later and make it all tidy and fix all the type errors and write all the tests.

> In Rust, this kind of “draft coding” is very difficult, because the compiler can and will complain about every goddamn thing that does not pass type and lifetime checking — as it is explicitly designed to do. This makes perfect sense when you need to build your final, production-ready implementation, but absolutely sucks when you’re trying to cruft something together to test an idea or get a basic foundation in place. The unimplemented! macro is helpful to a point, but still requires that everything typechecks up and down the stack before you can even compile.

This rings so true for me. I could "mock up" entire apps using interfaces in Java, without having to actually write impl code. I could be sloppy as hell around the edges, but that didn't matter, because I could get the large design right without the compiler screaming.

In Rust, there is the chasm between no code and anything that works, feels so draggy.

Re: Using Rust at a startup: A cautionary tale

#315
post #290

Earlier quoted context omitted.

go doesn't have null safety or adts though? (sum types)

I think you can have null safety in Go and you certainly can have adts. But even then, what about Ada? I’m also not an expert, but I assume between C#/Typescript/haskell/swift that you can find all those things in many GC/safer languages.

Yes, Ada. Maybe. I will have to look at it.

The rest all are missing basic things. Like, I love TS, but it's absolutely bonkers because js is js. I once worked on a 250k loc project of js/ts, and we had nothing but trouble

Re: Using Rust at a startup: A cautionary tale

#316

Earlier quoted context omitted.

I don't necessarily agree that Python overall is difficult to read, but one thing that seems to get my every time is the foo = x if y else z

I see where you're coming from. Many languages support the ternary operator, where it would be: foo = y ? x : z Which "feels better" but I think that's because I learned ternaries first. Some languages like Rust and Kotlin do support assignment of an if statement like foo = if (y) { x } else { z } And I think that's a good step, as it doesn't need to introduce new syntax, just allows assignment of "blocks"

Yes. It requires that `if else` can be used as expressions, which for some reason in most languages that can not.

In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less.

    foo = if y { x } else { y }
Works well :-)

Re: Using Rust at a startup: A cautionary tale

#317

Earlier quoted context omitted.

Kotlin has null safety, and there are plenty of ways to turn jvm into a binary

It has no adts at all. Like I'm reading blog posts right now about how to do what should be the simplest thing enum Foo { A(String), B(i32), } And it's.. not simple. And even if you manage to do it, it'll never be how Kotlin was meant to be written.

I agree with you 100%. It's the thing I miss most when not writing Rust. I will say that it as a feature alone isn't a good enough reason for me to write Rust, though!

Re: Using Rust at a startup: A cautionary tale

#318
post #101

This matches my experience. I have been doing compiler development in C++ for about 10 years, lisp before that and a bit of python more recently. We could not figure out how to be productive in Rust after starting a greenfield project and sticking to it for a month. Luckily this was not a project which requires incremental updates, we were on the verge of rewriting it in C++.

Well if you had 10 yoe with C++, you would certainly not achieve the same level of productivity with Rust for a while. Your point is valid in the sense that you should use the tool that you know if you need results, but it's not great criticism towards Rust.

For most languages it takes a few weeks to be reasonably productive.

This is not a criticism of Rust, just a trait which needs to be acknowledged if the situation has to be improved.

Re: Using Rust at a startup: A cautionary tale

#319
post #310

Earlier quoted context omitted.

I don’t why people keep finding one GC language that has unsafe, then declaring my argument wrong. My point is you can find a safe GC language with all the benefits of rust.

The quantifier I infer from "GC languages simply will not allow it" is "all", not "some". Anyway, can you name such a language then?

Are you gonna argue that no GC language exists that is more safe than rust?

There were over 200 memory safety violations discovered in rust crates: https://www.infoq.com/news/2021/11/rudra-rust-safety/

Elixir for example, is very safe and guarantees more safety than rust.

Re: Using Rust at a startup: A cautionary tale

#320
post #213
post #202

Earlier quoted context omitted.

What would you say to a C++ dev refusing to use rust because their code is memory safe and they have never had a memory safety issue? "Can" is the whole thing. A rust dev risking can is like a C++ dev risking can. I like rust and do what you want in personal projects, but introducing it to a GC space when there are langauges that "can't" be unsafe is irresponsible when a GC language can offer all the upside of rust.…

The difference is that it's fairly easy to prevent unsafe code from occurring: a "forbid(unsafe_code)" directive prevents unsafe code from even being accepted by the compiler. In C++ there is no equivalent - good linting can prevent some obvious errors, but a lot of valid code is inherently unsafe (in the Rust sense) if used incorrectly or under the wrong assumptions. It's also worth pointing out that most GC languag…

Right but to my knowledge (and I could be wrong) that unsafe tag does to prevent it in the crates.

Many memory safety violations have been discovered in rust crates: https://www.infoq.com/news/2021/11/rudra-rust-safety/

Maybe I wrong on that, but if it can’t guarantee crate safety, then it doesn’t really do anything.

Post reply on HN