Get Back On The Penguin

2010/03/15

So, I am back in that place where I don’t know what to do. I have a good list going, though, of what is NOT helpful:

So, what might be helpful?

  • Open the source code
  • Find the bug list
  • Try to repro the bug
  • Make a new to-do list
  • Make some tea

OK, tea is pri 1.

>>>

Sweet! Now I’ve done everything on both lists, except make a new to-do list. So:

  • Try to find where “search” is written and called
  • Try to step through code… using my IDE that does not step through code. This may be the first time in my life I’ve used this expression, but: d’oh.

Finding the spot where “search” is called…

>>>

Um… O Gods. What?

>>>

No, seriously… what?!

>>>

Holy mother of God… I feel really, really dumb.

>>>

So! “The strcasecmp() function compares the two strings s1 and s2, ignoring the case of the characters,” says you. And you claim that “The variable optind is the index of the next element to be processed in argv.” And you go so far as imply–no, state quite baldly–that “[t]here are at least two arguments to main: argc and argv. The first of these is a count of the arguments supplied to the program and the second is an array of pointers to the strings which are those arguments.”

I had never actually seen argc and argv used! I thought they were just window dressing.

So! We are checking to see whether the string passed in equals some other string, even if we pass in many many things as arguments. We check one at a time.

>>>

Yes, but that doesn’t explain why all these people on the ‘tubes are running around saying:

