Monthly Archives: December 2020

Tasting Johnny Walker

For a while I have been trying whisky head to head, all kinds of whisky, writing notes and making a ranking.

I came to wonder, why is blended whisky not as good as single malt? For the same money of course. I mean, a master blender can make a whisky from all the destilleries he wants following fewer rules, than someone making a single malt. The master blender should be able to produce a better product for the same money.

Is single malt really better? Better value?

I decided to buy a range of Johnny Walker blends: Red, Black, Gold, 18YO and Blue. I will try them head to head against single malts in the same price range (except for JW Red).

Here follows my head to head tasting notes. For the ranking, I am including Johnny Walker in my regular list (linked above).

JW Red Label vs J&B: I do a blind tasting. B is paler than A. B smells just lika a blend and very little of what I appreciate with whisky. A is marginally better, or I am just fooled by the darker color. I taste A, and I dont find it that bad. Over to B, it is worse, definitely. Back to A, it is not good, but it has something. A wins, and i guess it is JW (and it was).

JW Red Label vs Grants: Very similar color, perhaps Red being slightly darker. On the nose, very similar, perhaps Grants smells more like a real whisky. Also, in the mouth, there is something about Grants that convinces me more. Yes, Grants is more like the real thing, and I like it better.

JW Red Label vs Talisman: JW much darker in color. There is something about the aroma that makes me prefer the slightly softer and less chemical RW. Yes, it is the same with taste, JW is somewhat richer and softer and less chemical.

JW Red Label vs Teeling Rum Cask: Red Label is slightly more red, both rather pale. Aroma, not much in either of them. After a break, Red Label is more oily and peated, and Teeling is a bit sulphur. Tasting Red Label, a bit peat and quite sour in a not so nice way. Teeling is more neutral, less challenging, tasting nothing particular after Red Label, some odd chemical sweetness after trying again. Red Label is really doing its light peated thing. Red Label wins.

JW Red Label vs Dalmore 11YO Rare Find Oloroso: JW has a paler, nicer, color, and a very light nose. Dalmore is heavier, with some sherry notes. JW mostly smells alcohol. Tasting JW it has immediately a bit peated, it fades away quickly all of it but not bad. Much more flavour in Dalmore, and not so little sherry, but there is really very little about it i like. I prefer Red Label – is has never tasted so good before.

JW Black Label vs Old Pulteney 12: If I buy these today in my store they are exactly the same price. They are both 12YO. I blind taste. One (B) is more dark and red in color, the other (A) a bit more pale and brown. Not so much difference. Putting both to my nose I was sure both were Black Label! So it is not that easy to pick out the single malt. A, the slightly more pale whisky, has a richer, more complex and more soft creamy caramel aroma. B smells more alcohol and I find it harder to identify anything particular. I taste B, it is a bit salty, quite soft, a some bitterness lingering. I taste A, and it has a much more particular flavour: nutty and creamy, less balanced and subtle. Over to B again, it strikes me as somewhat peated and smoked.

I feel very confident that B is Johnny Walker. And I was correct.

Apart from the taste itself, Johnny Walker is a different experience to drink. It is first peated on the nose, it then comes softly into the mouth, grows and fades away. It is all very orchestrated. Old Pulteney is more raw and unrefined, yet soft, but perhaps not so balanced. If someone told me: they are the same price because they are equally good, that would be a bit of a relief actually.

But my rules are; there has to be a winner. And I choose Johnny Walker. First the elegant experience from the first smell to the final lingering taste. But it is also a very solid whisky with character: salty and a hint of peat, not a sweet sellout. Old Pulteney is tasty – definitely, but there is something experimental about it compared to the confidence of Johnny Walker.

I sometimes write “as blend” as a negative about aroma or taste. Whatever that is, Johnny Walker Black Label did not have (much) more of it than Old Pulteney 12.

JW Black Label vs Deanston Kentucky Cask Matured: JW much darker. Deanston has a soft vanilla and bourbon aroma, and JW is a bit thin, on the dry peated side. Deanston also has a soft vanilla and bourbon flavour. Black Label is, not sweet but not so much else. I find this Deanston delicate but thin, and yet the salty/peaty JW is even thinner. I enjoy Deanston more, in every way.

