[help] Formatting
#1
Posted 02 August 2012 - 06:04 PM
How should i write the code?
Were to put spaces betwwen lines?
How much of a indent on the side?
Thanks
#2
Posted 02 August 2012 - 06:19 PM
That is how i did it (not saying it is the correct way)
#3
Posted 02 August 2012 - 06:40 PM
Personally, I type my code as neat as possible. See HERE for example. That's because I'm a perfectionist, and because I know that if I look back at my programs in a couple of months time, I'm not going to want to spend ages working out what I meant at line 34!
A good rule to follow, is to leave a blank line between sections of the code, so that you can easily see what parts of the code work together.
In summary, as long as you put spaces in the places where you NEED spaces, then you can spread the code out as much as you like!
#4
Posted 02 August 2012 - 06:43 PM
Rsstn, on 02 August 2012 - 06:40 PM, said:
Personally, I type my code as neat as possible. See HERE for example. That's because I'm a perfectionist, and because I know that if I look back at my programs in a couple of months time, I'm not going to want to spend ages working out what I meant at line 34!
In summary, as long as you put spaces in the places where you NEED spaces, then you can spread the code out as much as you like!
#5
Posted 02 August 2012 - 06:54 PM
#6
Posted 02 August 2012 - 07:06 PM
Rsstn, on 02 August 2012 - 06:54 PM, said:
#7
Posted 02 August 2012 - 07:24 PM
Example:
function someFunction()
doSomethingHere()
if some_condition then
doSomethingElse()
end
end
while true do
local evt, id, msg = os.pullEvent()
if evt == "rednet_mesage" then
if id == someID then
print("Message: ", msg)
end
else
print("Not a rednet message :)/>/>")
end
end
BigSHinyToys, on 02 August 2012 - 07:06 PM, said:
Rsstn, on 02 August 2012 - 06:54 PM, said:
#8
Posted 02 August 2012 - 07:28 PM
Quote
Well, the nice thing about Lua is that you can just start programming straight away. Take the 'Hello World' program for instance.
However, in C++, there are a few things you need to declare before you can begin writing your program. Although this was an irritation at first, after a couple of weeks of on/off self-learning, you get used to it, and can experiment more.
It is not a particularly hard transition to make, as the formatting is fairly similar, and the function use is just as easy as Lua.
I've been reading through THIS website, and find it very useful. If you want to get an idea of what the language is like to use, you should look at '1.1: Structure of a program'.
Possibly the biggest difference to Lua is that you compile your program before you can run it, but this means that after the program has been compiled (into an exe file) you can run it without the aid of another program.
Lua is a nice starter language that can be learnt in-game (like in CC+Minecraft or Roblox), but C++ frees you from the limitations.
Sorry, I ended up waffling a lot and didn't answer your question very clearly, so I'll summarise:
Yes, it's a reasonably easy transition to make, but you need to remember to define nearly every variable/function you use. It takes a while longer to get into the fun coding, but it's worth it in my opinion!
EDIT: MysticT thinks that it's quite different, but when you use an IDE, it's very simple as far as I can see. I'm not that far into the language, so I guess I haven't encountered much stuff that I find hard to use as a Lua programmer.
#9
Posted 02 August 2012 - 07:36 PM
How did you learn C++? Are websites like that a reliable source?
#10
Posted 02 August 2012 - 07:53 PM
I learned C at the university, in the programming class, and then started learning C++ with tutorials and just trying by myself. If you like programming, it's easy to learn any language, and when you already know one, it's even easier, since they are all basically the same, just with a different syntax.
#11
Posted 03 August 2012 - 06:51 AM
MysticT, on 02 August 2012 - 07:53 PM, said:
I learned C at the university, in the programming class, and then started learning C++ with tutorials and just trying by myself. If you like programming, it's easy to learn any language, and when you already know one, it's even easier, since they are all basically the same, just with a different syntax.
Heh. I'd say that most imperative languages are fairly similar and use similar concepts for various tasks. There are, of course, things like functional languages (Haskell, etc.) and some even more unusual ones (Prolog), so I'm not sure I'd say that all of the languages are the same but for syntax.
#12
Posted 03 August 2012 - 07:49 AM
#13
Posted 03 August 2012 - 08:35 AM
Rsstn, on 03 August 2012 - 07:49 AM, said:
THAT IS SO AWESOME LMAO
#14
Posted 03 August 2012 - 12:01 PM
Rsstn, on 03 August 2012 - 07:49 AM, said:
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











