DEV Community

Angel Daniel Munoz Gonzalez
Angel Daniel Munoz Gonzalez

Posted on • Edited on

Rust, inspire me please!

Hello everyone!

I've been looking at rust recently I'm mostly a node developer
I like javascript quite a lot, it has the good and the bad parts, however today with the addition of babel/typescript (and of course es6 (jokes) =>,7,8,9,7,123,13,5,64, <= (jokes), es-next) etc. it's quite easy to do a bunch of tasks relatively quick, also we can't forget the npm registry etc.

However I have been looking at different alternatives at languages to program,
I know some python, C#, and stuff like that which aren't bad but it feels like every time I want to do some serious side project (hahaha, sure, sure: "Serious") in any of other languages I end up missing JavaScript.

Recently I've been diging up into Rust which aims to be a quite awesome programming systems language, and I quite like how it looks like, the fact that I don't need to keep much track of memory (only lifetime?) is what calls me onto it, you know I don't really want to mess up with C/C++ because while I'm pretty sure I know how to program I still feel like those languages are not easy when it comes to professional work, and Yes I know learning either C or C++ would make me a better developer because of those same things that make me feel they are hard to learn.

Also I'd like to mention that I'm sick of doing Restful API's (holy js right?) so rust seems like a good alternative in the sense that If I can get a really good hang of it I could even (some day) create a native add-on for node with the neon project. Also I would love to dig into games development it is a fairly unexplored area for me, while I enjoy them (Star craft, World of Tanks, and such) I don't do either experiment or learn much about how to do games.

this gets me to think How about mixing and matching Rust+Games+Node, I'd like to know if there's someone or some project exploring these areas and also, resources to learn all of that stuff.

Also I've been thinking on how good would it be to develop a small DSL for some of my teammates at work (that are non programmers) to help them do their tasks easier (and also easier for us programmers too) but I never learned at school (not that they taught that too) anything about compilers, lexers, and all of those things you need to create a programming language (while I don't aim to do a whole complete language I know it would be helpful to know that)

