KL-666 wrote in Fri Feb 13, 2015 10:50 pm:Not knowing much about fg coding in general, just generally speaking, a scripting language is not very efficient. So i wonder why fg leans so heavily on a scripting language like nasal.
1) So far, we're lacking hard evidence to prove that this is related/unrelated to Nasal - however, that wouldn't be necessary had the OP followed the instructions we posted.
2) Scripting languages don't generally need to be inefficient (c.f. V8)- however, Nasal definitely is a "niche" language that is not particularly well-maintained. Attempts by others to contribute patches/improvements have been generally treated unfavorably by core developers.
3) FlightGear in general doesn't rely heavily on scripting at all - however, there's a bottleneck when it comes to development, especially core development. You only need to look at core development vs. fgdata development over the course of last couple of years to see that there is a problem - or even just the number of core related features that never made it into fgfs (e.g. look at osgEarth support or the radio propagation code to name just two)
4) Nasal is extremely accessible, people don't need to be proficient coders to write working code - equally, getting Nasal code committed is usually fairly easy, too
5) in general, people writing inefficient/slow Nasal code would not necessarily be in a good position to write much better C++ code - however, C++ just happens to be much faster obviously.
6) with Nasal, there is basically no deployment challenge
7) the way Nasal is integrated with FlightGear, it is also unable to provide its full potential due to architectural FlightGear issues - those would apply just as well using another scripting language
8) equally, even skilled Nasal coders need to re-invent the wheel frequently, because very few core developers are actively seeking to expose existing C++ functionality to the scripting system - which is the reason for having so much redundant code when it comes to scripted FDMs, autopilot/route manager code and other code for which we have exceptionally-clever C++ code in SG/FG, but which is inaccessible to fgdata developers
I actually once put a branch together where the Nasal engine would be completely disabled for performance reasons - having such a mode could still be useful for troubleshooting, and those wanting to use other languages - but in general, the problem is not so much Nasal itself, but the lack of maintenance and the lack of willingness among core developers to nominate other contributors to help maintain Nasal, in conjunction with a crazy rate of adoption by aircraft developers and other base package contributors not wanting/able to write "native" code due to a plethora of reasons.
For a summary on the C++ vs. Nasal situation in FlightGear, refer to the wiki:
Shouldn't we favor C++ over Nasal? PS: Assuming that you are on Linux and/or using FireFox or Chrome, you are using highly-performant platform with tons of scripted code (think XUL/JavaScript). Application level scripting is extremely common and useful and may sometimes simply not be as obvious. The main issue FlightGear is facing is the fact that Nasal is a niche solution and not widely used. However, even supporting Python, Ruby or Lua would bring its own challenges - not just in terms of enormous flexibility/momentum (community), but also due to the sheer number of optional dependencies - i.e. all of a sudden, aircraft might need their own shared libs. Equally, all the architectural issues at the core level would not be magically solved by replacing Nasal with a better-maintained solution like V8 or Lua - i.e. main loop synchronization and threading would still be a huge undertaking (think extension functions). Basically, some kind of IPC mechanism (like HLA) is the best option for having scripting running in a separate thread/process with explicit synchronization. Ripping out/replacing Nasal would be possible - in fact, having a startup mode that boots a subset of FG without any Nasal would be a very good thing to have for regression testing purposes - but otherwise, FG without any scripting would not be a good thing - just look at the degree of fgdata coding vs. core development, so FG would be severely crippled. Replacing Nasal with a more mainstream language like Python or Lua would be a cool thing from a community standpoint, but it would make all the architectural/core development related issues even more prominent, and that probably very soon. Whenever there's very little feedback/interest or action from core developers to implement a certain features/ideas directly, scripting is the most natural approach - which is why we have features like the Bombable add-on and the local weather system, optional stuff that core developers didn't need to get involved in.
Generally, there are very few core developers writing non-aircraft specific Nasal code regularly - those who do occasionally do so because their code doesn't necessarily belong into the fgfs core. But otherwise, most Nasal developers are not core developers.