JW Black Label vs JW 18YO: Similar color. Both rather subtle on the nose, Black Label a bit more sour and salty, 18YO a bit more sweet. Same goes for the taste, and first impression is that they are equally complex and rich in flavour. I could say that these are equally good: Black Label is for those who prefer rough salt and peat, and 18YO is for those who prefer sweet flavours. But I think 18YO is better – unless you are looking for peat and roughness.

JW Black Label vs Glenlossie 9YO General Custard: JW very much darker. JW has a salty, slightly peated dry aroma. Glenlossie, light, malty vanilla and a bit pear. Tasting Glenlossie it balanced, a bit subtle, with not so dominant flavours. JW is surprisingly peated, very soft, oily and rich. I think I prefer Black Label.

JW Black Label vs Longrow 13 Red: Very similar color. Longrow has a rough aroma, salt and sea. Over to JW it is a bit candy and kind of sweet. Tasting Longrow a bit peated in a sour way, rich also a little margarine. JW is a bit dull and not quite up to it. Longrow wins.

JW Black Label vs Highland Park 10 Viking Scars: JW darker in color. HP is malty, fresh, light and a bit peated on the nose. JW is more heavy but more subtle. HP tastes good, quite light, dry in the mouth, with some sweetness. JW is soft with distinct peat flavour, but it is more anonymous and uninteresting. HP wins.

JW Black Label vs Nevis Dew Deluxe 12: JW is darker. Nevis Dew is very light and elegant, it requires some time and the nose deep in the glas, but what I find is classic and sweet in a sublte way. Black Label is more powerful, and not so little peat or at least leather, soil or dirt. JW smells more like a blend to me. I taste Nevis and it is not so subtle as I first thought, this is a blend with great balance and a soft caramel flavour. Black Label is a different beast and after they caramel Nevis, it almost tastes like an Islay whisky. This is very even. I almost decided for Nevis Dew, and tasted JW to be quite impressed. After a final big mouth of both it is victory to Black Label.

JW Black Label vs Super Nikka: Very similar color. Surprisingly similar aroma, I remember JW as more peated than I experience it tonight and without that peat the difference is little. Super Nikka slightly sweeter, and JW slightly more peated, salty and sour. Tasting JW it is malty, a bit burnt, slightly peated and a bit thin. Super Nikka is more caramel, vanilla (now I really feel the Nikka Coffey Malt in it), but also a bit bitter. Back to JW, it is a bit flat and uncharming, and sour – probably a side effect of the peat. I appreciate Super Nikka more.

JW Black Label vs Glenlivet 16 Nadurra: Glenlivet much paler. On the nose Glenlivet is fresh, dry, somewhat fruity but not very sweet. Black Label is more oily, slightly peated, more powerful. Glenlivet has a quite flawless, quite malty but quite thin and light flavour. Black Label is softer, richer, but a bit more odd-tasting. I add more and more water the to cask strength Glenlivet, but it kind of does not really open up. You may like superdry and not much flavour or Glenlivet, or you may dislike the oily peated character of JW, then Glenlivet is your pick. But I actually find JW the overall more interesting and tasty whisky.

JW Black Label vs Glenlossie SMWS 9YO Petrichor Vindaloo: JW much darker. Glenlossie has a very nice caramel aroma, hint of sherry and bourbon, or not. It is balanced and subtle yet powerful. JW is more peat, sweet and sour, definitely a peated whisky. Tasting findings match the nose. Glenlossie wins.

JW Black Label vs Smögen Dante: JW darker in color. Smögen is a bit more peated and with an unusual sweet smell that I know after I read about it think comes from the sauternes casks. JW is a bit more classic, thick and sweet, on the nose. I taste JW, balanced, not bad, I do not feel the peat much tonight. Smögen is a bit fresher and distinct at first, but it has a finish that to me tastes like too you and raw whisky (but Smögen is actualy 10YO). This is not so easy. Smögen is perhaps more interesting, but I think I would actually prefer a JW.

JW Black Label vs Chivas Regal 18: JW is slightly paler, they are probably both colored to the same perfect color. JW stands out as being more peated and Chivas Regal more bourbon, not just bourbon cask matured, but I actually thought it tasted not so little bourbon. None is perfect, JW is a bit more odd tasting, I prefer Chivas.

