понедельник, 2 ноября 2015 г.

Update: November 2015

Hey,

Right now I'm working hard on my new book, Practical Go Programming. If you are learning Go and curious to know, how to apply it in real world application, then this book is what you are looking for. I'm taking this task very seriously, and it's no suprise that this will be a long run, so I will be posting regular book updates.

You can pre-order the book on the Leanpub.

Last but not least, you will see a lot of new posts on using Go here, in my blog. The first one will be about interfaces - I'm writing it right now, and it will be out in the next few days.

Stay tuned and good luck!

четверг, 29 октября 2015 г.

How Relevant is C in 2015

Many programming languages have come and gone since Dennis Ritchie devised C in 1972, and yet C has not only survived three major revisions, but continues to thrive. 

But aside from this incredible legacy, what keeps C atop the Tiobe Index?


One of the big reasons C will probably not be going away any time soon is there is no replacement and not much work being done on one. The higher level languages, language designers are constantly trying to redo or replace, but there is not much interest in replacing such a low level language... and the people who do use C are not interested either since they tend not to be language fetishists. And the people who do use C are not interested either since they tend not to be language fetishists.

Software is like an organ of your computer; your computer typically won't do much worthwhile if there's not a whole bunch of the things working together to make complete systems. Almost every one of the higher level languages are implemented in C at some point in the software stack. 

Some might argue that certain JVM languages like Scala and Groovy and Clojure are written in pure java, but guess what? The JVM is written in C. Almost every piece of software out in the wild is either written in C or depends on critical components written in C all the way down to the operating system. If you're running embedded, you might not have an OS, but you probably should be using C on microcontrollers and embedded systems unless there's a real good reason not to.

This is one good reason I program in C.

The other reason is portability. You can write something in C and it will run on every major platform and almost every embedded platform. Furthermore, it is portable between languages. If you write a library in C, people can call it from C#, Java, Python, TCL, Ruby, or nearly any other language. It is the lingua franca of programming.


Shoot Yourself in the Foot


C is a great language, and it gives its programmers a great deal of power and flexibility. But with that comes responsibility not to code like an idiot. If you're going to wield its power carelessly, of course you're a danger. 

Perhaps C's greatest weakness is that it places too much trust in the coder, where other languages don't. C is not a tool for the incompetent (whether temporary due to alcohol or permanently). It is an expert-only tool. There are a few of those around and they will stay around, because in the hands of somebody skilled, these tools deliver exceptional results that no more generally usable tool can match.
In C, you shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible since you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me over there."

Or alternatively,


C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off. -- Bjarne Stroustrup

Big Bad


The biggest bad reason for C being popular is that we've standardised on C as the way of defining library APIs in UNIX-land. There's no IDL that describes higher-level concepts - there are just C headers, and the language that makes it easiest to use C libraries wins. There has been some improvement in C-calling FFIs recently, and a big part of the popularity of Python is the ease with which you can use C/C++ libraries from it. Even simple things are hard when interoperating with C. It's hard for an FFI generator to know whether that char * parameter is a null-terminated string or a pointer to an arbitrary block of memory that's going to be read by the callee, a pointer to a single char that's going to be written back, or whether the callee returns a pointer to within the block and needs the original memory to persist. Lots of libraries take function pointers that have a void* context pointer, so can be mapped to closures in the caller's language, but they all put the context object in different places so you need a custom trampoline for each one.

With over 8 billion lines of open source C code (source: OpenHub.net), there's a good chance that the library that you want to use is written in C.

среда, 28 октября 2015 г.

Learning Operating Systems


When you are starting out with learning about operating systems, it's easy to be overwhelmed. So you should learn about options and choose wisely.

My advice would be studying two books:
- general text (theory);
- implementation text (practice with OS of choice).

Theory


My best bet is Operating System Concepts by Silberschatz, Galvin and Gagne. It is a commonly used book on operating system courses. It is also called "dinosaur book" due to it's fancy cover. This is a great modern introduction into OS, and, in my opinion, is the best book to start from scratch.

Another good option is Operating Systems by Deitel, Deitel and Choffnes. It is a great alternative to "dinosaur book".

Others might recommend one of Tanenbaum's books, for example Modern Operating Systems. Yeah, there is a lot of talk about minix (and how bad Windows architecture is) but that's Tanenbaum.

If you prefer video lections, then there is a UC Berkeley Computer Science 162 on YouTube.

Practice


Linux:
- Linux Kernel Development by Robert Love, 
- Linux Kernel Architecture by Wolfgang Mauerer,
- Understanding The Linux Virtual Memory Manager by Mel Gorman

Windows
- Windows Internals by Russinovich and Solomon,
Programming Windows by Charles Petzold.

If you just want to have fun, you can try The Little Book About OS Developmentit is a free practical guide to writing your own x86 operating system.

Now you are ready for my last advice: the source to Linux and lots of other systems is out there, so read it!