Ken's ending from Street Fighter II as seen on Amiga
Monday November 5, 2012 03:25:21

This version of Street Fighter was understandably missing a few things, but the sprite work for Ken's fiance Lisa had to have been done by one of the developers as a joke (skip to 18:17).



Introducing Macaroni for C++
Monday October 1, 2012 00:28:20

It's with great pride and trepidation that I announce a project I've been working on for the past four years.

It's finally reached the point where I think it might be usable to people other than myself, so without further adieu I present “Macaroni for C++,” a sort of compiler for C++ that attempts to make working with C++ easier and more enjoyable.

Find out more here.



Intro to the Beginning of Getting Started on Windows
Sunday September 30, 2012 17:53:21

This blog post is intended to guide you through setting up a limited dev environment in Windows. The goal is to get around Windows annoyances and create a decent command line environment.

I'll be using Windows XP, since I have a spare license and can put a pristine install on a VM and can be assured the what I'm writing here is legit.

Change folder view options.
Right click on the Start bar, and select “Explore.” When the Explorer window pops up, click “Tools” then “Folder Options.” Select the “View” tab.
Check “Display the contents of system folders.”, “Show hidden files and folders.” Uncheck “Hide extensions for known file types” and “Hide protected operating system files (Recommended)” (click “Yes” to the popup). You may also want to uncheck “Remember each folder's view settings.” Finally, click Apply, then Ok.

Install Launchy.
Now, open up a internet browser (hopefully not IE), then download and install Launchy. Launchy lets you leave the Start Bar behind and open programs and folders by hitting ALT+Space then searching for them by name (it's why I'm incredulous when so-called power users write articles complaining about Windows 8 abandoning the Start Bar). Be sure to donate to Launchy if it helps you out!

Install Sublime Text 2.
Sublime Text is an awesome text editor that works on Windows, OSX, and Linux. Download it from this link and install it. Note that Sublime Text costs money, but one license is only $60 and applies to any computer you use which is awesome. You can try it out for free as long as you like, but if you use it forever without paying that'd make you a bad person.

Create a tools directory.
Pulling down a Windows Installer and letting it go nuts on your system is OK for some things but in general is a practice that 1. won't work for all tools and 2. isn't a good way to understand how the programs you use work. So my practice is to create a “Tools” directory which has all the stuff I use. An advantage to doing this is I can move the Tools directory to another machine if I need.

Create a new directory named “Tools” wherever. I'm going to assume it lives at “C:\Tools”.

Install Notepad2.
As nice as Sublime Text is, I also like to have use a different, single file editor at times to jot stuff down or open single files from Windows Explorer and Windows Notepad doesn't cut . Thankfully its freeware sequel is much nicer.

Download Notepad2 here. You can use the installer or not, it doesn't matter. However, it replaces the standard notepad, so lets try pulling down the non-installer version, which is a zip file. Open the zip file, then open a new Explorer window at the C:\Tools directory, create a folder named “Notepad2”, and dump the contents of the Zip file to it.

Now we're going to add Notepad2 to the “Send To” menu that appears when you right-click a file in Explorer. Open a new Explorer window, and enter the SendTo folder as explained here (for me it's located at C:\Documents and Settings\Tim\SendTo). Now, in the Explorer window with Notepad2 right click Notepad2.exe and select “Create Shortcut.” Move this shortcut into the SendTo folder and rename it to “Notepad2”.

At this point, Notepad2 will appear in the SendTo menu when you write click a file. This allows you quickly investigate the contents of a text file.

Create a batch file.
If you've ever had to change an environment variable in Windows, you'll probably agree that its a hellish experience and uses one of Microsoft's patented “impossible to resize even though all the critical contents can't be seen at once” windows.

That's OK though, because despite what most PHP installation tutorials tell you changing environment variables (especially PATH) globally is really gross and can destabilize your system.

Unix systems normally have a file called “bash.rc” or something similar which is executed every time a terminal is started. This is a great place to add environment variables and do other setup things. We're going to emulate that functionality in Windows by creating a batch file that'll execute each time we start a command prompt.

