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

标签:#rust

找到 278 篇相关文章

AI 资讯

Graceful Error Handling in Rust

Rust implements an explicit error handling paradigm instead of a traditional exception-driven system. Outside of rapid prototyping or testing scenarios—where unwrap() and subsequent panics might be tolerated—Rust strictly enforces explicit error management. However, this can become cumbersome when dealing with numerous disparate errors or when multiple errors need to be aggregated. To alleviate this burden, Rust introduces the question mark operator (?) as syntactic sugar. Operating on the Result type, the ? operator either extracts the underlying success value or immediately returns the error from the current function. While powerful, direct usage of ? often leads to type mismatches when a function encounters different error types. To resolve this complexity, crate ecosystems like anyhow are widely adopted. anyhow provides a universal Error type that seamlessly integrates with most concrete error types implementing the std::error::Error trait, allowing the ? operator to propagate errors without triggering compiler friction. Furthermore, the Context trait from such libraries offers an idiomatic approach to transforming an Option into a meaningful Result.

2026-06-04 原文 →
AI 资讯

Codegen to C: Native Binaries from Pascal (v2.18.0) | Codegen para C: binários nativos a partir de Pascal (v2.18.0)

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Codegen to C: Native Binaries from Pascal (v2.18.0) Sprint 10 ( v2.18.0 ) closes the loop on CrabPascal's most ambitious feature: turning Pascal source into real native executables via C codegen — with string builtins that actually match the interpreter. The pipeline Pascal (.dpr/.pas) → AST → C source + stubs.c → gcc/clang → native binary run skips the last steps and executes in Rust. build-exe is for when you want an .exe or ELF on disk without carrying the CrabPascal runtime as a dependency. End-to-end example program NativeHello ; uses System . SysUtils ; begin WriteLn ( Trim ( ' Hello, native world! ' )); end . crab-pascal build-exe NativeHello.dpr ./NativeHello # or NativeHello.exe on Windows Expected output: Hello, native world! — no leading or trailing spaces. What Sprint 10 fixed Parser: Trim , Copy , Length , and friends are recognized as SysUtils builtins , not mistaken for type names starting with T . A denylist prevents hard-casts that produced invalid C. Codegen: Forward declarations for pascal_* helpers in generated C. WriteLn emits correct %s formats for string expressions. main returns 0 like a well-behaved C program. Tests: build_string_conformance_stdout_matches_run_when_toolchain_present runs only when gcc/clang is available — skipping cleanly in CI sandboxes without a compiler, failing loudly when a compiler is present but output diverges. cargo test --test run_build_parity stubs.c: shared runtime surface String functions implemented once in Rust for run mirror into stubs.c for native builds: // conceptual — see repo for full signatures int pascal_Length ( const char * s ); char * pascal_Trim ( const char * s ); Generated Pascal calls route through these instead of ad-hoc inline logic, keeping Sprint 5–8 string semantics intact in binaries. When build-exe is not enough yet Sprint 10 explicitly did not ship full OO, exception, or generics codegen parity — those appear

2026-06-04 原文 →
AI 资讯

Building REST APIs in Pascal with Horse | APIs REST em Pascal com Horse

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Building REST APIs in Pascal with Horse Pascal is not stuck in desktop forms. With Horse — a lightweight HTTP framework popular in the Delphi ecosystem — CrabPascal v2.22.0 runs real REST servers from .dpr files. No IIS, no Apache: just crab-pascal run and curl. Why Horse in CrabPascal? Horse provides routing, JSON bodies, and middleware-style handlers. CrabPascal ships RTL shims and a runtime HTTP stack so examples work out of the box: Example Port Endpoints examples/crud/ 9000 Full product CRUD examples/time-server/ 9001 Time/date ping examples/agenda/ 9000 Contact registry All runnable with the internal runtime — no gcc required. Minimal API program SimpleAPI ; uses Horse , System . JSON ; begin THorse . Get ( '/ping' , procedure ( Req : THorseRequest ; Res : THorseResponse ; Next : TNextProc ) var J : TJSONObject ; begin J := TJSONObject . Create ; J . AddPair ( 'message' , 'pong' ); Res . Send ( J . ToJSON ); end ); THorse . Listen ( 9000 ); end . Run and test: crab-pascal run SimpleAPI.dpr curl http://localhost:9000/ping Expected response: {"message":"pong"} . CRUD example from the repo The examples/crud/crud.dpr project demonstrates production-style routes: THorse . Get ( '/produtos' , procedure ( Req , Res , Next ) begin Res . Send < TJSONObject >( TProdutoService . ListarProdutos ); end ); THorse . Post ( '/produtos' , procedure ( Req , Res , Next ) var json : TJSONObject ; begin json := Req . Body < TJSONObject >; Res . Send ( TProdutoService . CriarProduto ( json . GetValue ( 'nome' ). Value , json . GetValue ( 'categoria' ). Value , StrToFloatDef ( json . GetValue ( 'preco' ). Value , 0 ), StrToIntDef ( json . GetValue ( 'estoque' ). Value , 0 ) )); end ); Start the server: cd examples/crud crab-pascal run crud.dpr Testing with curl List products: curl http://localhost:9000/produtos Create a product: curl -X POST http://localhost:9000/produtos \ -H "Content-Type: application/j

2026-06-04 原文 →
开源项目

Configuring CrabPascal with crabpascal.toml | Configurando com crabpascal.toml

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Configuring CrabPascal with crabpascal.toml Every serious compiler needs project-level configuration. CrabPascal v2.22.0 reads crabpascal.toml from your project root — search paths, preprocessor symbols, Delphi vs FPC mode, output format, and runtime defaults. Where the file lives The compiler searches in order: crabpascal.toml (project root) .crabpascal.toml (hidden) config/crabpascal.toml If none exist, sensible defaults apply. Add the file when your project grows beyond a single .dpr . Starter configuration [compiler] version = "2.22.0" search_paths = [ "rtl/" , "lib/" , "examples/" ] defines = [ "CRABPASCAL" , "RELEASE" , "MSWINDOWS" ] mode = "DELPHI" # or "OBJFPC" strict = false warnings = true [preprocessor] enabled = true process_includes = true symbols = [] [output] error_format = "vscode" # or "gcc", "delphi" colors = true [runtime] default_http_port = 9000 [paths] rtl_path = "rtl/" output_path = "output/" Place this beside your .dpr file. All CLI commands ( check , run , build-exe ) pick it up automatically. Common use cases Delphi vs Free Pascal mode [compiler] mode = "DELPHI" defines = [ "CRABPASCAL" , "MSWINDOWS" ] Switch to FPC compatibility: [compiler] mode = "OBJFPC" defines = [ "FPC" , "UNIX" ] Mode affects parsing rules and RTL resolution under rtl/ . Custom unit search paths Large projects split units across folders: [compiler] search_paths = [ "rtl/" , "src/units/" , "src/services/" , "third_party/" ] This replaces hardcoded -U flags in scripts. Preprocessor symbols Match Delphi conditional compilation: [preprocessor] enabled = true symbols = [ "DEBUG" , "TESTING" ] Your Pascal code can use: {$IFDEF DEBUG} WriteLn ( 'Debug build' ); {$ENDIF} Run crab-pascal preproc MyApp.dpr to inspect expanded source. CI-friendly error output [output] error_format = "gcc" colors = false show_stacktrace = false GitHub Actions parsers often prefer gcc-style lines. Local development can

2026-06-04 原文 →
AI 资讯

Mutagen 0.4.0 Released: Service Extraction, Bug Crunches, and Fixed Persona Drift

Mutagen 0.4.0 addresses the friction points that plague agentic workflows: context bloat, brittle persona transitions, and the lack of a deterministic path from design document to deployed artifact. We aren't trying to make prompts smarter; we are making the harness that executes them more precise. This release introduces a Rust-based service extraction layer that decouples static dependency mapping from generative reasoning, implements an adversarial verification pipeline to gate deployment, and enforces strict stage transitions to prevent the agent personas we rely on from drifting into one another's scopes. The Service Extraction Layer: Decoupling Logic from LLM Context The primary bottleneck in current agentic stacks is token consumption. When a model attempts to reason about a codebase that spans multiple dependencies, it often spends its context window parsing file headers and resolving imports before it can actually write logic. This approach treats static infrastructure as if it were part of the reasoning problem. Mutagen 0.4.0 changes this by introducing a dedicated Rust layer designed to extract service definitions directly from your codebase without polluting the primary agent context. Instead of asking an LLM to map dependencies, the harness queries the local file system and executes static analysis routines. It isolates business logic execution from the generative reasoning loop used by Claude and Codex. This separation allows the model to focus on how to solve a problem rather than where the pieces are located. In practice, this means offloading static infrastructure queries to the harness rather than the LLM. The result is reduced latency and significantly lower token costs for complex applications. You get a dependency map that is as reliable as a compiler's parse tree, not a probabilistic guess from a prompt. // Example: Service extraction logic isolated from the reasoning loop fn extract_services_from_codebase () -> HashMap < String , Vec < Depende