What seems difficult to me on rust right now is the fact that (badly I know but hey it's almost 2018!) I rely too much in text editor/ide feedback so the fact that the vscode extensions either rust and rust(rls) sometimes aren't available or something, the type I need/want to know I end up fighting the compiler instead, how do you guys/gals work on that sense? I'd be really glad to have some pointers.

Also I'd like to know why you like rust? why don't you? what's the thing that has help you the most?

If you feel my ideas are too disperse, don't worry they are hahaha
Cheers!
-Angel D. Munoz

Top comments (9)

Collapse
 
dubyabrian profile image
W. Brian Gourlie • Edited

It's important that you evaluate a programming language from the proper context. I've seen a lot of comments on social media to the effect of "If you like node/ruby/python, you should check out rust!"

I think this is the wrong way to approach the language. If you traditionally work on projects where these dynamic, garbage-collected languages meet your needs, you generally wouldn't consider a language like rust as a meaningful alternative, the same way you wouldn't consider C++ a meaningful alternative. With that said, if the intention is to learn, nothing should stop you!

The most meaningful difference between rust and node/ruby/python is the use of a garbage collector. Garbage collectors are awesome because you don't have to worry about allocating and freeing memory, which makes development both much faster and safer than say, languages like C or C++.

Rust doesn't have a garbage collector. Or, perhaps, you could think of rust as having a static garbage collector: The compiler enforces certain rules that guarantee things will be properly allocated and freed. It's these rules that trip most rust newbies up—Things that would be trivial in familiar languages are all the sudden hours-long battles with the compiler because of rules that seem completely foreign at first.

When you compare how difficult it is to write a production-ready web application in rust vs a garbage-collected language, one typically walks away thinking, "That was way harder in rust and I don't notice much (if any) improvement in how my application operates!"

Again, that's not to say it isn't a useful exercise! It just may not inspire you to do more with rust. That's because you're not really leveraging rust in a way that truly distinguishes it from languages you're used to.

If you want rust to inspire you, here's my advice: Write a simple application in rust, similar to something you've already done in node. Don't expect it to be easier or even necessarily better. Once you start to feel a little more confident, go do something that you couldn't do in node!

Explore a domain where node doesn't satisfy the requirements. Where you need the speed and memory safety of rust, while having a compiler that guides you in writing fast, safe code.

Collapse
 
tunaxor profile image
Angel Daniel Munoz Gonzalez

I get you, I do. I'm not looking to replace node with rust at all I just want an alternative to do stuff as you mention that I wouldn't normally try on node, the inspiration thingy comes on the fact that I feel I'm too much into the web wagon (and I feel that it hinders me in the long run) and I don't know much about what I should do besides web

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Rust is also on my learning list for 2018.

Also, for the record, C++14 isn't hard at all. :)

Collapse
 
legolord208 profile image
jD91mZM2

Welcome to the best programming language, pal :^)

  1. Don't beat yourself up over not learning C/C++. Just because Rust has some nice abstractions doesn't mean you have to feel like you're missing out. Manual memory management is something unsafe Rust can do as well, so really no reason to beat yourself up. Just know that memory is a stream of bytes. Once you understand that you understand the core of manual memory management.
  2. Game development? Check out arewegameyet.com.
  3. Let me know if I can help you with DSL. For some reason I've always loved parsers, even though I'm not really good with them either. For something simple, a for loop with variables keeping track of the state (escaped? quoted? et.c) should do. Or if you wanna go fancier you could use an iterator peek/next in order to make the code more beautiful. Check out enigo's parser for an example.
  4. I've never really had an issue with RLS. Or, I have, but I haven't noticed it until it fixed itself (by updating nightly or something). I guess I'm used to typing->compiling->fixing rather than using a tool for it. In case RLS should malfunction for you, just remember the command cargo check. It's faster than building, but it doesn't produce a binary.
  5. I like Rust because of a lot of reasons. Mostly because I don't have to worry about memory leaks, segfaults, or thread unsafety, while still keeping my program fast. I have never really liked C for some reason, but I used to use Go. Back then I thought it was perfect. But it was never low level enough for me. Sure, you can make C FFI bindings. But it all felt like a hack. In Rust, all this feels natural somehow. I'd be surprised if I find a LLVM binding library for Go, while I'd be surprised if I didn't find one for Rust. Also, Go mutexes are a pain in the ass. As soon as I learned about race conditions, I hated every goroutine I ever saw.
Collapse
 
tunaxor profile image
Angel Daniel Munoz Gonzalez

Hey thanks for the lovely response I will definitely check the links provided, I also looked at github.com/Geal/nom but I haven't really tried much I'm still getting familiar with the language

Collapse
 
legolord208 profile image
jD91mZM2

Wow, nom looks cool. Wouldn't use it personally, but if you like it, definitely go for it!

Collapse
 
mnivoliez profile image
mnivoliez

First of all, hi!

Rust is indeed a good learning material. Trying to understand how and why things are done inside Rust is a mind blowing.
That said, as many already mention, Rust is hard. It is safe but it comes at a cost. And writting stuff in Rust will not make it faster for sure. However, it should make it more safe. You should check out this talk wich explain it better than me.
Also, as a student in video games, I think Rust got potential in it but not "industrially" ready. Again, it's a good place to learn.
Also, I don't see a need to mix node and rust in a "single unit". But I do not know your case.
So, welcome to Rust, land of joy and learning, frustration and exhaustion.

PS: The community is amazing, if you have any problem/difficulty/question, go ask them.

Collapse
 
mozoobear profile image
Zubair

I've been meaning to get started with Rust. It seems like a good investment if you want to get into system level development without dealing with complexity that comes with C++.

How are you learning Rust? are you following tutorials or reading a book? or just winging it and googling as you have questions?

Can you describe the DSL project you're doing a bit more?

Collapse
 
tunaxor profile image
Angel Daniel Munoz Gonzalez

Most that I've been looking at is source code from projects here and there, reading "the book" and I will most likely try to port a small lib I did when I was learning typescript.
The DSL I'm thinking on is somewhat for lawyers in Mexico, where they could describe what kind of parts of a text they need so after that generate a bunch of lawyery boilerplate for their needs it's a weird concept which I haven't really polished on thinking but that's somewhat the idea