Yup! I found out about it from there!micha wrote:And of course there are two great videos about it. Part 1 and Part 2.Davidobot wrote:How to have clean code. Clean code is of outmost importance.
Here's a great book about clean code: http://www.amazon.com/Clean-Code-Handbo ... 0132350882
What techniques that everyone should know?
Re: What techniques that everyone should know?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: What techniques that everyone should know?
What language other than python does this apply to?Robin wrote:Personally I prefer to use whatever is idiomatic for that language
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: What techniques that everyone should know?
Haskell, occam, and FORTRAN from twenty-three years ago.Azhukar wrote:What language other than python does this apply to?
Re: What techniques that everyone should know?
I'm sure he meant those.ejmr wrote:Haskell, occam, and FORTRAN from twenty-three years ago.
Re: What techniques that everyone should know?
I think the best thing to learn in any language, is to learn that the unit of reuse is the function. Different languages have different ways of bundling and shipping those functions around, but as a principle, you have to use a function to facilitate code reuse. As it applies to Lua, you have a lot of freedoms when it comes to bundling functions, but the best (IMO) is the simple mixin. A table whose only purpose is to serve as a collection of functions to allow other tables or objects to share and reuse the code.
Or perhaps a better style that's a bit more usable:
What this ultimately facilitates is that if you design your mixins as simple tables, you can give functionality to any object just through this sharing mechanism. Here's something i wrote recently that demonstrates this, it's a mixin that lets a object house and draw static image.
And no point here did I have to talk about metatables when talking about code reuse.
Code: Select all
function mixin(to, from)
for k, v in pairs(from) do to[k] = v end
end
Code: Select all
function mixin(self, ...)
for i = 1, select('#', ...) do
for k, v in pairs(select(i, ...)) do self[k] = v end
end
return self
end
Code: Select all
local image_component = {
load_image = function(self, name)
self._image = love.graphics.newImage(name)
self._image:setFilter("nearest", "nearest")
end,
draw_image = function(self, x, y)
love.graphics.draw(self._image, x, y)
end,
image_width = function(self) return self._image:getWidth() end,
image_height = function(self) return self._image:getHeight() end,
}
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: What techniques that everyone should know?
Yeah it was not easy to think of languages that apply different semantics based on whitespace, lol.Azhukar wrote:I'm sure he meant those.
I think that’s a great point Inny. Even when writing assembly language I still use labels and such to organize my code in the same way I would with functions in other languages.Inny wrote:I think the best thing to learn in any language, is to learn that the unit of reuse is the function. Different languages have different ways of bundling and shipping those functions around…. As it applies to Lua, you have a lot of freedoms when it comes to bundling functions, but the best (IMO) is the simple mixin. A table whose only purpose is to serve as a collection of functions to allow other tables or objects to share and reuse the code.
Going back to the OP’s original question, I think Inny’s post highlights something important about Lua: *you really, really, really need to be comfortable with tables.* They are ubiquitous. Tables in Lua act as arrays, hash tables, containers, linked lists, graphs—pretty much any non-trivial data structure that you will see in other languages. The book “Programming in Lua” is a useful resource about tables. This page may also help. And make sure to read about the standard library for tables because you will both see and use those functions a lot.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: What techniques that everyone should know?
He did say idiomatic, not significant.ejmr wrote:Yeah it was not easy to think of languages that apply different semantics based on whitespace, lol.Azhukar wrote:I'm sure he meant those.
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: What techniques that everyone should know?
You’re right, but I would say the significant whitespace in all of those languages is the genesis for many idioms found in each.bartbes wrote:He did say idiomatic, not significant.ejmr wrote:Yeah it was not easy to think of languages that apply different semantics based on whitespace, lol.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: What techniques that everyone should know?
Yeah, but other languages still have idiomatic use of whitespace. That's what I was going for. Nothing to do with the off-side rule.
Help us help you: attach a .love.
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: What techniques that everyone should know?
Can we all agree that Whitespace (the language) has the most idiomatic use of whitespace? Heh.
Who is online
Users browsing this forum: Google [Bot] and 3 guests