Quasi-newb drowning


#1

Will try to make a long post a short as possible.

I “was” a programmer. But I haven’t done any real coding in a long time. More than 5 years which is an eternity in the field. I need to write a kernel for a decentralized computational mesh that will ultimately be integrated with blockchain and Internet of Things systems. After some research I decided that Rust is the way to go because of the memory safe paradigm and that itcompiles to multiple platforms.

I’m coming from a Windows background but decided to go with Linux as my development environment. The Rust community is simply more attuned to Linux and I suspect that this entire project will end up tied in some ways to open source and Linux.

I’ve never been a command line/terminal sort of guy. I’ve always used some sort of full featured IDE.

So I’ve taken on a big task. I need to learn Linux, Rust, command line tools. It’s been frustrating as hell because everything I find on setting up a Rust environment “almost” works but runs into some detail that doesn’t quite fit the instructions.

My first pass at this was to use Linux Mint. I’m wondering if that is the best choice because it comes with so much pre-installed and some of the problems I encountered in setting up the tool chain were because of GDB and GNU components that didn’t play perfectly nice with rustup/nightl/stable compnonents.

I also will need to have Python and its tool chain in place. I suspect C and C++ in the future and whatever hooks need to be in place for a webservices API. But that can wait. Right now its Rust and Python.

So I’ve decided the first step is to pick the right version of Linux. I don’t want to have to spend a lot of time learning Linux at a deep level but I think I need a “lightweight” version with enough desktop usability that I don’t have to install a boatload of things just to do typical tasks. But I also think I would like to install the entire programming toolchains myself rather than have any of them preinstalled. I want the Python and Rust installs free of any artifacts that might come with a particular install of Linux. Am I asking for too much?

So I guess the requirement is the version of Linux that will let me do clean installs of Rust and Python with a good text editor/debugger combo (considering going to EMACS but I haven’t used that in 25 years - yeah, I’m that old).

Sorry this is so long. Help appreciated.


#2

Hi! Welcome!

I see you’re taking a huge leap in several areas. That is a lot to deal with…

Regarding toolchains, using C/C++ and Python shipped with a Linux distro is usually a good idea. Linux distributions package them carefully and ensure everything works together. Installing a custom toolchain “by hand” is going to cause you more work and pain — not only hassle of custom build, but also configuring everything else to use your version instead of the standard system one, and dealing with annoying errors when system-default version ends up mixed with yours. So I’d definitely recommend sticking to your distro’s package manager and installing C/C++ toolchain and Python from there. You will end up with dependence on packages from the distro, but it’s not a big deal. All Linux distros have more or less equivalent packages.

For Rust itself rustup is usually the best choice. Even if your distro comes with package for Rust, it may be an older release. Rustup will help you get the latest release and switch between stable and nightly easily. If you’re planning to write a kernel, you might want to use some nightly-only features and tools.

For the IDE, check out https://areweideyet.com/ I’ve heard good things about integration in IntelliJ IDEA and VS Code. I’m using Sublime Text with Rust Enhanced plugin and it’s pretty good too.


#3

This is extremely interesting to me; I actually use Linux Mint right now for Rust (installed from rustup) and Python (preinstalled), and I’ve never had any problems with this combination. What method did you use to install Rust?


#4

I suspect part of the problem is learning Linux at the same time as learning Rust. Almost every single command is new to me. And I’m also spoiled from the WIndows world. I’ve written installers for Windows and a requirement is they have to be brain dead easy. Click Click click done. I’m having flashbacks to college and Sun Sparc workstations and X Windows.

I think I may start a new thread and document this for posterity, Good walk throughs are really nice to have lying about.

I will say that I was really impressed at the Mint install. Linux has come a long way since the last time I played with it (20+ years ago).


#5

I’d agree with @Kornel. When in doubt try to use the distro’s packages for things because that’ll eliminate the unnecessary pain of installing and configuring everything manually. Installing Rust is a little different in that there’s a new release every 6 weeks and the version in the distro’s repositories will likely be 6-12 months out of date. Getting started with rustup is essentially Linux’s equivalent of a one-click installer (curl ... | sh), so you shouldn’t have any troubles there.

Rust doesn’t require any specific IDE so you can use pretty much any text editor you are familiar with. I usually like Vim, but VS Code is really good too and a lot more beginner friendly. If you prefer more heavy-weight solutions, IntelliJ has pretty good support for Rust and should let you do the usual things like compiling + running and debugging.

