Hi,
I'm new to Lua-World...
I was looking for some utility (external... not and ide-function) to reformat/reindent Lua code files...
I made the utility ... posted all in a new thread...[url]ttp://love2d.org/forums/viewtopic.php?f=3&t=2035[/url]
Lua Indenting and utilities and graphs
Lua Indenting and utilities and graphs
Last edited by bartoleo on Wed Oct 27, 2010 11:10 am, edited 2 times in total.
Bartoleo
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Lua Indenting and utilities
General questions like this are probably better asked on Stack Overflow.
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Lua Indenting and utilities
I don't agree.
This is the "General discussion about LÖVE, Lua, game development, puns, and unicorns", isn't it? The question is valid on my eyes.
(But hey, probably posting the question on both sites is a good idea)
Coming back to the question at hand:
Utilities that "reformat/reindent" code are usually called code beautifiers. Sometimes they are called prettifiers and I've also seen some rare cases where they called them tabifiers
I don't know of any lua-specific beautifier, and I don't think there is any (too specific).
However, Lua's syntax is actually pretty similar to other scripted languages, like ruby or python. You can probably google for "beautifier prettifier tabifier ruby python", and find some tools there. If you feed them some lua code, chances are that the resulting code will be quite good.
This is the "General discussion about LÖVE, Lua, game development, puns, and unicorns", isn't it? The question is valid on my eyes.
(But hey, probably posting the question on both sites is a good idea)
Coming back to the question at hand:
Utilities that "reformat/reindent" code are usually called code beautifiers. Sometimes they are called prettifiers and I've also seen some rare cases where they called them tabifiers
I don't know of any lua-specific beautifier, and I don't think there is any (too specific).
However, Lua's syntax is actually pretty similar to other scripted languages, like ruby or python. You can probably google for "beautifier prettifier tabifier ruby python", and find some tools there. If you feed them some lua code, chances are that the resulting code will be quite good.
When I write def I mean function.
- Thursdaybloom
- Citizen
- Posts: 81
- Joined: Mon Feb 15, 2010 3:43 am
- Location: Australia
Re: Lua Indenting and utilities
I've never heard of such a thing! Are you telling me that the time I've spent making my code aesthetically delicious has been wasted??kikito wrote:Utilities that "reformat/reindent" code are usually called code beautifiers. Sometimes they are called prettifiers and I've also seen some rare cases where they called them tabifiers.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Lua Indenting and utilities
Not at all. Doing it manually has lots of advantages.
The other day I was reading Coders at Work and one of the guys there said it better than I could. (From the top of my head, not verbatim):
The other day I was reading Coders at Work and one of the guys there said it better than I could. (From the top of my head, not verbatim):
Making your code reasonably indented is a discipline, and every programmer should practice it. Much like giving proper names to variables and functions.The first thing I do when I have to study some code that I didn't write is clean up the code. I tabify it all, manually. Then I start put some comments here and there. Renaming variables, etc. When I'm renaming functions I know how more or less everything works. But the first step is tabifying. It forces me to read the code more than once, and it forces me to stay longer on the uglier code.
When I write def I mean function.
Re: Lua Indenting and utilities
I agree with you all... I Try to code indented
But sometimes, it's better having 'identical' indenting on all code , so an utility could be a good solucion
I tried this:
UniversalIndentGUI
http://universalindent.sourceforge.net/
but I think that it doesn't indent lua (it highlights syntax)
In java I use the reformatter of Eclipse... and others 'small' but very good utilities like LINT...
But sometimes, it's better having 'identical' indenting on all code , so an utility could be a good solucion
I tried this:
UniversalIndentGUI
http://universalindent.sourceforge.net/
but I think that it doesn't indent lua (it highlights syntax)
In java I use the reformatter of Eclipse... and others 'small' but very good utilities like LINT...
Bartoleo
Re: Lua Indenting and utilities
Zed Shaw has a quote in his most recent book Learn Python the Hard Way that gets around to the same point as well. To paraphrase:Not at all. Doing it manually has lots of advantages.
Manually type the code examples in this book, don't copy in paste. By having to type the code you will "learn" the physical aspects of programming and be able to much more quickly identify syntax errors because you will "feel" the error before you see it.
Re: Lua Indenting and utilities
Wait what? A code prettifier? How does that work?
edit: Oh. They rename variables, fix up comments, and they tabify everything.
I do that manually, though automatic indentation and word completion are (most of the time) helpful.
edit: Oh. They rename variables, fix up comments, and they tabify everything.
I do that manually, though automatic indentation and word completion are (most of the time) helpful.
Hello, I am not dead.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Lua Indenting and utilities
I had totally forgotten about that one, and it is utterly important.walesmd wrote: "feel" the error before you see it.
Countless times I've spotted bugs just by being disciplined with my tabbing.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Lua Indenting and utilities
Yes, the question is valid, I just thought this is the kind of question that is especially suited for the people at SO.kikito wrote:I don't agree.
This is the "General discussion about LÖVE, Lua, game development, puns, and unicorns", isn't it? The question is valid on my eyes.
Anyway, back to the issue at hand: I'd say that if reading ugly code makes you feel hurt and/or dirty, you're probably on the right way to becoming a great programmer. It might be interesting to compare the output of a prettifier with manually indented and formatted code, to look for differences, although the problem with that is that everyone (every programmer, every project) has their own style, which probably will not match others exactly.
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 8 guests