if(!strcasecmp(doWhatVar, “Do This Thing”)

{

doThisThing();

}

That seems like… the opposite of what it should do.

Is 0 the same as not something? Oh god. How could I be so ignorant?

>>>

This is the part where I remind myself that I am still learning, don’t expect myself to know everything, etc., etc., etc. And maybe pour myself some beer. Because if I’m going to be ashamed and irrationally afraid that I’ll never get a job, I might as well do it with a tasty beverage.

>>>

Why are there slashes everywhere? Do I know this language at all?

>>>

Oh… slashes are line continuations inside a giant macro. Haven’t used macros before. That explains a lot!

>>>

Now there’s the part where I wonder if the answer is to soldier on and Get Back On The Penguin, as it were, or take a break and come back all fresh-faced and dewy. If it weren’t 11 o’clock at night, I’d go for a run. Maybe instead I’ll do some pushups. And ask my ever-patient roommate for help. And then maybe… maybe sleep.


Programming Credentials, Part 1 of n

2010/03/02

After renaming and moving around pieces of my project from the command line, I re-opened the project file in the IDE–and discovered that I’ve removed all my code.

Filed under: “You haven’t really coded until…”


Friday Night Bytes

2010/02/26

To prepare for my meeting with B tomorrow about his open source project, I’m trying to fix the teeny, tiny bugs he assigned me at our last meeting. A minor setback is getting the code to compile, though, much less open a big project in my new BFF geany.

The nice thing about working on a decent-sized code base with only one developer, though, is that when I couldn’t compile because of the error message, rather than having me go through the code and fix the string passing error, he just fixed the source. And I re-downloaded it. And now it should work. I’m running make (how does one conjugate that, anyway? “I’m making”? “It’s making”?), and soon will try to compile again from geany. I have a big pot of Monkey Pick oolong tea, just ran 6K in 33:45, and am ready for an awesome night.

>>>

Aaand… I don’t understand this new error at all. Distracted myself by writing about the infinitely quotable Patrick Rothfuss on his latest draft of The Wise Man’s Fear (“There were… not nearly enough lesbian unicorns.”) Love it.

Apparently I lose focus in the face of uncertainty. I don’t know what to do–so, let’s read about the health care meeting! Sigh.

No, but the massively scrolling text has left me with useful information. It tells me what file the error came from, and that it’s ignoring the return value of some function, which is declared with attribute warn_unused_result.

It’s both frustrating and rewarding that sometimes I try to simplify the language of an explanation–and realize that no, it’s already as simple as it can be. I just didn’t understand it the first time.

So, learned: switch statements can’t declare variables, because the compiler doesn’t know when they pass out of scope. Also, sometimes it’s expedient to hack something together for the sake of compiling, so you can work on your bug fix that B asked you to do.

>>>

It keeps amazing me… that I spend awhile looking for the solution to something, only to find that the exact name of the file I needed was clearly spelled out in the installation guide. I think my brain is used to filtering out certain input–and it needs to stop doing that with lists of files, terms it doesn’t understand, etc.

>>>

Compiling after tweaking feels a bit like bowling: I want to sit and give pep talks to the scrolling text, but I’ve already launched it! I cannot emotionally appeal to my code, especially after I’ve stopped editing it.

>>>

Compiling this code is a great experience, because I keep getting random errors and having to chase them down. It’s not as intimidating as it once was.


Readapt to APT

2010/02/25

Back getting source code to compile after a hiatus (taking care of post-surgery family member). Text scrolls through the terminal window, and every so often tells me I’m missing something, like libncursesw5. The first couple times, I searched the internet to find out what, exactly, these libraries were–but no one explains in clear language what is going on. Just nod, smile, and swallow the pill, dear. No use worrying your pretty head what’s in it.

At least this feels more like the rumors about Linux. You really aren’t supposed to just pop in a CD and watch everything magically come together.

>>>Much scrolling text later:

THE MAKEFILE EXISTS! Whew.

>>>Much more scrolling later:

And compiles! Beautiful. And it looks like the “error” is more of a warning from gcc about a string format than anything actually critical.

Now… to figure out how to actually look at the code…

>>>

Checking out geany, a relatively recent editor.

>>>

Loving it!

>>>

strtol is totally sexy. Anything that takes a base as an argument is hot.

>>>

Oh, and I found the strtol call because it turns out the code does NOT actually compile for me, because when gcc finds a warning it apparently stops compiling. That’s ok. I’m still playing.

>>> Hours later:

Have left the Big Project behind for now, but have stayed up so late working on Stanford programming assignment that I’m going to be exhausted at work tomorrow. But it’s super fun: I’m making a random-text generator given a source text and a k-length seed based on source. This is a fantastic way to get to know my new IDE while becoming more comfortable with the console in general. Lack of breakpoints is keeping me looking for new ways of debugging, which is keeping my brain happy and engaged.

Plus, I’ll take myself more seriously as a coder if I stay up till the wee hours making a beautiful, fun program. It’s like cub scout initiation. (Is there a cub scout initiation?) Then, once I get so excited about a project I stay up coding all night and keep going the next day, I will flipping add it to my resume ^.^


GUIs are for Pansies

2010/02/02

My awesome new open source project uses Mercurial for source control , but my first step is getting it to install properly. “In Ubuntu, it’s easy!” says the Internet. “Just use Synaptic and install!” Well, as we all know, GUI stands for “Give Up, Idiot?” and I am not leaving my command line without a fight.

sudo apt-get is almost as easy, but internet sources were mixed about whether my install had worked. I could use it to look at code, but its debuginstall “sanity test” failed to detect my user name. “Change it in the .hgrc file,” said the internet, “which is in your home directory.” Several finds and eyeball scans later, this file was nowhere to be found. I finally gave up, removed the package, reinstalled…. and poof! Now it just made up a user name for me based on my desktop. Why did that take an hour and a half?

(Exercise break: 5K, 2 hills peaking at 5% incline, 29:17. I am a champion.)

Every time I’m frustrated with task-specific minutae, though, I remember that this is NOT particular to programming. In programming, if your make files aren’t right, your program won’t work at all; in the small-fish-big-pond business world, if you send X information to Y organization without Z approval through J channel, you either get reprimanded by A and B–or Y organization is less likely to send you G business in the future, and there is no smoothing the ruffled feathers. Also, in programming, at several points during a project I have a wonderful creator-deity feeling: “AND SHE SAW THAT IT WAS GOOD.”

Back to it!


Open Letter: Begin at the Beginning (Off by One)

2010/01/29

Dear Writers of Beginners’ Guides,

There seems to be some miscommunication about the nature of “beginning”. My Beginning Linux Programming book “assume[s] that you know the basics of getting around in UNIX,” and in fact says directly, “Watch out if you’re new.” The top Google result for beginning emacs “assumes minimal famililarity with vi or a similar editor.”

In short, you assume lists begin with one, while in reality the first item is zero. Since this is a common programming error, I completely understand your confusion. The workaround will likely involve inserting some header at the beginning of your content; a tutorial pointer as the zeroth element would work quite well. This even provides an elegant recursive solution, as each zeroth element would direct a user to even more basic information, until (given sufficient detail) she learns how to create her own universe from scratch.

Meanwhile, I will continue to use superfluous quantifiers (“absolute beginner”) to find emacs tutorials.

Thank you for your attention,

A Relative Neophyte


Jump back

2010/01/28

I dream of bending flour to my will, while making single-celled organisms to all the heavy lifting. I also dream of turning the vegetables in my freezer into delicately spiced toppings for my twenty pounds of basmati rice. Yes, I have been completely distracted by searching for recipes for Indian sauces and pizza dough (not related).

You know what I should dream of first? THE COMMAND LINE.

>>>

Thoughts so far:

It’s strange that white space matters again.

My book clearly uses a different shell, since they use “ls /myDirectory” but in mine, the slash fails and you have to say “ls myDirectory.”

I said before I didn’t care about / versus \ –but forward slash is clearly the right answer on QWERTY keyboards. Loving it!

I finally understand this comic. Oh Raymond, this liberal arts major is so on to you.

UNIX naming conventions seem to avoid capital letters and vowels as much as possible. I know they believe the user is evil and must be punished–but would the extra letters (and maybe some camel case) really hurt anybody?

>>>

During an unintentionally rough computer move, the monitor turned off–though the machine was still running. I noticed that the monitor port was loose… oh dear. I turned it all off, opened the box, and though it was difficult to squiggle around in there with my fingers crossed, I pushed the video card back into its slot and popped the screw back in. Now, fully functional. WHEW.

>>>

It is super cool seeing the name of the project I’ll be working on, though, in miscellaneous screen shots of the shell in this book! It makes me feel famous. Even though, er, I have not actually done anything with said project yet.

>>>

Old-style gospel really disrupts my coding–because while I can sing and code, clapping usually involves both hands.

>>>

So! Mercurial, it turns out, sort of worked all along. Maybe. It functions the way an online tutorial says it should–although the python something-or-the-other still doesn’t think it has a user path. But I’m looking around code in the command line! And now my brain is full, or at least commanded out. And I am going to start cooking dinner ^.^ All in all, a day that started with a great run, went on to a productive afternoon, and is finishing with food!