今日已更新 133 条资讯 | 累计 37382 条内容
关于我们

标签:#Rust

找到 450 篇相关文章

AI 资讯

You've Seen the Pipeline. Now Meet the Matrix: The One `Vec ` Behind the 400 Shrink

How a single contiguous allocation — and a type system that won't let you feed strings to a scaler — is the real reason datarust fits in 2.3 megabytes. In the last post I showed you the whole datarust workflow: impute, scale, one-hot, train a logistic regression, evaluate, and save it as JSON — all without a Python runtime in sight. The Docker image shrank from ~900 MB to ~8 MB, and the binary was 2.3 MB. But I skimmed over something important. I kept saying "the flat memory layout" as if it were a detail. It isn't. It's the whole bet. Every scaler, every encoder, every model, every metric in datarust runs on top of one data structure. If you understand that structure — why it looks the way it does and what it refuses to let you do — the rest of the library stops being magic. So let's zoom in. Meet Matrix . Two containers, on purpose Real data is mixed. Numbers in one column, strings in the next. In Python, everything flows through one giant numpy.ndarray or a pandas.DataFrame , and the type system just... shrugs. A string column next to a float column gets coerced into object dtype. You'll find out at training time, in the form of an error message three frames deep. datarust does the opposite. It splits your data into two types at the source: use datarust :: Matrix ; use datarust :: matrix :: StrMatrix ; let numeric = Matrix :: new ( vec! [ vec! [ 3.0 , 85.0 , 24.0 ], vec! [ 12.0 , 70.0 , 31.0 ], vec! [ f64 :: NAN , 95.0 , 45.0 ], ]) ? ; let categorical = StrMatrix :: from_strings ( vec! [ vec! [ "MonthToMonth" ], vec! [ "OneYear" ], vec! [ "MonthToMonth" ], ]) ? ; Matrix is f64 only. StrMatrix is strings only. They are different types , and the compiler will refuse to compile a program that hands a string column to a scaler. Not at runtime — at compile time. In the last post I called this "putting on glasses for the first time." Let me show you what it actually buys you. The ColumnTransformer API is built on that split: ct .add_numeric ( "scaled" , vec! [ 0 , 1 ],

2026-08-02 原文 →
AI 资讯

Why I Fell in Love with Rust’s Memory Model (Even Though It’s Hard)

