【学習1日目】これまでプログラミング言語を習得できなかった人がRustを習得できるかどうか

無論仕事としてプログラミングをしたことは無し。趣味でちょこちょこいじってどれも習得できずに中途半端。

下地として以下

HTML = なんとなく読み書き。CSS嫌い。現在の小難しいのは無理。

JavaScript = 必要上ちょっとやったが嫌い。二度と触りたくない。

Perl = 人から頼まれて既存スクリプトのカスタマイズしたくらい。

php = 人の仕事の手伝いで既存コードのカスタマイズしたくらい。

シェルスクリプト = 好き。でも自分で一からは書けない。いろいろパクって組み立てる。

C言語 = 昔、「プログラミング言語C 第2版 ANSI規格準拠 (カーニハン/リッチー)」で1章目から挫折。

プログラミング習得 = 自分には無理、と思う。最初に出てくる「Hello world」を見るだけで拒絶反応が…。

しかし、Rustの記事を見かけたとき、これは挑戦してみたいと思えた。というかいい加減なにか一つ習得したい。ハードウェア寄りが好きなので、組み込み系(というのかな?)小さなチップ上で小さな機械を制御するようなことができればいいかなと。家電制御に興味がある。

で、これまでの挫折の経験から、学習進捗をここに記録していこうということです。自分用。学習方法なども現在いろいろ検索中。そもそも習得することで自分に何が出来るかもまだ良くわからないが、(大それたことだが) それで仕事の足しになるのが最終目標か? まあ、夢は大きく。

まず以下の読みを開始。

doc.rust-jp.rs

マシンはFreeBSD。2022年12月11日現在、pkgにもportsにも rustup は無いようです。

以下でRustのインストールスクリプトをダウンロードして、まずは内容を読む。

curl -sSf https://sh.rustup.rs/ > rustup-init.sh
curl コマンドオプション

  • s = Silent or quiet mode. Do not show progress meter or error messages.
  • S = When used with -s, --silent, it makes curl show an error message if it fails.
  • f = (HTTP) Fail fast with no output at all on server errors. This is useful to enable scripts and users to better deal with failed attempts.

読むときの less コマンドの基本的な操作

  • 次のページ = <スペースキー>
  • 前のページ = b
  • 最初のページ(というか1行目) = g
  • 最後のページ = G
  • 検索 = / を押して検索する語をタイプして<リターン>、nで後方。Nで前方。

して見たところ、FreeBSD とあったので、このshでいいのかな。chmod +x してから実行。

info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup home directory, located at:
/root/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/root/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at:
/root/.cargo/bin
This path will then be added to your PATH environment variable by modifying the profile files located at:
/root/.profile
/root/.zshenv
You can uninstall at any time with rustup self uninstall and these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-freebsd
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-freebsd
info: syncing channel updates for 'stable-x86_64-unknown-freebsd'
info: latest update on 2022-11-03, rust version 1.65.0 (897e37553 2022-11-02)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-freebsd'
stable-x86_64-unknown-freebsd installed - rustc 1.65.0 (897e37553 2022-11-02)

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"


rustc --version
rustc 1.65.0 (897e37553 2022-11-02)

Hello, world できました。