Enter C:\Tools\ and create a directory called “CmdTools”. Write click and select “New… Text Document.” Now right click the new file, select “Rename” and change the name to “DevStartup.bat”. Right click on it again, then select “Send To … NotePad2.”

Enter the following:

@ECHO OFF
REM SETLOCAL ENABLEDELAYEDEXPANSION
SET TOOLS_ROOT=C:\Tools
SET PATH=%PATH%;%TOOLS_ROOT%\CmdTools
ECHO Dev Environment

REM  Hard to see but there is indeed a lot of space on this next line
SET A_LOT_OF_SPACE=

REM Add some stuff to the path.
CALL :AddPath NOTEPAD2       "%TOOLS_ROOT%\Notepad2"

GOTO THE_END

REM Put subroutines and other stuff here.
:AddPath
SET TOOL_DIRECTORY_NAME=%1
SET TOOL_DIRECTORY=%2
REM - Strip quotes
SET TOOL_DIRECTORY=%TOOL_DIRECTORY:"=%
SET         FOUND=""
SET %TOOL_DIRECTORY_NAME%=%TOOL_DIRECTORY%

IF NOT EXIST "%TOOL_DIRECTORY%" GOTO NotFound
PATH=%PATH%;%TOOL_DIRECTORY%
SET FOUND=
GOTO PrintInfo
:NotFound
SET FOUND=MISSING
:PrintInfo
REM @ECHO %ELEMENT_NAME% == %ELEMENT_VALUE%

SET COL1=%A_LOT_OF_SPACE%%FOUND%
SET COL2=%A_LOT_OF_SPACE%%TOOL_DIRECTORY_NAME%
ECHO %COL1:~-7% %COL2:~-15% : %TOOL_DIRECTORY%
GOTO:EOF

:THE_END
REM ENDLOCAL
@ECHO ON

One important note: the line “SET A_LOT_OF_SPACE=” needs to have a bunch of spaces after it (like more than 80). As the comment implies there’s no good way (I could find in the two days I was interested in writing my batch file originally) to create a string with some set number of characters in it other than to just type a bunch of spaces after the equals.

Create a command line shortcut.
Open up C:\Tools in Windows Explorer, then right click somewhere and select “New Shortcut.” This will bring up a Wizard. For location, use:

C:\Windows\System32\Cmd.exe

Name can be anything I guess. I used “Dev Command Prompt”. Click Finish.

Right click the new shortcut and select properties.

For target, set this:

%comspec% /k ""C:\Tools\CmdTools\DevStartup.bat"" x86

For start in, put the name of whatever directory you most prominently work in. I personally have all of my work in a single root directory which is what I put here.

Now click “Layout”. In “Screen Buffer size”, the default number of lines is 300 which is absurd. You'll want something much higher. 2500 is probably good enough.

Width starts off as “80.” I personally try to make all of my work 80 columns, but the output of most tools is not so conservative so I go with 120 here. Enter that value for “Width” in both spots.

Click Apply to save the changes. Double click on the shortcut and you should see the following:

CMD PROMPT
                 NOTEPAD2 : C:\Tools\Notepad2
C:\Work>

Type “Notepad2” and you'll see Notepad2 pop up, even though we didn't use the installer.

Make Dev Command Prompt accessible from Launchy.

Right click the short cut and select copy.

Now click the Start Bar, and select All Programs, then right click Accessories and select Open. Paste the shortcut into that folder.

Hit Alt + Space to bring up Launchy. Right click on the little space ship icon to the right of the text box, and select “Rebuild Catalog.”

Now when you type “Dev Command Prompt” into Launchy it should open the new terminal.

Adding other programs.

The batch file puts the directory “C:\Tools\Notepad2” on the path, allowing you to type Notepad2 to launch it.

To add other tools to the path, add lines similar to the following:

CALL :AddPath NOTEPAD2       "%TOOLS_ROOT%\Notepad2"