2026-06-04 原文 →
AI 资讯

Stop shipping a 1990s C library to compute planets. Xalen is the pure-Rust, Apache-2.0 replacement for Swiss Ephemeris.

Stop shipping a 1990s C library to compute planets. Xalen is the pure-Rust, Apache-2.0 replacement for Swiss Ephemeris. If your app does astrology, you already know the dependency. Swiss Ephemeris: a C library from the 1990s, a folder of binary .se1 data files you have to ship and locate at runtime, and a license that is either AGPL or you pay for a commercial seat. For 30 years it was the only serious option, so everyone just swallowed the cost. That era is over. Xalen Ephemeris is a full planetary engine written in pure Rust, with no unsafe in the core engine (the only unsafe lives in the optional FFI, Node and WASM binding crates), released under Apache-2.0. No C toolchain. No data files to ship. No copyleft clause waiting for the day you try to make money. It is built to replace Swiss Ephemeris in production, not to admire it from a distance. Python is live on PyPI and the Rust crates are live on crates.io: # Python pip install xalen # Rust cargo add xalen-ephem xalen-time xalen-ayanamsa xalen-vedic Node and WASM build straight from the repo. Repo: https://github.com/vedika-io/xalen-ephemeris Switching takes one line Xalen ships a pyswisseph-shaped API on purpose. Migrating an existing codebase is a find-and-replace: # before import swisseph as swe # after import xalen.swe as swe jd = swe . julday ( 1990 , 6 , 15 , 10.5 ) xx , ok = swe . calc_ut ( jd , swe . SUN , swe . FLG_SWIEPH | swe . FLG_SPEED ) # same argument order, same SE_/SEFLG_/SIDM_ constants, same tuple layout Your function calls do not change. Your data-file directory disappears. Your license problem disappears. Xalen vs Swiss Ephemeris Line them up and the gap is hard to miss. Swiss Ephemeris is C from the 1990s, shipped as a native library you compile and link, fed by .se1 data files you have to bundle and locate at runtime, under AGPL or a paid commercial license. Xalen is pure Rust with no unsafe in the core engine, thread-safe, with no native dependency and no data files for the analytical eng

2026-06-03 原文 →
AI 资讯

I Was Asked to Add a Simple Classifier to a Website. Then I Saw the 250 MB Download.

A client asked me for a simple thing. Not ChatGPT. Not an agent. Not a multimodal assistant that can explain invoices, generate React components, and write poetry in three languages. Just a small classifier embedded into a website. The job sounded boring in the best possible way: take some text, classify it, return a result, keep it fast. So I started looking at the usual solutions. And then I had one of those moments where you stop reading documentation, lean back, and ask: Are we seriously doing this? Because the answer I kept running into looked like this: download a huge runtime download a huge model initialize a big ML stack then classify one small piece of text In one setup, the path was getting close to something like 250 MB per user . For a simple classifier. On a website. From a server. Every time. No. Sorry. That is insane. The problem The web has a strange habit now. You ask for one small AI feature, and the answer is often: bring the entire construction company. But sometimes I do not need a construction company. I need one person on the construction site. One task. One tool. One result. This is especially true for simple classification, embeddings, semantic search, routing, filtering, ranking, small local decisions. Not every AI problem needs an LLM. Not every website needs a full inference engine. Not every user should pay a 250 MB download tax because we were too lazy to think smaller. So I started digging I wanted something simple: runs in the browser does not require a server for inference small enough to actually ship works with transformer-style models can tokenize text can run BERT-like forward inference can produce embeddings or classification input does not bring ONNX Runtime, Candle, ndarray, or half the internet with it At first I thought: “Surely someone already made the tiny version.” There are great tools out there. Transformers.js is powerful. ONNX Runtime Web is powerful. Candle is powerful. But that was exactly the problem. They are pow

2026-06-03 原文 →
开发者

Microsoft could be the next Big Tech antitrust target

Over the past several years, Microsoft has largely managed to withstand populist calls to break up Big Tech while peers faced sweeping lawsuits. But a probe by the Federal Trade Commission suggests that grace period could be nearing an end. Earlier this year, Bloomberg outlined the contents of civil investigative demands (CIDs) - similar to […]

2026-06-01 原文 →