编程语言
Swift
Swift 6.4.0,来自 Swift 官方镜像:编译器、Swift Package Manager 和 Foundation。
bash
swift --version
# 单个文件
echo 'print("Hello from Swift")' > hello.swift
swiftc hello.swift -o hello && ./hello
# 一个 package
swift package init --type executable
swift runObjective-C
Objective-C 用 GCC 的 Objective-C 编译器(gobjc)编译,链接 GNUstep Base 库。GNUstep Base 提供 Foundation(NSString、NSArray、NSLog 等)。没有 AppKit / UIKit,只适合命令行程序。
objc
// hello.m
#import <Foundation/Foundation.h>
int main(void) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSLog(@"Hello from Objective-C");
[pool drain];
return 0;
}bash
gcc -fconstant-string-class=NSConstantString -I/usr/include/GNUstep \
hello.m -o hello -lgnustep-base -lobjc
./helloGCC 不支持一部分现代 Objective-C 语法,比如 @autoreleasepool 和 ARC。请像上面那样使用 NSAutoreleasePool,并手动管理内存。
用 GNUstep make 构建
文件不止一个时,可以让 GNUstep 的构建系统来处理编译参数。在源码旁边放一个 GNUmakefile:
make
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = hello
hello_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.makebash
make
./obj/hello有多个源文件时,在 hello_OBJC_FILES 里用空格分隔列出。容器里已经设置好了 GNUSTEP_MAKEFILES。
Go
Go 1.27.1,来自 Go 官方发行版。
bash
go version
go mod init example.com/hello
go run .Node.js
Node.js 26.10.0 和 npm,来自 Node.js 官方发行版。
bash
node --version
npm installPython
Python 3 和 pip,python 指向 python3。
bash
python --version
pip install requestspip install 可以直接使用,和在普通电脑上一样。包会装在容器的系统目录里,删除容器后就没了。
想让项目的包在不同容器之间保留下来,就在 /workspace 里建一个虚拟环境,它就在你的电脑上:
bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt每开一个新 shell,都要重新执行一次 source .venv/bin/activate。记得把 .venv/ 加进项目的 .gitignore。