Recommended code reads?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Recommended code reads?

Post 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 :)
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Recommended code reads?

Post 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.
:awesome: Have a good day! :ultraglee:
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Recommended code reads?

Post 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.
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Recommended code reads?

Post 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.
:awesome: Have a good day! :ultraglee:
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Recommended code reads?

Post by undef »

I always think sharing code is a good thing :)
But I think you should rather open another thread for that.
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: Recommended code reads?

Post 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...
:awesome: Have a good day! :ultraglee:
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Recommended code reads?

Post 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).
When I write def I mean function.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Recommended code reads?

Post 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.
twitter | steam | indieDB

Check out quadrant on Steam!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests