- Lua Hello World
- Lua Hello World C++ Download
- Lua Hello World C++ Free
- Lua Hello World C++ Online
- Lua Hello World C++ Code
- Lua Hello World
practice Lua interact with C. GitHub Gist: instantly share code, notes, and snippets.
Question: I would like to understand the basics of how to write and execute Lua program on Linux OS. Can you explain it with a simple example?
Answer: In this article, let us review very quickly how to write a basic Hello World Lua program and execute lua program on Linux or Unix OS.
1. Write a Hello World Lua Program
Create the helloworld program using a Vim editor as shown below.
Note: Comment in Lua starts with two hyphens “–“.
2. Make sure Lua Interpreter is installed on your system
Make sure Lua interpreter is installed on your system as shown below.
Installing Lua Interpreter
If you don’t have lua interpreter, install it as shown below.
3. Execute the Lua Program
You can either execute using lua helloworld or ./helloworld
Note: As lua is an interpreted language, you don’t have the compilation step similar to the C program.
4. Writing and Executing Lua One liner
You can also execute lua from the command line as shown below. This will print Hello World!.
Welcome back to yet another issue of the Hello World in Every Language. It’s been awhile since I’ve written one of these articles myself, so bear with me! Today, we’re covering Hello World in Lua, a scripting language from 1993.
Table of Contents
Lua Hello World
As usual, I’m not super familiar with the language we’re working with today, so let’s consult Wikipedia.
Like many of the languages we’ve touched on already, Lua is a scripting language. Unlike many of the scripting languages we’ve covered, Lua is extremely lightweight, so it shines in embedded applications.
Perhaps the oddest featured of Lua is the fact that it’s compiled, but this is not readily apparent to the user. That’s because the compilation occurs at run-time where the bytecode is then interpreted. However, it’s possible to precompile Lua to save a few CPU cycles during runtime.
Because Lua is built for embedded applications, it has its own C API which can be used to write Lua code in C. Personally, I don’t find the API to be that user-friendly, but it does eliminate the need for reference management, so I can’t really complain.
Lua Hello World C++ Download
Due to its lightweight and embedded nature, Lua has also found a home in the gaming community. How have I never used it?
Hello World in Lua
At any rate, let’s get down to business:
As we’ll quickly notice, Hello World in Lua is not that exciting. In fact, there are only a handful of languages with this boring of an implementation. For instance, both Ruby and Python can perform Hello World in a similar fashion. As a result, there’s not a ton of explaining that needs to be done.
Essentially, Lua has a native printing function which can be used to write a string to stdout. In this case, it’s called
puts. If you know of any other fun print function names, let me know in the comments.
As usual, we pass a string to the print function, and the function handles the rest.
How to Run the Solution
Well, perhaps running the script will be more interesting. Fortunately for us, there’s an online REPL for Lua, so we don’t have to worry about downloading anything. Once inside, drop the code snippet from above into the editor and hit run. That’s it!
Lua Hello World C++ Free
Alternatively, we could download a copy of Lua, and run the solution locally. Even better, we could build a Docker image, so we don’t clutter our machine with dependencies. If you want to help with the Docker initiative, head on over to the Sample Programs repository and fork it. We appreciate the help!
Sample Programs in Every Language
As usual, thanks for sticking around to support the series. I appreciate it!
If there’s anyone you know who might like this series, make sure you share it with them. And if you want to help the series grow, why not head over to the Sample Programs repository and make an addition.
Lua Hello World C++ Online
At any rate, until next time!
For 100 Days of Code, I’ve decided to implement a few sample programs in as many languages as possible. Each implementation details a brief history of the language and a description of the code.
Lua Hello World C++ Code
Lua Hello World
Who knows? Maybe the Sample Programs in Every Language series will become so popular it’ll never end. To help this series grow, consider sharing it on social media with your friends. Or, if you have a language you want to see, drop your suggestion in the comments.