Yeah, Ubuntu!

I was reading ESR’s (that’s Eric S. Raymond to you) excellent article “How to Become a Hacker” (if that alarms you, please Google “hacking vs. cracking”.)

Programming insights aside, how’s this for a line?

During the first ten years of this HOWTO’s life, I reported that from a new user’s point of view, all Linux distributions are almost equivalent. But in 2006-2007, an actual best choice emerged: Ubuntu. While other distros have their own areas of strength, Ubuntu is far and away the most accessible to Linux newbies.

Yeah, Ubuntu!

Comments (4)

Python and C…Wow…

I’ve come to the realization that as nice as Python is, I really ought to learn a lower-level language. Even though I own two C++ books, I’m only reading them to a)Gain a rudimentary knowledge of the C++ syntax, such that I can hack it if I have to b)Improve my conceputal knowledge c)Well, they are interesting.

Instead, I’m learning C, because it just seems like more of my cup of tea. And kernel hacking might be fun :)

So one of the sample programs in the tutorial I’m using is that which will list all the numbers from 1-2500, and say if they’re prime or not. I faithfully wrote and compiled it in C, ran it, and WOW! that was fast. I could not detect any sort of delay, or processing or anything, it was just:

<Enter><A screenfull of numbers, ending in “2500 is not prime” appears>

I was so impressed by this, I converted the code to Python. I even removed a function that listed the version number and time compiled. When I ran it, I could see numbers whizzing by the screen for half a second or so, and then it was done.

I know it’s old news that compiled languages are faster than interpreted ones, and that low-level languages are faster than high-level ones, but it’s just impressive to tangibly see it.

Comments (4)

Handy Tip #2: [Ubuntu] Alt-F2

Background:

It’s easy to agree that things take longer with a mouse. Sure, it’s easier/more intuitive, but that comes at the sacrifice of speed. Which is why powerful text editors like Vi and Emacs are so lightweight. And CLI systems are so fast. Etcetera.

It’s also easy to agree that the more icons GNOME/KDE/etc. has to load when it’s booted up, the longer it’s going to take.

The meat:

To quickly and efficiently launch a program–without the need for icons or even a mouse–press Alt-F2. A dialog box will come up. Just type the program name into it, and press enter.

Leave a Comment

A rant on the W3C/Tidy HTML

I really need to vent this:

Back in the day, when I learned HTML, I was taught that “Hello World!” was nothing more than:

<HTML>

<HEAD>

<TITLE>Hello World!</TITLE>

</HEAD>

<BODY>

Hello World!

</BODY>

</HTML>

So when I made my extremely simple Python page, I just did that. I obviously had to throw in some <a href=”http://whatever”></a>’s and some <em>’s (I actually thought I was being a good boy, using <em> instead of <i>) but it’s really a simple webpage.

So just for fun, I decided to run it through the W3C validator.

And it coughed up some errors. I have now looked through most of them, and all of them (with the exception of the DOCTYPE one) seem extremely arbitrary. And I would NOT like to use a stylesheet, I’ll get by just fine with my <FONT size=”4″>, thank you very much.

Now I’m sure that the W3C has legitimate reasons for these standards, but I just get the impression that they create new standards out of boredom, not necessity. Less is more and if it ain’t broke–don’t fix it for crying out loud!

I can hear your brilliant counterargument unfolding. “Timmy,” you say, “why don’t you just shut up and use Tidy HTML Generator? W3C had the good grace to include it, lest people greater than you are confused by their cryptic error generation.” to which I reply, “Take a  look at what Tidy suggested”

WHAT IS UP WITH THAT!?!

OK.

</rant>

I can breathe now.

Seriously though–why?

Leave a Comment

Playing Python, Programming Pianos

New programmers are never sure what it “takes” to learn a programming language. This is not helped by the quantity of “Learn x language in 24 hours/3 days/etc.!” books that are out there, and by the overabundance of technical information available.

So what I propose is an analogy.

You might think that the analogy I would make would compare learning a programming language to learning a foreign language (e. g. Spanish.) But after much deliberation, I don’t think that’s a valid for several reasons:

  • Foreign languages are almost always more complex than programming languages. Something like French has evolved for the past two millenia, while even ‘old’ programming languages have only been around for 50 years. Furthermore, French has the task of concisely communicating any conceivable expression to another human, while C/Java/Delphi only has to boss around some chunks of metal and silicon.
  • You must memorize every aspect of a foreign language, while with programming languages you have the all-powerful documentation to help you with some of the less common things.
  • Even if you know that “Hello” is the most common greeting in English, you’ll sound dumb if you don’t use “Hi”, “Hey”, and “What’s up?” in the right circumstances. Meanwhile, BASIC will always think “10 PRINT “HELLO, WORLD!” is the best way of doing things.
  • Similar to the first one, foreign languages have a MUCH bigger vocabulary to learn than programming languages.

