Monday, March 18, 2013

Scary Code

When I was a young kid I always thought programming was all in cryptic numbers and symbols without any semblance to natural language. As it turns out, this is indeed (usually) largely untrue. For example:

<if:Empty $%username>
...
</if:Empty>

That is relatively straight forward - if the username is empty, then run what ever code is between those lines.
This segment stores the value 0 on the computer for use later:
remainingPoints = 0;
There are times, however, that code really does resemble my preconceptions. The following code comes from the configuration file of my server:
 #apps
RewriteRule ^apps/([^/.]+)(?!.)$ $1.sfw.php [L]
#app resources
RewriteRule ^apps/(.*(?=\.).*)$ $1 [L]
I wrote it to tidy up the web addresses (URLs) that my users visit.
Now,
http://www.fractalcanvas.com/apps/iterativecanvas
is the same page as
http://www.fractalcanvas.com/iterativecanvas.sfw.php
except a much nicer address. In fact, other applications I develop will have similar URLs now, of the form:
http://www.fractalcanvas.com/apps/some_app_name

There is a little insight into what programming really looks like- granted, each of those examples was hand-picked to prove a point. I'll be posting some code segments soon that are more representative of what my project entails.
Istvan.

1 comment:

  1. I really like this idea. While your blog is not about learning a programming language - though technically it is in an indirect way - I as a reader am very intrigued to learn about how the code works and what it does. I look forward to reading more of these!

    Mr. Kirk

    ReplyDelete