Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zig for C++ programmers #65

Open
kassane opened this issue Dec 9, 2020 · 3 comments
Open

Zig for C++ programmers #65

kassane opened this issue Dec 9, 2020 · 3 comments

Comments

@kassane
Copy link

kassane commented Dec 9, 2020

Based on the requested proposal: #46

I would like to ask, either as an extra chapter or as an extension of the initial proposal, an explanation about the differences and equivalence for modern c++ programmers, emphasizing:

  • Zero Cost Abstraction
  • Allocators & pointers
  • Strings handling
  • Conteiners: Map, Tuple, List, ...
  • Generic Programming
  • Anonymous functions and functors
  • Error handling (exception x error code)
  • Object Oriented Programming
  • Namespaces
  • Compile time (constexpr x comptime)
  • User Type and Type Conversion
@suirad
Copy link

suirad commented Jan 19, 2021

Id like to see some examples of interacting with C++ structs/classes from zig code.

@Sobeston
Copy link
Owner

https://zig.guide/standard-library/arraylist
image

Today added support for these little language-specific show/hide tips. This one isn't very useful but my C++ is rusty. What do you think of this approach?

@kassane
Copy link
Author

kassane commented Dec 28, 2024

What do you think of this approach?

It's good for an initial reference. Particularly quoting C++'s most used feature std::vector<T>. This way you could also compare std::array<T> with C static array and zig array (different from zig slice).

I know not everything described above is applicable for this comparison since it involves too many internal compiler differences to explain. For example, C++ also has the complexity around const, constexpr, consteval and constinit.

When compared to zig comptime is closer to consteval (C++20) strictly compile-time. Since constexpr cannot guarantee compilation time, allows for both compile-time and runtime evaluation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants