A Guide to HTML

As part of my ongoing series on client-side web programming, I decided to write a guide to HTML.

To many programmers, this may seem like a big waste of time. Nowadays, everyone has worked with HTML. Plenty of programmers (myself included) started coding personal websites well before they even glanced at a programming language like C or Java. The comments on most websites accept certain HTML tags, so even non-programmers know how to mark up text with <strong> or <em> tags. What’s the point in telling people what they know already?

The answer is that many people think they know HTML, but few actually do. HTML has been around for a long time, and many practices that used to be common (or necessary “hacks”) are simply bad practices today. Also, the HTML5 standard is fairly new, and many people aren’t used to using it. People who learned HTML before 2006 or so are probably using it wrong. Their HTML is bad, and they should feel bad.

This, as it turns out, includes me. Researching this article has led me to tags that I didn’t know existed, and to discussions about Web standards that I had never read before. So, I wrote this guide for me as much as for all of you. Still, I hope you all find it helpful – and if not, or if I make mistakes, then please contact me to let me know.

One more thing. The last couple of paragraphs notwithstanding, I think it’s great that HTML is used by non-programmers. HTML can (and should) be used by people who have never heard of a closure, and don’t know the difference between pass-by-value and pass-by-reference. The fact that it can be understood by graphic designers or content authors is one of its strengths. So, I’m not going to assume any knowledge of programming at all, and only a basic knowledge of how the Internet works. In particular, I do not expect the reader to know JavaScript, and I won’t cover it here. (If you’re so inclined, you can read A Programmer’s Tour Of Javascript for that.)

First, let’s take a look at what HTML is – and what it is not.

Continue reading

Posted in HTML | Tagged , | 4 Comments

A Programmer’s Tour Of Javascript

In the spring of 2014, I took a terrible, terrible web programming course at college. One of the many reasons it was so bad was because of the short shrift it gave to the JavaScript language.

This, unfortunately, seems to be very common among undergraduate courses dealing with any kind of web development. Most of these courses use source material that is geared towards web designers – people whose primary interest is in graphic design or UI design, and who are not themselves computer scientists. Though they are usually 300- or 400-level courses, they never seem to take into account that the students in the class are of the sort that have actually written a compiler, or coded a driver for a network card in assembly language, or who know what P vs. NP means. Instead, the course material is little more than beginning tutorials for people who have never touched a line of C++ in their lives.

This is a tragedy, because JavaScript (and web development in general) is a deep subject. After taking the course (and easily getting an A), I revisited JavaScript to (re-)learn all of the things the class didn’t teach. And now that I know more about different programming languages, I was impressed with how powerful and beautiful JavaScript really is.

So, I’m writing this article to combat the shallow view of the JavaScript language that is fostered among programmers. My intended audience is programmers who know C++, Java, and possibly a functional language like Scheme, and who want to actually learn JavaScript from a programmer’s perspective. It may also be helpful to intermediate JavaScript programmers who want to learn other languages, but will be tripped up by the many differences between JavaScript and other OOP languages.

But it is not meant for web designers. I will not cover HTML or CSS at all. I will mainly talk about core JavaScript, and only those parts that differ from other C-style languages. I will only briefly cover client-side JavaScript, when I talk about the JavaScript environment. There are plenty of other places to learn that stuff. I do assume that people reading this have at least a basic knowledge of HTML, because these days, who doesn’t?

Now, on to JavaScript. To start off, we should know exactly what kind of language JavaScript is. Continue reading

Posted in JavaScript, Programming | Tagged | Leave a comment

Classes in C++

If you’ve been following this blog, then you know I just wrote an article about passing objects as arguments in C++.

This article was originally intended to be part of that one. But while writing it, I realized that you need to know about objects in general, and how they work in C++. This is not a trivial subject, and what started out as a mere introduction ballooned into the article you see before you.

This article will cover object life cycles, inheritance, polymorphism, and composition. These are deep subjects in their own right, so I’ll only cover how C++ handles them. Even so, it is not an article for people who are completely new to object-oriented programming. It will require lot of thought, but in my opinion, it’s worth it. Aside from being a better C++ programmer, you will also gain a deeper understanding of how other languages operate “behind the scenes.”

Continue reading

Posted in c++, Programming | Leave a comment

Like Bigger Stones: Argument Passing in C++, Part 2

In my previous article, I talked about how C++ handles parameter passing when the arguments are primitive types or arrays. This article will talk about passing objects in C++. Objects are more complicated than primitives or arrays, so as you can imagine, passing them is also more complicated.

Before you read this article, you should understand the three basic C++ mechanisms for parameter passing: by value, by reference, or by pointer (or “simulated reference”). You should also understand how C++ hanldes automatic local variables. If you don’t understand this already, you should read my previous article on the subject. (If you don’t understand that, then I’m not a good writer, and you shouldn’t read this article anyway.)

Continue reading

Posted in c++, Programming | Leave a comment

Like Stones: Argument Passing in C++, Part 1

For people new to C++, argument passing can be very hard to understand. Most programming languages handle argument passing “behind the scenes” somehow. Either there is really one form of argument passing (e.g. C), or your choices are determined for you (e.g. Java). Not so with C++. Like almost everything else, C++ requires that you handle argument passing yourself.

So, for those people, I thought I’d write up a couple of posts about the various types of argument passing. But be aware: despite what you may think, this is not really an article for beginners. I wrote this mostly for people who already have some programming experience in another language, but are new to C++. It doesn’t require a lot of knowledge, and I’m not saying that beginners won’t get anything out of it. But if you are an absolute beginner, you may be overloaded with information.

With that out of the way, let’s talk about C++. The short version is that C++ has three mechanisms for argument passing: passing by value, passing by reference, or passing by pointer (or “simulated reference”). I’ll explain how each one works in turn.

Continue reading

Posted in c++, Programming | Tagged , | 1 Comment

An Evil Scheme

In the winter of 2013, I took a course at UMass Boston called CS 450: The Structure of Higher Level Languages. I had no choice; it is a required course for getting a CS degree. I hated, hated, hated that course. And I am hardly alone; of all my classmates that I talked to, not one liked it. The best one could say is that others hated it less than me.

The main reason for my hatred is because it is a Scheme course. I know that there are many programmers who love Scheme, but I have no idea why. I also know that most programmers have never written a single line of Scheme code in their entire lives. But quite a few of them will be forced to eventually; UMass is not the only university that has a Scheme requirement.

If you’re one of those programmers, then this article is for you. By reading this article, you will hopefully be a little more prepared for your inevitable pain. On the flip side, if you read this article and say, “Hey, that actually sounds kinda cool” – well, then, Scheme is the language for you. Good for you; you’ll save lots of money on therapy.

Continue reading

Posted in Programming, Scheme | Tagged , | 1 Comment

Efficient prime number testing

In nearly every lower-level CS class, students are invariably asked to create a function that can recognize a prime number. There are very good reasons for this. For one thing, the study of prime numbers is one of the longest-running fields in mathematics; the ancient Greeks were the first to study them in depth, but even the ancient Egyptians distinguished between prime numbers and composites. For another, the study of prime numbers has applications in a wide variety of fields. The one that will probably interest CS students the most is cryptography.

But the reason I’m going to talk about them is because recognizing prime numbers is a good starting point for talking about algorithms. By starting with the most basic, inefficient algorithm, we can learn some techniques to improve efficiency and eliminate redundancy. These same techniques can be applied to almost any algorithm, and will be useful (I hope) throughout our entire careers.
Continue reading

Posted in Programming | Tagged , , | Leave a comment