"Coming-from" language tips
Recently added support for custom show/hide admonitions for other programming languages.
Here's one found on the Slices page:
Occasional narrow comparisons for other languages, or additional context for people coming from specific languages, may be very useful for some. Feel free to suggest more in this issue.
-
Go
- [X] slices: comparison
-
C++
- [X] arraylist: ~= std::vector
- [ ] comptime: vs constexpr/consteval
- [ ] errors: vs exceptions
-
JS
- [X] assignment: "undefined" isn't the same
-
C
- [ ] comptime: comptime vs macros / converting macros to comptime
- [ ] single-item pointers: strictly single-item
- [ ] imports: vs include / note on code guards & circular references
- [ ] allocators: compare with c_allocator and malloc/free
-
Rust
- [ ] switches: comparison with match
- [ ] enums: comparison
- [ ] errors: comparison
- [ ] optionals: comparison
related: https://github.com/Sobeston/zig.guide/issues/65 https://github.com/Sobeston/zig.guide/issues/46
I don't know if you want to add to this guide, how to create basic custom allocator, like c_allocator/raw_c_allocator (more simple) - using std.mem.Allocator.
The example below shows a minimal version of both interfaces for custom allocators.
- C++17 (
std::pmr::memory_resource), - Rust (
std::alloc::GlobalAlloc)
https://github.com/kassane/zig-gpa-ffi