JW Black Label vs Bergslagen Gast: JW is darker, and more subtle on the nose. Bergslagen is more peated and with a slighly unusual woody sourness. Black Label is very smooth but with a somewhat industrial alcohol finish. Bergslagen Gast has more flavour, a bit peated and a somewhat salty and sour balanced body and it tastes better.

JW Black Label vs Writers Tears: These are two very good value whiskies. Black Label is more amber color, Writers Tears is more honey-yellow, almost a bit milkish. Very different nose, Writers Tears is sweet and spicy. JW is dirty, leather and a bit peated. Same impression in the mouth, JW is a bit softer more like velvet, Writers Tears ha more kick, even after adding some water. Given that these two blends are so different I could pick either of them, but if I have to pick one, it is Black Label.

JW Gold Label vs Glenfiddich 15 Solera Reserve: Again, these are exactly the same price in my store, and I am doing blind tasting. Color is probably identical, perhaps (A) is somewhat darker. A has a soft, sweet aroma, but B perhaps even more so. They are quite similar. Very similar. Well, I find B more fruity and fresh. A is a bit thicker – that could be more Sherry – which someone else could prefer while I dont. From smell and prejudice only, I would guess JW is A. Lets taste. A is surprisingly dry, perhaps not salted but a littler bitter – I would have expected a sweeter flavour. B is more of an explosion of flavours in the mouth, also some lingering bitterness. Back to A, I am not so impressed, a bit metallic in my mouth. And over to B, it is rather soft and fruity. Yes, I am quite confident now, that A has quite much blend character and that it is JW, and B is Glenfiddich. B wins in any case.

And it turns out I was right. Glenfiddich wins.

JW Gold Label vs Balvenie 12 Double Wood: Again, exactly the same price, but no blind test this time. Very similar color. Balvenie has a soft, kind of nutty and malty aroma, while JW has something alcohol/blend and sharp about it. Tasting both, I definitely find Balvenie easier to enjoy. Balvenie is more malty and full in the mouth, JW is a more sour, bitter and closed experience.

JW Gold Label vs Jameson Black Barrel: JW slightly paler. Jameson has a sweet smooth caramel-bourbon aroma. JW is more subtle, and more dry. It is the same when it comes to flavour, and the difference in character is so massive that it is hard to compare. In the end, there is something sweet and naive about Jameson and the more sophisticated JW wins, a narrow victory.

JW Gold Label vs Glenmorangie 10: JW much darker. JW is also heavier and more oily on the nose. Glenmorangie is more vanilla and caramel. They taste surprisingly similar. JW has a bit more of leather/oil flavour and also some more bitternes. Glenmorangie is softer and richer in flavour, and it wins (and it kind of wins the soft/sweet game of blended gold label).

JW Gold Label vs Balvenie 14 Caribbean: JW is slightly darker. Balvenie has more bourbon aroma, JW is more leather and oil. It is kind of the same when tasting them, Balvenie is the sweeter and softer, Gold Label has more character. Unless all you want is soft and sweet, JW is the better and more interesting whisky.

JW Gold Label vs Glenfiddich 12: Isn’t this the comparision of giants? Glenfiddich is a little paler. First impression is that Gold label has a thicker and more oily aroma, Glenfiddich is more subtle dry malty aroma. Glenfiddich is simple yet excellent in the mouth. JW has that oily, leathery, dirty kick (like Loch Lomond) – it is a surprisingly dominant characteristic for a blend like this. This is very close. JW is sweeter, thicker, richer. Glenfiddich is fresher, saltier and more complex. I personally prefer Glenfiddich, but I somehow have a feeling that I fail to appreciate why JW is the better whisky. But I like fresh and salt, so Glenfiddich it is.

JW Gold Label vs Glen Moray: JW a bit darker, and on the nose a bit oily, dirty, and almost peated. Glen Moray lighter, fruitier, a classic malt aroma. Tasting Glen Moray, it is rather dry and it lingers quite nicely. But it is rather sublte and very balanced. JW a bit peated, a little bitter and very balanced. I think I prefer Glen Moray, it is simple and good, and JW simply does not impress and I don’t like the flavour too much.

JW Gold Label vs Nevis Dew Deluxe 12YO: JW is darker. Nevis Dew has a light thin aroma. JW is richer, more oily and more sweet. Nevis Dew tastes surprisingly fresh, sweet and soft (although thin). JW is heavier, dirtier and more bitter in flavour. I prefer Nevis Dew.

