generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Java and Lua: The Similarities and Differences

Previous Thread :: Next Thread 
CoolNerd2 is not online. CoolNerd2
Joined: 29 May 2011
Total Posts: 44
08 Nov 2013 10:25 PM
Hello. I am a person who knows how to code in Java/is currently learning how to code in Java. I want to be able to code in Lua as well (so that I can create cool things on ROBLOX), but I'm having a bit of trouble, because I'm so used to the Java platform.

Can someone please explain to me the main structural differences between Java and Lua? (for example, how "for" loops are set up in both programming languages) and some things that I probably don't need from Java to code in Lua (";" after statements, etc.).

If you have a link that can explain the differences and similarities, that would work, too.

Thanks for your time, and have a nice day!
Report Abuse
dekkonot is not online. dekkonot
Joined: 22 Dec 2010
Total Posts: 6685
08 Nov 2013 10:29 PM
Hi, and welcome to the wonderful world of Lua!

The first thing to understand is that you do not need brackets to open and close scopes. You can, however, use ';'s to mark the end of lines.

In Java, you can do: i++, but in Lua it's i = i + 1

Thus, you might assume for loops were

for i, i = i + 1, i > 5

but no

It is done like so:

for i = 1, 3 do
print(i)
end

Do opens the scope, and end closes it...

~ Linguam latinam est optimum ~
Report Abuse
CoolNerd2 is not online. CoolNerd2
Joined: 29 May 2011
Total Posts: 44
08 Nov 2013 10:37 PM
Thanks for the help!
Report Abuse
ScriptNHelper is not online. ScriptNHelper
Joined: 15 Oct 2013
Total Posts: 1600
08 Nov 2013 11:10 PM
I do have a set that teaches scripting! Subscribe and open it up in studio! http://www.roblox.com/My/Sets.aspx?id=1178903
Report Abuse
Charl3s7 is not online. Charl3s7
Joined: 07 Dec 2007
Total Posts: 4146
08 Nov 2013 11:29 PM
One's good and one sucks.
Report Abuse
YEGGOR is not online. YEGGOR
Joined: 02 Apr 2013
Total Posts: 1150
09 Nov 2013 02:32 AM
You can learn some basic stuff about Lua at LuaLearners(dot)com
Report Abuse
Bassics is not online. Bassics
Joined: 24 Apr 2012
Total Posts: 415
09 Nov 2013 02:39 AM
Java is a lot more structured than Lua. And I mean a LOT more structured.

Plus, Java is way more strict on syntax.

For example, here's two similar codes in Lua and Java.

Lua:

function a(message)
print(message)
end

a("Hi")

Java:

public class Script {
public static void main(String args[]) {
a("Hi");
}
public static void a(String message) {
System.out.println(message);
}
}
Report Abuse
TheColorMan is not online. TheColorMan
Joined: 30 Jan 2010
Total Posts: 11228
09 Nov 2013 06:26 AM
Another really important difference is that Java is Object-Orientated and Lua is more procedural.
Report Abuse
AbsoluteLOL is not online. AbsoluteLOL
Joined: 01 Dec 2012
Total Posts: 3939
09 Nov 2013 07:08 AM
You can't compare them.
Java is a strictly-typed object-oriented programming language that compiles into Java Executables (.jar).
Lua is a loosely-typed scripting language that is interpreted.
The only major similarity is that they both run in a VM.
Report Abuse
AbsoluteLOL is not online. AbsoluteLOL
Joined: 01 Dec 2012
Total Posts: 3939
09 Nov 2013 07:15 AM
Also, you should look into C#. It's syntax is nearly identical to Java, but it's more Form-based than Java.

using System;
using System.Windows.Forms;

namespace MyApp
{
public partial class MainForm : Form
{
public void MainForm() // entry point
{
InitializeComponent();
}
}
}
Report Abuse
TheLuaWeaver is not online. TheLuaWeaver
Joined: 09 Feb 2010
Total Posts: 1504
09 Nov 2013 12:24 PM
>Another really important difference is that Java is Object-Orientated and Lua is more procedural.

Lua is object-oriented too. -_-

while obamacare() do benefitMiddleClass() end --LuaWeaver
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
09 Nov 2013 12:26 PM
No Lua is multi-paradigm.
Report Abuse
TheLuaWeaver is not online. TheLuaWeaver
Joined: 09 Feb 2010
Total Posts: 1504
09 Nov 2013 12:28 PM
Lua is object-oriented nonetheless.

while obamacare() do benefitMiddleClass() end --LuaWeaver
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
09 Nov 2013 12:32 PM
No, Lua provides constructs that allow you to use it in an OO way, but it can also be used as a procedural language like C, or even in a functional way, albeit not as much as a language like Haskell.
Report Abuse
TheLuaWeaver is not online. TheLuaWeaver
Joined: 09 Feb 2010
Total Posts: 1504
09 Nov 2013 12:34 PM
If it can be used in an OO way, it is by definition object-oriented.
I'm not saying it isn't procedural or functional, but it is object oriented.

while obamacare() do benefitMiddleClass() end --LuaWeaver
Report Abuse
digpoe is not online. digpoe
Joined: 02 Nov 2008
Total Posts: 9092
09 Nov 2013 01:10 PM
No. Lua is NOT Object oriented.

Lua has the facilities to allow you to create object oriented libraries, but it by definition is NOT object oriented.

"A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways."
Report Abuse
chickenman158 is not online. chickenman158
Joined: 18 Jan 2011
Total Posts: 915
09 Nov 2013 09:25 PM
Java wakes you up in the morning when you drink it. I think that Lua is a bit tough to drink, considering it is so far away.
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
10 Nov 2013 08:57 AM
[ Content Deleted ]
Report Abuse
cheatmaster18 is not online. cheatmaster18
Joined: 29 Oct 2010
Total Posts: 1871
10 Nov 2013 01:29 PM
@Oysi

Lol, den var god XD
Report Abuse
Tr3e is not online. Tr3e
Joined: 03 Aug 2011
Total Posts: 54
11 Nov 2013 07:01 PM
"Lua is object-oriented nonetheless.

while obamacare() do benefitMiddleClass() end --LuaWeaver"

You're telling me that scripts can become super/sub scripts and can inherit eachothers functions, variables, and more?

Plus not to be off-topic but Obama Care is not benefiting the middle class.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Nov 2013 07:03 PM
lol middle class is his signature
Report Abuse
MettaurSp is not online. MettaurSp
Joined: 20 Mar 2010
Total Posts: 3179
11 Nov 2013 07:07 PM
The explanation for that siggy (which I saw on another thread a day or two ago) is:
obamacare stalls until it works meaning it never returns and benefitMiddleClass never gets called o3o
Report Abuse
xSIXx is not online. xSIXx
Joined: 06 Aug 2010
Total Posts: 9202
11 Nov 2013 08:24 PM
@oysi

kuk
Report Abuse
IlIll is not online. IlIll
Joined: 28 Aug 2011
Total Posts: 896
12 Nov 2013 06:09 PM
JUST DO IT! Attempt to create something... ok just find some random BASIC java code and try to understand what each line does...

Just Google "basic java code." and start with that
System.out.print("Hello World");
stuff
Report Abuse
WebGLWeasel is not online. WebGLWeasel
Joined: 11 Jun 2013
Total Posts: 929
12 Nov 2013 06:44 PM
[ Content Deleted ]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image