Content

Why I am not too big on using Github (programming)

Page is part of Articles in which you can submit an article

written by owen on 2015-Sep-23.

related image

I write alot of custom code, often times ranging from 100 to a 1000 lines. I could throw it up on github but IMHO code is all a matter of context and without context code is basically nothing. Time is money and you can't just blindly write code in the hopes that one day it will output the correct results. This is the reason I prefer to explain the code that I write so that other people can learn from it. Putting it up for someone to fork and bug me forever about it is not high on my agenda.

static int collision_region_get_index(float val){  //round a number up to the nearest value and add it to the middle
        unsigned int t = (int)((float)(COLL_COORD_BOUNDS * 0.5f) + ceil( val / (float)collision_block_size )); //balance
        
        if( /* (t < 0) | */ (t > COLL_COORD_BOUNDS-1) ){ limit_coord_bounds++; return ERROR_STATE; }
        //t can never be less than zero cause i use the number for array indexs
        return t;
}

The C code above is generating an integer from a given float. This is an unsigned integer and is balanced between a certain positive range because I need the result for use as an array index in a spacial index.

Another example I wrote an was achievement engine for a game I wrote in C which took me a couple months to get working properly. This engine is peculiar because it only does one thing well and nothing else. You can define an achievement, its requirements and either choose to reset it or add 1. Keeping it this simple allows it to do some neat tricks while still being able to run fast. I dont even remember exactly how it works because it has been so long since I wrote it.

A lot of the times people seem to go on Github looking for a hammer that can cut down trees. And other people are looking for people to help them cut down a tree with a hammer.

What I look for when looking at code on github

As I mentioned before I write alot of weird custom code. I spend my time solving peculiar problems in various domains (web dev, games, graphics, UX, data analysis). Whenever I come up on unique problem I am NOT looking for a large library that I can fork.
What I am looking for is the simplest solution that I can use to solve my problem. I am not looking for a library or an API that I can "hot-plug" into my framework. Give me 100 lines of code. The smaller the code base the easier it is to maintain. I am looking for a neat "concept" or "explanation" that I can adapt.

I am NOT looking for a OOP wrapper class. In the worst case I will find a OOP framework that runs on top of wordpress or drupal. In the best case what I want is 100 lines of functional code that takes an input and returns the output result that I want - nothing else. I'm not looking for a API/service hosted in the cloud that I have to pay a subscription fee just to use until the authors decide to deprecate it because they found something more shiny. I am not looking for 7 million lines of design patterned code written by 500 contributors over 10 years.

Github is full of useless code

There is a ton of code on public Github. Most of it should not even be public. Especially copy pasted framework OOP wired-up scaffolding apps inside apps. Some of this code is useful, most are just variations of same thing. The last time I checked there are 64 ways to write a todo list using the MVC design pattern. A search on Github for "todolist" returned 4850 repositories, 519k code hits. I understand that some people love to shiv through mountains of code and change logs but do we really need so many public repos of the same thing? I could pick a random repo and hope that it provides the solution to my problem. OR I can choose the most starred one which was last updated 4 years ago and hope that it is not 1 million lines long. Whichever one I choose is matters little because none of the readme.md files explain why any of the code exists. Its like I have ended up lost in a 90s Programmer version of Yahoo Geocities.

There is hope

I find that if you know EXACTLY what you are looking for and you are working in unpopular languages you can find some cool stuff that might be hard or impossible to find elsewhere. For example if I search for "quadtree" I get 453 repositories in almost every language. Quadtrees are useful and hard to figure out for novices. Also quadtrees as hard to OOP. Having so much information to reference especially when you are working in an "unpopular" language platform is pretty cool - IF YOU KNOW WHAT YOU ARE LOOKING FOR. Once you have learnt to read code and deduce its "intent" there is nothing like finding some nice code to read. Github is easy street in this case.

Conclusion

Github is good for certain things but explaining code is not one of them. Its good for source control, and browsing/stalking your favourite repo. The problem with github as a sharing platform is that it does not do much to explain "why" some code is written the way it is and that is mostly what I myself am interested it. I like interesting code but with github you really have to know what you are looking for and be willing to look long and hard.

permanent link. Find similar posts in Articles.

comments

    Comment list is empty. You should totally be the first to Post your comments on this article.


comment