JW Gold Label vs Chivas Regal 12: JW darker. Chivas has a soft aroma, mostly vanilla (with caramel and bourbon). JW more powerful, more oily and dirty. I taste Chivas and it is just like smelling it, vanilla and caramel, soft, not much to either like or dislike. But it is easy to drink. Drinking JW more happens, it is actually slightly peated and there are more flavours. It leaves me with an aftertaste of blended whisky alcohol, and I quite don’t like the flavour of it. I prefer Chivas.

JW Gold Label vs Glenallachie 10 Murray McDavid: JW is darker, with a distinctive leather aroma. Glenallachie is a little softer, on the fruity side, and also lighter. I taste JW and I find it soft and quite complex, the problem is that it does not taste so good. Glenallachie is lighter, less rich, also not quite so tasty. This is quite close, but I prefer Glenallachie.

JW Gold Label vs Highland Park 1998-2010: Similar color. Highland park a bit peated and leather, JW also a bit leather but more to honey. I taste Gold Label and it is a bit fruity at first, with a soft flavour. Highland park is more to old storage roam, seaside and fish. Back to Gold Label, the problem with it is that it is so balanced that no flavours stand out in an interesting way, and it is simply not so tasty. There is something odd with this HP that I dont quite like, so I think I would prefer JW in most cases.

JW Gold Label vs Deanston 15 Organic: JW is much darker, and on the nose much more dirt and leather. It is Deanston that smells like a blend. JW first has a quite rich and soft flavour (of dirt and leather), but it fades very quickly into a blend-alcohol flavour. Deanston is more salty and malty, a more slow change in the mouth, and less blend character in the end. Tasting again reach a different conclusion. JW is better.

JW Gold Label vs Benriach Heart of Speyside: JW is darker in color. Quite similar aroma, JW is a bit more sweet and mature, Benriach a bit more chemical. JW has a quite classic flavour, Benriach a little sharp, like som bitter herb or something. JW slightly better.

JW Gold Label vs Edradour 10: Edradour is darker, and has this odd smell of, is it fusel oil? I cant describe it, a bit minty. JW is a bit leather and peat. Tasting Edradour it has a thin flavour dominated by bitterness, not so much bitterness, but it is quite thin. JW wins.

JW Gold Label vs Dufftown Malt Masters Selection: JW is a bit darker, with a slightly more sweet and oily nose. Dufftown has a more light and fresh flavour, JW a bit on the oily peated side. I could pick either way here, but there is something pure about Dufftown that is more questionable in JW, so Dufftown wins.

JW 18YO vs Glenlivet 18YO: Again I blind taste, and JW is a bit more expensive. Very similar color. A has a smooth, rich, malty caramel aroma, very nice. After that, B strikes me as a blend: thin and much alcohol smell. I try more with B, and there is a nice subtle sweetness, sure there is. I taste B, it is softly everywhere in the mount, nothing bad at all, and very typical scotch (speyside) malt whisky. I taste A, it is saltier, rougher, less sweet, yet soft. My honest conclusion must be that A is the better whisky. If you just want light, smooth and slightly more sweet you might prefer B. I am quite sure B is JW (and it was).

JW 18YO vs Glenmorangie 10: JW is darker. Glenmorangie is a bit lighter and fresher on the nose, JW is more sweet and deep. Tasting JW I find it quite subtle and delicate (not heavy/rich), but it tastes very very good. Over to Glenmorangie, it is as complex and rich as JW, but JW simply tastes better. It makes Glenmorangie bitter. JW wins.

JW 18YO vs Glenfiddich 18: Same color. Glenfiddich has a more dry (like hay) aroma, and JW is more sweet (like sweet wine). They taste very different (in line with the aroma). JW has a very elegant sweetness and balance. Glenfiddich is like a rebel, tasting artichokes and salt, yet very soft. I prefer Glenfiddich: it makes JW taste bitter and boring.

JW 18YO vs Macallan Fine Oak: JW darker in color and stronger aroma, but more like a blend. Taste is quite similar, but Macallan is rich and soft enough to win.

