gsnedders

In an infinite möbius. Infinite loops are so yesterday.

PHP Grievances

Tags: June 28, 2009 (2 comments)

Below is a list of things that have annoyed me with PHP while writing various pieces of code, especially SimplePie 2 and the PHP html5lib (this list will be probably be added to over-time):

  • No native Unicode support (how a web facing high-level language can still not support Unicode in 2009 is beyond me: HTML, XML, CSS, and ECMAScript are all layered on top of Unicode, so almost everything going over the web is Unicode). There's no real way to implement Unicode in an interpreted language without taking a large performance hit, and the two main extensions PHP has for dealing with Unicode don't help in a lot of situations (mbstring, for example, can return a string that isn't UTF-8 when you try to convert data to UTF-8; iconv (per spec) fails when it hits an invalid byte, which doesn't work for a lot of web stuff).
  • The library of classes and functions you can actually rely upon is very small, because almost everything can be turned off via --disable-all. This means you end up having to re-implement in conditionals stuff you really ought to be able to rely upon. Even the "PHP Standard Library" can be disabled, which makes it non-standard, and means you can't rely upon it. I'd much rather there was a sane set of extensions that were always enabled and could not be disabled: preferably, everything that ships as PHP should always be enabled and should not be able to be disabled.
  • No native queue structure. Sure, you can use array_shift and array_push, but array_shift is an O(n) operation, and n can get quite large in the real-world, to a large enough extreme that it becomes undesirable from a performance point of view. While PHP 5.3 adds SPLQueue, this suffers from the problem of it being something that can be disabled (see above). I'd expect something as basic as a queue structure to exist in a language in the 21st century.
  • Inability to override object comparison. I may want objects that represent the URIs http://example.com and http://example.com/ to be equivalent, while keeping their original form.
  • Inability to override how objects are type-cast to any type apart from string (bool would be nice, for a start…).
  • ((bool) '0' === false) is an endless source of bugs.
  • There never appears to be that much regard to backwards/forwards compatibility, as it seems there is willingness to break small things in each release causing problems for a lot of people, but never to have more major changes that would break everything, but fix a lot of the problems with the language.
  • When implementing things like the DOM API, there are subtle differences to the spec.
  • XMLWriter doesn't actually necessarily output XML. Bugs reported to say this are bogus, so are we meant to assume that XMLWriter isn't actually meant to be able to be used as an XML serializer that can be relied upon? If that is the case, what are we meant to meant to use? Is it too much to ask for an XML serializer whose output always meets the "document" production in the XML specification (sorry, standard)?
  • There is an overhead of around 70 bytes per array entry, which makes using arrays of codepoints a not-entirely-satisfactory workaround of the language's lack of Unicode support.
  • Learning the argument order of functions takes years to do, if ever, a fact which is in part due to the internal variation, for example between array_search($needle, $haystack) and strpos($haystack, $needle).
  • PHP internally has a function that does type-hinting to some extent (zend_parse_parameters), yet it is repeatedly rejected to have type-hinting in the userland of anything apart from arrays and objects.
  • The filter extension (which apparently people need to use, according to the PHP developers) is buggy to the extreme of being useless. See this for some issues with its IPv6 support (I've also found issues, including regressions from 5.2.6 to 5.2.9… maybe I'll need to implement my own again). Equally, the URL filter uses the parse_url function internally, which the manual notes is not meant to validate the given URL, which inspires confidence in the extension. Why should I use the filter extension when it can be disabled, and when it is buggy? I cannot use it in distributed code that must run consistently on PHP 5.2.0 and above, even if those bugs are fixed in future releases. Likewise, having any bugs makes me weary of using it at all, as it makes me suspect of it having further bugs.
  • The reasons behind some of the most annoying version inconsistency, and one that hit both SimplePie 1 and MagpieRSS badly was data missing all pre-defined XML entities, a bug that was ultimately caused by PHP using an internal libxml2 API, which (unsurprisingly as an internal API) changed in libxml2 2.7. This means that with any version of PHP less than 5.2.9 with a version of libxml2 of 2.7 or above the xml extension is more or less useless. This was, thankfully, redeemed in PHP 5.2.9 by using a public API only added in libxml 2.7.3, so with libxml 2.7.0–2 the xml extension never works.
  • The wonderful zend.ze1_compatibility_mode, when turned on, causes $foo = new ReflectionClass('StdClass'); to throw E_ERROR (i.e., a fatal error).