I’ve found you tend to use a debugger significantly less often than most other languages (only a handful of times in the last 2 years compared to almost every day). 90% of the time the type system will make sure that if something compiles, it’s pretty much correct. Rust has pretty good support for testing out of the box (i.e. you don’t need any 3rd party test harness libraries like GoogleTest or ctest), so that is usually enough to make sure you don’t have logic errors.

That said, gdb and lldb already work well with Rust code and I’ve had to use them several times when interoperating with C or other languages (e.g. writing DLLs).


#6

My suggestion is to avoid going “big bang” in life. Change one parameter at a time and change things step by step, going one step forward when you are feeling OK.


#7

Hmm. I can only speak for the two distributions I’ve tried, which are Ubuntu and Arch Linux.


Ubuntu is, from what I understand, probably similar to Linux Mint; after all Mint is derived from Ubuntu. It’s a fairly popular distribution, meaning you’ll have an easy time finding help.

Ubuntu was my first Linux, and I used it as my primary OS for over six years, beginning with 9.10 Karmic Koala. The destop grid feature alone multiplied my productivity by a hundred compared to Windows, and I was blown away by how easy it was to install software (again, compared to Windows). Judging from release dates, I guess this was the first release to come with the (GUI-based) Ubuntu Software Center, and perhaps that’s why I never used it (as most guides at the time used the CLI tool apt-get).

Over the years, I became increasingly frustrated with Ubuntu. Doing a full system upgrade can be a hassle, so I stuck to the LTS releases that came every two years. And I found myself in this repeating cycle where every two years I’d find myself having to manually build more and more parts of my toolchain as I would find that every package related to code dev on the Canonical repositories is incredibly out-of-date!

(note: Mint probably has this same issue as well, since their releases vaguely follow the Ubuntu LTS schedule)

You say you’d like to install everything yourself, but I can’t really tell what you have in mind there. “Manually installing” something on Linux almost always means building it from source yourself, which is basically just a bunch of gruntwork of locating the source, RTFM, running a few commands, and, most importantly, installing all of its dependencies first (and all of their dependencies, etc.). That last point makes the process brutally tedious, and it is why you should let a package manager take care of this whenever it is humanly possible.

This is why I switched to Arch Linux.


Arch Linux is different. Here’s the thing:

The problem of having outdated tools does not exist in Arch Linux, because it uses a rolling distribution model. Everything is up-to-date, all the time, so you always have the latest, greatest, (and buggiest!) software. The only reason I ever need to build anything myself is if the thing I’m trying to install is not too popular yet.

However, Arch is also not for beginners. If you try Arch out right now, it’ll basically be sink or swim, and you’ll need to learn a lot of Linux before you get to any Rust. The Arch installation process is 100% CLI driven. A minimal arch install will plop you into a terminal with virtually nothing at all (at which point you’ll probably discover that you forgot to install tools for WiFi or something and will have to switch back to the Live USB).

That doesn’t mean you can’t start with Arch. I know a couple of people who started with Arch basically as a sort of rite of passage. They seemed to turn out alright. (a bit pompous, perhaps, for some of them, but this was in high school!)

After installing it, you’ll be able to install any desktop environment you like; even the one from Mint. (I’ve been trying out KDE plasma lately, but good heavens is it buggy)


#8

Others have commented about switching to Linux, which I agree with(didn’t read heavily tho), so I’ll skip commenting on your switch of OS.

I absolutely have to say that is a really big switch. I tried learning Rust a year or two ago, but didn’t actually pick it up successfully until I played with a somewhat similar language for a while(used OCaml for a roughly a year before picking up Rust properly).

Ditto. Maybe just first focus on using Linux with your last favourite programming language and doing everyday stuff, then add Rust to the formula after a while.

Some resources you may find helpful

  • Thread about IDEs and stuff
  • If you’re thinking about going with Emacs, I’d recommend spacemacs(especially if you like vim binding), or anything more ergonomic by default. Last time I used vanilla Emacs I almost wore my pinkie out entirely in a day.

#9

A lot of great comments. Let’s see if I can catch the highlights.

First - why Rust? The memory safety is really important but it goes further than that. There is something about the ownership and borrowing that seems like is was tailor made for the way this project needs to operate. Like someone created the language just for me. Weird. Without going into the details, nodes in this computational mesh have very limited knowledge of global states and receive and operate on data in a manner that requires the rest of the mesh to “not care” what the results of those operations are. In something like C, it would be extraordinarily easy to alter data in ways that corrupt the states of nodes far outside the “awareness” of the node performing the operations.