JW 18YO vs Deanston Kentucky Cask: Deanston is much paler, but it has more aroma: a somewhat spicy and fruity vanilla aroma. JW is more subtle, it comes after a while, mostly elegantly sweet. JW has a soft, malty sweet flavour, very little bitterness and a hint of sweetness. Deanston is more like bourbon, caramel and vanilla, but it is a little bit strange in flavour. Deanston lacks the balance and sofistication of JW, and JW wins.

JW 18YO vs Aberfeldy 16: JW a little bit darker, very similar. JW has a very classic whisky aroma, very little surprises. Aberfeldy a little more fruit and wine. JW perhaps a hint of peat, and a hint of mint, and not so little character. Aberfeldy tastes good, creamy and caramel. JW a little more dry, very soft and balanced. A hint of mint, and JW is more dry and malty than Aberfeldy. These whiskies are rather similar. JW is a bit more oily and heavy, Aberfeldy a little bit more fresh. Very narrow victory to JW.

JW 18YO vs Super Nikka: Very similar color, JW perhaps more red but not darker. Super Nikka quite light on the nose, very balanced and soft. JW a bit more powerful but also a something is more off: a hint of mint or hay that I did not quite expect (although I should have remembered from my Aberfeldy 16 test above). Super Nikka is more elegant, more dark caramel. I taste JW, it is nice, classic and balanced. Nikka is a bit more bitter, metallic even, but also classic. Back to JW it is somewhat fresh, quite dry, not fruity. Back to Nikka, not bad, but not quite up to it. JW wins.

JW 18YO vs Ballantines 17: Ballantaines slightly paler, fruitier, maltier and more bourbon. JW more sweet, honey, caramel, some peat and some leather. I think the occation for this kind of whisky is easy to drink, easy to enjoy whisky with people who are not much into whisky – I recommend Ballantines.

JW 18YO vs Bunnahabhain 12YO CS (2021 Special Edition): Very similar color JW slightly darker when Bunnahabhain is watered down . On the nose JW is more like velvet, soft, balanced but also some not so nice chemical notes. Bunnahabhain is more salt and raw, with more fruitiness. JW is soft in the mouth as well, easy to drink, kind of complex yet a bit thin. Bunnahabhain has more of a kick and a rough character, also some sourness. I give victory to JW.

JW 18YO vs Highland Park Cask Strength: JW is somewhat darker, less difference than I expected. JW has a velvet kind of aroma, soft, slightly dirty oil peated, not very powerful. HP is more dry and sour, and not as peated as I expected and also more subtle than expected. After a while I feel HP is coming a bit, and it has some maltiness to it. I taste JW and find it surprisingly fruity, soft, quite complex and easy to drink. HP (with not so little water) is a more dry, peated and pure experience. Not so easy to pick a winner. If JW wins it is because of the softer and richer full flavour. If HP wins it is because of it refreshing salty peated pure flavour. I will give a narrow victory to JW.

JW Blue Label vs Glenlivet 21YO Archive: I blind taste, and JW is a bit more expensive. Very similar color, A is probably slightly paler, and its aroma is actually dominated by smooth peat. B has more the aroma of malt, honey and caramel. I taste B and it is rich, full of flavour, and very well balanced. I taste A, it is softly dominated by peat, but it is more thin and it fades away. Well, anyone who simply prefers more peat will prefer A, but then there are more peated whiskies to find. I really appreciate both, and they are both very tasty, but by an criteria I can argue for, B is the better whisky. And I am quite sure B is Glenlivet (I was right).

JW Blue Label vs Highland Park 18: JW is about twice the price, and I blind taste. Very similar color, both are beautiful kind of dark brown, if I had to make a difference, A is darker. A has a thick aroma of leather and oil. B is surprisingly light and thin after A. There is some peat in B, and there is some bourbon, even fruitiness in A.

I taste B and find it very soft and easy to enjoy, with hints of peat, salt and Island whisky. I taste A and also find it soft, but it more raw and salty, yet less peated. There is also some sourness to A (that could be a hint of peat). Over to be, is is more soft and refined, and more openly peated.

I am happy to compare these two whiskies, they are similar enough, yet different.

I come back after a while and in A I feel more fruity aroma, almost like sherry. B more clearly has peat and island character. Tasting both, back and forth, A is much sweeter, in a sherry way, and more powerful, while B remains the softer (yet peated) whisky.