Friendship

Tags: , , , June 26, 2009 (0 comments)

Friendship is a key part of any society, yet has as many interpretations as there are people. Over the past few years I have come to think that honesty is vital within any friendship, though as I've gone through them my ability to trust people has steadily decreased, coming from one place where I was very frequently betrayed, and had little expectation of trust ever existing, to another where I entered with hope for a new beginning, only to have this dream come crashing down around me.

Fundamentally, the dishonesty and the lack of trust of many people seems to stem from vanity, a state which any form of society is likely to perpetuate, as people become increasingly concerned with how other people view them, and what are people to judge on apart from acts? In Robert Lewis Stevenson's Markheim, the murderer is concerned about how he is being judged by who he takes to be the devil:

To you before all, returned the murderer. I supposed you were intelligent. I thought — since you exist — you would prove a reader of the heart. And yet you would propose to judge me by my acts! Think of it; my acts! I was born and I have lived in a land of giants; giants have dragged me by the wrists since I was born out of my mother — the giants of circumstance. And you would judge me by my acts! But can you not look within? Can you not understand that evil is hateful to me? Can you not see within me the clear writing of conscience, never blurred by any wilful sophistry, although too often disregarded? Can you not read me for a thing that surely must be common as humanity — the unwilling sinner?

While, as is clear from the murderer's rhetoric, and his ultimate fate, that he consciously is very dissimilar to how he has acted for his entire life, nobody, not even the devil himself, will judge him to be who he emotionally is. The world is a very similar place, with all judgement resting on actions, not on any rhetoric or emotion. When we are judged in such ways, it is really sensible to expect people to not be vain? Perhaps not, but this depends solely on morals. But what are morals? Mere constructs of a human mind trying to rationalize its own existence and come up with answers about how to live? If we believe the morals to live by are human constructs, then certainly vanity is inevitably in terms of interpersonal relationships; if we do not, then vanity is likely the disobedience against the morals set out to live by.

So, under the first scenario (for I think the latter scenario deserves little more comment than that these people should already be aware that what they are doing is wrong), when vanity is inevitable, should it still be tolerated? This ultimately comes down to a question of what morals you choose to live under, but I would hope most people would put honesty above vanity in terms of morals. Then why does vanity become so prevalent in today's secular society? The only plausible answer I can come up with is egoism, people having a single concern about how people perceive them, caring more about acquaintances than morals I hope exist (as I hope most people believe honesty is a moral). In some ways, Anna Karenina's ability to ignore society's perception of her is a virtue: she gave everything up for love. Everything is finished… I have nothing but you, remember that.

It is in this disregard of society that Anna manages to become who she is, transcending the rules of etiquette drawn up by society. It is this egoistic interest that the majority of people appear to have in their appearance to society that leads people to be dishonest (that is not to say, however, that Anna is perfectly virtuous character, free of all immorality including dishonesty), and further leads them to believe that short-term dishonesty is what long-term friendship entails, not that long-term honesty is what long-term friendship entails, even at the risk of short-term friendship. I believe that long-term honesty, even if it causes hurt in the short-term, will ultimately cause friendship to prevail. I do not believe that dishonesty, even if it causes great attachment in the short-term, will hold strong friendships together for any length of time. The truth hurts; lies hurt more.

