Thursday, April 28, 2011

Program Like in the Movies

  If you've ever wanted to wanted to hack like in the movies but never thought your programming skills were up to snuff or couldn't type a thousand words per minute, have some fun with Hacker Typer. Select the file you want to generate and then go nuts on the keyboard. In seconds you'll transform into a Hollywood programmer, typing perfect code impossibly fast. If the code generated seems pretty cryptic, don't worry, even I had to look up to figure out what the second and third file choice was. Mobile Substrate is used by third party groups to patch system functions on the iPhone and fini.sh is a type of Linux shell, or operating systems environment, but I couldn't find any real information about it.
  But the first choice is the one I want to talk about, the Linux kernel. A kernel is the core of the operating system, the bridge between software applications and hardware level devices. All user generated resource requests, things like saving to disk space or loading up a program to be placed in memory for quick access, are directed through the kernel. The kernel then takes these requests and generate systems calls to these devices and returns the necessary information back to the application to be passed on to the user.


  Direct kernel interaction can be dangerous without the proper knowledge. Kernels have the least amount of restrictions on what they can and cannot access in the computer. They act as resource managers for the central processing unit, memory, and I/O devices, keeping applications and devices from interfering with each other that could cause catastrophic crashes while doling out resources for system requests quickly and efficiently.
  Kernel coding is considered one of the more difficult of any coding practice, as it requires a strict finesse to utilize the raw power of the kernel while not damaging any critical areas of the computer. So using Hacker Typer as a quick sandbox just for fun can be a nice distraction.

Tuesday, April 26, 2011

Computer Greats: Grace Hopper

  One I the things I love about today's technology is its ability to pull things that would seem like they were lost in the void of time, never to be seen again. I was wandering around and I happen to stumble upon something I thought I'd never see. An uploaded set of two videos on Youtube of a 60 Minutes interview of Grace Hopper from nearly thirty years ago.
  Grace Hopper was one of the greatest pioneers of the early computer science and a powerful force in communicating computer science. She was one of the programmers for the Harvard Mark I in 1944, which is landmarked as the beginning of the modern computer era. In 1949, she assisted in the development of the UNIVAC I, the very first commercially produced computer. While working on the UNIVAC system, Hopper created the very first compiler for electronic computer systems. Compilers are incredibly important for modern programmers as they allow to write human readable code which is then translated by the compiler into machine code that the computer is able to run. Later, Hopper participated in the creation of the widely used language COBOL, based on a simpler language she had created earlier. After her retirement from the Navy, Hopper went on a lecture circuit, educating students, military personnel, and business leaders about computer science.

  0:03 Grace laces her talks with a bit of humor and personal history, techniques we've seen as positive speaking techniques in Communicating Science.
  1:35 Grace describes the current frame of the computer science revolution, remarking it is still in its infancy
  3:49 Grace hands out bits of wire to her crowds to give them an understanding of a billion. The wire is cut to the distance light travels in a vacuum in a billionth of a second. She then pulls out a cord of wire nearly a thousand feet long to compare to a micro second.

  The second part of the interview turns a bit away from her contributions and work in the field of computer science and more towards military, politics, and gender.
  Grace Hopper is one of the most important figures in the dawning of the modern computer era. It was a wonderful find to see these videos uploaded of such a keen lady.

Wednesday, April 20, 2011

