LUA INTERVIEW QUESTIONS WITH ANSWERSHere we come with Lua programming language interview questions with answers, As we writing all type of interview questions, so we are start getting mail from Lua learners, they want Lua language related interview questions with answers, because there is no enough material available on internet. So we come with this article which will help you to clear you interview.
1). What is Lua?
Ans: Lua is a lightweight multi-paradigm programming language designed primarily for embedded systems and clients. Lua is cross-platform since it is written in ANSI C, and has a relatively simple C API.
2). When is the next version due?
Ans: Lua is in continuous development but new versions are infrequent.
Lua 5.3 was released on 12 Jan 2015.
3). Who is/are the founder of Lua?
Ans: Lua was created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, members of the Computer Graphics Technology Group (Tecgraf) at the Pontifical Catholic University of Rio de Janeiro, in Brazil.
Ans: Yes, Lua is freely available for any purpose, including commercial purposes, at absolutely no cost, and using it requires no paperwork. Read the details in the license page.
5). Is Lua compatible with GPL software?
Ans: Yes. Lua is distributed under the terms of the very liberal and well-known MIT license, which is compatible with GPL and is approved by the Open Source Initiative. Read the details in the license page.
6). Is there a public revision control repository?
Ans: No, there is no publicly available repository of Lua development code. Read this explanation. If you want to see a preview of what is coming in the next version, you'll have to wait until a work version is available.
7). What are the Advantages and disadvantages of using Lua?
Ans: Lua has a couple of advantages:
- It's lightweight: It doesnt require much storage and is easy to learn
- It's 'quite fast': It is actually about as fast as python
- It's fully written in C: You can easly manipulate lua if you know C
- Lua also has a great documentation.
- There's LuaJIT!
- It's lightweight: If you want python style regex, you'll have to code your own, or download a library.
- It has a small community: If hou have questions, it might take a while before you get answers.
Ans: We encourage discussions based on tested code solutions for problems and enhancements, but we never incorporate third-party code verbatim. We always try to understand the issue and the proposed solution and then, if we choose to address the issue, we provide our own code. All code in Lua is written by us. See also the previous question.
9). Is there a mailing list for Lua?
Ans: Yes, a friendly and active one called lua-l. Everyone is welcome. Read all about it here.
For discussions in Portuguese, there is Lua BR, the Brazilian version of lua-l.
10). What make Lua distinct from other languages?
Ans: Lua provides a set of unique features that makes it distinct from other languages. These include
- Free and open
Ans: Lua is mainly use for following purpose
- Game Programming
- Scripting in Standalone Applications
- Scripting in Web
- Extensions and add-ons for databases like MySQL Proxy and MySQL WorkBench
- Security systems like Intrusion Detection System.
Ans: It's great if you know what you're using Lua for. Lua is a scripting language commonly used in games like Multi Theft Auto or Garry's Mod.
You don't need it unless you're planning on implementing a plugin/resource system or interested in easy modding.
It's really easy to set up and really easy to use for its purpose.
13). Can or will Lua be used as a web programming language?
Ans: Yes, given its a general interpreted programming language just like Python or Ruby, but with a smaller library and a small community.
At this point I would say: do it if you want to experiment, but not for professional stuff.
14). What is LuaJIT?
Ans: LuaJIT is a Just-In-Time Compiler for the Lua programming language. LuaJIT offers more performance, at the expense of portability. On the supported OS's (all popular operating systems based on x86 or x64 CPUs (Windows, Mac OSX, Linux, ...), ARM based embedded devices (Android, iOS) and PPC/e500v2 CPUs) it offers an API- and ABI-compatible drop-in replacement for the standard Lua interpreter.
15). What makes LuaJIT faster than Lua?
Ans: Firstly, LuaJIT has a faster baseline interpreter. Even without the JIT, LuaJIT is already faster than baseline Lua for three reasons:
The interpreter uses a custom bytecode format. The Lua 5.1 format needs a bit more bit fiddling to decode an instruction, but LuaJIT's format only uses fields that are multiples of 1 byte. This makes decoding instructions faster. Since decoding has to be done for every single instruction, a simpler format directly translates into a faster interpreter. (By how much depends on the complexity of each instruction, though.)
It uses direct dispatch. The standard way of implementing an interpreter in C is to use a loop and a big `switch` statement at the top which then dispatches to the code that executes the instruction. A faster way is to use a table of code labels, have each instruction decode the next instruction, and directly jump to the label for the next instruction based on the opcode of the following instruction. If you want to do this in C you need a special GNU/Clang instruction. You cannot do this in ANSI C, which standard Lua aims to.
LuaJIT's interpreter is written in assembly. This makes matters quite a bit more complicated (and obviously unportable), but opens the potential to outsmart the compiler. For this specific use case hand-rolled assembly indeed beats a compiler in almost all cases. Google's Dalvik VM interpreter is also written in assembly, and I believe so is JVM's.
16). What are the pros and cons of Lua vs. Python and vice versa?
Ans: Following are the pros/Advantages and cons/disadvantage of Lua vs Python
- Lua is off-the-charts portable. It's by far the most portable language I've ever seen, maybe even the most portable program.
- What I mean by this isn't that Lua programs are portable (they're not, compared to Java), but Lua itself is.
- Just recently I built Lua on an IBM iSeries, with zero changes to the source code, I just compiled each Lua source file with the IBM ILE C compiler.
- Compare that to getting say, Python building on some unknown UNIX, let alone a completely different OS like IBM i (OS/400).
- Lua is very simple, easy to port to a new platform, easy to integrate with C on that platform. It's a nice enough language, but nothing special, but it's portability is special.
- If the platform has an ANSI C compiler (and they pretty much all do, I can only think of a couple that do not), then you can almost certainly build Lua, that's very cool indeed.
Ans: for variable = x, 1, .5 do
18). How can you convert a string to an integer in Lua? If you have a string like this: a = "10", You would like it to be converted to 10, the number.
Ans: I will use the tonumber function. As in a = tonumber("10")
Ans: Click here to see the answer
Visit Our New Site for HR Interview Questions Answers http://www.interviewboat.com/Company/GetCompanySponsored Ads