TinyS – Python-shaped syntax with Rust semantics

divingstar1 pts0 comments

TinyS/TLDR.md at main · ewiger/TinyS · GitHub

//blob/show" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

//blob/show;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

ewiger

TinyS

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

FilesExpand file tree

main

/TLDR.md

Copy path

Blame<br>More file actions

Blame<br>More file actions

Latest commit

History<br>History<br>History

69 lines (52 loc) · 2.63 KB

main

/TLDR.md

Copy path

Top

File metadata and controls<br>Preview

Code

Blame

69 lines (52 loc) · 2.63 KB

Raw<br>Copy raw file<br>Download raw file

OutlineEdit and raw actions

TinyS — TL;DR

If you are an AI developer wanting to learn rust, you can take all your python knowledge and put it into TinyS ;-)

Python-shaped syntax, Rust semantics, native binaries.

You write indentation-based .sn source; it transpiles to Rust and compiles to<br>a native binary. No GC, no runtime — ownership, borrowing, lifetimes, traits,<br>and Result-based errors all carry over from Rust unchanged.

.sn source → generated .rs → rustc / Cargo → native binary

Python's look, not Python's guarantees: conditions must be bool, matches<br>are exhaustive, no implicit truthiness, no implicit conversion, no null.

In one glance

TinyS<br>Rust

def f(x: i32) -> i32:<br>fn f(x: i32) -> i32 {}

list[i32] / dict[str,i32]<br>Vec / HashMap

ref T / mut ref T<br>&T / &mut T

at value<br>*value

.a, .source<br>'a, 'source

Result[User, Error]<br>Result

match / case<br>match arms

and / or / not<br>&& / || / !

str / ref str<br>String / &str

from rust.regex import …<br>use regex::…

A taste

str:<br>return format("Hello, {}", self.name)

def main() -> void:<br>user = User(id=1, name="Ada")<br>print(user.greeting())">from rust.serde import Serialize, Deserialize

#[derive(Debug, Clone, Serialize, Deserialize)]<br>struct User:<br>id: u64<br>name: str

impl User:

def greeting(self: ref Self) -> str:<br>return format("Hello, {}", self.name)

def main() -> void:<br>user = User(id=1, name="Ada")<br>print(user.greeting())

The essentials

Immutable by default — count = 0, opt into mutation with mut total = 0.

Borrowing is a keyword — ref / mut ref instead of & / &mut;<br>dereference with at; move for explicit ownership transfer.

Errors — Result/Option, ? propagation, none for absence. No exceptions.

Pattern matching — exhaustive, an expression; _ wildcard, | alternatives,<br>if guards, as binds the whole value.

Control flow is expression-oriented — if, match, and loop produce values.

Async — async def with postfix .await.

Rust interop is always visible — crates come through the rust root<br>(from rust.serde import …); macros are imported and called without !.

Packaging — tinys.toml maps onto Cargo; modules follow the file layout.

Full design drafts live in doc/draft/; see the README<br>for the complete tour.

You can’t perform that action at this time.

rust user tinys file name python

Related Articles