zig.guide icon indicating copy to clipboard operation
zig.guide copied to clipboard

"Coming-from" language tips

Open Sobeston opened this issue 11 months ago • 1 comments

Recently added support for custom show/hide admonitions for other programming languages.

Here's one found on the Slices page:

image

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

Sobeston avatar Dec 28 '24 19:12 Sobeston

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

kassane avatar Dec 28 '24 20:12 kassane