lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Tue, May 19, 2020 at 9:09 PM Gé Weijers <ge@weijers.org> wrote:


On Sat, May 16, 2020 at 4:58 AM Philippe Verdy <verdyp@gmail.com> wrote:

C/C++ is very difficult to port and test: programs written in these languages need to be tested on specific platforms. One solution would be to develop a virtual platform model and develop a separate VM engine for it (this is what is used to support a Linux-like system in 100% pure _javascript_; not only this is not inefficient, but it is in fact very fast and removes lot of necessary tests: it's easier to develop and test the VM itself than tons of candidate programs using it; on such modelized virtual platform, there is no logner any complex portability problem: programs are specifically tuned for that single virtual platform, which is then emulated and recompiled ion a true local machine using all sorts of possibile optimizations that zillions of initial programs don't have to manage themselses; this is the same reason of the success of Java: one code running everywhere with the best performances for each target machine; the JIT compiler becomes an integrant part of the VM supporting the same virtual machine model with very precisely defined goals and rules; the same could apply to Lua and applies already to _javascript_, but C/C++ lays far behind). C/C++ should have been abandonned since long for application development, but only for implementing VMs (and in that case you don't even need all the complexity of C++, a "stronger C" is enough for most part of the code, plsu a some native assembly code for the specific platform for which the VM is built).


I'm not defending C++, it's not my favorite language to begin with, and it's gotten too freaking complicated, template programming is quite bizarre, and it takes years to get proficient in C++, but for some low level (embedded) programming there are no good alternatives (yet). Java won't run on a $1.00 processor that has to run for years on a battery, but C++ can if you know which things to avoid. Java is useless for low level/driver development, and it's a resource hog. There is no one size fits all programming language.


As was implied, the description of a virtual platform model is exactly what Java set out to do. Java can and does have the ability to run on dirt-cheap processors that consume very little power. That was, in fact, one of Java's design goals, and if your cell phone has a SIM card in it then you're using Java in exactly that context. It's not the language itself that's the problem. It's the runtime and the library -- the Java implementation used on SIM cards is nowhere near as full-featured as your typical Java SE; it doesn't even have garbage collection. It's useless for driver development but that's because it's a VM, not because it's bad. And I say this and I don't even LIKE Java.

C++ is also a lot less terrible than you accuse it of being. Yes, it has some noteworthy warts due to its historical legacy, but it doesn't require "years" to become proficient -- only to become a guru, and you don't need to be a guru to be a competent C++ developer. Template programming isn't required for application-level developers, template METAprogramming is even less important unless you're maintaining a big library, and outside of templates the vast majority of the complexity is actually inherited from C. The entire purpose of the rest of C++ is insulate the application-level developer from HAVING to deal with that complexity without PREVENTING them from accessing that underlying power if they need it. Application-level developers can learn to write in modern idiomatic C++ with about the same amount of investment as any other language.

That's one of the reasons it's still around and under active development and use even after nearly 30 years. It's a powerful, expressive, performant workhorse of a language that can be used effectively in pretty much any paradigm and use case you want to throw at it. Is it perfect? No, far from it, but its compatibility is UNPARALLELED. No other language runs on more platforms (except maybe C) or has more tools and libraries available for it (not even C), and the only language to rival it (that is, C itself) has some of the worst memory management ever seen in an applications language.

/s/ Adam