
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

2K+ Views
We can create standalone Lua executables with the help of the third party packages like srlua.srlua does a perfect job in converting a Lua script file into an executable, and we can do it on both the major platforms, whether that is the windows or the Unix based systems.Let’s first learn how to do it on a Windows system.Consider the steps mentioned below as a reference −First, visit the github link of the srlua project. Please click the following link. After that, you need to clone the repository on your local windows machine with this command −git clone https://github.com/LuaDist/srlua.gitIt should ... Read More

753 Views
In order to create a sandbox and to be able to use it we must first understand what a sandbox is and why we need it. A sandbox is term that is used in different fields of computer science, like in case we are talking about the software testing domain, then a sandbox is a testing environment that isolates untested code changes and outright experimentation from the production environment and if we talk about cybersecurity, then a sandbox is an environment that is an isolated virtual machine in which potentially unsafe software code can execute.Sandboxing is basically all about isolating ... Read More

5K+ Views
Lua does the implicit conversion or also known as coercion when it notices that you are trying to use a number but wrote a string, then it automatically converts the string into an int, and it is quite useful.Let’s consider a simple example where I will declare a string variable, and then I will try to do an arithmetic operation on it, then once the Lua compiler infers that we are trying to use the string as an int, it will automatically convert it into an int.ExampleConsider the example shown below − Live Demostr = "10" print(type(str)) num = 2 * ... Read More

597 Views
A regular expression is a special text string that is used to describe a search pattern.PCRE (Perl Compatible Regular Expressions) is a C library implementing regex. It was written in 1997 when Perl was the de-facto choice for complex text processing tasks. The syntax for patterns used in PCRE closely resembles Perl. If you want to learn about PERL and its use cases, you should visit this link.Now, let's take an example to see how to convert a PCRE into Lua and then print it.ExampleConsider the code shown below −"\002\003\004\005\006\007\008\009\010\011\012\”The above string acts as a PCRE and we will convert ... Read More

4K+ Views
When working with JSON we generally need to decode JSON into a string or maybe encode a string into JSON. Both of these processes of converting the string into a JSON or the opposite are seen frequently.While Lua doesn’t provide an official library to do the same, we can still make use of the third party libraries.There are many third party libraries that we can make use of, out of these the most common one is the json-lua library which can be located on this link.We can either clone the repository on our local machine and then install it or ... Read More

2K+ Views
We know that Lua does a great job when it comes to being a simple language and an embedded language. Lua works even better with C, because of the different libraries that provide a great amount of support for it.In order to compile embedded Lua in C, we need to first write a Lua program followed by a C program that will invoke the Lua program function, and then we will compile the C program.Consider the program shown below as the Lua program −print("--I am using Lua from within C--")It should be noted that the above Lua script should be ... Read More

739 Views
While there are different ways with which a person can compile a Lua executable, some of them require more time and resources.The most basic approach is to set the Lua Path environment variable and then simply run the lua command. While this might seem to be not much of a pain, setting the Lua Path definitely requires some work.Instead of setting the Lua path, we can simply make use of the env and lua combination which will allow us to convert a Lua file into an executable or run a Lua script.The command shown below does the same −#!/USR/BIN/ENV LUAIn ... Read More

3K+ Views
Calling a Lua function from C is something that requires a series of steps and a mastery in the Lua library functions. Lua provides several library functions that we can use whenever we want to call Lua functions from C or the opposite.Some of the most commonly used Lua library functions for calling a Lua function from C are −luaL_dofile(L, "myFile.lua");lua_getglobal(L, "add");lua_pushnumber(L, a);and much more.We will make use of these functions when we will call a Lua function from C.The first step is to shut down the Lua interpreter and for that we need to write a code in C.ExampleConsider ... Read More

373 Views
Lua provides automatic garbage collection that is very helpful in providing safe memory management. It basically means that you do not need to worry about the newly created object or how to allocate memory.Lua is running a garbage collector to collect all dead objects (that is, objects that can not be accessed in Lua) to perform automatic memory management.Lua also provides us with different functions that we can use to interact with the garbage collector, these functions are −collectgarbage ( "collect") − returns a number that denotes whether the collector does a full garbage collection cycle.collectgarbage ( "count") − returns ... Read More

2K+ Views
Copying a table means that we want all the values or pairs that are present in one table in another table. In Lua, there’s no standard library function that we can use to create such a table but we can create our own function to do so.Let’s create a function in Lua that will take a table as an argument and will create a new table that will be the exact copy of the table passed as an argument to the function.ExampleConsider the example shown below as reference − Live Demoa = {} a["name"] = "mukul" a["age"] = 23 a["isWorking"] = ... Read More