Frank ([info]frankvw) wrote,
  • Mood: working
  • Music: BossaCucaNova, "Ague de Beber"

My homework is done - long live the homework!

I'm done with my homework brewing. I've brewed several batches of a light blonde beer (this being summer after all) with identical grain bills but different yeasts, and I have learned a lot. Now it's time to start brewing for winter. A Scottish ale (probably a 90/- ale, if the style works out the way it should) is about to be bottled, and a stout, a Belgian ale or two, and a brown ale are next. When all that is done, the weather should have cooled sufficiently to start using lager yeasts, and brew a pilsner, a schwarzbier and other bottom fermented styles.

(BTW, to quickly digress into something totally different: of course my spell checker in Ubuntu Linux doesn't know the word 'schwarzbier". However, the typical Linux geekiness really shows through in the alternatives it suggests: the list starts with Schwarzenegger and Schwartz (as in "May the Schwartz be with you") and continues with Schweitzer, Schweppes and, for no apparent reason, Auschwitz. Go figure.)

While all these goings on were going on, I have learned a distressing thing. Guinness, which is arguably the Rolls Royce of commercial Irish stouts, is being brewed locally in South Africa as well. But while Guinness in Dublin brews a proper stout, here the process is quite different. It all starts with Amstel, which is a pilsner in the Netherlands but a lager in South Africa. The local variety is brewed with simple pale (not pilsner) malt, and a lot of... corn syrup. Then they take that Amstel, chuck in a lot more corn syrup and some black malt, and after fermentation and forced carbonation, eh presto, there's your Guinness! Not that it tastes like anything, but it says "Guinness" on the label, so it has to be Guinness, right?

Ye gods. This should be illegal.

Anyway. Enough about booze-- on to a subject that drives me to drink and has done so for years: JavaScript. I have repeatedly moaned about my problems with JavaScript (the messy syntax, the awkward capitalization of some but not all built-in functions and data types, the many browser-dependencies, the fact that you essentially need a different piece of code for each browser) but those are all things of the past. Now that AJAX has become ubiquitous technology, the DOM has matured and browsers have finally sorted out their non-compliance problems (heck, even IE now more or less follows the W3C standards up to a point!) JavaScript has actually evolved into something that is robust enough for the real world. And indeed, many popular websites (starting with Facebook, to name one) and many popular software products (such as Wordpress) make extensive use of JavaScript.

So. It's about time I got onto the band wagon, right?

So for starters I have plunged myself headlong into jQuery - a great library with all kinds of Useful Stuff... if only I managed to work out how to use it. Granted,  I have not done this properly, by getting a beginners tutorial to Javascript and starting on page one. I guess I'm still expecting JavaScript to be a bit like ANSI C, which I learned to use from a 50 page booklet that covered all one really needed to know, and with a function reference manual within easy reach all was sorted. In contrast, an often-recommended book from which to learn Javascript (there are many bad books about JavaScript, by the way) is Flanagan's "JavaScript: the definitive guide" which has over a thousand pages. Whatever happened to those books you could read on a weekend and know everything you really needed by Monday morning??

Now, because in JavaScript some thing like
cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);
is perfectly valid code, which one may encounter in the wild at any time, things are obviously not so easy here as they used to be in C in the early 1990's. I grew up with strictly procedural languages, while today's serious JavaScript applications require one to be familiar with defining callback functions linked to event handlers in an object-oriented manner.

So I'm plodding on... but it's rough going. Sometimes I pine for the good old days of Real Mode programming in MS-DOS.

I guess I'm getting old.

Update (while I'm sitting here waiting for a sick server to complete it's harddisk surface check):
Yes, I suppose I am getting old. Because after reading some more, I have concluded that my main irritation with Javascript is the same thing that put me off Perl: "There's more than one way to do it". Which I don't like. I like for things to be consistent and uniform. When there's more than one way to do it, different bits of code will use different ways to do the same things, and it will look like this here, and like that there. I hate that.

For example. In good old procedural C there is only one way to declare a function:
int addThisShit (int a, int b) {
  return (a + b);
}
Simple, straightforward, unambiguous. You declare a fuction called "addThisShit", which accepts two integers and returns an integer. And that's it. Either it looks like this, or it isn't proper syntax which will generate at least a warning in the compiler.

In JavaScript, however, there is a multitude of ways to do the above that is not exactly as messy as what one would get away with in Perl, but still too eclectic for my tests. Consider the following, for example:
function addThisShit(a, b) {
  return(a+b);
};
Fine. So far, so good. Simple and straightforward. But the following is also legal:
var addThisShit=function (a, b) {
  return(a+b);
};
What happens here is, we take an unnamed function (which, Javascript being object oriented, is an object that we can manipulate in any way we like) and assign it to a variable. We can then use this variable as if it were a function. BUT... we can also do this with a named function rather than an unnamed one, like so:
var addThisShit=function theAdder (a, b) {
  return(a+b);
};
which we can than call both under the variable name, i.e.addThisShit (10, 20) or under the fuction name, i.e.theAdder (10, 20).
Messy.

Yes, I know, I know... there are advantages to this, most of all that it allows you to assign a function to an object and then call it as a method, like so:
var myObject=new Object();
myObject.addThisShit=function(a,b){return a+b};
which then can be referred to as myObject.add(1, 2). That is a Good Thing... but the various ways to do it do not encourage the clean and consistent syntax that I like so much.

And then there is a fourth way of doing the same (aargh!) which is to declare the function as a new object:
var addThisShit=new Function("a", "b", "return a+b;");
Note that now the 'Function' keyword is capitalized (which makes sense because it has to be set apart from a normal function declaration). Things get more convoluted from there on in.

Yes, it's true... I am getting old....

Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…