Pivity

What is considered optimized or "good" code?

Last read Never
#1

I'm sorry if this thread seems ignorant or naive, but I'm fairly new to Lua and programming in general. I've done some small projects, but nothing major or worth implementing into a server. Once again I apologize if this seems "dumb", but I was looking from some insight. What do you consider "good" or "optimized" code? Is there any tips that could be given to a new Lua developer such as myself (or something you wish you knew beforehand)? Tips to learning syntax or understanding code in general? I'm looking forward to developing new custom content for my server, and I'm curious if you guys have any tips or ideas I should pick up on!

Thanks, -Novus

#2

Formatted code that is easily readable by other people other than yourself.

Limited whitespacing

Don't spam comments like a mad man (some people do to make their script look like it's a million lines long then when you remove them, it's legit 10 lines).

If you're making a Lua addon make sure your net n' shit is optimized, I don't know much about it but people bitch about net code being horrid most of the time.

Winner x 2
#3

Thanks ^^, I appreciate the response I'll make sure to keep that in mind :3

#4

Going off what Luna said...

With your comments and keeping them minimal - comment confusing portions. Look at it this way, if anyone else or yourself looks at it in a week, will they know what's going on? If not, then you can probably do with a comment.

Primarily optimization can best be accomplished by doing things on an event basis. This means if you can avoid checking for things in a Think hook, I suggest you do it. The less something runs, the better.

Never trust the client. They're arses, and will try to break your stuff at every turn, or exploit it. Assume the client is ALWAYS going to try and cheat the system somehow, as if you were the house at a casino.

There's a lot more, but these are a few important ones.

Agree x 3
#5

anything not made by ray champ

Funny x 4Agree x 2Winner x 1
#6
ByPaperlacksat 9th of January 2017 23:48:51
anything not made by ray champ

So what can you teach me besides micro optimizations?

My code is efficient enough.

I'll give you $10 per addon for optimizations that you find through any of my addons which actually make a real difference to the customers server performance.

If you weren't just trying to be an edgy guy, and actually mean what you say, add me on steam and i'll send you the source code.

Dumb x 2
#7

I mean to his defense, OP asked for #good and optimized scripts so

Winner x 2Dumb x 2Funny x 1
#8

-snip- resolved

Disagree x 3
Users viewing this thread
Nobody