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
|
  |
| 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
|
  |
| Joined: 29 May 2011 |
| Total Posts: 44 |
|
| |
|
|
| 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
|
  |
| Joined: 07 Dec 2007 |
| Total Posts: 4146 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 09 Nov 2013 06:26 AM |
| Another really important difference is that Java is Object-Orientated and Lua is more procedural. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
| |
|
|
| 09 Nov 2013 12:28 PM |
Lua is object-oriented nonetheless.
while obamacare() do benefitMiddleClass() end --LuaWeaver |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
| |
|
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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Nov 2013 07:03 PM |
| lol middle class is his signature |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
| |
|
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 |
|
|
| |
|