Here's (a rough, quickly thrown together) list of what I expect friends to be:

  • Honest (see above),
  • Caring (if I am in tears, I probably would much rather have someone's arm around me than me all alone),
  • Inclusive (if something is happening, I would like to know, as even if you think I won't be interested, it's nice to have my existence acknowledged), and
  • Accepting (I don't want to have your morals forced on to me, I'm perfectly happy with my own morals).

Is this to much to ask? All too often it seems like this is so. Yet whenever I try and settle for less, I only end up getting hurt badly in the end, after a year, two years, or more. Trying to accept I won't get this and drowning my loneliness by having hundreds (literally) of friends I speak to on a daily basis doesn't work either; I still feel lonely. I guess my only option is to dig out the few people who share such morals, but that inevitably involves getting to know far too many people, and getting hurt far too many times.

Seven Things You Probably Don't Know About Me

Tags: April 18, 2009 (3 comments)

So, that damned guy annoying bugger random person who actually replies to me on Twitter Chris Wilson tagged me in this annoying meme, which I guess means I ought to participate in it (just over two years after the Five Meme went around).

So, the rules:

  • Link to your original tagger(s) and list these rules in your post.
  • Share seven facts about yourself in the post.
  • Tag seven people at the end of your post by leaving their names and the links to their blogs.
  • Let them know they’ve been tagged.

The seven things:

  1. I trust very few people (this is one of many consequences of what happened in May 2007, more on that later) although I do tend to be fairly open, albeit vague (as anyone who follows me on Twitter probably knows). Those people who I do trust do tend, however, to know almost everything. This does at times make things interesting.
  2. Also, having lost all trust in almost everyone, to the extent that I would struggle to call anyone I knew a "friend", I tried to drown my loneliness by getting to know as many people as possible. To this day, I know (and speak to regularly) an absurd number of people.
  3. Despite having called myself bisexual for around four years, I have never had a girlfriend for longer than two days.
  4. I dislike any form of synchronous communication, primarily because it leaves almost no time to think of about my response. I can only just bear forms of communication like IM and IRC which are only just synchronous, and as most people who've ever spoken to me on either will know, it is not unheard of me taking five minutes to reply.
  5. Everything you think you know is wrong. All the world's a stage/And all the men and women are merely players. Very little of how I appear externally is how I am internally. Only one or two people really know me.
  6. I find extreme atheists and religious fundamentalists equally irrational. Having no degree of agnosticism whatsoever, and placing absolute faith in the existence/non-existence of any deity is, in my opinion, illogical.
  7. I grow my hair long because I'm lazy, and because it gets all the girls. Well, mainly the lazy part…

And seven tagged people:

  • Andrew Krespanis because he really ought to blog more and he’s stopped trying to blog on one theme so he might actually do this.
  • Ryan Parman because he's my archnemesis.
  • Ryan McCue because otherwise he’ll feel left out (poor little boy).
  • Morten Fangel because I'm going to force more than one person to return to blogging.
  • Andrew Sutherland because forcing only two people to return to blogging is boring.
  • Emma Boyd just because I'm going to tag someone who I don't know through web dev/standards stuff, and she's the latest such person to have tweeted (or at least when I looked when deciding who to tag).
  • Anne van Kesteren because this list wouldn't be complete without someone from the #whatwg cabal teamsters.

(Oh, and yes, I know it has taken me almost three months to post this. I fail.)

Installing lxml on Dreamhost

Tags: , March 15, 2009 (2 comments)

I just spend the best part of 50 minutes getting lxml running on Dreamhost (really not recommended as a host, at all). Here's what I hope is a working shell script that takes a pristine Dreamhost site and installs lxml on it.

#!/bin/sh
mkdir work
cd work
curl -O ftp://xmlsoft.org/libxml2/LATEST_LIBXML2
curl -O ftp://xmlsoft.org/libxml2/LATEST_LIBXSLT
tar -xzf LATEST_LIBXML2
tar -xzf LATEST_LIBXSLT
cd libxml2-*
./configure --prefix=${HOME}/.local
make
make install
cd ../libxslt-*
./configure --prefix=${HOME}/.local --with-libxml-prefix=${HOME}/.local --with-libxml-include-prefix=${HOME}/.local/include --with-libxml-libs-prefix=${HOME}/.local/lib
make
make install
export LDFLAGS=-L/$HOME/.local/lib
export CPPFLAGS=-I/$HOME/.local/include
export LD_RUN_PATH=$HOME/.local/lib
curl -O http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install --prefix=~/.python lxml
python -c "from lxml import etree"

My Year In Cities, 2008

Tags: , December 31, 2008 (0 comments)

Following the lead of Anne (who himself followed some Mark), here is a list of cities I visited in 2008:

  • St Andrews, United Kingdom
  • Edinburgh, United Kingdom
  • Dundee, United Kingdom
  • Cambridge, United Kingdom
  • Aberdeen, United Kingdom
  • Ely, United Kingdom
  • Berlin, Germany
  • Prague, Czech Republic
  • Copenhagen, Denmark
  • Kalmar, Sweden
  • Borgholm, Sweden
  • Lyon, France
  • Nice (though mainly Mandelieu), France
  • Monaco
  • Glasgow, United Kingdom

One or more nights in each place, apart from: Edinburgh, Dundee, Glasgow (these are all fairly close to home (St Andrews)), and Monaco (half a day after TPAC with Anne, Lachlan, and Marcos).

Page:  1 2 3 … 30