After trying different positions, arguing with myself, and getting back to them i different order I must decide that A is better than B. And I am very sure A is Highland Park (and it was).

JW Blue Label vs Longrow: JW is darker. On the nose JW is softer and Longrow saltier (and perhaps more peated). Tasting both, my first impression is that Longrow is thinner, more sour, and more peated. Yes, the very balanced, soft, rich and complex JW tastes better than Longrow (which is very unrefined and raw in comparison).

JW Blue Label vs Dufftown 18: Same quite dark color. Dufftown is very balanced, rich and elegant on the nose. JW clearly peated compared to Dufftown. JW kind of richer (and peated) in flavour, but it fades quite quickly, Dufftown a bit sweeter and more lingering, but lighter. I could argue both ways here, Dufftown is more elegant and easy to enjoy and JW is a bit heavier and both have more and less quality in different ways. I will give JW a narrow victory.

JW Blue Label vs Deanston Signatory 10YO #900074: After reducing Deanston from cask strength I see no significant difference in color. Deanston has a caramel and light bourbon aroma. Blue Label has a sweet peated aroma. After tasting both, JW is obviously softer, like velvet in the mouth (perhaps not so little because it is only 40%). Deanston tastes a bit, not so balanced, not so easy to define. I find Deanston a bit bitter and kind of lacking good character to compensate it. JW Blue Label may be a bit dull, and thick (as opposed to fresh), but victory has to go to JW.

JW Blue Label vs Mackmyra Reserve Förlagrat Refill Gravity: JW is darker, more classic whisky amber and Mackmyra is more greenish. JW has a rich, complex slighly peated nose, very balanced. Mackmyra smells more fruity, candy and kind of grappa after JW. Tasting is kind of the same, JW is rather boring for its price, but flawless. Mackmyra is very experimental and after JW it is not quite obvious that Mackmyra is whisky at all. I prefer JW Blue Label.

JW Blue Label vs Arran Quarter Cask: Blue Label is darker, with a soft lightly peated classic aroma. Arran is more caramel, almost candy and chemical. I taste Arran and find a creamy sweetness, JW is definitely peated. Neither whisky is quite perfect, but JW wins after a while.

JW Blue Label vs Springbank 18: JW is darker. Springbank is more dirty, oily and peated on the nose. JW is more delicate. These whiskies resemble each other in a strange way. Tasting JW I find it a bit salty, very balanced and quite rich in flavour, super soft, yet with some peated character. My Springbank experience is ruined beacause I taste that suphur finish, but apart from it, while JW is super refined and balanced, Springbank tastes like the unrefined product, process going wild. I have big respect for Springbank, and of course it is in a way a more interesting and authentic whisky, but I appreciate Blue Label much more.

JW Blue Label vs Oban 14: JW slightly darker. Oban has a more fresh, malty, fruity and salty aroma. JW smells more old and closed, slightly peated. Drinking is a bit the same, after going back and forth a few times JW tastes pretty dull and boring, Oban more fresh, interesting and refreshing. Oban wins.

JW Blue Label vs Writers Tears Double Oak: Similar color, JW perhaps slightly darker and more brown. JW being a very smooth and delicate whisky still has a bit of scottish peat, oil and leather. Writers Tears is equally smooth, but more caramel, creamy and nutty and absolutely no peat. I think the quality and overall experience is quite comparable. I think Writers Tears tastes very good, Blue Label is anyway more of an acquired taste, yet it is quite subtle. I appreciate drinking Writers Tears more.

JW Blue Label vs Hazelburn 2007-2021: JW a bit darker with a warmer color. Quite similar aroma, both a bit oily, JW slighly more peated and Hazelburn slightly more fresh. Blue Label is very soft in the mouth, a hint of peat, and it lingers nicely. Hazelburn is salter, maltier more fresh and less balanced and complex. Both do their thing very good and they both taste good being compared to each other. Hazelburn is even a bit peppery. I prefer Hazelburn.

Optimizing Objects in JavaScript

I have web applications with JavaScript business objects coming from constructors, like:

function Animal() {
  this.type      = null;   // 'Cat'
  this.color     = null;   // 'Black'
  this.legs      = 0;      // 4
  this.carnivore = false   // true
}

