I don’t rattling undergo how some Canadians we hit here but I meet posted and essay most river Law and Self Defence.
I don’t rattling undergo how some Canadians we hit here but I meet posted and essay most river Law and Self Defence.
Francis Cheng continues on his walk through of ECMAScript Edition 4 features, this time discussing type parameters (read: generics in Java).
We could end up with code like this:
I have to admit to having a few shakes when I see this. I went through the Generics migration in Java land, and if I had a choice I would probably roll it back, or at least get erasure in there.
And the period before the angle brackets instead of just copying Java? Hmm. In general I don't like the angle brackets as they mess up when you mix with HTML. Now I am rambling.
Where would you like to see this go in a future JavaScript?
At first when you hear "FooAjaxLibrary now supports AIR" you think "er, OK, AIR has WebKit so it supports them all doesn't it?". SitePen added support for AIR in Dojo and gave us detailed information about the changes.
The value of this document is that it gives hints to us Ajax folk as we develop applications running on AIR. The main message is that the security sandbox that AIR gives you has subtle side effects that you need to be aware of.
For example, note the function(){} wrapper in the AIR-specific code:
There are other small issues such as not having eval() available post-load that you can see in the changeset. If you run into something as you develop your Ajax application in AIR, you have another resource to check (as well as the Adobe resources of course).
As well as making changes to get Dojo working in AIR, SitePen also added support for some of the AIR APIs themselves, including:
AirFileStorageProvider
The AirFileStorageProvider store the data in flat files in the app-storage directory. For example, a key of “MyKey”, value of “Hello World!”, and namespace of “MyNamespace” would create the file app-storage:/__DOJO_STORAGE/MyNamespace/MyKey which contains the text “Hello World!”. This storage provider allows for large amounts of data to be stored. Not only can strings be stored, but also objects thanks to AIR's serialize/de-serialize functionality. On the downside, data is not encrypted on disk. It would be trivial however to encrypt the information using dojox.crypto before storing the data.
AirDBStorageProvider
The AirDBStorageProvider leverages AIR's embedded database. When the provider is initialized, a database file is created in the app-storage directory and the Dojo storage table is created. The table holds the namespace, key, and value. This provider is similar to the AirFileStorageProvider in which it can store large amounts, but it cannot store serialized objects because there is no way to de-serialize them due to eval() being unavailable post-onload. The database file is not encrypted, but you could encrypted the data using dojo.crypto prior to storing the data. One advantage of the AirDBStorageProvider is there is only one file written to disk whereas the AirFileStorageProvider writes a file for each key/value.
AirEncryptedLocalStorageProvider
The AirEncryptedLocalStorageProvider uses AIR's encrypted local data store functions. Data, such as passwords, will be encrypted when being stored and decrypted when being retrieved. Similar to the AirEncryptedLocalStorageProvider, objects cannot be stored because they cannot be
de-serialized with an eval(). One limitation of the AIR's encrypted local data store is it does not provide a way to enumerate keys. To solve this, the AirEncryptedLocalStorageProvider creates a registry using AIR's encrypted local data store to track the namespaces and keys.
Dojo adds it's name to the list of Ajax frameworks that are ready for AIR work. Since Dojo has a large coverage of features (especially via the dojox.* components) it can be well suited for larger desktop apps.
Oliver Steele continues to spend time thinking about languages in his recent post on More Monads on the Cheap: Inlined fromMaybe.
He details the pain of dealing with nulls and various checks:
This article is about how to deal with null values. It follows up on this one. It’s intended for code stylists: people who care a lot about the difference between one line of code and two, or keeping control statements and temporary variables to a minimum. (A code stylist is kind of like the dual of a software architect, although one person can be both.) It’s not about code golf — although you might learn some strokes to use on that — but about keeping the structure of your code, even at the expression level, close to the way you think about the problem, if you think like me.
If you’re not a code stylist — and I’m not saying that being a code stylist, any more than being a prose stylist, is either a good or a bad thing — you might find it baffling that someone would put so much time into such simple topic. I won’t try to convince you otherwise. In that case, you might want to check back next week, when I’ll move back up to the bigger picture. (Specifically, some fun stuff involving how to use meta-object programming to solve race conditions in client-server models.)
He ends up with an inline fromMaybe solution:
To change code that expects a non-nullable array to a nullable array, change array to array||[]. This is a local transformation: it changes an expression into an expression (not a statement), so you don’t need to re-write the code that contains it. It’s also a linear transformation (again, in the sense of linear logic, not linear algebra): an expression that only occurs once before the transformation, only occurs once after it.
James Newton-King has quickly released a new version of Json.NET that has a new easier syntax for querying and and creating JSON.
Creating JSON
Querying JSON
"The index is up a towering 14.4 per cent from its January 21 low close, which is not a bad year's work"
Canadian equities marked the first leap day in four years with a sharp drop, taking a triple-digit dive Friday amid widespread losses led by gold, mining and financial stocks. via Globeinvestor.com
Web Info & Tutorials is Hosted by Chaaban