Page 2 of 2

Re: Recommended code reads?

Posted: Mon Oct 06, 2014 8:01 pm
by undef
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.

Thanks for pointing me to it though :)

Re: Recommended code reads?

Posted: Mon Oct 06, 2014 10:59 pm
by nice
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.

Re: Recommended code reads?

Posted: Mon Oct 06, 2014 11:24 pm
by undef
nice wrote:
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.

Re: Recommended code reads?

Posted: Mon Oct 06, 2014 11:46 pm
by nice
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.

Re: Recommended code reads?

Posted: Tue Oct 07, 2014 12:40 am
by undef
I always think sharing code is a good thing :)
But I think you should rather open another thread for that.

Re: Recommended code reads?

Posted: Tue Oct 07, 2014 10:48 am
by nice
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...

Re: Recommended code reads?

Posted: Tue Oct 07, 2014 11:48 am
by kikito
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).

Re: Recommended code reads?

Posted: Tue Oct 07, 2014 4:02 pm
by undef
Thanks Kikito, I can definitely take cues from your code!
I haven't done that extensive testing with my code yet, but it looks very reasonable to me.

I also think your detailed error messages are really useful!

I think I might look into busted as well.