These objects may be created on the web, but quite quickly this happens:

  1. Client
    1. creates an Object
    2. serializes Object with JSON.stringify()
  2. The JSON text is sent over the network from client to the server
  3. Server
    1. uses JSON.parse() to get the object back
    2. validates the object
    3. stores it (perhaps by doing JSON.stringify())
  4. Client (perhaps the same) asks the server which sends it over the network
  5. Client
    1. uses JSON.parse to get the object back
    2. keeps the object in memory for application logic use

This works fine! If you do not add prototypes/functions to your constructors (like Animal.prototype.eat()) the client can use the object it got from JSON.

Since I send millions of such objects in this way over the network every day, I can’t help asking myself if what I do is reasonably efficient, or rather wasteful?

One idea I have had is that for this purpose I could turn Objects into Arrays (when shipping over the network, or perhaps storing them), like:

// As Object                          // As Array
{                                     [
  type      : 'Cat',                    'Cat',
  color     : 'Black',                  'Black',
  legs      : 4,                         4,
  carnivore : true                       true
}                                     ]

Another idea has been to create an object with “new Animal()” rather than using the raw Object I get from JSON.parse().

Possible benefits could be

  1. Arrays are smaller to store on disk
  2. Arrays are smaller to send over the network
  3. A real Animal Object may be stored more efficiently in client RAM than the raw Object
  4. A real Animal Object may be faster to operate on, in the client, than the raw Object

So rather than just sending, receiving and processing raw JSON, I could be sending and receiving Arrays, and create objects using their constructors.

Test Results

I implemented some Node.js code to test my ideas. I was using objects like:

// As Object                                 // As Array
{                                            [
  "theWorst":0.1560387568813406,               0.1560387568813406,
  "lowerQuartile":0.2984895507275531,          0.2984895507275531,
  "median":0.47865973555734964,                0.47865973555734964,
  "higherQuartile":0.7832137265963346,         0.7832137265963346,
  "theBest":0.8893834668143412                 0.8893834668143412
}                                            ]

When there is a memory range (below), the low value is after the GC has run, and the high value is the peak value. JSON means an object received from JSON.parse. Object means an Object created with a constructor.

Intel i7-8809GRAM/DiskCPU
1M Arrays94MB
-> gzip43MB7.7s
-> gunzip1.1s
1M Objects154MB
-> gzip48MB5.6s
-> gunzip1.3s
Receive & Convert data
Arrays->Arrays100-240MB0ms
Arrays->Objects76-240MB334ms
JSONs->JSONs123-310MB0ms
JSONs->Objects76-382MB280ms
Access & Use data
Arrays21ms
JSONs25ms
Objects9-11ms

Well, I find that:

  1. It is surprising that GZIP is more expensive on the smaller array than the larger object file.
  2. Costs (CPU) to compress/decompress much higher (~10x) than the cost of “packing/unpacking” JSON-data in JavaScript code.
  3. If we are using gzip for network traffic the benefit of sending the more compact arrays rather than the more wordy objects, is questionanable (higher CPU cost, 10% smaller end result).
  4. Arrays like this require basically the same amount of RAM in Node.js as disk space.
  5. Objects like this require less RAM in Node.js than the corresponding JSON file.
  6. Both when it comes to RAM usage and performance on the client side, Arrays are better than raw JSON objects, but worse than real objects from a Constructor.
  7. Unless an object is used many times on the client (10+) it is not worth it from a strict performance perspective to make it with its constructor, instead of the raw JSON.

When it comes to the different strategies I thus find:

IO/Stored formatJavaScript formatConclusion
ArrayArrayanimal[1] or animal[COLOR] (where COLOR is a global constant) is generally not acceptable compared to animal.color. And it is not justified from performance perspective either.
ArrayJSONThis would not happen
ArrayObjectGiven the extra cost of gzip, and the significant complexity of serializing/deserializing, this is hardly a good general strategy. It requires the least disk space, the least network traffic, and the least RAM on the client though.
JSONArrayThis would not happen
JSONJSONThis is the most simple, readable way of doing things, at a surprisingly low overhead. You can not use prototype though.
JSONObjectIf you find a simple and reliable way to create objects with a construtor and populate it from a JSON object, this method is probably best for performance and efficiency.

Conclusion

JSON is very simple and using it thoughout your full stack is very productive. Unless you really need to optimize things, write your code for pure raw JSON objects.