I’ve worked with languages like JavaScript and Go , and I enjoyed both for different reasons. JavaScript gave me speed and flexibility. Go gave me simplicity and practical concurrency. Then I met Rust and at first, it felt difficult. But once I understood how Rust handles memory without a garbage collector , I fell in love with it. Memory Safety Without a Garbage Collector Most modern languages solve memory management with a garbage collector (GC) . A GC periodically finds memory that is no longer used and frees it automatically. Rust takes a different path: No runtime garbage collector No manual free() like in C Memory safety guaranteed at compile time (in most cases) Rust uses three core ideas: Ownership Borrowing Lifetimes These rules are checked by the compiler before your program runs. 1) Ownership: One Owner at a Time In Rust, every value has a single owner. When the owner goes out of scope, Rust automatically drops the value and frees memory. { let s = String :: from ( "hello" ); // s owns the string memory here } // s goes out of scope, memory is freed automatically This avoids memory leaks and double-frees in normal code paths, without needing a GC pause. 2) Borrowing: Use Data Without Taking Ownership Instead of copying or transferring ownership all the time, Rust lets you borrow references: Immutable borrow: &T Mutable borrow: &mut T But Rust enforces strict aliasing rules: Many immutable references OR One mutable reference Not both at the same time This rule prevents data races at compile time. 3) Lifetimes: References Must Always Be Valid Lifetimes describe how long references are valid. Often, Rust infers lifetimes automatically. When needed, you can annotate them. This helps prevent dangling references references to memory that no longer exists. How Rust “Behaves” in Practice When writing Rust, you feel the compiler acting like a strict mentor: “Who owns this value?” “How long does this reference live?” “Are you mutating while also sharing?” “Could th

2026-08-02 原文 →
开发者

Falco — a from-scratch browser engine in ~36k lines of Rust (v0.1.0 release)

Hi everyone! I just released v0.1.0 of Falco — a browser engine I've been building in Rust on nights and weekends. No WebKit, no Gecko, no Chromium — every module is written from scratch in ~36,000 lines. 🔗 GitHub : https://github.com/poxk/Falco 🔗 Releases (prebuilt binaries for Linux/macOS/Windows): https://github.com/poxk/Falco/releases/tag/v0.1.0 What's inside All modules are from scratch, with no dependency on existing browser engines: HTML5 ( html5/ + html.rs ) Tokenizer — all 80 states of WHATWG §13.2.5, including script-data escape/double-escape state machine, attribute parsing with duplicate detection, named + numeric character references with Windows-1252 quirks table Tree builder — all 22 insertion modes of WHATWG §13.2.6, stack of open elements with scope algorithms (default/button/table/select/list-item), active formatting elements list, adoption agency algorithm (8-iteration outer loop with full inner loop and bookmark tracking), foster parenting for table content XML parser — strict, with namespace bindings, CDATA, PIs Encoding detection — BOM, HTTP Content-Type charset, <meta charset> , <meta http-equiv> , heuristic UTF-8/UTF-16 detection, decoders for UTF-8 / UTF-16LE / UTF-16BE / Windows-1252 innerHTML/outerHTML serialization — void elements, <template> contents fragment, raw text elements, full attribute value escaping DOM ( dom2/ ) NodeRef = Rc<RefCell<Node>> with parent/firstChild/lastChild/previousSibling/nextSibling pointers per spec MutationObserver with observe()/disconnect()/take_records(), subtree ancestor matching, attributeFilter Shadow DOM — attachShadow() with open/closed modes, host validation, named + default slots, fallback content, slot distribution (flatten tree algorithm) Custom elements — customElements.define() with name validation, observedAttributes, lifecycle callbacks (connected/disconnected/adopted/attributeChanged/form-associated), pending upgrades, customized built-in elements (is="...") Accessibility tree — parallel tree

2026-08-02 原文 →
AI 资讯

Introducing Fitz LiveViews: real-time UI in one language, zero JS build

TL;DR — Fitz LiveViews is a real-time UI framework for Fitz , a compiled, gradually-typed language where HTTP, WebSockets, auth, and an ORM are part of the syntax. You write single-file components ( .fitzv ) with state / event / <template> , and the server renders HTML, diffs it, and patches the browser over a WebSocket — no JavaScript build step, no client framework . The same .fitzv can also compile to WebAssembly for offline, zero-round-trip widgets. There's a live component gallery, a course, and a full flagship app (an admin panel with auth + Postgres + Docker) already built with it. Repo : github.com/Thegreekman76/fitz-liveviews · Docs : thegreekman76.github.io/fitz-liveviews This is the first post in the FitzLiveViews series. I'll start with the pitch and the setup; the following posts build things. The problem Building a modern web UI usually means two languages, two type systems, and a build pipeline: a backend (Python / Node / Go) plus a frontend framework (React / Vue / Svelte) plus its toolchain (Vite / Webpack / Babel). You duplicate your types across the wire, you keep two mental models in sync, and node_modules grows a personality of its own. Phoenix LiveView (Elixir) showed there's another way: render on the server, push diffs over a WebSocket, and let the browser stay dumb. No client framework, no API to hand-write, no JSON serialization dance. Fitz LiveViews brings that model to Fitz — and adds a twist: the same component can also compile to WebAssembly when you want purely client-side, offline interactivity. What Fitz LiveViews looks like A component is a single .fitzv file — state, event handlers, and a template, like Vue or Svelte: component Counter { state { count : Int = 0 } event increment () { count = count + 1 } event decrement () { count = count - 1 } event reset () { count = 0 } < template > < div id = " counter-app " > < p > Count : { count } < /p > < button @ click = " increment " >+ 1 < /button > < button @ click = " decrement " >- 1 <

2026-08-01 原文 →
AI 资讯

Presentando Fitz LiveViews: UI en tiempo real en un solo lenguaje, sin build de JS

TL;DR — Fitz LiveViews es un framework de UI en tiempo real para Fitz , un lenguaje compilado y de tipado gradual donde HTTP, WebSockets, auth y un ORM son parte de la sintaxis. Escribís componentes de un solo archivo ( .fitzv ) con state / event / <template> , y el servidor renderiza HTML, lo diffea y parchea el browser por WebSocket — sin paso de build de JavaScript, sin framework de cliente . El mismo .fitzv puede además compilar a WebAssembly para widgets offline sin round-trip. Ya hay una galería de componentes en vivo, un curso, y una app flagship completa (un panel de administración con auth + Postgres + Docker) construida con esto. Repo : github.com/Thegreekman76/fitz-liveviews · Docs : thegreekman76.github.io/fitz-liveviews Este es el primer post de la serie FitzLiveViews . Arranco con el pitch y el setup; los siguientes construyen cosas. El problema Armar una UI web moderna normalmente implica dos lenguajes, dos sistemas de tipos, y un pipeline de build: un backend (Python / Node / Go) más un framework de frontend (React / Vue / Svelte) más su toolchain (Vite / Webpack / Babel). Duplicás tus tipos de un lado al otro del cable, mantenés dos modelos mentales en sync, y node_modules desarrolla personalidad propia. Phoenix LiveView (Elixir) mostró que hay otra forma: renderizar en el servidor, empujar diffs por WebSocket, y dejar que el browser quede tonto. Sin framework de cliente, sin API que escribir a mano, sin la danza de serializar JSON. Fitz LiveViews trae ese modelo a Fitz — y suma una vuelta de tuerca: el mismo componente puede además compilar a WebAssembly cuando querés interactividad puramente client-side y offline. Cómo se ve Fitz LiveViews Un componente es un solo archivo .fitzv — state, event handlers y template, como Vue o Svelte: component Counter { state { count : Int = 0 } event increment () { count = count + 1 } event decrement () { count = count - 1 } event reset () { count = 0 } < template > < div id = " counter-app " > < p > Count : { cou

2026-08-01 原文 →
AI 资讯

100 Days of Solana: What I Actually Learned (Not What I Expected to Learn)

One hundred days ago, I had no idea this challenge would become one of the most rewarding technical journeys I've taken. There were days when everything clicked, and there were days when nothing compiled. I celebrated successful deployments, stared at cryptic errors for hours, rewrote programs that weren't good enough, and learned that understanding Solana has far less to do with memorizing APIs than changing how you think about state, ownership, and security. Looking back now, I realize I didn't just complete 100 challenges; I built a completely different mental model of software. Where I started I came in with a biochemistry degree I never used, a self-taught engineering career I built in public, and a GitHub full of Rust and Python work. I co-maintain statix, a Nix linter that ended up in the canonical NixOS/nixpkgs upstream. I had shipped real software before. What I did not have was any intuition for how Solana actually works. I knew the buzzwords. I had the mental model of "it's fast and cheap." I did not know what an account was. I did not know what a program was. I did not know why those two things were different. That gap, between knowing the words and understanding the model, is what these 100 days actually closed. What I expected I expected Solana to feel like a database with extra steps. In Web2, you have a server that holds state. You call an API. The server reads from the database, does something, writes back. I expected a blockchain to be the same thing, just slower and decentralized. The first thing that broke that model: accounts. On Solana, an account is not a row in your database. It is the database. Every piece of state, your wallet balance, a token you hold, the program you deployed, is an account. Programs are accounts. Data is accounts. Everything is an account. That sounds obvious written down. It took me until around Day 15 to actually feel it, when I was staring at a getAccountInfo call wondering why the program I deployed was also an accou

2026-07-31 原文 →
AI 资讯

[Advanced Rust] 1.14. Memory Types Pt.2 - Dynamically Sized Types and Wide Pointers, Packed Layouts, Larger Alignment for Speci…

Full title: [Advanced Rust] 1.14. Memory Types Pt.2 - Dynamically Sized Types and Wide Pointers, Packed Layouts, Larger Alignment for Specific Fields or Types, Memory Representation of Complex Types, and Repr Rust 1.14.1. repr(Rust) Remember the example in the previous article? That example used repr(C) , and the limitation of the C representation is that all fields must be placed in the same order as they are defined in the original struct. repr(Rust) is the default representation. It intentionally provides fewer layout guarantees than repr(C) : the compiler may reorder fields, and two types with the same fields in the same order are still not guaranteed to share a layout. Because the compiler may reorder fields (for example, placing larger fields first), padding can often be reduced. In the Foo example from the previous article, one possible optimized layout needs no padding. With fewer guarantees about layout, the compiler has room to rearrange things and produce efficient code. If repr(Rust) is used, then one possible memory layout of the Foo struct from above is: Code Field Type Size Default Representation Padding Final Alignment #[repr(Rust)] struct Foo { long: u64, 8 bytes 8-byte aligned 8 bytes normal: u32, 4 bytes 4-byte aligned short: u16, 2 bytes 2-byte aligned small: u8, 1 byte 1-byte aligned tiny: bool, 1 byte 1-byte aligned } Total 16 bytes The compiler first orders the fields by size, putting the largest first so that it can determine what alignment the struct should use. In this example, u64 is the largest and takes 8 bytes, so the struct is aligned to 8 bytes The compiler then looks at the remaining fields and sees that their total size is exactly 8 bytes, so it can place them together and avoid padding In the end, this struct only needs 16 bytes, which saves half the memory compared with repr(C) This is more efficient, but compilation time may be a little longer 1.14.2. Packed Layouts You can tell the compiler that no padding is needed between fiel

2026-07-30 原文 →
开发者

RustForge: A Modular, Adoptable Rust Test-Suite Template

Hey everyone, Whenever I start scaling out a new Rust service or protocol, I always find myself hitting the same wall: testing gets messy fast. You end up juggling basic cargo test unit checks, hacking together ad-hoc integration scripts, and manually setting up coverage tools every single time. I put together RustForge to solve that headache for my own projects, and figured it might save a few of you some time too. It’s a clean, zero-bloat starter template designed to take you from simple unit tests all the way to compiler-style UI snapshots and coverage tracking without having to reinvent the harness every project. https://github.com/rwilliamspbg-ops/RustForge

2026-07-29 原文 →
AI 资讯

Why We Built Bitweave: Sub-Millisecond Hybrid Retrieval in <1.1 MB RSS Memory

When building local RAG (Retrieval-Augmented Generation) applications, edge agents, or serverless AI pipelines, developers usually hit a wall with standard vector stores: memory overhead. Running a dedicated vector database locally often demands hundreds of megabytes—or gigabytes—of RAM just to keep indices warm. On the flip side, lightweight local options like scanning raw JSON files or querying SQLite don't scale well when vector dimensions climb into the thousands (1536d+). We built Bitweave to solve this exact trade-off: a zero-copy, SIMD-accelerated hybrid retrieval engine in Rust (with Python bindings) that handles categorical filtering and vector search while locking its active heap footprint under 1.1 MB RSS. The Architecture: How Bitweave Achieves Sub-Millisecond Speed at <1.1 MB RAM Bitweave relies on a 3-part design to maximize search speed while keeping memory consumption negligible: [ Categorical Filters ] ---> Bit-Sliced Bitmaps │ ▼ [ Query Vector (1536d) ] --> 1-Bit SIMD Pre-Filtering (Hamming Distance) │ (Top K Candidates) ▼ [ Raw Embeddings Buffer ] -> Zero-Copy Float32 Rescoring (exact_rescore=True) │ ▼ Top-K Results Array (NumPy) Zero-Copy Memory Mapping (memmap2) Instead of deserializing index files into Python RAM or Rust heap space, Bitweave uses memory-mapped files (.bweave). The operating system's page cache handles lazy loading of index segments directly from disk into virtual address space. As a result, the active RSS memory footprint remains static around 1.1 MB, whether your index holds 5,000 or 200,000 records. 1-Bit Vector Quantization & SIMD Hamming Distance High-dimensional float32 vectors (1536d) are quantized down to 1-bit sign masks (where values > 0 map to 1 and <= 0 map to 0). During pre-ranking, Bitweave uses SIMD bitwise XOR and POPCNT operations to compute Hamming distances across candidate vectors in microseconds. Zero-Copy 2-Pass Float32 Rescoring (exact_rescore=True) Quantization speeds up initial candidate selection, but f

2026-07-29 原文 →