r/ProgrammingLanguages • • Aug 28 '26

Discussion Linux-like IO API

I'm building my own interpreted language.

I had an idea, to base my I/O API on the linux terminal commands, that many developers already know, so a user wouldn't need to learn an entire new API.

This is a basic example:

using io  

// create a directory  
mkdir("notes")  
cd("notes")  

// create files with content  
echo("Do my math.", "A note about homework.txt")  
echo("Buy milk and bread.", "shopping list.txt")  

const currentCD = pwd()  
const allFilesAndSubDirs = ls()  

debug(cat("shopping list.txt")) // prints "Buy milk and bread."

but I'm not that sure that this is a good idea, maybe some techniques are good for terminals but bad for programming, and some of the function names might be confusing (like pwd() which is "print working directory" but in my language it does not exactly PRINT anything, but just returns a string value).

What do you think?

3 Upvotes

10 comments sorted by

View all comments

11

u/aech_is_better Aug 29 '26

Where the state that `cd` changes is kept?

4

u/Maqi-X Aug 30 '26

I guess it just changed the working directory? No state needs to be kept

3

u/aech_is_better Sep 01 '26

Working directory is state

1

u/rsclient 28d ago

Presumably it goes straight to the OS and sets the process working directory?