bdjnk wrote:The lua code I learned the most from might have been rxi's flux library. It was totally outside of my normal way of thinking, and you know it's good because it's short, readable, and works flawlessly.
That is actually pretty nice code. It's short, clean, and easy to read.
Thanks for showing me that libary, I don't really use any libaries except the love and lua standard libaries, and my own of course.
(That's why I miss out on a lot of libaries in the forum)
I like it how he generates most of his code with a string, I thought about doing this as well recently but in my particular case metatables were a better solution.
It looks like a pretty nice libary as well, however it's biggest flaw (for me at least) seems to be that you can not easily provide your own interpolation function without having modify the libary.
undef wrote:Reading code can be a valuable learning rescource.
Is there any particular source code you have read, that taught you a lot of things? (Preferably but not nescessarily Lua)
If so, this is the place to share it!
Does the code that you have made on your own (with some help from my mentor/employer) count?
Because the code that I made a year ago was a Asteroids clone with a twist and that was when I was interning at a startup company in the U.S. and that was the first time that I have coded something.
undef wrote:Reading code can be a valuable learning rescource.
Is there any particular source code you have read, that taught you a lot of things? (Preferably but not nescessarily Lua)
If so, this is the place to share it!
Does the code that you have made on your own (with some help from my mentor/employer) count?
Because the code that I made a year ago was a Asteroids clone with a twist and that was when I was interning at a startup company in the U.S. and that was the first time that I have coded something.
Code for a simple game can be a great example for beginners.
However I'm rather looking for code that is a must read for programmers...
Besides, I'm not sure you're allowed to share that code if you made it at a company, depending on your contract.
undef wrote:
Code for a simple game can be a great example for beginners.
However I'm rather looking for code that is a must read for programmers...
Besides, I'm not sure you're allowed to share that code if you made it at a company, depending on your contract.
I can understand the must reads but the code I'm talking about is where I made my own game, we didn't release it, I made it to learn what programming is, the code is my own.
I was just thinking if you (or others) wanted to hear how it was for someone who where new to programming, that's all.
undef wrote:I always think sharing code is a good thing
But I think you should rather open another thread for that.
Ah okay, was just asking to see if there was any interest about that in this thread.
And if there's a another thread about it then please direct me too it I think I have a book at home that focuses on interviews about programming but I don't remember...
Ok, I have decided to put some of my code here - but only because no one has mentioned specs yet, and I think they are quite important for libraries.
Most of my libs have specs. Specs are a type of "automated test"; they are Lua code which checks that my libraries do what I say they do. I use the busted library to write the spec, and I usually set up Travis CI so it runs the tests automatically every time I push new code to my repos.
This might look like a lot of extra work (why write code to test code that you yourself write?), but it is very useful when I revisit a library after some time and I want to change it - the tests that my past self wrote help me check that everything is consistent; I know immediately when I "break old things" with my changes, by running the specs (or Travis CI runs them for me and sends me an email if I forget).
One simple example is cron.lua. The code is simple, but the specs are what makes it robust over time.
A more complex example is anim8. Since it creates two types of entities (Grids and Animations) in the same file the specs are divided into two. Also, since they call some LÖVE functions, I had to create fake versions of of them (in retrospective, I should have called that file fake-love.lua )