For example, if you want to put MinGW on your path, you'd probably write this:

CALL :AddPath MINGW           "C:\MinGW\bin"

The nice thing is the batch file will show you just how populated your PATH environment variable is.

This batch file is also a good place to stick other vars. For example, lets say you're using the Clojure programming tool Leiningen and need to set the var “LEIN_JAR.” Just put the following line next to all the calls to “AddPath:”

SET LEIN_JAR=C:\Users\Tim\Tools\Local\Leiningen\leiningen-2.0.0-preview10-standalone.jar

At this point you should be ready to go. If you want more information on how the batch file works you can read this post from my old blog where I went into greater detail on it.



The Tenets of a Code Nomad
Sunday September 30, 2012 16:31:41

Programming in Windows is culturally different than programming in Linux. In Linux most acolytes get their start using the terminal and a simple text editor such as Vim, and are able to pull down almost every tool they need for free with a simple command like “apt-get install.” Windows programmers on the other hand are given tools (usually by Microsoft, and often at a job) which are GUI-centric and hide the command line or totally eschew it. Generally speaking, Windows developers grow attached to their GUI power-apps, such as Visual Studio, and have no idea why they'd ever give them up. Linux developers are instantly infuriated with Windows as most literature tells them their former workflows are incompatible.

I worked in the .NET, Windows world for five years before switching over to Linux. When I made the change, it hit me how dependent on Visual Studio I had become. If a programming language wasn't supported by Visual Studio, I gave it only an academic interest. If a project couldn't be built in Visual Studio, there was a high probability I wouldn't investigate it.

The switch to Linux forced me to see the error of my ways. By getting so comfy in Windows and .NET, I'd actually not just hurt my ability to work in foreign programming environments, but to understand them.

These days I see many people who have the same issue. Maybe they're Java power users who can't, for the life of them, leave Eclipse, or Linux programmers who won't touch Windows with a ten-foot pole.

I however have become a bit of a nomad. Switching from Windows to Linux slowed me down for awhile, but ultimately taught me a methodologies that are universal among operating systems and software projects.

It also inspired these beliefs:

  • The Windows console is god awful compared to most Linux terminals or the one in OSX. Copy and paste is particularly atrocious.
  • The Windows console can do everything you need a terminal to do and should be used regardless.
  • There are numerous replacement consoles for Windows. In my experience these are buggy and seem to execute programs slower.
  • IDEs, especially Visual Studio, which is platform dependent, should never be relied on to do something critical like build an app unless you can also perform that action at the command line.
  • That said, IDEs are still very useful and you should try to support them for larger projects.
  • If you're writing your own tools, GUIs can sometimes be more useful than command line apps. However the payoff almost never justifies the time it takes.
  • You don't need an IDE to debug code. However most non-IDE based debuggers are a pain (which is why tests are so great).
  • JetBrains makes some truly nice cross-platform IDEs.
  • IDEs slow down experimentation and discovery by forcing you to configure them for every project you work with. That's why simpler text editors, which can be made to view files in a directory in a single step, are so useful. If you want to be able to pull down random projects from GitHub, possibly written in programming languages you've never used, it makes sense to get acquainted with a simple text editor.
  • Sublime Text is the greatest cross-platform text editor in existence. Other tools to consider are Vim and Emacs, though you will have to spend time learning them. College professors always say that becoming proficient at those two editors will ultimately make you faster than using other tools but I believe this is a myth. I've never witnessed a Vim or Emac power user navigate a code base faster than a Sublime Text user.
  • The greatest attribute of a text editor is the ability to quickly locate files. In Sublime Text, you can do this by pressing Ctrl + P and entering the name of the file. In JetBrains IDEs hit Ctrl + Shift + N.

These days, I feel comfortable on any operating system or code base because I have a set of practices that apply to all of them. It's not the best set for any given project but it gets me most of the way there and practicing it has made me a better programmer.





<---2012-12-22 17:31:53 history 2012-09-22 16:19:46--->



-All material © 2007 Tim Simpson unless otherwise noted-