So I really don’t think it’s a valid comparison.

What I consider more vaild is comparing programming languages to musical instruments. First, let’s think about a story about little Billy.

Little Billy decided one morning that, since he really like music, he wanted to learn to play a musical instrument, so he could make his own music. He went to the music store, and was initially awed by the sheer quantity of different types of instruments for sale. After much inner turmoil, he decided to use the piano, since it was common, rationalizing his choice by thinking, “Since so many people use it, it must be one of the best choices. There’ll also be more people who can help me. Finally, it sounds good.” While he was in the music store, he also picked up a tutorial on learning how to play the piano.

He went home, and did a chapter of the book per day, being sure to actually play the piano as much as possible. By the time he finished working through the book, he was a decent piano player, but still had a lot to learn. He kept playing, hired a teacher, and within a few years he was downright adept.

Now consider little Billy’s brother–Tom.

Tom decided one morning that, since he really like computers, he wanted to learn to program, so he could make his own programs. He went online, and was initially awed by the sheer quantity of different types of programming languages available. After much inner turmoil, he decided to use Python, since it was common, rationalizing his choice by thinking, “Since so many people use it, it must be one of the best choices. There’ll also be more people who can help me. Finally, the syntax looks good.” While he was online, he also picked up a tutorial on programming in Python.

He went home, and did a chapter of the tutorial per day, being sure to actually do the programs as much as possible. By the time he finished working through the tutorial, he was a decent programmer, but still had a lot to learn. He kept programming, started working on projects so he could learn from the project chief, and within a few years he was downright adept.

Now that you know where I’m going with this, I can fill in some details:

They both give you ‘instant success.’ Anybody, and I mean anybody, can either make his computer say “Hello World!”, or play a few notes on an instrument within ten minutes.

They both have specific technique. Java programmers know that using a variable without declaring it first is a big no-no. Trumpet players will fail if they just move their fingers–and don’t blow.  Another way of saying this is that they both teach through failure–be it a bad sound or a segfault.

They both provide gratification. People get really excited when they play a tune well, or solve a particularly sticky programming problem.

If you do something again, you’ll do it better When an elementary school band plays “The Star-Spangled Banner”, it is very apparent that it’s not the New York Philharmonic playing “The Star-Spanled Banner.” A first-year programmer will use a very different method for solving a problem when compared to an old-hand.

So if you’ve ever learned how to play an instrument, you’re primed for programming. And if you’ve ever programmed, you know what it takes to play an instrument.

——-

I’m kind of interested in the reception this is going to get–please let me know what you think!

Comments (1)

FTP managers

I updated my post on FTP managers to include gFTP.

In case you were wondering, it seemed a lot better to maintain one post about FTP managers and update it as necessary, rather than tacking on supplemental information as I produced it :)

Leave a Comment

Handy tip #1: [Aptitude]

First of all, I’m sorry I haven’t posted for a while–school went ‘banoonoos’ (as Joss Whedon would say), and any remaining time went to FSM.

Second of all, I’m contemplating starting a new ‘syle’ of post–handy tips. They’re meant to be concise bits of usefulness. Yes, yes, yes, this one isn’t very concise, but I consider it an extenuating circumstance :) They should have two parts–the [Background:], for…um…background information, and then another part which is the real tip.

That was way too long-winded. Sorry.

At any rate, here’s the real post:

[Background:]

A lot of people use the command line to install packages. Add/Remove is incomplete, Synaptic is slow, and the command-line is awesome.

I find myself using Apitude a lot more than apt-get, for the plain and simple reason that it’s a lot easier to make up commands. sudo aptitude install thunderbird works, sudo apt-get thunderbird doesn’t.

I always kind of got frustrated by the fact that after thinking for a while, I would need to type in ‘Y’ to confirm that I wanted to use disk space. (I suppose I can see the rationale for that feature, but it is annoying)

[Meat:]

To make Aptitude not ask you if you’re OK with the disk space it’s going to use, and the dependencies that have to be installed, use the following command:

sudo aptitude -y install yourprogramname

Where yourprogramname is the name of the program you want to install.


				

Comments (1)

Really concise explanation of random integers in Python

I wanted to use Python to generate some random integers, and a few minutes of Googling was not very helpful. I figured it out in the end, but I feel like something this basic should be easy.

First you need to import the random module, so:

import random

Then, to get a random integer from 1 to x, use

random.randrange(x)

It’s as easy as that.

(OK, OK, sorry. I know this probably isn’t of general interest, and it’s probably of minimal help, but I was just irritated that it wasn’t really easy to find online.)

Leave a Comment

Did GMail finally mess up?

I think GMail has made an error.

No, it’s not a big error, and yes, it’s still my favorite web-based email service.

But they still messed up with GMail Labs.

