Currently showing entries with the tag: Windows
|
page 1 of 1
|
Book Review: Programming Erlang
October 23, 2007 • 8:54PM • permalink
As you may know from reading my previous blog entries, I've recently been trying to mix up the books in my reading queue by exploring the benefits of a few new programming languages. Recently a friend of mine told me a few things about functional programming, concurrency and Erlang which inspired me to check it out.
Joe Armstrong, one of the creators of the Erlang language, has recently published a new book on the topic and its truly a fascinating read.
One of the biggest complaints I hear from other developers about any introductory level book about a new programming language is the lack of useful programs that can be created upon completion of the book. What I mean is that you may be able to do the normal "Hello World", Fibonacci sequence output, etc. - but you probably won't be able to do anything really useful. This isn't the case with Armstrong's book.
The main ideas of the book and of Erlang (free for most environments at http://www.erlang.org) in general is concurrency or the simultaneous execution of code. While C and its variants offer multi-threading, it is still essentially executing sequential code and hence subject to deadlocks, race-conditions, etc. Erlang enforces some strict rules from the get-go to support concurrency and allow for true simultaneous execution that is free from not only race-conditions and deadlocks, but from semaphores, mutexes and locks as well.
In order to do that, Erlang turns computer science on its head (from a sequential programming point-of-view) which Armstrong is quick to point out at every turn. For example, variables are only called as such because it makes things easier. The fact is they can't actually vary and an Exception is thrown if you even try.
On that same note, the equal sign is not the assignment operator like it usually is in programming, it is instead used to perform pattern matching. An example would probably work best to explain it:
1>X = 5.
5
2>X = 5.
5
3>X = 3.
=ERROR REPORT==== 16-Oct-2007::21:26:12 ===
Error in process <0.30.0> with exit value: {{badmatch,3},[{erl_eval,expr,3}]}
** exited: {{badmatch,3},[{erl_eval,expr,3}]} **
As I stated before, the = is not the assignment operator, it is instead used for pattern matching. An additional caveat though, when used with an uninitialized variable (which usually start with Capital letters), the variable is assigned that value. In line 1 above, we match the variable X against the literal value 5. Since X is uninitialized at the time we match it against the literal 5, it then takes on that value.
This is why, when we repeat the action in the second line, it returns the value 5 (indicating a match). Consequently, when we hit the third line, the shell throws an exception since we're matching X against 3, when it has already taken on the value 5.
You may wonder what the value of such an operator is, but when you dive into server programming, you'll see that it can be used (among other things) to direct functionality within network protocols. By matching against certain patterns, you can essentially code mini-conditional statements to perform various actions upon receipt of certain data. It seems complicated, but it's really not - since this is a Book Review and not an Introduction to Erlang, so I'll leave the explanation to Armstrong...
Within 75 pages, I had gained an enthusiasm for Erlang that was apparently infectious and it has been embraced by a few other developers in my Department (including Jon over at Rusty Razor Blade). While we're still not 100% sure it will be able to support the traffic load and perform fast enough, we're motivated enough to try. Armstrong makes it easy to learn from example too, since the book contains Erlang source to create a server for almost any major network protocol or project you could think of including IRC, SHOUTcast, a simple Error logger, a SQL Server and a Web Server.
We've discussed a plethora of different ideas we could run on our "new Erlang Framework", some more ambitious than others. We're convinced we could rewrite memcached in a few hundred lines of code, including all the features of the original - a few that are missing and commonly implemented in other cache systems - as well as a few of our own custom design. We figure if we can even get 80% of the throughput of our current memcached implementation than it will be worth our trouble. Especially if it enables us to build a Erlang Framework to support any scalable idea we can come up with.
So if the idea of scalable server applications, functional programming or Erlang in general seems interesting, I highly suggest you check out Programming Erlang.
Joe Armstrong, one of the creators of the Erlang language, has recently published a new book on the topic and its truly a fascinating read.
One of the biggest complaints I hear from other developers about any introductory level book about a new programming language is the lack of useful programs that can be created upon completion of the book. What I mean is that you may be able to do the normal "Hello World", Fibonacci sequence output, etc. - but you probably won't be able to do anything really useful. This isn't the case with Armstrong's book.
The main ideas of the book and of Erlang (free for most environments at http://www.erlang.org) in general is concurrency or the simultaneous execution of code. While C and its variants offer multi-threading, it is still essentially executing sequential code and hence subject to deadlocks, race-conditions, etc. Erlang enforces some strict rules from the get-go to support concurrency and allow for true simultaneous execution that is free from not only race-conditions and deadlocks, but from semaphores, mutexes and locks as well.
In order to do that, Erlang turns computer science on its head (from a sequential programming point-of-view) which Armstrong is quick to point out at every turn. For example, variables are only called as such because it makes things easier. The fact is they can't actually vary and an Exception is thrown if you even try.
On that same note, the equal sign is not the assignment operator like it usually is in programming, it is instead used to perform pattern matching. An example would probably work best to explain it:
1>X = 5.
5
2>X = 5.
5
3>X = 3.
=ERROR REPORT==== 16-Oct-2007::21:26:12 ===
Error in process <0.30.0> with exit value: {{badmatch,3},[{erl_eval,expr,3}]}
** exited: {{badmatch,3},[{erl_eval,expr,3}]} **
As I stated before, the = is not the assignment operator, it is instead used for pattern matching. An additional caveat though, when used with an uninitialized variable (which usually start with Capital letters), the variable is assigned that value. In line 1 above, we match the variable X against the literal value 5. Since X is uninitialized at the time we match it against the literal 5, it then takes on that value.
This is why, when we repeat the action in the second line, it returns the value 5 (indicating a match). Consequently, when we hit the third line, the shell throws an exception since we're matching X against 3, when it has already taken on the value 5.
You may wonder what the value of such an operator is, but when you dive into server programming, you'll see that it can be used (among other things) to direct functionality within network protocols. By matching against certain patterns, you can essentially code mini-conditional statements to perform various actions upon receipt of certain data. It seems complicated, but it's really not - since this is a Book Review and not an Introduction to Erlang, so I'll leave the explanation to Armstrong...
Within 75 pages, I had gained an enthusiasm for Erlang that was apparently infectious and it has been embraced by a few other developers in my Department (including Jon over at Rusty Razor Blade). While we're still not 100% sure it will be able to support the traffic load and perform fast enough, we're motivated enough to try. Armstrong makes it easy to learn from example too, since the book contains Erlang source to create a server for almost any major network protocol or project you could think of including IRC, SHOUTcast, a simple Error logger, a SQL Server and a Web Server.
We've discussed a plethora of different ideas we could run on our "new Erlang Framework", some more ambitious than others. We're convinced we could rewrite memcached in a few hundred lines of code, including all the features of the original - a few that are missing and commonly implemented in other cache systems - as well as a few of our own custom design. We figure if we can even get 80% of the throughput of our current memcached implementation than it will be worth our trouble. Especially if it enables us to build a Erlang Framework to support any scalable idea we can come up with.
So if the idea of scalable server applications, functional programming or Erlang in general seems interesting, I highly suggest you check out Programming Erlang.
0 comments
Book Review: Microsoft Windows Internals
August 12, 2007 • 1:06AM • permalink
Microsoft Windows Internals by David Solomon and Mark Russinovich dictates the internals of multiple parts of the Windows operating system, mainly focusing on Windows XP, Windows 2000 and Windows Server 2003 (including 64-bit versions and any IA-64 specifics). The book is directed at Operating System and Device Driver developers and every concept coupled with specific Win32 API functions or kernel variables that can be used to follow along or test out the concepts it presents. Additionally, sysadmins will be able to use the book as a very low-level reference manual since the kernel variables are matched up to performance counters that can be viewed using the standard Windows Performance Monitor.
The book moves from the basic systems that power the operating system using a layering technique to build your knowledge of Windows as you read. Startup, shutdown, processes, threads, virtual memory, security, I/O, caching and more - and then ending with the higher-level support that Windows provides for networking and a simple crash analysis of a basic BSoD (Blue-Screen-of-Death). The book also touches on several protocols like TCP/IP, uPnP and NTFS which helps give developers an overall understanding of how the different systems work together to drive the Windows user experience.
Occasionally it reads like a bloated advertisement for Russinovich's SysInternals toolset (http://www.sysinternals.com) - that is until you take the time to download any of the tools. Process Explorer in particular is one of the most valuable Windows Tools I've ever encountered and eliminates any need for the primitive Task Manager that you might have had in the past. The tools are used throughout the text in experiments that illustrate various parts of the Windows kernel.
The book moves from the basic systems that power the operating system using a layering technique to build your knowledge of Windows as you read. Startup, shutdown, processes, threads, virtual memory, security, I/O, caching and more - and then ending with the higher-level support that Windows provides for networking and a simple crash analysis of a basic BSoD (Blue-Screen-of-Death). The book also touches on several protocols like TCP/IP, uPnP and NTFS which helps give developers an overall understanding of how the different systems work together to drive the Windows user experience.
Occasionally it reads like a bloated advertisement for Russinovich's SysInternals toolset (http://www.sysinternals.com) - that is until you take the time to download any of the tools. Process Explorer in particular is one of the most valuable Windows Tools I've ever encountered and eliminates any need for the primitive Task Manager that you might have had in the past. The tools are used throughout the text in experiments that illustrate various parts of the Windows kernel.

A screenshot of Process Explorer.
Additionally, the humor of Solomon and Russinovich keep an otherwise boring subject more interesting than it should be, including which Registry key is spoofed to display the current computer's processor in the Control Panel's System applet and a BSoD Screensaver to install on your co-worker's computers.
To sum it up, this is one of the best books about Windows Development that I've read since Petzold's classic "Programming Windows 95" (Programming Windows 4th edition). Anyone interested in learning more about the fundamentals of Windows development should pick up a copy. A better understanding of the systems underlying your programs will allow for better optimization and performance, as well as a means to perform some "down and dirty" debugging work at the kernel level.
How to Bring Up Task Manager During a Remote Desktop Session
August 08, 2007 • 9:38PM • permalink
This was something I'd wondered how to do for a long time. In Windows, all images (or exe files) that are started are created as children of the Winlogin.exe process, which is created when a user first logs in. As a [intentional] consequence of this, Winlogin.exe captures the Ctrl-Alt-Delete control key sequence which can't be overridden by another process.
Sometimes when connecting to another computer over the network, I might need to use Task Manager to suddenly terminate an application in order to free up either memory or reduce network latency from any applications that might have open connections. I'm used to using the Ctrl-Alt-Delete sequence, but since this is always hooked by the Winlogin.exe on the LOCAL computer, Remote Desktop can't transmit it over the connection.
Now that you know why - the solution! The control sequence Ctrl-Alt-End will act the same as a Ctrl-Alt-Delete when used in a Remote Desktop Session.
Sometimes when connecting to another computer over the network, I might need to use Task Manager to suddenly terminate an application in order to free up either memory or reduce network latency from any applications that might have open connections. I'm used to using the Ctrl-Alt-Delete sequence, but since this is always hooked by the Winlogin.exe on the LOCAL computer, Remote Desktop can't transmit it over the connection.
Now that you know why - the solution! The control sequence Ctrl-Alt-End will act the same as a Ctrl-Alt-Delete when used in a Remote Desktop Session.
|
page 1 of 1
|

