Thread: Programming!
View Single Post
Old March 4th, 2013 (8:57 AM). Edited March 4th, 2013 by Archenoth.
Archenoth's Avatar
Archenoth Archenoth is offline
The arch foe
    Join Date: Jan 2012
    Gender: Male
    Nature: Lonely
    Posts: 467
    Aye. No worries.

    Also, I suppose that is where we differ. As an abstractions guy who likes the functional paradigm, I like context-sensitive code. While I'll admit it can be terrifying in the hands of an inexperienced programmer, if you utilize it well, you can make some stupid-powerful abstractions.

    For example, I implemented an entire AJAX REST API using a single larger context-sensitive function, and a bunch of smaller functions calling it in various ways in JavaScript. I just committed it into a Github repo so you can see what I am talking about. (Hopefully this code wont give you an aneurysm, since it is by no stretch of the imagination in your style.)

    (This abstraction is incomplete currently, and yes I am using jQuery as a crutch currently.)
    This is the large dynamic function...

    This is where all of the public smaller functions are...

    Every one of those functions can be called with a callback function to call with data after the function is complete, they all provide the correct type of requests to add, edit, remove, update, and view things from the database. (With some further abstraction to combine functions to just store JavaScript objects in general if you are unsure of its status.) You can set a number of flags that modify how the function works by passing different data types, including how the function responds. You can do everything from:

    Code:{"name":"Archenoth"}, function(data){
    }); add a user and echo out what it looks like in the database to:
    Code:{"name":"Archenoth"}, 1); update the user with the first ID with an awesome name to:
    Code: add the user if it doesn't already exist but to update it if it does.

    It all depends how you call it and that's not even scratching the surface of what it can do.

    As you can see, you can squeeze out a lot of functionality by overloading things and by making context-sensitive code. The fact that I don't have to write a lot of code to get crazy amounts of functionality is something that I love.

    The fact that I write like this makes me not care much about overloaded operators in languages, because I deal with similar risks all the time.

    The thing about Python is that it is a very solid language. (From what I understand anyway, please correct me if I'm wrong.) There is usually one right way to do things, which makes the code into something that is relatively easy to read regardless of the author. Then there are languages like Perl (Yes, the code above is JavaScript, but it is written with Perl-like argument parsing for the request function.) that utilize the whole TIMTOWTDI ideology, which means I have the ability to make some really cool things, but also really really horrible code if I misuse it.
    Reply With Quote