Are clearly not a waste of time. Thanks to my brother Conor for the link to qwantz.com
Category: Uncategorized
stack based languages
The May issue of Dr Dobbs had a neat article on the cat stack based language. Pity that I’m only getting around to reading it now but I’ve been busy 🙂 In many ways, stack based languages are very elegant and remind those learning to program of the processing underlying higher level languages such as Java, which is actually implemented as stack based instructions in an abstract VM.
The cat language is essentially a statically typed version of Joy which is a reasonbly well known lambda-less functional language. Joy is useful in that you can write useful applications with it having the functionality of ISO C. It’s also straightforward to understand once you free yourself of some of the conventions of imperative languages. This is helped by homomorphism or as the Joy wikipedia page suggests:
“That is, the syntactic relation of concatenation of symbols maps directly onto the semantic relation of composition of functions”
As Joy defines functional compositions without typing their parameters it has the potential for unpredictability in its results. Whereas, every function in Cat will always produce the same number and type of results, given the same number and type of arguments.
E.g. consider an implementation of the fibonacci function in cat
define fib { dup 1 <= [] [dup 1 - fib swap 2 - fib +] if }
dup just pushes a copy of the top element (duplicates) to the stack. swap interchanges the top two elements. So calculating the fibonacci number for e.g. 5 can be thought of in terms of pushing 5 to the stack, then pushing fib which operates on 5, does the necessary comparisong and sets up the expected recursive addition defining Fib(N) = Fib(N-1) + FIb(N-2) through swapping the top two of the stack. We then push the if to the stack which operates on the 3 elements which are boolean and the true/false values.
Neat, tidy and fantastically terse if you remove the unnecessary formatting. The bracketting is obviously important however as it is used to define the variables being pushed to the stack. Cat is neat by Joy is, ironically enough, more fun!
A thought
A society has to evolve itself without benefitting from vicarious lessons from other societies. Probably because most people don’t effectively learn without first hand experience. As I’m typing this I’m watching a tv programme about american child preachers. It strikes me that with harsh neo-conservatism to the fore, if often appears that much of america hasn’t benefitted from the renaissance. The critical thought and analysis that so enlightened European philosophy and even spirituality has been discarded in favour of simplistic and unquestioning religiosity. There’s little I can think of more disturbing than hundreds of adults hanging on every word of a 7 year old telling them how homosexuality is evil and how all illnesses can be cured by faith. It’s terrifying. Even more so when you have parents making thousands from merchandising. So that’ll be a one way express ticket to the 9th circle for them. 🙂
Include your county in Monopoly
I’m not sure that everybody is playing fair with Hasbro’s Monopoly All-Ireland edition website which allows you to vote for your country to be included in the all-ireland edition.. Leitrim at #1? You gotta be kidding me.. Could be the extreme security which can only be cracked using expensive and unavailable applications like wireshark
POST /asp/submitVote.asp HTTP/1.1
Host: www.monopoly.ie
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: ASPSESSIONIDCCCTSTDB=CMELBCDCJFIECKHFLNNABJBI
Content-type: application/x-www-form-urlencoded
Content-length: 124
optin=0&ageId=2&votingReason=blah&countryCode=2&cityName=Waterford&cityId=79&email=me%40mydomain%2Ecom&name=Shane%20DempseyHTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: Fri, 27 Apr 2007 13:46:17 GMT
X-Powered-By: ASP.NET
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Fri, 27 Apr 2007 13:46:23 GMT
X-Powered-By: ASP.NET
Content-Length: 83
Content-Type: text/html
Cache-control: private
<?xml version="1.0" encoding="utf-8"?><response><result>success</result></response>
</body>
</html>
Yep, it’d be pretty tricky to script a HTTP post command. Even tricker to fake an email address. Not sure I’m up to it & I certainly wouldn’t advocate it. I’m not sure IIS 5.0 would handle the load anyway. Either way when you monitor the voting results it looks a tad suspicious.