I agree. I think the first step is to focus more on Linux. Try out a few text editors, research mor on debuggers and wrestle with basics.

Outdated tools are part of what I ran into setting up rust on my first try. But it sounds like Arch might be a stretch right now. I’ll keep it in the back of my mind. One thing I have to keep in mind is that this will result in production code that will be distributed to end users. So the nightly tool chain may become problematic once it gets that far. But I may be thinking too far ahead.

I’ve already looked at VSCode. It might be the better choice over EMACS. I really don’t want a heavy IDE. One of the things I don’t like about Visual Studio is that it is so damn fat and bloated. Net Beans is heavy. Eclipse not as bad as those two. Since I’m not doing a GUI around this kernel, a light weight tool set is more suitable. A good text editor and debugger is enough. I like how Clippy adds another layer of checks to writing good code.

I’m thinking Python to cut my teeth on. I did do some limited Python programming a few years ago, It was fun and it was actually easy to learn so I think I’ll play with a few editors and get a feel for how they work debugging and managing files. I’m leaning towards VSCode, Emacs or Gnome Builder


#10

Just to clarify, Arch won’t pin you to nightly rust. Actually, the rust experience should be pretty much the same in any Linux distribution so long as you use rustup (which you should, because it is awesome):

  • You check your distribution has a package for rustup. If it does, install it, and your package manager will manage rustup (but not rust itself). If not, go to https://www.rustup.rs/ and install.
  • rustup default stable to install the latest stable and make it the default.
    (note: your package manager may have done this for you)
  • You can also rustup toolchain add nightly (you’ll need it for clippy).
    Then cargo +nightly [ARGS]... will let you temporarily switch to nightly for a single build.
  • At any time later, you can use rustup update to update to a new stable or nightly.

#11

I would recommend getting familiar with Linux with a “stable” distribution like Mint before moving to rolling releases. The reason is that there is one major counterpart to the “freshness” of rolling release distributions, and that is reduced reliability. Upgrades are much less tested in the rolling world, and from time to time (not too often thankfully) you will see one that breaks your system, generally by being incompatible with proprietary software that you need to use such as the NVidia graphics driver. When that happens, you must be ready to fix it, and that can require significant background knowledge of the underlying system.

With that disclaimer, there is an interesting middle-ground between the user-friendliness of Mint and the hardcore-geekiness of Arch, which is openSUSE Tumbleweed. It is a rolling release which tries to retain many of the graphical conveniences of popular stable-release distros, and adds to that several useful tools that enhance the rolling release experience such as a more extensive automatic QA infrastructure before packages are accepted, or an automatic system snapshot mechanism in the spirit of Windows System Restore. As a drawback, it is less popular than other rolling releases such as Gentoo or Arch, so you will need to use the annoying “manually build packages” approach relatively more often.

Personally, I have found it to be my favorite Linux distro compromise so far. It allows me to use the latest software, it doesn’t break too often, and when it does it is relatively easy to fix (“snapper rollback” now, investigate more later). This allowed me to use it as my daily driver both at home and at work, where I would never have dared that with Gentoo or Arch due to traumatic memories of that one time where a bad package update completely broke one of my systems.

But again: still not a beginner distribution. It is best to stick with the likes of Ubuntu and Mint while you are getting comfortable with the OS, as stability is an invaluable property at this stage of the learning process.


#12

You could use Visual Studio Code which runs on Windows/Linux/Mac and has nice support for Rust. That way you might be able to stay on Windows at least to start with. It’s a quick start - install vscode, rustup, and use the extension manager in vscode to install the rls plugin and you are good to go.

I often write code that I am intending to deploy on Linux on a Windows machine and use WSL (Windows Subsystem for Linux) to run the tests as I am working. I use the Ubuntu image in WSL which works well.

It will depend a lot on what your code needs to interface with, but pretty much everything I work on in Rust will run on Linux/Windows/Mac with essentially no porting.

I’m not a big python user, but I think virtualenv will let you (effectively) create an isolated python installation with a specific set of packages installed.


#13

Hi, @BobC,

Yes, you’ve definitely taken on a big task in a new language in a new environment! It’s a lot, to be sure.

I don’t know if it’s too late, but in the interest of trying to make things just a bit easier on yourself, have you considered using Windows as your development environment, since you are more familiar with it?

If you really want to learn Linux, you can eventually fire up the Windows Subsystem for Linux, which is an officially supported Ubuntu Linux environment on Windows, but for the time being, you can get going in a more familiar, traditional Windows environment.