It’s a great idea, so far it’s giving off great fruit, and I would be a sadder person today if it did not exist. That said, I was kind of interested in how to develop for it. So I went to the Labs portion of my Settings page, scrolled to the bottom, and was told:

Looking for something we don’t have? Suggest a Labs feature or join the Gmail team and write your own!

Lame! There are probably hundreds of people who would love to get a development kit from GMail and write their own Labs features, host them externally, and suddenly POOF! GMail would have hundreds of plugins, and it would suddenly be just as awesome as Firefox or gedit or vim! I’m not saying GMail needs to release its source. All I’m saying is that they should release enough of it for developers.

FAQ

Q: How would this help Google?

A: It would make GMail much more powerful, giving it an edge over the competition.

Q: How would this help me?

A: It would provide you, the GMail user, with a much more powerful interface.

Q: Why do you keep using the phrase “much more powerful”?

A: Because it sounds better than “powerfuler”.

Q: That was a terrible answer.

A: And that’s not a question. Are we even?

Q: But, couldn’t you just submit a feature request?

A: Yes, but it’d have to be an exceptional idea for the official GMail staff to make it. Opening it up would provide a lot more people willing to code, which would make the good ideas happen too.

Q: What if this crashes GMail?

A: They already have the option to open GMail without Labs.

Q: What about privacy?

A: I’m sure there’s a way to give developers enough control to develop, but not enough control to feed them your personal information.

Q: What about Better GMail/Greasmonkey? (Thanks, Peter)

A: First of all, native is better than third-party. Second of all, a LOT of end users don’t know about/care about Better GMail/Greasmonkey. Third of all, Better GMail/Greasemonkey only works on computers you install it on, while what I propose would be universal for your account.

Comments (4)

TI-BASIC (Round Three) (Control Flow: If-Then-End)

Consider the following code:

1->A
If A = 1
Disp "A=1"

Let’s study it a bit. The first line just stores 1 as A. Standard stuff. The second line is freaky, and the third line just displays “A=1″. Standard stuff. Let’s go back to the freaky part. It introduces one of the more powerful commands in TI-BASIC: If. What it says, is that if A equals 1, to do something. The syntax isn’t nearly as remarkable as the code, just If [value][thingy][value]. Thingy can be anything from the ‘Test’ menu. =, <, >, etc.

Note: Due to the constraints of this keyboard, the less-than-or-equal-to sign will be written as <=, and the greater-than-or-equal-to sign will be written as >=. Also, the not-equal-to sign will be written as !=.

If you’re looking for ‘if’, it’s under ‘Ctl’, not ‘I/O’. And this is the first time we’re using ‘Ctl’…Yay! OK, digression over :)

If’s power comes from the fact that it introduces uncertainty into the program. This means the program can rocket off in a lot more directions, which means: Sweeeeeeet.

Since you handled that chunk of code so beautifully, let’s consider this one too.

Input A
If A=1
Disp "A=1"
Disp "Where is this?"

I hope you’re wondering if the ‘Where is this?’ line is part of the if statement or not. It’s not. The only command that’s conditional is the one immediately after the if line. Which is really useful for a code snippet like this:

If A=1
Disp "A is 1"
If A=2
Disp "A is 2"
If A>2
Disp "A is pretty big"
If A<1
Disp "A is pretty small"

That's a lot cleaner than the following method, which is also legal.
If A=1
Then
Disp "A is 1"
End
If A=2
Then
Disp "A is 2"
End
If A>2
Then
Disp "A is pretty big"
End
If A<1
Then
Disp "A is pretty small"
End

You’re probably wondering why that’s legal. It’s stinking huge! Which brings us back to our problem–if only lasts for a line. If-Then-End fixes that problem. Then means that all of the following instructions are only to happen if the statement is true, and End means that an end has been put to the conditional instructions. There’s no arguments required for Then or End (an argument is something that has to be put with it to make the syntax legal.) So let’s look at our ‘Guess!’ program again. Last time we’d gotten this far:

Disp "Guess!","","(GPL) 2008", "T. Macdonald"
#Note that going from the outline to the implementation there was a better idea--putting 'Guess!' and the GPL on separate lines.
Input "Guess:".G
#Oh no! We don't know how to make a random number!
#Oh no! We don't know how to say if the number is too big or too small!
#(That's why the tutorial's not done. Stay tuned.)

And now we do know how to say if a number is too big or too small!
So
#I'm not copying all the code, we'll pick it up here:
Input "Guess:", G
If G<R
Disp "Too small!"
If G>R
Disp "Too big!"
If G=R
Disp "You win!"

Unfortunately, that’s really all we can do with that, as of right now.
Next time we’ll talk about Else.

Assignment: Write a program that will ask the user for his age, and then will classify them as “Kid” (12 and under), “Teenager” (13-19) or “Adult” (20+).

Leave a Comment