Compare
PickleScript next to the language you already write.
PickleScript is on the left of every pair. The comparisons change with the language, because a C kernel and a TypeScript codebase do not ask the same questions. Pick a side and read what actually differs.
Syntax snapshot PickleScript 0.1.0, TypeScript 5, Rust 2021, Python 3.10 or newer, Go 1.21 or newer, C17, C++20, Java 21
PickleScript and TypeScript
The language most people arrive from. The compiler is strict about types, but the places it stops checking are exactly the places you get bitten, so that is what this tab compares.
Optionals
A missing value is a value you have to take apart. TypeScript hands you a union and trusts you to compare it, and the check disappears the moment strict null checks are off.
fn describe(token: string?) -> string {
match (token) {
case some(value) -> "found {value}"
case none -> "no token"
}
}function describe(token: string | null): string {
if (token === null) return 'no token';
return `found ${token}`;
}Closed sums
A PickleScript enum is closed, so a match with no catch-all arm is a compile error. A TypeScript union is checked by hand: add a variant and a switch that forgot it falls through to undefined at run time.
enum Status {
ready
running
failed
}
fn label(status: Status) -> string {
match (status) {
case ready -> "ready"
case running -> "running"
case failed -> "failed"
}
}type Status =
| { kind: 'ready' }
| { kind: 'running' }
| { kind: 'failed' };
function label(status: Status): string {
switch (status.kind) {
case 'ready':
return 'ready';
case 'running':
return 'running';
case 'failed':
return 'failed';
}
}Typed collections
Both sides know what the list holds, so a wrong element type is a compile error in each. Neither knows how long the list is, so an out of range index is caught at run time in both, and TypeScript will not warn unless you turn on noUncheckedIndexedAccess.
fn first(xs: List<string>) -> string? {
if (len(xs) == 0) {
return none
}
return xs[0]
}function first(xs: string[]): string | undefined {
return xs.length === 0 ? undefined : xs[0];
}Interfaces
A PickleScript interface is nominal, so a type has to say implements and is checked against the runtime class. A TypeScript interface is structural, so any object with the right shape fits and the contract disappears at run time.
interface Drawable {
fn draw()
}
class Canvas implements Drawable {
title: string
constructor(title: string) {
this.title = title
}
fn draw() {
print("drawing {this.title}")
}
}
fn main() {
let shape: Drawable = Canvas("poster")
shape.draw()
}interface Drawable {
draw(): void;
}
class Canvas implements Drawable {
constructor(public title: string) {}
draw() {
console.log(`drawing ${this.title}`);
}
}
const shape: Drawable = new Canvas('poster');
shape.draw();String length
A JavaScript string is UTF-16, so length counts code units and an emoji outside the basic plane counts as two. A PickleScript string is UTF-8 and counted in bytes, so the same emoji is four, and a string that came off the network is not the same length as the one you typed.
fn label(s: string) -> string {
return "bytes: {len(s)}"
}function label(s: string) {
return `units: ${s.length}`;
}TypeScript against PickleScript
Both columns are about this pair, not about the language in isolation. The left column is where TypeScript is genuinely better, including the parts PickleScript has no answer to, and nothing here is decided in advance.
Where TypeScript wins
- The ecosystem is where a project actually gets done. The editor, the package manager and the libraries are years ahead, and none of that is a language feature you can download.
- Gradual adoption. You can add types to an existing JavaScript codebase a file at a time, and PickleScript has nothing to adopt from, so the first decision is whether to start at all.
- It ships where JavaScript already runs, in the browser, in every editor extension and on every host, which is a distribution channel rather than a language feature.
Where PickleScript wins
- The checker cannot be switched off per file, and there is no `any` that quietly disables it for everyone downstream.
- `let` is immutable and mutation is a keyword, so a value that changes says so in the source instead of being inferred from a diff.
- Strings are UTF-8 and counted in bytes, so the length of a string does not depend on whose Unicode table you ask.
- There is no null. A function that might return nothing returns `T?`, and the caller is told in the signature.
What this page is not
A comparison page is easy to write when every row makes the language look good. The limits below are the ones that would make this page worthless if they were left out, so they are on the page instead of in a footnote.
Not a benchmark
Nothing here measures speed, memory or safety, because the numbers would depend on the program, the flags and the machine. A comparison that only reports a winner is marketing, so this page reports differences instead.
Not the same questions
The concept list is chosen per language, because C and Java have no optional type, Go has no null safety and Rust has a null. Forcing all seven tabs into the same five rows would produce rows that are technically true and completely useless.
Not a replacement for the guide
This page covers what surprises somebody arriving from another language. Feature lists, standard library detail and the full language reference live in the documentation, and they are the source for everything here.
Pinned, and it will rot
Each tab is pinned to the version in its header. Languages move, and so will this page, because a comparison with no version attached quietly turns into a wrong answer.
Written by the other side
Each tab concedes real wins to the other language, including the ecosystem, the toolchain and the decades of production code that PickleScript does not have. A comparison where the other side never wins is not a comparison.
Snippets, not programs
The PickleScript side is written against the language reference and checked for syntax, not for the surrounding program. Where the compiler and this page disagree, the compiler is right.
