Thursday, 31 January 2013

How to I put a Unicode Character in my C# String?

Answer: Use a Unicode character ESCAPE SEQUENCE - representing a SINGLE Unicode character. C# uses a 16 bit character encoding for Unicode code points. BACKSLASH U.

Unicode codes are all here. To use in C#, lower-case the U and remove the + sign.

Example:

public static string sigma = '\u03C3'.ToString();

Maths requires use of "Greek and Coptic" character subset of Unicode, Coptic being an adapted Greek alphabet that was being used in Egypt.

Saturday, 19 January 2013

What is Software Science? Let's ask Sedgewick.

What's the latest book on software science you have recently read?

Wait - first off, what IS software science?

If you had to teach a course called software science to cover the more scientific aspects of modern computing, what would it include? Probably the following:
  • basic algorithmic knowledge, like how to analyse an algorithm (time complexity and space complexity - yes this is still important, e.g. when programming for small devices) and the classic algorithms like quicksort and bubblesort, what their characteristics are
  • basic knowledge on audio compression technology like MP3 and Ogg Vorbis and the underlying concepts
  • working knowledge of maths underneath RSA and other cryptographic protocols and algorithms (prime numbers, number theory)
  • basic computational physics for use in programming physics engines and ray tracers used in game development
What are the "great tomes" of software science?

Consider the first category of "basic algorithmic knowledge". Robert Sedgewick's 1983 tome simply-named "Algorithms" is always a firm favourite with students, and even covers a bit of linear programming as well (albeit under "Advanced Topics). There is also a fantastic book called "Computer Algorithms C++" by Ellis Horowitz (University of Southern California) and Sartaj Sahni (University of Florida) and Rajasekaran Florida) published in 1996, which delves quite nicely into parallel algorithms also, which is getting more fashionable with the whole Google map-reduce malarkey.

Caveat: Sedgewick says you probably need about a year's worth of programming experience to get the most out of his book.

In terms of audio and multimedia technology (one of the areas of computer science strongly influenced by maths and more traditional engineering disciplines, like electronics engineering) most of the information can be gleaned from the web but there are of course books available too. One such is Digital Audio Signal Processing, Udo Zolzer, Wiley, 2008 (the book has been described as "useful" but not very accessible).

For RSA, Shneier's Applied Cryptography is a must (highly praised by Dr. Dobbs Journal when it first came out). For computational physics, try: David Eberly's Game Physics, 2003. To get the most out of this book, you really need to get psyched about mastering Newtonian and Lagrangian dynamics.

Ogg Vorbis Sound Files

What are Ogg Vorbis sounds files a.k.a. .ogg files? Ogg Vorbis is an audio compression format comparable to MP3. Ogg is a container format for audio, video and metadata maintained by xiph.org. Vorbis is the specific audio compression scheme used.

According to the Vorbis technical specification, the codec is based on the Modified Discrete Cosine Transform (MDCT) which is also used in the MP3 format. Vorbis is, however, computationally simpler than MP3 but requires more working memory.

Wednesday, 16 January 2013

WPF Docking with Avalon Dock

Avalon Dock brings docking to W-P-F - Awesome! Check it out on CodePlex - Microsoft's free open source project hosting site!

Wednesday, 9 January 2013

Four Octets - Demystifying Networking Jargon

An octet is basically 8 bits. The term is used in telecommunications, particularly when referring to IP addresses. An IPv4 address is referred to as "four octets", usually represented by decimal values from 0 to 255, for example: 255.255.255.255 (the highest representable IPv4 address). This is known as "dotted-decimal" notation. Maximum number of addresses is 2^32 or 256^4 = 4.29 billion.

TCP/IP Concepts for Windows Programmers

Everybody claiming to be a Windows Joe should know the basic concepts of TCP/IP.

The TCP/IP "Reference Model"

The TCP/IP "reference model" was based on an older "reference model" known as the OSI Reference Model, which was, in comparison, very complicated, made up of seven layers from the Application to the Physical layer. TCP/IP came and it was simpler: declaring Application, Transport, Internet and Host-to-Network as the four major layers. Understanding the reference model, gives you more idea of the relationship between TCP and IP.

Details of TCP/IP including Three-Way Handshake

After all, that's how the Internet works!  The Internet works thanks to two protocols working in partnership. The first, Transmission Control Protocol, is what establishes the "virtual connection" between two endpoints and ensures smooth data transfer. TCP, if you will, is the "taxi driver" that takes data from A to B.

You can get a sense of round-trip time for TCP using traceroute, or in Windows, tracert. You will notice that TCP is not optimised for performance but for reliability.

A three-way handshake is what initialises the TCP connection (SYN, SYN-ACK and ACK).

What is the relationship between TCP and IP?  The TCP information is transported in IP datagrams, which at the receiver end get processed by IP software and sent to TCP software for "demultiplexing" and further processing. If TCP is the Airway Bill, then IP are the boxes being shipped. Again, refer back to the TCP/IP reference model for renewed conceptual clarity.

TCP Offload Engines and Gigabit Ethernet

One bit of jargon that's gone into fore is "TCP Offload Engine". TCP, being a fairly CPU-intensive protocol, has been embraced by certain network interface cards (NICs) to offload the processing from the main CPU(s). It is used in high-speed network interfaces, such as Gigabit Ethernet (GbE) for moving data at a BILLION BITS PER SECOND.