Sort Your Heart Out

  Sorting is a fundamental issue for computer scientists. Given a list of unordered objects and a way to compare them, what is the best way to sort them into a logical order? There are many different answers to this question out there, each ranging in simplicity and efficiency. The Sapientia University of Romania took a few of the most simple sorting algorithms and showed how they work in a fairly novel way, through the magic of dance. Using a local Central European folk dance team and a folk band, the team is able to show off some of the more simple sorting algorithms in a little livelier fashion that most demonstrations of sorting.
  The first and simplest of sorts is the bubble sort. Bubble sort starts at the beginning of the list and compares the first two objects. It does nothing if those two objects are in the correct order or swaps them if they are not. The algorithm then compares the second and third elements in the list, swapping when necessary and forcing the higher number up the list, "bubbling" it towards where it needs to go. This iteration continues until the sort reaches the end of the list where it goes back to the beginning, starting the sort all over again. This is repeated until an entire pass across the list has no swaps. The algorithm is complete and ceases operation.




  Insertion sort is another simple algorithm. Starting at the beginning of the list, the algorithm "separates" the first element into what is considered a sorted list, where by itself, the element is sorted. It then takes the next element in the list and places it into the correct location inside the sorted list. This continues down the list of objects until a fully sorted list is produced.




  Akin to the bubble sort and insertion sort, shell sort compares two elements half the size of the list together and swaps if needed. If the elements were swapped, then the gap is used again to compare the elements before to check for needed swaps. After comparing all elements with this gap, it once again iterates over the list using a smaller gap and continues until the list is sorted, the final iteration through the list being exactly like insertion sort.



  Selection sort takes a slightly different approach, only swapping when it knows it has the correct value for that position in the list. The algorithm iterates over the entire list to find the lowest value in the list, then swaps that value with whatever element is in the first position of the list. The algorithm then repeats the process with the next lowest value in the list, placing it in the second position in the list. The process is continued until the list is sorted.

Monday, April 18, 2011

On a Lighter Note

  A few weeks ago I wrote a blog post about a comic I'd run across in Dinosaur Comics which talked about lazy posting. Dinosaur Comics are definitely a good read but doesn't have much connection to computer science with the exception of a wild one here or there. I thought it would be a good idea to share some other comics I've run across that largely deal with computer science and I enjoy a lot.
  Abstruse Goose is the most recent one I've read. It's a comic with no real overarching presence but has a pretty strong connection to computer science, art, and mathematics. This comic sums up my college career pretty well.
Abstruse Goose
  xkcd by Randall Munroe is a well known and well acclaimed web comic that has a very heavy focus on math, physics, and computer science, although it does get sidetracked sometimes with some rather sappy comics that can feel a bit off track. He also has a lengthy blog of his own with tons of mathematics and science to read to your hearts content.
xkcd
  Saturday Morning Breakfast Cereal by Zach Weiner is my favorite of the comics listed here. Updated daily, Weiner is able to produce consistently funny comics over a wide range of subjects, from philosophy to economics, from politicians to scientists, and inject enough of his own goofy humor into it that it's always a great read. He even has a comic about communicating science!
Saturday Morning Breakfast Cereal

Saturday, April 9, 2011

Pixel Coding

  What we have here is what is called pixel coding. More of an art than an actual coding language, pixel coding takes advantage of the common language between all computer files, binary. Colors can be encoded in differing amounts of bits, 12 or 24 or 32 or more, depending on what is needed by the user. By controlling red, blue, and green values along with opacity, it's possible to generate any 32 bit binary string needed. Along with an understanding of application programming interfaces, or APIs, and knowing the binary strings needed to generate different function calls, it's possible to translate to them directly. A system's API is the set of instructions that allow the user to utilize the functionality build into the system. Aside from some header information depending on the file extension, changing the file from .raw to .com shouldn't change the binary strings located within. The API generated by the file created a texture tunnel from nothing but pixels.

Wednesday, April 6, 2011

When Random Isn't Random Enough

  For anyone who has done a bit of programming, there is a good chance that you've had to use random numbers. They can been very helpful for simulating the chaotic events we need for experiments or programs, such as basic AI for a game or natural events. But an important thing to know about most random numbers generated by a computer are not random at all but psudorandom.
  Random numbers generated by a computer require a seed, or some number put into an algorithm to produce the random number. This seed can come from many different places depending on the random number generator. The most basic generator uses a static number each time, producing the same exact string of random numbers each time, not very random. The next step up uses the system clock to pull the current time based in seconds from midnight of January 1, 1960. This is a decent way to to "randomize" the seed, but numbers generated within the same second pull from the same seed, which may cause problems. Other random number generators use chaotic inputs from the user to determine seeds, such as mouse movements or keyboard inputs. Mike Ash has a good blog post about the different tiers of random number generators here.
  If you desire true random numbers, then look no farther than Random.org. At Random.org, they use atmospheric noise to generate random numbers in a variety of forms, from simple integers to die rolls or cards drawn from a deck. They also have a very good piece detailing psudorandom number generators and how they compare with true random number generators. You could always use it to generate your passwords or choose your next vacation spot, probably better than throwing darts at a map.