by makecheck · 10y ago · 0 comments
While I have worked on plenty of C++ projects that had sections with performance-critical code or frequently-allocated data structures that need careful control over memory, I have never seen an entire program in this category. For that matter, I probably haven’t seen one with more than 40-50% of the C++ code in this category. Invariably, you start to see people write painful code to do trivial-things-that-are-not-trivial-in-C++, intermixed with the things that might actually benefit from C++.
You can offload a lot of less-critical C++ code, forcing it into a higher-level programming environment where fewer things can go wrong, in a language that is accessible to more programmers.
Python is not very good as an embedded language (globals and locks). Lua is OK but AFAIK making C++-like classes in Lua is a pain, and the language is a bit annoying for other reasons.
As of Windows 8,it is even easier given the new COM ABI model aka WinRT that all languages that wish to be used must support. You just need the ability to use WinRT projects on the language tools.
On mainframes like IBM i, you can take advantage that all languages, including C and C++, compile to a common bytecode to make some wrapper libraries as well.
Rather than embedding Python in the C++, write the top-level loop in Python and call into the C++ from there.
1-based indexing. Prototypes rather than classes -- I don't think having to roll your own or research an object system for every project is a good use of time.
Lua is a great language implementation, but whenever I try to actually program in it, it feels like an inferior version of Python...
- [0]: https://github.com/rustbridge/helix
Besides the usual set of using, with, try-finally, there are higher order functions for those languages that support it.
For example,
with-file "/pathname" {
//fd is only visible and open here
}
accept-connection {
// socket
}
// ....
You just need higher order functions and implicit parameters to be able to do that in your GC language of choice.You also need to remember to use RAII in every other case.
You might also need to implement RAII handle classes in specific use cases.
Ideally it'll lead to something like Terra http://terralang.org/ or Cxx.jl https://github.com/Keno/CXX.jl
But now Haxe http://haxe.org/ has several advantages that's worth consider.