I develop on Windows 10 for a client, and IIRC, it was a three-step process to get things going.
Here is what I am thinking might be good for you:

  1. Install the MinGW/MSYS2 toolchain as outlined here (since you will likely be working with GNU (Linux) based libraries). Rust needs to use the linker from this toolchain to create binaries.

  2. Intall rustup: here is the 64-bit Windows/GNU installer. (That should be the right installer for a modern Windows installation, but if not, you can select your installer from here.) I strongly recommend installing rustup (as opposed to via a package manager, regardless of which platform you are on).

  3. Install Visual Studio Code with this Rust extension and you should be all set.

Feel free to ask lots of questions here, on gitter or on the #rust-beginners IRC channel–you’ll find the community very open and incredibly helpful. You are not alone! :slight_smile:

Take care, and all the best, @BobC,
U007D


#14

I can echo this sentiment. The breakage is real. Even though I’ve only been using Arch for a year, I can already recall two breakages that I never would have been able to work through without at least a few years of experience with Linux. Recommending Arch to a beginner really is a bad idea.

Ah! It appears I have been living under a rock for the last couple of years!

Looking into it, it appears that this is some sort of Linux emulation layer, kind of like Wine in reverse? There’s a couple of distributions to choose from on the Windows store, and they do include package management. IIUC, programs built for the WSL target the Linux platform, as opposed to on MinGW/msys where they would target Windows.

Indeed, it sounds like this could be a convenient, fairly non-committal way for a learner to get the Linux experience on Windows.

That said, the main reason that I personally use Linux for everyday use is because the window managers available for it are so powerful; despite the name, it still feels like Windows was never designed to support having more than one (or I guess two, now) windows open at once. So while you do not need to make the switch, I still feel that anybody who seriously wants to be productive should consider taking a serious go at Linux eventually.


#15

@ExpHP WSL does indeed include the package management. It’s a better marriage of Linux and Windows than MinGW or Cygwin, IMHO, but if you want to build native Windows apps under WSL, I believe you will be cross-compiling, yes.

But what is interesting is you can launch Windows executables from WSL. So if you want to build Windows binaries, at least in theory, you could set your Rust config to default to cross-compile to Windows, and launch your .exe’s transparently? (Disclaimer: I’ve never tried this.)

I brought this up merely to let @BobC know that learning Linux isn’t mutually exclusive with building on Windows… @BobC can start with a traditional Windows environment, where they stated they have more background and easily migrate to Linux later, whenever the time is right.


#16

A few of you have recommended learning Rust in a Windows environment since I’m already familiar with it. Normally I would agree wholeheartedly, but if this project comes together, it will be at least partially open source and operating within the cryptocurrency/blockchain ecosystem which strongly leans to the Linux side of The Force. And we are planning on scaling up the proof of concept onto a Beowulf Cluster. I will end up leading the tech team and they are going to most likely be a Linux shop first and Windows/Mac second. So I need to be able to work well with Linux adepts even if I’m just competent with the OS. So I need to bite the bullet.


#17

Yes, but, if you get it working/developed in Windows, it will be easy to port to Linux. Rust cross-compiles really well and easily.


#18

Sounds fair, then yeah, choosing the path with the least resistance to begin with is best, otherwise you will absolutely get burned out very quickly.

Ubuntu, Fedora, Linux Mint, OpenSUSE, and other more user friendly distros are very good to start with. Most distros share a lot of common software, so you don’t have to worry about switching between distros too much.

Arch does not end up being very usable even after years of use, unless you write your own installer suite(mine), or use a Arch based distro with nice installer(e.g. Manjaro). So unless you absolutely want heavy customizations, not much need to look into Arch/Gentoo/etc.

One good thing about working on Linux is that you will almost always be able to debug errors thanks to quite explicit error messages, and Googling “How do I … Linux?” practically works all the time(you will find a blog/article, or a stackoverflow answer about whatever you want to do).

Otherwise you can always ask in the forum of your distro or reddit, usually people are pretty friendly.


#20

Nope. I actually invented and hold the patent for the computational mesh. I was expecting that the hard core coding would be done by others, Turns out it isn’t working out very well that way so I need to resurrect my programming skills. It’s a long story. But truthfully, I prefer doing it this way instead of spending so much energy talking to investors and business development organizations. I’m handing that off to someone else with better soft skills.


#21

Maybe, since I’ve never been a brilliant coder. But I understand how this mesh works better than anyone since I invented it.