3 ms·
I'm disappointed (in pony) that one suggest is to use tuple instead of a class, and in general avoid naking little clases. One often overlooked benefit of c++
by CJefferson 9y ago
I'm disappointed (in pony) that one suggest is to use tuple instead of a class, and in general avoid naking little clases.
One often overlooked benefit of c++ (and I am sure other langyages) is that I can wrap one or two ints in a class, add some constructors and little member functions, and be fairly confident the whole lot will get inlined and compiled away.
- trishume 9y agoIndeed, this is a good document for Pony (and a lot applies to other languages like OCaml as well!) but it shows what programming in a language like Rust or C++ that has many zero-cost abstractions gets you. In Rust I can always use wrappers, aliases and union types, and idiomatic error handling. And since the abstractions are either zero-overhead or will reliably be optimized away by LLVM, I don't have to worry about sacrificing performance.
- pjmlp 9y agoThis is not 100% true, just see the efforts of Google in optimizing string allocation on Chrome. Just because a language offers zero-cost abstractions, doesn't mean performance comes for free, one needs to know how to use them properly. And be clever to chose libraries that are also designed with performance in mind.
- srean 9y agoI would say std::string and std::io are special cases and somewhat atypical. Both have large performance overheads. I think the standardization committee blessed existing implementationsite that had become popular rather than design one with performance in mind. Strings really ought to have been immutable by default.
- nine_k 9y agoIn Rust or C++, you can make the abstractions zero-cost with some effort. I'm many other languages, you can't, no matter the effort.
- pjmlp 9y agoYes, but that "some effort" also has a development cost, which might be worthwhile or not, depending on the use case. Going a bit off-thread, Ada, Object Pascal, Active Oberon, D, Nim, Modula-3, Swift also offer such capabilities. C# also has on their roadmap plans to adopt more features from System C# and Midori, specially when coupled with .NET Native and CoreRT.
- vanderZwan 9y agoThat's a bit of an apples to oranges comparison since class in pony isn't a class in C++. It's an actor, with all of the machinery that this entails.
- mkishi 9y agoClasses and Actors are two different things in Pony.
- vanderZwan 9y agoMy apologies, I just checked and you're right. I remembered wrongly. Sadly it's too late to edit the comment above