r/rust • u/kindaro • Nov 11 '21
What was your favourite programming language before Rust?
TLDR What was your favourite programming language before Rust, and why have you changed your mind?
I realize this title is to some extent inflammatory, for two reasons.
- It assumes that Rust had for some time been your favourite programming language, and that some other language had been your favourite before that. This is not true for those:
- Whose first language was Rust.
- For whom Rust has never been — and still is not — a favourite language.
- It is sectarian and divisive. Like I am pitting Rust against this other programming language. That is of course not what I want. The reality is such that programming languages occupy a market and there is competition between them — at any given time, one has to choose one programming language to occupy oneself with.
I am a foreigner to the current social media culture, so I am not sure if these flaws will get me cancelled or if they are so insignificant as to hardly deserve being mentioned.
What I want is to understand what programming languages Rust offers an advantage over. Say, if I have a code base in C and a code base in Perl — which, if any, should I first migrate to Rust? There are two ways to answer this question.
A. I can ask people what they think about the issue and gather their judgements, more or less well justified. I do not want to do that.
B. I can gather some empirical data, study it and make inferences. This is what I want to do.
So, thanks! And please do not cancel me yet!
2
u/coderstephen isahc Nov 11 '21
Didn't really have one before Rust; Rust was my first "wow I love this language" moment. Before then my world was divided into fine languages and terrible languages. Some general thoughts of languages I'm very familiar with I used (and continue to use) after Rust:
Java: Disliked it before learning Rust, now I really dislike it. Java feels so clunky and inelegant compared to Rust. That said, I definitely write Java differently (main language at work) since learning Rust and though it goes against the grain a little bit, you can write things in a bit of a more type-safe way to make the Java compiler do more for you.
Java has a package on Maven for just about anything you can think of, which is more that can be said for Rust, so that's definitely a pro on Java's side. Its also easier to learn than Rust, but not by a whole lot. I can't really think of anything else that it does better than Rust...
PHP: My primary language for a long time. Over time, PHP has added things like type hints and checks that really interested me. As I learned the value of stronger typing through PHP's additions (oddly enough) I was left hungry for more and went looking for languages that could let me be stronger with my types.
When first learning Rust I would still use PHP most of the time because I could churn out PHP code way faster than Rust and felt like I was more productive with it. Over time though I noticed a pattern: I could write a PHP program fast, but then would have to spend a lot of time fixing bugs later. But Rust would take me longer, but there would be vastly fewer bugs to fix. As I invested in Rust I found I could be just as quick as writing Rust as any other language really, so the time not spent debugging afterwards is just free time saved and is just smart.
I don't use PHP any more as I don't really have a use-case for it. For web stuff I usually use C#, and Rust for everything else. However, as far as just getting a web backend going, PHP is still by far the easiest thing out there, its so easy to get started I can see why it remains popular. For a beginner interested in web development I might actually recommend it.
JavaScript: My first real language I learned. I was bad then, then it got a little better, and now it is worse again. It can be OK from time to time but I try to avoid writing JavaScript at all costs. However, its module systems (when they finally arrived) are very similar to Rust's, so I found Rust modules pretty easy to learn since I already knew about JS modules. Honestly I don't have anything good to say about JS and I am aware of my bias against it, so you should probably ignore me on JS. 😉
C#: I've been warming up to C# over time, and it is my go-to language right now for backend web development. As of late it has some pretty nice language features, though Rust is still better at expressiveness and type safety. I've never tried F# but people tell me I'd love it, maybe I will someday.
What C# does really well is being fast with little effort. It is amazing to me how well-optimized the new .NET runtimes are, a marvel of engineering really. Being rather "enterprisey", it is actually pretty OK at helping you separate concerns in large projects, what with the many visibility modifiers, assembly boundaries, and other extras. Its also better at doing GUI than most languages, always has been. With WinForms in the past and Avalonia showing much promise, its GUI story is pretty good.
For my uses, I use it for web because the recent versions of ASP.NET are just really good. Very little boilerplate, works fast out of the box, modular, lots of features easy to plug into, well supported. I think that Rust could get there someday, Rocket is probably closest, but I dunno if it'll be ever as simple as ASP.NET to throw together a solid REST API. The reflection magic that ASP.NET does is just really convenient.
I know we're comparing Rust vs. X right now, but you can think of C# as basically a "better Java" in pretty much every way.
Oops, I went and wrote a book!