视频课程目录16
全部视频课程

01 · HHY 1.7.0

Install HHY and Run Your First Script

Install the command, verify your environment, and run a saved HHY script.

4:43 · 英文旁白与字幕

学习进度保存在此浏览器,无需登录。

阅读对应手册章节

章节与讲稿

点击时间跳转视频,展开标题查看讲稿与代码。

Your first result

By the end of this lesson, you will have a small HHY program saved on your computer and running from the terminal. We will install the command, check which version we are using, create a dot hhy file, and run it twice. The goal is a repeatable starting point for every later lesson. Keep the terminal open beside your editor so each small change gets immediate feedback.

hello.hhy
let language = "HHY"
print("Hello, " + language + "!")

Follow along with the downloadable example.

Choose a supported environment

The documented installer supports Apple silicon macOS, Linux on sixty four bit Intel or AMD, and Linux on arm. Use the installation section of the manual if your machine needs another route. These commands are shell commands, so enter them in a terminal, not inside the HHY source file. You need network access for the download. The default install uses your own home directory and does not require sudo.

hhy
macOS arm64
Linux x86_64
Linux arm64

Follow along with the downloadable example.

Install the course version

Download the official installer and run it with the course version selected. Saving the installer first also lets you inspect it before execution. The version variable here applies to the installer command; it keeps this course on one known baseline. The installer detects the platform, downloads the release and its checksum, and verifies the archive before installing. Wait for it to finish successfully before moving to the next command.

sh
curl -fsSL https://hhylang.dev/install.sh -o install.sh
HHY_VERSION=1.7.0 sh install.sh

Follow along with the downloadable example.

Make hhy discoverable

Add the default command directory to this terminal session, then ask the shell where it finds hhy. Finally, print the version. For these examples the target is one point seven point zero. If a different installation appears first, the path check helps you notice it. The export lasts for this shell session. To keep it for future terminals, add that export to the startup file appropriate to your shell.

sh
export PATH="$HOME/.local/bin:$PATH"
command -v hhy
hhy --version

Follow along with the downloadable example.

Save a real source file

Create a small folder and open it in your editor. Save the two line program as hello dot hhy, using a plain text file. The extension matters because it helps you and the tooling recognize the source. An editor integration is helpful for highlighting, but the command line is enough for this lesson. Keep source code in the file and shell commands in the terminal; they are different inputs with different jobs.

sh
mkdir hhy-first-script
cd hhy-first-script
# Save hello.hhy here in your editor.

Follow along with the downloadable example.

Read the program

The first line creates a binding named language and gives it a string value. The second calls print. The plus signs join strings into one message. We use explicit concatenation in these examples so the result is reproducible on the tested runtime. There is no need to memorize every detail yet. For now, identify the name, the quoted text, and the function that sends the completed message to the terminal.

hello.hhy
let language = "HHY"
print("Hello, " + language + "!")

Follow along with the downloadable example.

Check and execute

Save the file before running these commands. Check asks HHY to validate syntax and core semantics; execution actually runs the program. A successful check is useful, but it does not prove that every future file read or network request will work. Here our program only prints text. You should see Hello, HHY, with an exclamation mark. The run subcommand is another spelling: hhy run followed by the same file name.

sh
hhy check hello.hhy
hhy hello.hhy
# Hello, HHY!

Follow along with the downloadable example.

Fix the common setup mistake

If the shell says command not found, investigate the command path first. That error happens before HHY reads your program. If HHY cannot find hello dot hhy, check the current directory with pwd and list the files with ls. A file called hello dot hhy dot txt is a different name. Separating shell problems from program problems will save time throughout the course. Correct one thing, then repeat the smallest relevant command.

sh
pwd
ls
command -v hhy
export PATH="$HOME/.local/bin:$PATH"

Follow along with the downloadable example.

Practice and continue

For the exercise, change the greeting and add a second print call. Save, run, and compare the output with your prediction. Then close and reopen the terminal and make sure hhy is still discoverable; if needed, finish the persistent path setup for your shell. The downloadable example contains the original program and its expected output. Next we will use bindings, values, and collections to represent something more useful than a greeting.

hhy
let language = "HHY"
print("Learning " + language)
print("My first script is running.")

Follow along with the downloadable example.