Our great sponsors
-
zig
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
Tokamak
SwiftUI-compatible framework for building browser apps with WebAssembly and native apps for other platforms
I love the use of `@hasDecl(root, "mime_types")`. I didn't realize that `@import("root")` was a thing.
https://github.com/cztomsik/tokamak/blob/main/src/mime.zig
Yes, fundamentally. In Rust if you take a parameter of generic type T without any bounds, you cannot call anything on it except for things which are defined for all types. If you specify bounds, only things required by the bounds can be called (+ the ones for all types). Another difference is where you get an error when you try pass something which doesn't adhere to a certain trait. In Rust you will get an error at the call site, not at the place of use (except if you don't specify any bounds).
Zig is doing just fine without any trait mechanism and it simplifies the language a lot but it does come up from time to time. The usual solution is to just get type information via @typeInfo and error out if the type is something you're not expecting [0]. Not everybody is happy about it though [1] because, among other things, it makes it more difficult to discover what the required type actually is.
[0] https://github.com/ziglang/zig/blob/b3aed4e2c8b4d48b8b12f606...
[1] https://github.com/ziglang/zig/issues/17198
Related posts
- Tokamak: SwiftUI-compatible framework for building browser apps with WebAssembly
- Swift UIKit web frontend?
- I would like to get a job as a iOS developer. Should I begin by learning UIKit or SwiftUI first?
- Beginner - is it complicated to make a web app from an app written with SwiftUI for iOS?
- Swift, Wow! What the Heck!?