Pop quiz. Why is the following Java 8 code unsafe? UPDATE: this code is fine, see comments. Still good to think about, though. Entity e = new Entity(); e.setName(“my new entity”); persistanceLayer.put(e); To provide some context, Entity is a POJO representing something we want to store in a database. And persistanceLayer is an instance of a…
Category: languages
There are a number of sieve algorithms that can be used to list prime numbers up to a certain value.  I came up with this implementation in Scala. I rather like it, as it makes no use of division, modulus, and only one (explicit) multiplication. Despite being in Scala, it’s not in a functional style. It uses…
A lexer might seem like one of the boringest pieces of code to write, but every language brings it’s own little wrinkles to the problem. Elegant solutions are more work, but also more rewarding. There is, of course, a large body of work on table-driven approaches, several of them listed here (and bigger list), though…
A cautionary tale of language from Ted Nelson: We might call a common or garden spade– A personalized earth-moving equipment module A mineralogical mini-transport A personalized strategic tellurian command and control module An air-to-ground interface contour adjustment probe A leveraged tactile-feedback geomass delivery system A man-machine energy-to-structure converter A one-to-one individualized geophysical restructurizer A portable…
This epic posting on MVC helped me better understand the pattern, and all the variants that have flowed outward from the original design. One interesting observation is that the earlier designs used Views primarily as output-only, and Controllers primarily as input-only, and as a consequence the Controller was the one true path for getting data…
I wish I could say I had something to do with the planning of this: part of Balisage 2010 is a contest to “encourage markup experts to review and to research the current state of wiki markup languages and to generate a proposal that serves to de-babelize the current state of affairs for the long…
This brilliant bit is almost a throwaway paragraph on page 304, near the end. [Two men in a satirical dialog] managed only to demonstrate that the mathematical limit of an infinite sequence of “doubting the certainty with which something doubted is known to be unknowable when the ‘something doubted’ is still a preceding statement ‘unknowability’…
The new feature called rich snippets shows that SearchMonkey has caught the eye of the 800 pound gorilla. Many of the same microformats and RDF vocabularies are supported. It seems increasingly inevitable that RDFa will catch on, no matter what the HTML5 group thinks. -m
Omito: (Spanish) First-person singular (yo) present indicative form of omitir (to omit). (Proto-English) Shortened word form of an error of omission, e.g. in written. More collected Geek Thoughts at http://geekthoughts.info.
The remarkable (and prolific) Stephen Wolfram has an idea called Wolfram Alpha. People used to assume the “Star Trek” model of computers: that one would be able to ask a computer any factual question, and have it compute the answer. Which has proved to be quite distant from reality. Instead But armed with Mathematica and…
From the company home page, reknown XSLT trainer and friend G. Ken Holman has expanded his offerings to include XQuery training. The first such session is March 16-20, alongside XML Prague. I’ve always thought there is great power in having both XSLT and XQuery tools at one’s disposal. I’ve seen people tend to polarize into…
I’ve started looking into porting the WebPath code (and eventually XForms Validator) over to Python 3. The first step is external libraries, of which there is only one. WebPath uses the lex.py module from PLY. I had got it into my head that Python 2.x and 3.x were thoroughly incompatible, but leave it to the…
Wendell Piez, Mulberry Technologies Assertion-based schema language. A way to test XML documents. Rule-based validation language. Cool report generator. Good for capturing edge cases. Same architecture as XSLT. (Schematron specifies, does not perform) <schema xmlns=”http://purl.cclc.org/dsdl/schematron”> <title>Check sections 12/07</title> <pattern id=”section-check”> <rule context=”section”> <assert test=”title”>This section has no title</assert> <report test=”p”>This section has paragraphs</report> … Demo….
Lately I’ve been playing with some more advanced XQuery. One thing nearly every XQuery engine supports is some kind of eval() function. MarkLogic has several, but my favorite is xdmp:eval. It’s lightweight because it reuses the entire calling context, so for instance you can write let $v := 5 return xdmp:value(“$v”). Not too useful, but…
I’ve been playing lately with this site, and it’s a fantastic resource. The word carboy probably comes from Persian qarabah “large flagon.” Who knew? -m
The XQuery Working Group is debating the need for higher-order functions in the language. I’m working on honing my description of why this is an important feature. Does this work? What would work better? Imagine you are writing a smallish widget app, in an environment without a standard library. When you need to sort your…
Has there ever been a case of mitigated gall? More collected Geek Thoughts at http://geekthoughts.info/.
It would be awesome of someone made a site that catalogued all the common mis-encodings. Even in 2008, I see these things all over the web–mangled quotation marks, apostrophes, em-dashes. I’d love to see a pictoral guide. curly apostrophe looks like ?’ – original encoding=_________ mislabeled as __________ . That sort of thing. Surely somebody…
I registered ‘xfv’ on Google App Engine. Too bad there doesn’t appear to be any significant XML libraries supported. I have XPath covered by my pure-python WebPath, but what about Relax NG? Anyone know of anything in pure python? -m
In my about page, I’ve written my CV in two lines. Why don’t you try it, then link back to here? I’ve been known to use this as an interview question, and it’s quite a bit harder than it looks. A clever candidate will turn the paper sideways giving themselves more room to write “two…
When making hash browns xkcd style, there are at least 14 ways it could go badly. That’s not a potato, it’s a misshapen rock. Unexpectedly flammable tennis racket. Sparks landing on gas can. Food poisoning via undercooked hash browns due to limited flame contact time. Broken plate fragments. Dripping, flaming gasoline. Swing and a miss;…
If you want to get anything done, give it to a busy person… In my life, I’ve started four novels, completed my goals on three, gotten to “The End” on two, and completely flamed out on one. The first was in 2001. I hadn’t written much since high school. Something clicked in my head that…
Where’s Project Gutenberg? One difficulty in launching an ebook platform is the lack of available titles. I keep hearing about 80,000+ titles, but expressed as a percentage of Amazon’s book catalog, it’s minuscule. There should be all kind of public domain titles ready to go on day one. And where’s the Creative Commons books? There’s…
As one who, in the all-too-near future, will be hammering out the visuals to go with my talk at XML 2007, this made my day. (be sure to check out the deeper pages too) -m
What is the difference between placing instanceof=”prefix:val” vs. rel=”prefix:val” on something? How do I decide between the two? In the example of hEvent data, why is it better/more accurate to use instanceof=”cal:Vevent” instead of a blank node via rel=”cal:Vevent”? -m
The more I look at RDFa, the more I like it. But still it doesn’t help with the pain-point of namespaces, specifically of unmemorable URLs all over the place and qnames (or CURIEs) in content. Does GRDDL offer a way out? Could, for instance, the namespace name for Dublin Core metadata be assigned to the…
It’s a common need to parse space-separated attribute values from XPath/XSLT 1.0, usually @class or @rel. One common (but incorrect) technique is simple equality test, as in {@class=”vcard”}. This is wrong, since the value can still match and still have other literal values, like “foo vcard” or “vcard foo” or ” foo vcard bar “….
My Copious Free Time(tm) has been filled lately by two different evaluation projects. One is the 2nd Annual Writing Show Best First Chapter of a Novel Contest, for which the first round of judging is just winding up. The main benefit for contest entrants is that every submission gets a professional critique of at least…
Everyday Life in Ancient Mesopotamia, Jean Bottéro Mesopotamia: The Invention of the City, Gwendolyn Leick The Structure of Scientific Revolutions, Thomas S. Kuhn Yeah, they’re related. -m