I'm not sure how many people will dislike or like this idea but my plan would be to get as many coders involved from the community in developing a set of optional standards to adopt in their GLua coding. It would be somewhat similar to the python PEP-s. I.E
[url]https://www.python.org/dev/peps/pep-0008/[/url]
I would probably look at using git or Google docs so it is in such a way people can suggest changes.
Just interested in seeing who is interested?
Everyone has their own coding preference. Most of it for me is mostly my OCD speaking :v:
I wouldn't support this
can't wait for the git or google docs so i can suggest you to stop while you're ahead.
lol
not gonna happen
Ah okay. So people feel that sticking to their own styles is best? You can never be sure, some coding communities are religious to certain standard where others like here seem to be more preferential. Thank you for the feedback.
Communism doesn't work.
Allowing some person to define the ways you should and shouldn't write lua is dumb, and it's just supporting more people on facepunch to mock other's coding styles. This already happens enough, we don't need more of this bullshit.
[QUOTE=MeepDarknessM;49478913]Communism doesn't work.
Allowing some person to define the ways you should and shouldn't write lua is dumb, and it's just supporting more people on facepunch to mock other's coding styles. This already happens enough, we don't need more of this bullshit.[/QUOTE]
Its nice to see people vocal about how they feel. It is not communism or enforced as such but more about developing a guideline for newer coders who aren't sure what works well or what others do. I understand why you feel this way though.
[QUOTE=Strideynet;49478879]some coding communities are religious to certain standard[/QUOTE]
Lua is a programming language and not a cult like Python.
[QUOTE=!cake;49478949]Lua is a programming language, not a cult like Python.[/QUOTE]
Haha. Indeed that is true, some of that python shit is creepy when you see them typing away at it. Reminds of Scientology, but after all that is now classed as a religion.
I think we can all agree Python is shit
fuck python
Who are you?
[QUOTE=Netheous;49478961]Who are you?[/QUOTE]
Neither a man nor a muffin.
[QUOTE=!cake;49478949]Lua is a programming language and not a cult like Python.[/QUOTE]
You don't need to be a cult to enjoy using a code standard, most languages have one or two major ones that everyone adheres too after a few years of "lol i am programm hurr". For the sake of yourself, and everyone who ever has to maintain your shit, a good standard can be fairly important.
Lua is just kinda arse syntax wise though, no standard is going to really make it look good or properly readable in big projects.
[QUOTE=hexpunK;49479124]You don't need to be a cult to enjoy using a code standard, most languages have one or two major ones that everyone adheres too after a few years of "lol i am programm hurr". For the sake of yourself, and everyone who ever has to maintain your shit, a good standard can be fairly important.
Lua is just kinda arse syntax wise though, no standard is going to really make it look good or properly readable in big projects.[/QUOTE]
If anything I would perhaps consider producing a page on the wiki with some "good practices" that newer coders would like to adhere to. It wouldn't be horribly in depth but would give good advice on keeping code pretty, functionals and debuggable. Its up to people if they want to follow it but it would be nice for the newbs who need something to compare with.
It's really basic stuff.
Indenting: One level per scope. Additional tabs for neatness or grouping aren't required but can help. Take up the spaces vs tabs holy war on your own time.
New lines: \n or \r\n. Primitive text editors don't understand \r.
Variable names: Good names are appreciated - they help provide context to functions.
Function names: Good names are expected - casing is your preference, but some variant of camel case ( lib.someFunc, lib.SomeFunc, etc ) is typical. Core functions are all lower ( string.format ).
Commenting: For the love of god, comment anything that is weird or complex so you can remember it six months from now. Don't comment every line, but leave yourself notes for things like why you did it a certain way or todo improvements.
Operators: Since we have access to some C operators, be consistent. Don't mix comment types in the same file, don't use both &&/and, ||/or, !/not, !=/~=, etc.
File naming: Your preference, but contextual/hinted names ( sv_meta, sh_networking, cl_ui, etc ) can simplify your life.
The most important part: BE CONSISTENT. Nobody likes to read code that has mixed levels of indenting ( or no indenting... ), doesn't have any comments and is steeped in deep magic, has variable / function / file names that make no sense or provide no clues about their function or are nonsensical, or are just a general sloppy mess. If your code looks like it was slapped together from other scripts, we're going to assume that's the exact thing going on.
In short, the standard is that there is no standard other than not shooting yourself in the foot for anything you plan to revisit in more than a month.
personally, I also try to avoid all the c-style stuff garry added (//, && ||, etc), there's no real point to using them and they just prevent code from working outside of gmod
[QUOTE=PortalGod;49481431]personally, I also try to avoid all the c-style stuff garry added (//, && ||, etc), there's no real point to using them and they just prevent code from working outside of gmod[/QUOTE]
Agreed, it also can occasionally make reading files on github and text editors hard particularly when you use an apostrophe in a C-style comment (which makes the file appear completely broken)
I also add heaps of spaces everywhere to make things easier on the eyes
I have to agree and disagree there, yeah, i've used löve and this turned me mad when i've tried to write code and having to see too many exceptions, but also, i'm a c# programmer, js and action script, all those languages uses && and ||, if i'm used to && and ||, i don't see why would be a bad thing to use this in lua
[CODE]
--[[
comment
]]
[/CODE]
Is a lua thing right? Few times I've had the following problem:
[CODE]
--[[
print(Array1[Array2[x]])
]]
[/CODE]
Notepad++ highlighting understands what I mean, but the compiler stops the comment at x]] and errors. Easy to workaround with different syntax, but I'm just curious if that's a lua or glua thing.
[QUOTE=RealDope;49486399][CODE]
--[[
comment
]]
[/CODE]
Is a lua thing right? Few times I've had the following problem:
[CODE]
--[[
print(Array1[Array2[x]])
]]
[/CODE]
Notepad++ highlighting understands what I mean, but the compiler stops the comment at x]] and errors. Easy to workaround with different syntax, but I'm just curious if that's a lua or glua thing.[/QUOTE]
[code]--[[
comment
--]][/code]
or
[code]/*
comment - ONLY WORKS WITH GLUA
*/[/code]
[QUOTE=gonzalolog;49482064]I have to agree and disagree there, yeah, i've used löve and this turned me mad when i've tried to write code and having to see too many exceptions, but also, i'm a c# programmer, js and action script, all those languages uses && and ||, if i'm used to && and ||, i don't see why would be a bad thing to use this in lua[/QUOTE]
Actionscript? When will flash die... :nope:
! and != are the only ones I use. Feels better to only have to use ! instead of ~ and "not". Every other C thing is just ugly and unwelcome imo.
[QUOTE=RealDope;49486399][CODE]
--[[
comment
]]
[/CODE]
Is a lua thing right? Few times I've had the following problem:
[CODE]
--[[
print(Array1[Array2[x]])
]]
[/CODE]
Notepad++ highlighting understands what I mean, but the compiler stops the comment at x]] and errors. Easy to workaround with different syntax, but I'm just curious if that's a lua or glua thing.[/QUOTE]
In that case you'd use equal signs, for example:
[code]
--[=[
Code here
--]=]
[/code]
[code]
--[===[
Code here
--]===]
[/code]
The amount of equal signs must be the same on both the opening and closing sequence.
You can read more about it [URL="http://lua-users.org/wiki/StringsTutorial"]here[/URL]
Garry's decision to add C-style stuff to lua is a bit like adding Spanish conjunctions, such as "y" (and) and "o" (or) to the English language to make the English language "easier" for Spanish speakers.
Nah, come on - just keep Lua the same dude, I doubt people are going to forget what language they're using halfway through using it.
I don't know any VB programmers that complain that you have to write "OrElse" instead of "||".
Sorry, you need to Log In to post a reply to this thread.