CommunityNews

CommunityNews

TypeScript as fast as Rust: TypeScript++

TL;DR: This is a proposal to create a language that sits somewhere between Typescript and Rust, and which you can incrementally adopt if you already use Typescript.

Typescript and Rust can feel pretty similar:

// Typescript
type Vec2 = { x: number, y: number };

function avgLen(vecs: Vec2[]): number {
    let total = 0;
    for (const vec of vecs) {
        total += Math.sqrt(vec.x*vec.x + vec.y*vec.y);
    }
    return total / vecs.length;
}
// Rust
struct Vec2 { x: f64, y: f64 }

fn avg_len(vecs: &[Vec2]) -> f64 {
    let mut total = 0.0;
    for vec in vecs {
        total += (vec.x*vec.x + vec.y*vec.y).sqrt();
    }
    return total / vecs.len() as f64;
}

In some ways, Rust feels like a more restrictive but faster version of Typescript. But Typescript/Javascript can be very fast too; owing to years of hard work by browser vendors. In this article we’ll look at the performance characteristics of each in more detail, and see if we can have the best of both worlds.

Read in full here:

https://zaplib.com/docs/blog_ts++.html

This thread was posted by one of our members via one of our news source trackers.

Where Next?

Popular Backend topics Top

First poster: bot
Powerful, flexible, complex: The origins of C++ date back 40 years, yet it remains one of the most widely used programming languages toda...
New
First poster: bot
There is a long, difficult road from vague, pie-in-the-sky ideas about what would be cool to have in a new programming language, to a rob...
New
CommunityNews
Microsoft is trying to leapfrog competitors like Google and Amazon as they face record antitrust scrutiny. The big picture: The deals ...
New
First poster: AstonJ
Pocketlang is a small (~3000 semicolons) and fast functional language written in C. It’s syntactically similar to Ruby and it can be lear...
New
First poster: KnowledgeIsPower
Rocket is a web framework written in Rust. It provides a concise API and is opinionated and feature-rich beyond what you would typically ...
New
First poster: bot
GitHub - audulus/rui: Experimental Rust UI library. Experimental Rust UI library. Contribute to audulus/rui development by creating an a...
New
First poster: OvermindDL1
GitHub - mcobzarenco/zee: A modern text editor for the terminal written in Rust. A modern text editor for the terminal written in Rust -...
New
First poster: bot
GitHub - Shirakumo/trial: A fully-fledged Common Lisp game engine. A fully-fledged Common Lisp game engine. Contribute to Shirakumo/tria...
New
First poster: bot
GitHub - WhatsApp/waraft: An Erlang implementation of RAFT from WhatsApp. An Erlang implementation of RAFT from WhatsApp. Contribute to ...
New
First poster: AstonJ
Ruby 3.1’s incompatible changes to its YAML module (Psych 4). Ruby made its YAML interpreter more secure by default at the cost of backw...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New